From 7b57d79f50157c02f95db8adb067311cc4dacf15 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 21 Feb 2020 12:39:41 +0100 Subject: [PATCH 01/93] Create client geo auto fill --- back/models/province.json | 89 +++++++++++---------- front/core/components/datalist/index.js | 9 ++- modules/client/front/create/index.html | 67 ++++++---------- modules/client/front/create/index.js | 66 +++++++++++---- modules/client/front/fiscal-data/index.html | 55 ++++++------- modules/client/front/fiscal-data/index.js | 58 ++++++++++++++ 6 files changed, 213 insertions(+), 131 deletions(-) diff --git a/back/models/province.json b/back/models/province.json index 49a971b650..2e2ace5eda 100644 --- a/back/models/province.json +++ b/back/models/province.json @@ -1,46 +1,53 @@ { - "name": "Province", - "description": "Provinces of every country", - "base": "VnModel", - "options": { - "mysql": { - "table": "province" - } - }, - "properties": { - "id": { - "type": "Number", - "id": true, - "description": "Identifier" + "name": "Province", + "description": "Provinces of every country", + "base": "VnModel", + "options": { + "mysql": { + "table": "province" + } }, - "name": { - "type": "string", - "required": true - } - }, - "relations": { - "country": { - "type": "belongsTo", - "model": "Country", - "foreignKey": "countryFk" + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "name": { + "type": "string", + "required": true + } }, - "warehouse": { - "type": "belongsTo", - "model": "Warehouse", - "foreignKey": "warehouseFk" + "relations": { + "country": { + "type": "belongsTo", + "model": "Country", + "foreignKey": "countryFk" + }, + "warehouse": { + "type": "belongsTo", + "model": "Warehouse", + "foreignKey": "warehouseFk" + }, + "zone": { + "type": "belongsTo", + "model": "Zone", + "foreignKey": "zoneFk" + } }, - "zone": { - "type": "belongsTo", - "model": "Zone", - "foreignKey": "zoneFk" - } - }, - "acls": [ - { - "accessType": "READ", - "principalType": "ROLE", - "principalId": "$everyone", - "permission": "ALLOW" - } - ] + "scopes": { + "location": { + "include": { + "relation": "country" + } + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + } + ] } \ No newline at end of file diff --git a/front/core/components/datalist/index.js b/front/core/components/datalist/index.js index bf3cab9a18..adf33b50a3 100644 --- a/front/core/components/datalist/index.js +++ b/front/core/components/datalist/index.js @@ -52,7 +52,14 @@ export default class Datalist extends Textfield { validSelection(selection) { return this.modelData && this.modelData.find(item => { - return item[this.valueField] == selection; + let dataValue = item[this.valueField]; + if (typeof(dataValue) === 'string') + dataValue = dataValue.toLowerCase(); + + if (typeof(selection) === 'string') + selection = selection.toLowerCase(); + + return dataValue == selection; }); } diff --git a/modules/client/front/create/index.html b/modules/client/front/create/index.html index ce4b7d4ed0..23676a36fb 100644 --- a/modules/client/front/create/index.html +++ b/modules/client/front/create/index.html @@ -49,76 +49,57 @@ - - + rule> + {{name}} ({{country.country}}) - - - - + + {{name}}, {{province.name}} + ({{province.country.country}}) + + + - - + this.$state.go('client.card.basicData', {id: json.data.id}) + ); + } + + get province() { + return this._province; + } + + // Province auto complete + set province(selection) { + this._province = selection; + + if (!selection) return; + + const country = selection.country; + + this.client.countryFk = country.id; + } + + get town() { + return this._town; + } + + // Town auto complete + set town(selection) { + this._town = selection; + + if (!selection) return; + + const province = selection.province; + const country = province.country; + const postcodes = selection.postcodes; + + this.client.provinceFk = province.id; + this.client.countryFk = country.id; + + if (postcodes.length === 1) + this.client.postcode = postcodes[0].code; + } + + get postcode() { + return this._postcode; + } + + // Postcode auto complete + set postcode(selection) { + this._postcode = selection; if (!selection) return; @@ -29,17 +76,8 @@ export default class Controller { this.client.provinceFk = province.id; this.client.countryFk = country.id; } - - onResponse(response) { - this.client.postcode = response.code; - } - - onSubmit() { - return this.$.watcher.submit().then( - json => this.$state.go('client.card.basicData', {id: json.data.id}) - ); - } } + Controller.$inject = ['$scope', '$state', '$http', '$translate', 'vnApp']; ngModule.component('vnClientCreate', { diff --git a/modules/client/front/fiscal-data/index.html b/modules/client/front/fiscal-data/index.html index 3bbc48630f..98d0e9318e 100644 --- a/modules/client/front/fiscal-data/index.html +++ b/modules/client/front/fiscal-data/index.html @@ -33,9 +33,7 @@ - - + {{name}} ({{country.country}}) - - - - - + show-field="code" + rule> + {{code}} - {{town.name}} ({{town.province.name}}, {{town.province.country.country}}) + Date: Mon, 24 Feb 2020 11:27:36 +0100 Subject: [PATCH 02/93] Added datalist auto completion --- front/core/components/datalist/index.js | 2 +- .../client/front/address/create/index.html | 76 +++++++++---------- modules/client/front/address/create/index.js | 60 ++++++++++----- modules/client/front/address/edit/index.html | 66 ++++++++-------- modules/client/front/address/edit/index.js | 48 +++++++++++- modules/client/front/create/index.html | 11 ++- modules/client/front/create/index.js | 8 +- modules/client/front/fiscal-data/index.html | 22 +++++- modules/client/front/fiscal-data/index.js | 19 +++-- modules/client/front/postcode/index.html | 2 +- modules/client/front/postcode/index.js | 31 ++++---- 11 files changed, 210 insertions(+), 135 deletions(-) diff --git a/front/core/components/datalist/index.js b/front/core/components/datalist/index.js index adf33b50a3..d52e6ca230 100644 --- a/front/core/components/datalist/index.js +++ b/front/core/components/datalist/index.js @@ -27,7 +27,7 @@ export default class Datalist extends Textfield { value = value == '' || value == null ? null : value; oldValue = oldValue == '' || oldValue == null ? null : oldValue; - this.refreshSelection(); + if (oldValue === undefined) this.refreshSelection(); if (!value || value === oldValue && this.modelData != null) return; diff --git a/modules/client/front/address/create/index.html b/modules/client/front/address/create/index.html index 1c70a1cbd7..383f37d0a1 100644 --- a/modules/client/front/address/create/index.html +++ b/modules/client/front/address/create/index.html @@ -39,61 +39,53 @@ - + rule> + {{name}} ({{country.country}}) - - - - + - - + + {{code}} - {{town.name}} ({{town.province.name}}, + {{town.province.country.country}}) + + + + + + { if (this.address.isDefaultAddress) @@ -51,6 +31,46 @@ export default class Controller extends Component { return this.$http.post(`CustomsAgents`, this.newCustomsAgent) .then(res => this.address.customsAgentFk = res.data.id); } + + get town() { + return this._town; + } + + // Town auto complete + set town(selection) { + this._town = selection; + + if (!selection) return; + + const province = selection.province; + const postcodes = selection.postcodes; + + this.address.provinceId = province.id; + + if (postcodes.length === 1) + this.address.postalCode = postcodes[0].code; + } + + get postcode() { + return this._postcode; + } + + // Postcode auto complete + set postcode(selection) { + this._postcode = selection; + + if (!selection) return; + + const town = selection.town; + const province = town.province; + + this.address.city = town.name; + this.address.provinceId = province.id; + } + + onResponse(response) { + this.address.postalCode = response.code; + } } Controller.$inject = ['$element', '$scope']; diff --git a/modules/client/front/address/edit/index.html b/modules/client/front/address/edit/index.html index 0356081209..a5a9d8e0a9 100644 --- a/modules/client/front/address/edit/index.html +++ b/modules/client/front/address/edit/index.html @@ -65,49 +65,43 @@ value-field="id" label="Province"> - - - - + + {{name}}, {{province.name}} + ({{province.country.country}}) + + + - - - + + {{code}} - {{town.name}} ({{town.province.name}}, + {{town.province.country.country}}) + + + + + + this.$.model.save(true)) @@ -39,6 +35,50 @@ export default class Controller extends Component { return this.$http.post(`CustomsAgents`, this.newCustomsAgent) .then(res => this.address.customsAgentFk = res.data.id); } + + get town() { + return this._town; + } + + // Town auto complete + set town(selection) { + const oldValue = this._town; + this._town = selection; + + if (!selection || oldValue === null || oldValue === undefined) + return; + + const province = selection.province; + const postcodes = selection.postcodes; + + this.address.provinceFk = province.id; + + if (postcodes.length === 1) + this.address.postalCode = postcodes[0].code; + } + + get postcode() { + return this._postcode; + } + + // Postcode auto complete + set postcode(selection) { + const oldValue = this._postcode; + this._postcode = selection; + + if (!selection || oldValue === null || oldValue === undefined) + return; + + const town = selection.town; + const province = town.province; + + this.address.city = town.name; + this.address.provinceFk = province.id; + } + + onResponse(response) { + this.address.postalCode = response.code; + } } ngModule.component('vnClientAddressEdit', { diff --git a/modules/client/front/create/index.html b/modules/client/front/create/index.html index 23676a36fb..faffc118f0 100644 --- a/modules/client/front/create/index.html +++ b/modules/client/front/create/index.html @@ -96,9 +96,16 @@ show-field="code" rule> - {{code}}, {{town.name}} - {{town.province.name}} - ({{town.province.country.country}}) + {{code}} - {{town.name}} ({{town.province.name}}, + {{town.province.country.country}}) + + + + diff --git a/modules/client/front/create/index.js b/modules/client/front/create/index.js index 3201f70977..a663717d62 100644 --- a/modules/client/front/create/index.js +++ b/modules/client/front/create/index.js @@ -12,10 +12,6 @@ export default class Controller { }; } - onResponse(response) { - this.client.postcode = response.code; - } - onSubmit() { return this.$.watcher.submit().then( json => this.$state.go('client.card.basicData', {id: json.data.id}) @@ -76,6 +72,10 @@ export default class Controller { this.client.provinceFk = province.id; this.client.countryFk = country.id; } + + onResponse(response) { + this.client.postcode = response.code; + } } Controller.$inject = ['$scope', '$state', '$http', '$translate', 'vnApp']; diff --git a/modules/client/front/fiscal-data/index.html b/modules/client/front/fiscal-data/index.html index 98d0e9318e..d29e31f64c 100644 --- a/modules/client/front/fiscal-data/index.html +++ b/modules/client/front/fiscal-data/index.html @@ -64,7 +64,10 @@ where="{provinceFk: province.selection.id}" show-field="name" value-field="name"> - {{name}} ({{province.name}}, {{province.country.country}}) + + {{name}}, {{province.name}} + ({{province.country.country}}) + - {{code}} - {{town.name}} ({{town.province.name}}, {{town.province.country.country}}) + + {{code}} - {{town.name}} ({{town.province.name}}, + {{town.province.country.country}}) + + + + + @@ -148,3 +161,8 @@ message="Found a client with this data" on-accept="$ctrl.onAcceptDuplication()"> + + + \ No newline at end of file diff --git a/modules/client/front/fiscal-data/index.js b/modules/client/front/fiscal-data/index.js index 42aa8032ab..e1669b1fae 100644 --- a/modules/client/front/fiscal-data/index.js +++ b/modules/client/front/fiscal-data/index.js @@ -86,7 +86,8 @@ export default class Controller extends Component { const oldValue = this._province; this._province = selection; - if (!selection || !oldValue) return; + if (!selection || oldValue === undefined) + return; const country = selection.country; @@ -102,7 +103,8 @@ export default class Controller extends Component { const oldValue = this._town; this._town = selection; - if (!selection || !oldValue) return; + if (!selection || oldValue === undefined) + return; const province = selection.province; const country = province.country; @@ -123,17 +125,24 @@ export default class Controller extends Component { set postcode(selection) { const oldValue = this._postcode; this._postcode = selection; - console.log(selection); - if (!selection || !oldValue) return; + console.log(oldValue); + if (!selection || oldValue === undefined) + return; + + console.log('setter'); const town = selection.town; const province = town.province; const country = province.country; - console.log(province.id); + this.client.city = town.name; this.client.provinceFk = province.id; this.client.countryFk = country.id; } + + onResponse(response) { + this.client.postcode = response.code; + } } ngModule.component('vnClientFiscalData', { diff --git a/modules/client/front/postcode/index.html b/modules/client/front/postcode/index.html index 55990281c3..fd81534eda 100644 --- a/modules/client/front/postcode/index.html +++ b/modules/client/front/postcode/index.html @@ -1,7 +1,7 @@ + on-accept="$ctrl.onAccept()">
New postcode

Please, ensure you put the correct data!

diff --git a/modules/client/front/postcode/index.js b/modules/client/front/postcode/index.js index bbf0b1953c..836ea9a81e 100644 --- a/modules/client/front/postcode/index.js +++ b/modules/client/front/postcode/index.js @@ -35,25 +35,20 @@ class Controller extends Component { this.$.postcode.focus(); } - onResponse(response) { - if (response == 'accept') { - try { - if (!this.data.code) - throw new Error(`The postcode can't be empty`); - if (!this.data.townFk) - throw new Error(`The town can't be empty`); + onAccept() { + try { + if (!this.data.code) + throw new Error(`The postcode can't be empty`); + if (!this.data.townFk) + throw new Error(`The town can't be empty`); - this.$http.patch(`postcodes`, this.data).then(response => { - if (response.data) { - this.vnApp.showMessage(this.$translate.instant('The postcode has been saved')); - - this.emit('response', {response: response.data}); - } - }); - } catch (e) { - this.vnApp.showError(this.$translate.instant(e.message)); - return false; - } + this.$http.patch(`postcodes`, this.data).then(res => { + this.vnApp.showMessage(this.$translate.instant('The postcode has been saved')); + this.emit('response', {$response: res.data}); + }); + } catch (e) { + this.vnApp.showError(this.$translate.instant(e.message)); + return false; } return true; } From 2fdd2750852fcafcda70b8437b6a89e4f0cead40 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Tue, 25 Feb 2020 11:43:50 +0100 Subject: [PATCH 03/93] log in ticketUpdate --- modules/ticket/back/methods/ticket/componentUpdate.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/componentUpdate.js b/modules/ticket/back/methods/ticket/componentUpdate.js index 2cba62540f..4d05e28d6e 100644 --- a/modules/ticket/back/methods/ticket/componentUpdate.js +++ b/modules/ticket/back/methods/ticket/componentUpdate.js @@ -1,4 +1,5 @@ const UserError = require('vn-loopback/util/user-error'); +const diff = require('object-diff'); module.exports = Self => { Self.remoteMethodCtx('componentUpdate', { @@ -87,9 +88,13 @@ module.exports = Self => { if (!zoneShipped || zoneShipped.zoneFk != zoneId) throw new UserError(`You don't have privileges to change the zone`); } - + const originalTicket = await models.Ticket.findById(id); + const properties = Object.assign({}, ctx.args); + delete properties.ctx; + delete properties.option; // Force unroute const hasToBeUnrouted = true; + console.log('args', originalTicket); let query = 'CALL vn.ticket_componentMakeUpdate(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; let res = await Self.rawSql(query, [ id, From 85db094f1d9578d99a5745312f040cf26fa16c7f Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Tue, 25 Feb 2020 12:36:33 +0100 Subject: [PATCH 04/93] componentUpdate --- modules/ticket/back/methods/ticket/componentUpdate.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/ticket/back/methods/ticket/componentUpdate.js b/modules/ticket/back/methods/ticket/componentUpdate.js index 4d05e28d6e..3447f52bfe 100644 --- a/modules/ticket/back/methods/ticket/componentUpdate.js +++ b/modules/ticket/back/methods/ticket/componentUpdate.js @@ -88,13 +88,17 @@ module.exports = Self => { if (!zoneShipped || zoneShipped.zoneFk != zoneId) throw new UserError(`You don't have privileges to change the zone`); } - const originalTicket = await models.Ticket.findById(id); + const originalTicket = await models.Ticket.findById(id, {fields: + ['id', 'clientFk', 'agencyModeFk', 'addressFk', 'zoneFk', + 'warehouseFk', 'companyFk', 'shipped', 'landed', 'isDeleted'] + }); const properties = Object.assign({}, ctx.args); delete properties.ctx; delete properties.option; // Force unroute const hasToBeUnrouted = true; - console.log('args', originalTicket); + console.log('originalTicket', originalTicket); + console.log('properties', properties); let query = 'CALL vn.ticket_componentMakeUpdate(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; let res = await Self.rawSql(query, [ id, From 5e86f67b377f008717ecaa1bbe4dc87509ab73e8 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Mon, 2 Mar 2020 08:18:41 +0100 Subject: [PATCH 05/93] dbtest workerTimeControCheck --- .../00-workerTimeControlCheck.sql | 182 ++ .../10161-postValentineDay/00-zoneEvent.sql | 2 - db/dump/dumpedFixtures.sql | 34 +- db/dump/fixtures.sql | 43 +- db/dump/structure.sql | 2657 ++++++++--------- db/tests/vn/workerTimeControlCheck.spec.js | 398 +++ 6 files changed, 1892 insertions(+), 1424 deletions(-) create mode 100644 db/changes/10161-postValentineDay/00-workerTimeControlCheck.sql delete mode 100644 db/changes/10161-postValentineDay/00-zoneEvent.sql create mode 100644 db/tests/vn/workerTimeControlCheck.spec.js diff --git a/db/changes/10161-postValentineDay/00-workerTimeControlCheck.sql b/db/changes/10161-postValentineDay/00-workerTimeControlCheck.sql new file mode 100644 index 0000000000..19cd9c4e9d --- /dev/null +++ b/db/changes/10161-postValentineDay/00-workerTimeControlCheck.sql @@ -0,0 +1,182 @@ + +DROP procedure IF EXISTS `vn`.`workerTimeControl_check`; + +DELIMITER $$ +CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`workerTimeControl_check`(vUserFk INT, vTabletFk VARCHAR(100), vTimed DATETIME) +BEGIN + +/** + * Verifica si el empleado puede fichar en el momento actual, si puede fichar llama a vn.workerTimeControlAdd + * @param vUserFk Identificador del trabajador + * @return Retorna si encuentra un problema 'odd','maxTimeWork','breakDay','breakWeek' ; + * En caso de tener algun problema retorna el primero que encuentra + */ + DECLARE vLastIn DATETIME ; + DECLARE vLastOut DATETIME ; + DECLARE vDayWorkMax INT; + DECLARE vDayBreak INT; + DECLARE vWeekBreak INT ; + DECLARE vWeekMaxBreak INT; + DECLARE vWeekScope INT; + DECLARE vWeekMaxScope INT; + DECLARE vDayStayMax INT; + DECLARE vAskInOut INT; + DECLARE vTimedWorked INT; + DECLARE vCalendarStateType VARCHAR(20) DEFAULT NULL; + DECLARE vDepartmentFk INT; + DECLARE vTo VARCHAR(50) DEFAULT NULL; + DECLARE vUserName VARCHAR(50) DEFAULT NULL; + DECLARE vBody VARCHAR(255) DEFAULT NULL; + + IF (vTimed IS NULL) THEN + SET vTimed = NOW(); + END IF; + + SELECT dayBreak, weekBreak, weekScope, dayWorkMax, dayStayMax, weekMaxBreak, weekMaxScope, askInOut + INTO vDayBreak, vWeekBreak, vWeekScope, vDayWorkMax, vDayStayMax, vWeekMaxBreak, vWeekMaxScope, vAskInOut + FROM vn.workerTimeControlParams; + + SELECT MAX(timed) INTO vLastIn + FROM vn.workerTimeControl + WHERE userFk = vUserFk AND + direction = 'in'; + + SELECT MAX(timed) INTO vLastOut + FROM vn.workerTimeControl + WHERE userFk = vUserFk AND + direction = 'out'; + + SELECT email INTO vTo + FROM vn.worker w + WHERE w.id = (SELECT bossFk FROM vn.worker WHERE id = vUserFk); + + SELECT CONCAT(firstName,' ',lastName) INTO vUserName + FROM vn.worker w + WHERE w.id = vUserFk; + + -- VERIFICAR CONTRATO EN VIGOR + IF (SELECT COUNT(*) + FROM postgresql.business b + JOIN postgresql.profile pr ON pr.profile_id = b.client_id + JOIN postgresql.person p ON p.person_id = pr.person_id + JOIN vn.worker w ON w.id = p.id_trabajador + WHERE w.userFk = vUserFk AND + b.date_start <= CURDATE() AND + IFNULL(b.date_end,CURDATE()) >= CURDATE() + ) = 0 THEN + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"No hay un contrato en vigor") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + CALL util.throw("No hay un contrato en vigor"); + END IF; + + -- VERIFICAR DEPARTAMENTO + IF vTabletFk IS NOT NULL THEN + IF ( SELECT COUNT(*) + FROM vn.tabletDepartment td + JOIN vn.workerTimeControlUserInfo wtcu ON wtcu.departmentFk = td.departmentFk + WHERE td.tabletFk = vTabletFk AND wtcu.userFk = vUserFk + ) = 0 THEN + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"No perteneces a este departamento.") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + CALL util.throw("No perteneces a este departamento."); + END IF; + END IF; + + SELECT IFNULL(dayBreak, vDayBreak) INTO vDayBreak + FROM postgresql.business b + JOIN postgresql.profile pr ON pr.profile_id = b.client_id + JOIN postgresql.person p ON p.person_id = pr.person_id + JOIN postgresql. business_labour bl ON b.business_id = bl.business_id + JOIN postgresql.professional_category pc ON bl.professional_category_id = pc.professional_category_id + WHERE p.id_trabajador = vUserFk AND + b.date_start <= DATE(vTimed) AND + IFNULL(b.date_end, DATE(vTimed)) >= DATE(vTimed); + -- VERIFICAR DESCANSO DIARIO + -- 12 / 9 horas dependiendo del valor de vDayBreak + IF UNIX_TIMESTAMP(vTimed) - UNIX_TIMESTAMP(vLastOut) < vDayBreak THEN + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos ", FORMAT(vDayBreak/3600,0) ," h") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + CALL util.throw(CONCAT("Descansos ", FORMAT(vDayBreak/3600,0) ," h")); + END IF; + + -- VERIFICAR FICHADAS IMPARES DEL ÚLTIMO DÍA QUE SE FICHÓ + IF (SELECT MOD(COUNT(*),2) -- <>0 + FROM vn.workerTimeControl + WHERE userFk = vUserFk AND + timed >= vLastIn + ) THEN + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Dias con fichadas impares") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + CALL util.throw("Dias con fichadas impares"); + END IF; + -- VERIFICAR VACACIONES + SELECT cs.type INTO vCalendarStateType + FROM postgresql.calendar_employee ce + JOIN postgresql.business b USING(business_id) + JOIN postgresql.profile pr ON pr.profile_id = b.client_id + JOIN postgresql.person p ON p.person_id = pr.person_id + JOIN postgresql.calendar_state cs USING(calendar_state_id) + JOIN vn.worker w ON w.id = p.id_trabajador + WHERE ce.date = CURDATE() AND + cs.isAllowedToWork = FALSE AND + w.userFk = vUserFk + LIMIT 1; + + IF(LENGTH(vCalendarStateType)) THEN + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Vacaciones") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + CALL util.throw(vCalendarStateType); + END IF; + + -- VERIFICAR DESCANSO SEMANAL + SET @vHasBreakWeek:= FALSE; + SET @vLastTimed:= UNIX_TIMESTAMP((vTimed - INTERVAL vWeekScope SECOND)); + + DROP TEMPORARY TABLE IF EXISTS tmp.trash; + CREATE TEMPORARY TABLE tmp.trash + SELECT IF(vWeekBreak-(UNIX_TIMESTAMP(timed)-@vLastTimed) <= 0, @vHasBreakWeek:=TRUE, TRUE) alias, + @vLastTimed:= UNIX_TIMESTAMP(timed) + FROM workerTimeControl + WHERE timed>= (vTimed - INTERVAL vWeekScope SECOND) AND + userFk= vUserFk AND + direction IN ('in','out') + ORDER BY timed ASC; + + IF UNIX_TIMESTAMP(vTimed) - UNIX_TIMESTAMP(vLastOut) < vWeekBreak AND @vHasBreakWeek = FALSE THEN -- REVISA SI EL DESCANSO SE HA REALIZADO DESPUÉS DE LA ÚLTIMA FICHADA + SET @vHasBreakWeek:= FALSE; + SET @vLastTimed:= UNIX_TIMESTAMP((vTimed - INTERVAL vWeekMaxScope SECOND)); + DROP TEMPORARY TABLE tmp.trash; + CREATE TEMPORARY TABLE tmp.trash + SELECT IF(vWeekMaxBreak-(UNIX_TIMESTAMP(timed)-@vLastTimed) <= 0, @vHasBreakWeek:=TRUE, TRUE) alias, + @vLastTimed:= UNIX_TIMESTAMP(timed) + FROM workerTimeControl + WHERE timed>= (vTimed - INTERVAL vWeekMaxScope SECOND) AND + userFk= vUserFk AND + direction IN ('in','out') + ORDER BY timed ASC; + IF UNIX_TIMESTAMP(vTimed) - UNIX_TIMESTAMP(vLastOut) < vWeekMaxBreak AND @vHasBreakWeek = FALSE THEN -- REVISA SI EL DESCANSO SE HA REALIZADO DESPUÉS DE LA ÚLTIMA FICHADA + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos ", FORMAT(vWeekMaxBreak/3600,0) ," h") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + CALL util.throw(CONCAT( "Descansos ", FORMAT(vWeekMaxBreak/3600,0) ," h")); + END IF; + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos ", FORMAT(vWeekBreak/3600,0) ," h") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + CALL util.warn(CONCAT( "Descansos ", FORMAT(vWeekBreak/3600,0) ," h")); + END IF; + DROP TEMPORARY TABLE tmp.trash; + + -- Preguntar dirección de la fichada + IF UNIX_TIMESTAMP(vTimed) - UNIX_TIMESTAMP(vLastIn) >= vAskInOut AND (SELECT MOD(COUNT(*),2) + FROM vn.workerTimeControl WHERE userFk = vUserFk AND timed >= vLastIn) THEN + CALL util.warn("AskInOut"); + END IF ; +END$$ + +DELIMITER ; diff --git a/db/changes/10161-postValentineDay/00-zoneEvent.sql b/db/changes/10161-postValentineDay/00-zoneEvent.sql deleted file mode 100644 index 1554afbec1..0000000000 --- a/db/changes/10161-postValentineDay/00-zoneEvent.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE `vn`.`zoneEvent` -ADD COLUMN m3Max DECIMAL(10,2) UNSIGNED NULL DEFAULT NULL AFTER bonus; \ No newline at end of file diff --git a/db/dump/dumpedFixtures.sql b/db/dump/dumpedFixtures.sql index 74290b4514..acdd3ea14b 100644 --- a/db/dump/dumpedFixtures.sql +++ b/db/dump/dumpedFixtures.sql @@ -23,7 +23,7 @@ USE `util`; LOCK TABLES `config` WRITE; /*!40000 ALTER TABLE `config` DISABLE KEYS */; -INSERT INTO `config` VALUES (1,'10140',0,'production',NULL); +INSERT INTO `config` VALUES (1,'10160',0,'production',NULL); /*!40000 ALTER TABLE `config` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -36,7 +36,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-02-13 9:07:05 +-- Dump completed on 2020-02-27 13:26:24 USE `account`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -71,7 +71,7 @@ UNLOCK TABLES; LOCK TABLES `roleInherit` WRITE; /*!40000 ALTER TABLE `roleInherit` DISABLE KEYS */; -INSERT INTO `roleInherit` VALUES (9,0),(66,0),(5,1),(13,1),(18,1),(31,1),(32,1),(34,1),(35,1),(37,1),(40,1),(42,1),(44,1),(47,1),(51,1),(53,1),(54,1),(56,1),(58,1),(1,2),(1,3),(30,5),(39,5),(60,5),(67,5),(11,6),(1,11),(2,11),(3,11),(16,13),(20,13),(21,13),(22,13),(34,13),(41,13),(43,13),(45,13),(48,13),(50,13),(52,13),(55,13),(57,13),(59,13),(61,13),(16,15),(20,16),(21,18),(52,19),(65,19),(17,20),(30,20),(5,21),(19,21),(22,21),(39,21),(30,22),(5,33),(34,33),(15,35),(41,35),(52,35),(65,35),(69,35),(49,36),(61,36),(17,37),(38,37),(60,37),(67,37),(17,39),(41,40),(43,42),(36,44),(45,44),(36,47),(48,47),(69,47),(50,49),(60,50),(65,50),(52,51),(21,53),(30,53),(55,54),(57,56),(15,57),(39,57),(50,57),(60,57),(49,58),(59,58),(50,59),(17,64),(30,64),(38,64),(20,65); +INSERT INTO `roleInherit` VALUES (9,0),(66,0),(5,1),(13,1),(18,1),(31,1),(32,1),(34,1),(35,1),(37,1),(40,1),(42,1),(44,1),(47,1),(51,1),(53,1),(54,1),(56,1),(58,1),(1,2),(1,3),(30,5),(39,5),(60,5),(67,5),(11,6),(1,11),(2,11),(3,11),(16,13),(20,13),(21,13),(22,13),(34,13),(41,13),(43,13),(45,13),(48,13),(50,13),(52,13),(55,13),(57,13),(59,13),(61,13),(16,15),(20,16),(21,18),(52,19),(65,19),(17,20),(30,20),(5,21),(19,21),(22,21),(39,21),(50,21),(30,22),(5,33),(34,33),(15,35),(41,35),(50,35),(52,35),(65,35),(69,35),(49,36),(61,36),(17,37),(38,37),(60,37),(67,37),(17,39),(41,40),(43,42),(36,44),(45,44),(36,47),(48,47),(69,47),(50,49),(60,50),(65,50),(52,51),(21,53),(30,53),(55,54),(57,56),(15,57),(39,57),(50,57),(60,57),(49,58),(59,58),(50,59),(17,64),(30,64),(38,64),(20,65); /*!40000 ALTER TABLE `roleInherit` ENABLE KEYS */; UNLOCK TABLES; @@ -81,7 +81,7 @@ UNLOCK TABLES; LOCK TABLES `roleRole` WRITE; /*!40000 ALTER TABLE `roleRole` DISABLE KEYS */; -INSERT INTO `roleRole` VALUES (0,0),(0,1),(0,2),(0,3),(0,5),(0,6),(0,9),(0,11),(0,13),(0,15),(0,16),(0,17),(0,18),(0,19),(0,20),(0,21),(0,22),(0,30),(0,31),(0,32),(0,33),(0,34),(0,35),(0,36),(0,37),(0,38),(0,39),(0,40),(0,41),(0,42),(0,43),(0,44),(0,45),(0,47),(0,48),(0,49),(0,50),(0,51),(0,52),(0,53),(0,54),(0,55),(0,56),(0,57),(0,58),(0,59),(0,60),(0,61),(0,62),(0,64),(0,65),(0,66),(0,67),(0,69),(1,1),(1,2),(1,3),(1,6),(1,11),(2,2),(2,6),(2,11),(3,3),(3,6),(3,11),(5,1),(5,2),(5,3),(5,5),(5,6),(5,11),(5,13),(5,18),(5,21),(5,33),(5,53),(6,6),(9,0),(9,1),(9,2),(9,3),(9,5),(9,6),(9,9),(9,11),(9,13),(9,15),(9,16),(9,17),(9,18),(9,19),(9,20),(9,21),(9,22),(9,30),(9,31),(9,32),(9,33),(9,34),(9,35),(9,36),(9,37),(9,38),(9,39),(9,40),(9,41),(9,42),(9,43),(9,44),(9,45),(9,47),(9,48),(9,49),(9,50),(9,51),(9,52),(9,53),(9,54),(9,55),(9,56),(9,57),(9,58),(9,59),(9,60),(9,61),(9,62),(9,64),(9,65),(9,66),(9,67),(9,69),(11,6),(11,11),(13,1),(13,2),(13,3),(13,6),(13,11),(13,13),(15,1),(15,2),(15,3),(15,6),(15,11),(15,13),(15,15),(15,35),(15,56),(15,57),(16,1),(16,2),(16,3),(16,6),(16,11),(16,13),(16,15),(16,16),(16,35),(16,56),(16,57),(17,1),(17,2),(17,3),(17,5),(17,6),(17,11),(17,13),(17,15),(17,16),(17,17),(17,18),(17,19),(17,20),(17,21),(17,33),(17,35),(17,36),(17,37),(17,39),(17,44),(17,47),(17,49),(17,50),(17,53),(17,56),(17,57),(17,58),(17,59),(17,64),(17,65),(18,1),(18,2),(18,3),(18,6),(18,11),(18,18),(19,1),(19,2),(19,3),(19,6),(19,11),(19,13),(19,18),(19,19),(19,21),(19,53),(20,1),(20,2),(20,3),(20,6),(20,11),(20,13),(20,15),(20,16),(20,18),(20,19),(20,20),(20,21),(20,35),(20,36),(20,44),(20,47),(20,49),(20,50),(20,53),(20,56),(20,57),(20,58),(20,59),(20,65),(21,1),(21,2),(21,3),(21,6),(21,11),(21,13),(21,18),(21,21),(21,53),(22,1),(22,2),(22,3),(22,6),(22,11),(22,13),(22,18),(22,21),(22,22),(22,53),(30,1),(30,2),(30,3),(30,5),(30,6),(30,11),(30,13),(30,15),(30,16),(30,18),(30,19),(30,20),(30,21),(30,22),(30,30),(30,33),(30,35),(30,36),(30,44),(30,47),(30,49),(30,50),(30,53),(30,56),(30,57),(30,58),(30,59),(30,64),(30,65),(31,1),(31,2),(31,3),(31,6),(31,11),(31,31),(32,1),(32,2),(32,3),(32,6),(32,11),(32,32),(33,33),(34,1),(34,2),(34,3),(34,6),(34,11),(34,13),(34,33),(34,34),(35,1),(35,2),(35,3),(35,6),(35,11),(35,35),(36,1),(36,2),(36,3),(36,6),(36,11),(36,36),(36,44),(36,47),(37,1),(37,2),(37,3),(37,6),(37,11),(37,37),(38,1),(38,2),(38,3),(38,6),(38,11),(38,37),(38,38),(38,64),(39,1),(39,2),(39,3),(39,5),(39,6),(39,11),(39,13),(39,18),(39,21),(39,33),(39,39),(39,53),(39,56),(39,57),(40,1),(40,2),(40,3),(40,6),(40,11),(40,40),(41,1),(41,2),(41,3),(41,6),(41,11),(41,13),(41,35),(41,40),(41,41),(42,1),(42,2),(42,3),(42,6),(42,11),(42,42),(43,1),(43,2),(43,3),(43,6),(43,11),(43,13),(43,42),(43,43),(44,1),(44,2),(44,3),(44,6),(44,11),(44,44),(45,1),(45,2),(45,3),(45,6),(45,11),(45,13),(45,44),(45,45),(47,1),(47,2),(47,3),(47,6),(47,11),(47,47),(48,1),(48,2),(48,3),(48,6),(48,11),(48,13),(48,47),(48,48),(49,1),(49,2),(49,3),(49,6),(49,11),(49,36),(49,44),(49,47),(49,49),(49,58),(50,1),(50,2),(50,3),(50,6),(50,11),(50,13),(50,36),(50,44),(50,47),(50,49),(50,50),(50,56),(50,57),(50,58),(50,59),(51,1),(51,2),(51,3),(51,6),(51,11),(51,51),(52,1),(52,2),(52,3),(52,6),(52,11),(52,13),(52,18),(52,19),(52,21),(52,35),(52,51),(52,52),(52,53),(53,1),(53,2),(53,3),(53,6),(53,11),(53,53),(54,1),(54,2),(54,3),(54,6),(54,11),(54,54),(55,1),(55,2),(55,3),(55,6),(55,11),(55,13),(55,54),(55,55),(56,1),(56,2),(56,3),(56,6),(56,11),(56,56),(57,1),(57,2),(57,3),(57,6),(57,11),(57,13),(57,56),(57,57),(58,1),(58,2),(58,3),(58,6),(58,11),(58,58),(59,1),(59,2),(59,3),(59,6),(59,11),(59,13),(59,58),(59,59),(60,1),(60,2),(60,3),(60,5),(60,6),(60,11),(60,13),(60,18),(60,21),(60,33),(60,36),(60,37),(60,44),(60,47),(60,49),(60,50),(60,53),(60,56),(60,57),(60,58),(60,59),(60,60),(61,1),(61,2),(61,3),(61,6),(61,11),(61,13),(61,36),(61,44),(61,47),(61,61),(62,62),(64,64),(65,1),(65,2),(65,3),(65,6),(65,11),(65,13),(65,18),(65,19),(65,21),(65,35),(65,36),(65,44),(65,47),(65,49),(65,50),(65,53),(65,56),(65,57),(65,58),(65,59),(65,65),(66,0),(66,1),(66,2),(66,3),(66,5),(66,6),(66,9),(66,11),(66,13),(66,15),(66,16),(66,17),(66,18),(66,19),(66,20),(66,21),(66,22),(66,30),(66,31),(66,32),(66,33),(66,34),(66,35),(66,36),(66,37),(66,38),(66,39),(66,40),(66,41),(66,42),(66,43),(66,44),(66,45),(66,47),(66,48),(66,49),(66,50),(66,51),(66,52),(66,53),(66,54),(66,55),(66,56),(66,57),(66,58),(66,59),(66,60),(66,61),(66,62),(66,64),(66,65),(66,66),(66,67),(66,69),(67,1),(67,2),(67,3),(67,5),(67,6),(67,11),(67,13),(67,18),(67,21),(67,33),(67,37),(67,53),(67,67),(69,1),(69,2),(69,3),(69,6),(69,11),(69,35),(69,47),(69,69); +INSERT INTO `roleRole` VALUES (0,0),(0,1),(0,2),(0,3),(0,5),(0,6),(0,9),(0,11),(0,13),(0,15),(0,16),(0,17),(0,18),(0,19),(0,20),(0,21),(0,22),(0,30),(0,31),(0,32),(0,33),(0,34),(0,35),(0,36),(0,37),(0,38),(0,39),(0,40),(0,41),(0,42),(0,43),(0,44),(0,45),(0,47),(0,48),(0,49),(0,50),(0,51),(0,52),(0,53),(0,54),(0,55),(0,56),(0,57),(0,58),(0,59),(0,60),(0,61),(0,62),(0,64),(0,65),(0,66),(0,67),(0,69),(1,1),(1,2),(1,3),(1,6),(1,11),(2,2),(2,6),(2,11),(3,3),(3,6),(3,11),(5,1),(5,2),(5,3),(5,5),(5,6),(5,11),(5,13),(5,18),(5,21),(5,33),(5,53),(6,6),(9,0),(9,1),(9,2),(9,3),(9,5),(9,6),(9,9),(9,11),(9,13),(9,15),(9,16),(9,17),(9,18),(9,19),(9,20),(9,21),(9,22),(9,30),(9,31),(9,32),(9,33),(9,34),(9,35),(9,36),(9,37),(9,38),(9,39),(9,40),(9,41),(9,42),(9,43),(9,44),(9,45),(9,47),(9,48),(9,49),(9,50),(9,51),(9,52),(9,53),(9,54),(9,55),(9,56),(9,57),(9,58),(9,59),(9,60),(9,61),(9,62),(9,64),(9,65),(9,66),(9,67),(9,69),(11,6),(11,11),(13,1),(13,2),(13,3),(13,6),(13,11),(13,13),(15,1),(15,2),(15,3),(15,6),(15,11),(15,13),(15,15),(15,35),(15,56),(15,57),(16,1),(16,2),(16,3),(16,6),(16,11),(16,13),(16,15),(16,16),(16,35),(16,56),(16,57),(17,1),(17,2),(17,3),(17,5),(17,6),(17,11),(17,13),(17,15),(17,16),(17,17),(17,18),(17,19),(17,20),(17,21),(17,33),(17,35),(17,36),(17,37),(17,39),(17,44),(17,47),(17,49),(17,50),(17,53),(17,56),(17,57),(17,58),(17,59),(17,64),(17,65),(18,1),(18,2),(18,3),(18,6),(18,11),(18,18),(19,1),(19,2),(19,3),(19,6),(19,11),(19,13),(19,18),(19,19),(19,21),(19,53),(20,1),(20,2),(20,3),(20,6),(20,11),(20,13),(20,15),(20,16),(20,18),(20,19),(20,20),(20,21),(20,35),(20,36),(20,44),(20,47),(20,49),(20,50),(20,53),(20,56),(20,57),(20,58),(20,59),(20,65),(21,1),(21,2),(21,3),(21,6),(21,11),(21,13),(21,18),(21,21),(21,53),(22,1),(22,2),(22,3),(22,6),(22,11),(22,13),(22,18),(22,21),(22,22),(22,53),(30,1),(30,2),(30,3),(30,5),(30,6),(30,11),(30,13),(30,15),(30,16),(30,18),(30,19),(30,20),(30,21),(30,22),(30,30),(30,33),(30,35),(30,36),(30,44),(30,47),(30,49),(30,50),(30,53),(30,56),(30,57),(30,58),(30,59),(30,64),(30,65),(31,1),(31,2),(31,3),(31,6),(31,11),(31,31),(32,1),(32,2),(32,3),(32,6),(32,11),(32,32),(33,33),(34,1),(34,2),(34,3),(34,6),(34,11),(34,13),(34,33),(34,34),(35,1),(35,2),(35,3),(35,6),(35,11),(35,35),(36,1),(36,2),(36,3),(36,6),(36,11),(36,36),(36,44),(36,47),(37,1),(37,2),(37,3),(37,6),(37,11),(37,37),(38,1),(38,2),(38,3),(38,6),(38,11),(38,37),(38,38),(38,64),(39,1),(39,2),(39,3),(39,5),(39,6),(39,11),(39,13),(39,18),(39,21),(39,33),(39,39),(39,53),(39,56),(39,57),(40,1),(40,2),(40,3),(40,6),(40,11),(40,40),(41,1),(41,2),(41,3),(41,6),(41,11),(41,13),(41,35),(41,40),(41,41),(42,1),(42,2),(42,3),(42,6),(42,11),(42,42),(43,1),(43,2),(43,3),(43,6),(43,11),(43,13),(43,42),(43,43),(44,1),(44,2),(44,3),(44,6),(44,11),(44,44),(45,1),(45,2),(45,3),(45,6),(45,11),(45,13),(45,44),(45,45),(47,1),(47,2),(47,3),(47,6),(47,11),(47,47),(48,1),(48,2),(48,3),(48,6),(48,11),(48,13),(48,47),(48,48),(49,1),(49,2),(49,3),(49,6),(49,11),(49,36),(49,44),(49,47),(49,49),(49,58),(50,1),(50,2),(50,3),(50,6),(50,11),(50,13),(50,18),(50,21),(50,35),(50,36),(50,44),(50,47),(50,49),(50,50),(50,53),(50,56),(50,57),(50,58),(50,59),(51,1),(51,2),(51,3),(51,6),(51,11),(51,51),(52,1),(52,2),(52,3),(52,6),(52,11),(52,13),(52,18),(52,19),(52,21),(52,35),(52,51),(52,52),(52,53),(53,1),(53,2),(53,3),(53,6),(53,11),(53,53),(54,1),(54,2),(54,3),(54,6),(54,11),(54,54),(55,1),(55,2),(55,3),(55,6),(55,11),(55,13),(55,54),(55,55),(56,1),(56,2),(56,3),(56,6),(56,11),(56,56),(57,1),(57,2),(57,3),(57,6),(57,11),(57,13),(57,56),(57,57),(58,1),(58,2),(58,3),(58,6),(58,11),(58,58),(59,1),(59,2),(59,3),(59,6),(59,11),(59,13),(59,58),(59,59),(60,1),(60,2),(60,3),(60,5),(60,6),(60,11),(60,13),(60,18),(60,21),(60,33),(60,35),(60,36),(60,37),(60,44),(60,47),(60,49),(60,50),(60,53),(60,56),(60,57),(60,58),(60,59),(60,60),(61,1),(61,2),(61,3),(61,6),(61,11),(61,13),(61,36),(61,44),(61,47),(61,61),(62,62),(64,64),(65,1),(65,2),(65,3),(65,6),(65,11),(65,13),(65,18),(65,19),(65,21),(65,35),(65,36),(65,44),(65,47),(65,49),(65,50),(65,53),(65,56),(65,57),(65,58),(65,59),(65,65),(66,0),(66,1),(66,2),(66,3),(66,5),(66,6),(66,9),(66,11),(66,13),(66,15),(66,16),(66,17),(66,18),(66,19),(66,20),(66,21),(66,22),(66,30),(66,31),(66,32),(66,33),(66,34),(66,35),(66,36),(66,37),(66,38),(66,39),(66,40),(66,41),(66,42),(66,43),(66,44),(66,45),(66,47),(66,48),(66,49),(66,50),(66,51),(66,52),(66,53),(66,54),(66,55),(66,56),(66,57),(66,58),(66,59),(66,60),(66,61),(66,62),(66,64),(66,65),(66,66),(66,67),(66,69),(67,1),(67,2),(67,3),(67,5),(67,6),(67,11),(67,13),(67,18),(67,21),(67,33),(67,37),(67,53),(67,67),(69,1),(69,2),(69,3),(69,6),(69,11),(69,35),(69,47),(69,69); /*!40000 ALTER TABLE `roleRole` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -94,7 +94,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-02-13 9:07:05 +-- Dump completed on 2020-02-27 13:26:25 USE `salix`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -119,7 +119,7 @@ USE `salix`; LOCK TABLES `ACL` WRITE; /*!40000 ALTER TABLE `ACL` DISABLE KEYS */; -INSERT INTO `ACL` VALUES (1,'Account','*','*','ALLOW','ROLE','employee'),(3,'Address','*','*','ALLOW','ROLE','employee'),(5,'AgencyService','*','READ','ALLOW','ROLE','employee'),(7,'Client','*','*','ALLOW','ROLE','employee'),(9,'ClientObservation','*','*','ALLOW','ROLE','employee'),(11,'ContactChannel','*','READ','ALLOW','ROLE','employee'),(13,'Employee','*','READ','ALLOW','ROLE','employee'),(14,'PayMethod','*','READ','ALLOW','ROLE','employee'),(16,'FakeProduction','*','READ','ALLOW','ROLE','employee'),(17,'Warehouse','* ','READ','ALLOW','ROLE','employee'),(18,'State','*','READ','ALLOW','ROLE','employee'),(20,'TicketState','*','*','ALLOW','ROLE','employee'),(24,'Delivery','*','READ','ALLOW','ROLE','employee'),(25,'Zone','*','READ','ALLOW','ROLE','employee'),(26,'ClientCredit','*','*','ALLOW','ROLE','employee'),(27,'ClientCreditLimit','*','READ','ALLOW','ROLE','employee'),(30,'GreugeType','*','READ','ALLOW','ROLE','employee'),(31,'Mandate','*','READ','ALLOW','ROLE','employee'),(32,'MandateType','*','READ','ALLOW','ROLE','employee'),(33,'Company','*','READ','ALLOW','ROLE','employee'),(34,'Greuge','*','READ','ALLOW','ROLE','employee'),(35,'AddressObservation','*','*','ALLOW','ROLE','employee'),(36,'ObservationType','*','*','ALLOW','ROLE','employee'),(37,'Greuge','*','WRITE','ALLOW','ROLE','employee'),(38,'AgencyMode','*','READ','ALLOW','ROLE','employee'),(39,'ItemTag','*','WRITE','ALLOW','ROLE','buyer'),(40,'ItemBotanical','*','WRITE','ALLOW','ROLE','buyer'),(41,'ItemBotanical','*','READ','ALLOW','ROLE','employee'),(42,'ItemPlacement','*','WRITE','ALLOW','ROLE','buyer'),(43,'ItemPlacement','*','WRITE','ALLOW','ROLE','replenisher'),(44,'ItemPlacement','*','READ','ALLOW','ROLE','employee'),(45,'ItemBarcode','*','READ','ALLOW','ROLE','employee'),(46,'ItemBarcode','*','WRITE','ALLOW','ROLE','buyer'),(47,'ItemBarcode','*','WRITE','ALLOW','ROLE','replenisher'),(48,'ItemNiche','*','READ','ALLOW','ROLE','employee'),(49,'ItemNiche','*','WRITE','ALLOW','ROLE','buyer'),(50,'ItemNiche','*','WRITE','ALLOW','ROLE','replenisher'),(51,'ItemTag','*','READ','ALLOW','ROLE','employee'),(53,'Item','*','READ','ALLOW','ROLE','employee'),(54,'Item','*','WRITE','ALLOW','ROLE','buyer'),(55,'Recovery','*','READ','ALLOW','ROLE','employee'),(56,'Recovery','*','WRITE','ALLOW','ROLE','administrative'),(58,'CreditClassification','*','*','ALLOW','ROLE','insurance'),(60,'CreditInsurance','*','*','ALLOW','ROLE','insurance'),(61,'InvoiceOut','*','READ','ALLOW','ROLE','employee'),(62,'Ticket','*','*','ALLOW','ROLE','employee'),(63,'TicketObservation','*','*','ALLOW','ROLE','employee'),(64,'Route','*','READ','ALLOW','ROLE','employee'),(65,'Sale','*','READ','ALLOW','ROLE','employee'),(66,'TicketTracking','*','READ','ALLOW','ROLE','employee'),(68,'TicketPackaging','*','*','ALLOW','ROLE','employee'),(69,'Packaging','*','READ','ALLOW','ROLE','employee'),(70,'Packaging','*','WRITE','ALLOW','ROLE','logistic'),(71,'SaleChecked','*','READ','ALLOW','ROLE','employee'),(72,'SaleComponent','*','READ','ALLOW','ROLE','employee'),(73,'Expedition','*','READ','ALLOW','ROLE','employee'),(74,'Expedition','*','WRITE','ALLOW','ROLE','deliveryBoss'),(75,'Expedition','*','WRITE','ALLOW','ROLE','production'),(76,'AnnualAverageInvoiced','*','READ','ALLOW','ROLE','employee'),(77,'WorkerMana','*','READ','ALLOW','ROLE','employee'),(78,'TicketTracking','*','WRITE','ALLOW','ROLE','production'),(79,'TicketTracking','changeState','*','ALLOW','ROLE','employee'),(80,'Sale','removes','*','ALLOW','ROLE','employee'),(81,'Sale','moveToTicket','*','ALLOW','ROLE','employee'),(82,'Sale','updateQuantity','*','ALLOW','ROLE','employee'),(83,'Sale','updatePrice','*','ALLOW','ROLE','employee'),(84,'Sale','updateDiscount','*','ALLOW','ROLE','employee'),(85,'SaleTracking','*','READ','ALLOW','ROLE','employee'),(86,'Order','*','*','ALLOW','ROLE','employee'),(87,'OrderRow','*','*','ALLOW','ROLE','employee'),(88,'ClientContact','*','*','ALLOW','ROLE','employee'),(89,'Sale','moveToNewTicket','*','ALLOW','ROLE','employee'),(90,'Sale','reserve','*','ALLOW','ROLE','employee'),(91,'TicketWeekly','*','READ','ALLOW','ROLE','employee'),(94,'Agency','landsThatDay','*','ALLOW','ROLE','employee'),(96,'ClaimEnd','*','READ','ALLOW','ROLE','employee'),(97,'ClaimEnd','*','WRITE','ALLOW','ROLE','salesAssistant'),(98,'ClaimBeginning','*','*','ALLOW','ROLE','employee'),(99,'ClaimDevelopment','*','READ','ALLOW','ROLE','employee'),(100,'ClaimDevelopment','*','WRITE','ALLOW','ROLE','salesAssistant'),(101,'Claim','*','*','ALLOW','ROLE','employee'),(102,'Claim','createFromSales','*','ALLOW','ROLE','employee'),(103,'ClaimEnd','importTicketSales','WRITE','ALLOW','ROLE','salesAssistant'),(104,'Item','*','WRITE','ALLOW','ROLE','marketingBoss'),(105,'ItemBarcode','*','WRITE','ALLOW','ROLE','marketingBoss'),(106,'ItemBotanical','*','WRITE','ALLOW','ROLE','marketingBoss'),(107,'ItemNiche','*','WRITE','ALLOW','ROLE','marketingBoss'),(108,'ItemPlacement','*','WRITE','ALLOW','ROLE','marketingBoss'),(109,'UserConfig','*','*','ALLOW','ROLE','employee'),(110,'Bank','*','READ','ALLOW','ROLE','employee'),(111,'ClientLog','*','READ','ALLOW','ROLE','employee'),(112,'Defaulter','*','READ','ALLOW','ROLE','employee'),(113,'ClientRisk','*','READ','ALLOW','ROLE','employee'),(114,'Receipt','*','READ','ALLOW','ROLE','employee'),(115,'Receipt','*','WRITE','ALLOW','ROLE','administrative'),(116,'BankEntity','*','*','ALLOW','ROLE','employee'),(117,'ClientSample','*','*','ALLOW','ROLE','employee'),(118,'WorkerTeam','*','*','ALLOW','ROLE','salesPerson'),(119,'Travel','*','READ','ALLOW','ROLE','employee'),(120,'Travel','*','WRITE','ALLOW','ROLE','buyer'),(121,'Item','regularize','*','ALLOW','ROLE','employee'),(122,'TicketRequest','*','*','ALLOW','ROLE','employee'),(123,'Worker','*','*','ALLOW','ROLE','employee'),(124,'Client','confirmTransaction','WRITE','ALLOW','ROLE','administrative'),(125,'Agency','getAgenciesWithWarehouse','*','ALLOW','ROLE','employee'),(126,'Client','activeWorkersWithRole','*','ALLOW','ROLE','employee'),(127,'TicketLog','*','READ','ALLOW','ROLE','employee'),(129,'TicketService','*','*','ALLOW','ROLE','employee'),(130,'Expedition','*','WRITE','ALLOW','ROLE','packager'),(131,'CreditInsurance','*','READ','ALLOW','ROLE','employee'),(132,'CreditClassification','*','READ','ALLOW','ROLE','employee'),(133,'ItemTag','*','WRITE','ALLOW','ROLE','marketingBoss'),(135,'ZoneGeo','*','READ','ALLOW','ROLE','employee'),(136,'ZoneCalendar','*','READ','ALLOW','ROLE','employee'),(137,'ZoneIncluded','*','READ','ALLOW','ROLE','employee'),(138,'LabourHoliday','*','READ','ALLOW','ROLE','employee'),(139,'LabourHolidayLegend','*','READ','ALLOW','ROLE','employee'),(140,'LabourHolidayType','*','READ','ALLOW','ROLE','employee'),(141,'Zone','*','*','ALLOW','ROLE','deliveryBoss'),(142,'ZoneCalendar','*','WRITE','ALLOW','ROLE','deliveryBoss'),(143,'ZoneIncluded','*','*','ALLOW','ROLE','deliveryBoss'),(144,'Stowaway','*','*','ALLOW','ROLE','employee'),(145,'Ticket','getPossibleStowaways','READ','ALLOW','ROLE','employee'),(147,'UserConfigView','*','*','ALLOW','ROLE','employee'),(148,'UserConfigView','*','*','ALLOW','ROLE','employee'),(149,'Sip','*','READ','ALLOW','ROLE','employee'),(150,'Sip','*','WRITE','ALLOW','ROLE','hr'),(151,'Department','*','READ','ALLOW','ROLE','employee'),(152,'Department','*','WRITE','ALLOW','ROLE','hr'),(153,'Route','*','READ','ALLOW','ROLE','employee'),(154,'Route','*','WRITE','ALLOW','ROLE','delivery'),(155,'WorkerCalendar','*','READ','ALLOW','ROLE','hr'),(156,'WorkerLabour','*','READ','ALLOW','ROLE','hr'),(157,'WorkerCalendar','absences','READ','ALLOW','ROLE','employee'),(158,'ItemTag','*','WRITE','ALLOW','ROLE','accessory'),(160,'TicketServiceType','*','READ','ALLOW','ROLE','employee'),(161,'TicketConfig','*','READ','ALLOW','ROLE','employee'),(162,'InvoiceOut','delete','WRITE','ALLOW','ROLE','invoicing'),(163,'InvoiceOut','book','WRITE','ALLOW','ROLE','invoicing'),(164,'InvoiceOut','regenerate','WRITE','ALLOW','ROLE','invoicing'),(165,'TicketDms','*','READ','ALLOW','ROLE','employee'),(167,'Worker','isSubordinate','READ','ALLOW','ROLE','employee'),(168,'Worker','mySubordinates','READ','ALLOW','ROLE','employee'),(169,'WorkerTimeControl','filter','READ','ALLOW','ROLE','employee'),(170,'WorkerTimeControl','addTime','WRITE','ALLOW','ROLE','employee'),(171,'TicketServiceType','*','WRITE','ALLOW','ROLE','administrative'),(172,'Sms','*','READ','ALLOW','ROLE','employee'),(173,'Sms','send','WRITE','ALLOW','ROLE','employee'),(174,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(175,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(176,'Device','*','*','ALLOW','ROLE','employee'),(177,'Device','*','*','ALLOW','ROLE','employee'),(178,'WorkerTimeControl','*','*','ALLOW','ROLE','employee'),(179,'ItemLog','*','READ','ALLOW','ROLE','employee'),(180,'RouteLog','*','READ','ALLOW','ROLE','employee'),(181,'Dms','removeFile','WRITE','ALLOW','ROLE','employee'),(182,'Dms','uploadFile','WRITE','ALLOW','ROLE','employee'),(183,'Dms','downloadFile','READ','ALLOW','ROLE','employee'),(184,'Client','uploadFile','WRITE','ALLOW','ROLE','employee'),(185,'ClientDms','removeFile','WRITE','ALLOW','ROLE','employee'),(186,'ClientDms','*','READ','ALLOW','ROLE','employee'),(187,'Ticket','uploadFile','WRITE','ALLOW','ROLE','employee'),(188,'TicketDms','removeFile','WRITE','ALLOW','ROLE','employee'),(189,'TicketDms','*','READ','ALLOW','ROLE','employee'),(190,'Route','updateVolume','WRITE','ALLOW','ROLE','deliveryBoss'),(191,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(192,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(194,'Postcode','*','WRITE','ALLOW','ROLE','employee'),(195,'Ticket','addSale','WRITE','ALLOW','ROLE','employee'),(196,'Dms','updateFile','WRITE','ALLOW','ROLE','employee'),(197,'Dms','*','READ','ALLOW','ROLE','employee'),(198,'ClaimDms','removeFile','WRITE','ALLOW','ROLE','employee'),(199,'ClaimDms','*','READ','ALLOW','ROLE','employee'),(200,'Claim','uploadFile','WRITE','ALLOW','ROLE','employee'),(201,'Sale','updateConcept','WRITE','ALLOW','ROLE','employee'),(202,'Claim','updateClaimAction','WRITE','ALLOW','ROLE','salesAssistant'),(203,'UserPhone','*','*','ALLOW','ROLE','employee'),(204,'WorkerDms','removeFile','WRITE','ALLOW','ROLE','hr'),(205,'WorkerDms','*','READ','ALLOW','ROLE','hr'),(206,'Chat','*','*','ALLOW','ROLE','employee'),(207,'Chat','sendMessage','*','ALLOW','ROLE','employee'),(208,'Sale','recalculatePrice','WRITE','ALLOW','ROLE','employee'),(209,'Ticket','recalculateComponents','WRITE','ALLOW','ROLE','employee'),(211,'TravelLog','*','READ','ALLOW','ROLE','buyer'),(212,'Thermograph','*','*','ALLOW','ROLE','buyer'),(213,'TravelThermograph','*','*','ALLOW','ROLE','buyer'),(214,'Entry','*','*','ALLOW','ROLE','buyer'),(215,'TicketWeekly','*','WRITE','ALLOW','ROLE','buyer'),(216,'TravelThermograph','*','READ','ALLOW','ROLE','employee'); +INSERT INTO `ACL` VALUES (1,'Account','*','*','ALLOW','ROLE','employee'),(3,'Address','*','*','ALLOW','ROLE','employee'),(5,'AgencyService','*','READ','ALLOW','ROLE','employee'),(7,'Client','*','*','ALLOW','ROLE','employee'),(9,'ClientObservation','*','*','ALLOW','ROLE','employee'),(11,'ContactChannel','*','READ','ALLOW','ROLE','employee'),(13,'Employee','*','READ','ALLOW','ROLE','employee'),(14,'PayMethod','*','READ','ALLOW','ROLE','employee'),(16,'FakeProduction','*','READ','ALLOW','ROLE','employee'),(17,'Warehouse','* ','READ','ALLOW','ROLE','employee'),(18,'State','*','READ','ALLOW','ROLE','employee'),(20,'TicketState','*','*','ALLOW','ROLE','employee'),(24,'Delivery','*','READ','ALLOW','ROLE','employee'),(25,'Zone','*','READ','ALLOW','ROLE','employee'),(26,'ClientCredit','*','*','ALLOW','ROLE','employee'),(27,'ClientCreditLimit','*','READ','ALLOW','ROLE','employee'),(30,'GreugeType','*','READ','ALLOW','ROLE','employee'),(31,'Mandate','*','READ','ALLOW','ROLE','employee'),(32,'MandateType','*','READ','ALLOW','ROLE','employee'),(33,'Company','*','READ','ALLOW','ROLE','employee'),(34,'Greuge','*','READ','ALLOW','ROLE','employee'),(35,'AddressObservation','*','*','ALLOW','ROLE','employee'),(36,'ObservationType','*','*','ALLOW','ROLE','employee'),(37,'Greuge','*','WRITE','ALLOW','ROLE','employee'),(38,'AgencyMode','*','READ','ALLOW','ROLE','employee'),(39,'ItemTag','*','WRITE','ALLOW','ROLE','buyer'),(40,'ItemBotanical','*','WRITE','ALLOW','ROLE','buyer'),(41,'ItemBotanical','*','READ','ALLOW','ROLE','employee'),(42,'ItemPlacement','*','WRITE','ALLOW','ROLE','buyer'),(43,'ItemPlacement','*','WRITE','ALLOW','ROLE','replenisher'),(44,'ItemPlacement','*','READ','ALLOW','ROLE','employee'),(45,'ItemBarcode','*','READ','ALLOW','ROLE','employee'),(46,'ItemBarcode','*','WRITE','ALLOW','ROLE','buyer'),(47,'ItemBarcode','*','WRITE','ALLOW','ROLE','replenisher'),(48,'ItemNiche','*','READ','ALLOW','ROLE','employee'),(49,'ItemNiche','*','WRITE','ALLOW','ROLE','buyer'),(50,'ItemNiche','*','WRITE','ALLOW','ROLE','replenisher'),(51,'ItemTag','*','READ','ALLOW','ROLE','employee'),(53,'Item','*','READ','ALLOW','ROLE','employee'),(54,'Item','*','WRITE','ALLOW','ROLE','buyer'),(55,'Recovery','*','READ','ALLOW','ROLE','employee'),(56,'Recovery','*','WRITE','ALLOW','ROLE','administrative'),(58,'CreditClassification','*','*','ALLOW','ROLE','insurance'),(60,'CreditInsurance','*','*','ALLOW','ROLE','insurance'),(61,'InvoiceOut','*','READ','ALLOW','ROLE','employee'),(62,'Ticket','*','*','ALLOW','ROLE','employee'),(63,'TicketObservation','*','*','ALLOW','ROLE','employee'),(64,'Route','*','READ','ALLOW','ROLE','employee'),(65,'Sale','*','READ','ALLOW','ROLE','employee'),(66,'TicketTracking','*','READ','ALLOW','ROLE','employee'),(68,'TicketPackaging','*','*','ALLOW','ROLE','employee'),(69,'Packaging','*','READ','ALLOW','ROLE','employee'),(70,'Packaging','*','WRITE','ALLOW','ROLE','logistic'),(71,'SaleChecked','*','READ','ALLOW','ROLE','employee'),(72,'SaleComponent','*','READ','ALLOW','ROLE','employee'),(73,'Expedition','*','READ','ALLOW','ROLE','employee'),(74,'Expedition','*','WRITE','ALLOW','ROLE','deliveryBoss'),(75,'Expedition','*','WRITE','ALLOW','ROLE','production'),(76,'AnnualAverageInvoiced','*','READ','ALLOW','ROLE','employee'),(77,'WorkerMana','*','READ','ALLOW','ROLE','employee'),(78,'TicketTracking','*','WRITE','ALLOW','ROLE','production'),(79,'TicketTracking','changeState','*','ALLOW','ROLE','employee'),(80,'Sale','removes','*','ALLOW','ROLE','employee'),(81,'Sale','moveToTicket','*','ALLOW','ROLE','employee'),(82,'Sale','updateQuantity','*','ALLOW','ROLE','employee'),(83,'Sale','updatePrice','*','ALLOW','ROLE','employee'),(84,'Sale','updateDiscount','*','ALLOW','ROLE','employee'),(85,'SaleTracking','*','READ','ALLOW','ROLE','employee'),(86,'Order','*','*','ALLOW','ROLE','employee'),(87,'OrderRow','*','*','ALLOW','ROLE','employee'),(88,'ClientContact','*','*','ALLOW','ROLE','employee'),(89,'Sale','moveToNewTicket','*','ALLOW','ROLE','employee'),(90,'Sale','reserve','*','ALLOW','ROLE','employee'),(91,'TicketWeekly','*','READ','ALLOW','ROLE','employee'),(94,'Agency','landsThatDay','*','ALLOW','ROLE','employee'),(96,'ClaimEnd','*','READ','ALLOW','ROLE','employee'),(97,'ClaimEnd','*','WRITE','ALLOW','ROLE','salesAssistant'),(98,'ClaimBeginning','*','*','ALLOW','ROLE','employee'),(99,'ClaimDevelopment','*','READ','ALLOW','ROLE','employee'),(100,'ClaimDevelopment','*','WRITE','ALLOW','ROLE','salesAssistant'),(101,'Claim','*','*','ALLOW','ROLE','employee'),(102,'Claim','createFromSales','*','ALLOW','ROLE','employee'),(103,'ClaimEnd','importTicketSales','WRITE','ALLOW','ROLE','salesAssistant'),(104,'Item','*','WRITE','ALLOW','ROLE','marketingBoss'),(105,'ItemBarcode','*','WRITE','ALLOW','ROLE','marketingBoss'),(106,'ItemBotanical','*','WRITE','ALLOW','ROLE','marketingBoss'),(107,'ItemNiche','*','WRITE','ALLOW','ROLE','marketingBoss'),(108,'ItemPlacement','*','WRITE','ALLOW','ROLE','marketingBoss'),(109,'UserConfig','*','*','ALLOW','ROLE','employee'),(110,'Bank','*','READ','ALLOW','ROLE','employee'),(111,'ClientLog','*','READ','ALLOW','ROLE','employee'),(112,'Defaulter','*','READ','ALLOW','ROLE','employee'),(113,'ClientRisk','*','READ','ALLOW','ROLE','employee'),(114,'Receipt','*','READ','ALLOW','ROLE','employee'),(115,'Receipt','*','WRITE','ALLOW','ROLE','administrative'),(116,'BankEntity','*','*','ALLOW','ROLE','employee'),(117,'ClientSample','*','*','ALLOW','ROLE','employee'),(118,'WorkerTeam','*','*','ALLOW','ROLE','salesPerson'),(119,'Travel','*','READ','ALLOW','ROLE','employee'),(120,'Travel','*','WRITE','ALLOW','ROLE','buyer'),(121,'Item','regularize','*','ALLOW','ROLE','employee'),(122,'TicketRequest','*','*','ALLOW','ROLE','employee'),(123,'Worker','*','*','ALLOW','ROLE','employee'),(124,'Client','confirmTransaction','WRITE','ALLOW','ROLE','administrative'),(125,'Agency','getAgenciesWithWarehouse','*','ALLOW','ROLE','employee'),(126,'Client','activeWorkersWithRole','*','ALLOW','ROLE','employee'),(127,'TicketLog','*','READ','ALLOW','ROLE','employee'),(129,'TicketService','*','*','ALLOW','ROLE','employee'),(130,'Expedition','*','WRITE','ALLOW','ROLE','packager'),(131,'CreditInsurance','*','READ','ALLOW','ROLE','employee'),(132,'CreditClassification','*','READ','ALLOW','ROLE','employee'),(133,'ItemTag','*','WRITE','ALLOW','ROLE','marketingBoss'),(135,'ZoneGeo','*','READ','ALLOW','ROLE','employee'),(136,'ZoneCalendar','*','READ','ALLOW','ROLE','employee'),(137,'ZoneIncluded','*','READ','ALLOW','ROLE','employee'),(138,'LabourHoliday','*','READ','ALLOW','ROLE','employee'),(139,'LabourHolidayLegend','*','READ','ALLOW','ROLE','employee'),(140,'LabourHolidayType','*','READ','ALLOW','ROLE','employee'),(141,'Zone','*','*','ALLOW','ROLE','deliveryBoss'),(142,'ZoneCalendar','*','WRITE','ALLOW','ROLE','deliveryBoss'),(143,'ZoneIncluded','*','*','ALLOW','ROLE','deliveryBoss'),(144,'Stowaway','*','*','ALLOW','ROLE','employee'),(145,'Ticket','getPossibleStowaways','READ','ALLOW','ROLE','employee'),(147,'UserConfigView','*','*','ALLOW','ROLE','employee'),(148,'UserConfigView','*','*','ALLOW','ROLE','employee'),(149,'Sip','*','READ','ALLOW','ROLE','employee'),(150,'Sip','*','WRITE','ALLOW','ROLE','hr'),(151,'Department','*','READ','ALLOW','ROLE','employee'),(152,'Department','*','WRITE','ALLOW','ROLE','hr'),(153,'Route','*','READ','ALLOW','ROLE','employee'),(154,'Route','*','WRITE','ALLOW','ROLE','delivery'),(155,'WorkerCalendar','*','READ','ALLOW','ROLE','hr'),(156,'WorkerLabour','*','READ','ALLOW','ROLE','hr'),(157,'WorkerCalendar','absences','READ','ALLOW','ROLE','employee'),(158,'ItemTag','*','WRITE','ALLOW','ROLE','accessory'),(160,'TicketServiceType','*','READ','ALLOW','ROLE','employee'),(161,'TicketConfig','*','READ','ALLOW','ROLE','employee'),(162,'InvoiceOut','delete','WRITE','ALLOW','ROLE','invoicing'),(163,'InvoiceOut','book','WRITE','ALLOW','ROLE','invoicing'),(164,'InvoiceOut','regenerate','WRITE','ALLOW','ROLE','invoicing'),(165,'TicketDms','*','READ','ALLOW','ROLE','employee'),(167,'Worker','isSubordinate','READ','ALLOW','ROLE','employee'),(168,'Worker','mySubordinates','READ','ALLOW','ROLE','employee'),(169,'WorkerTimeControl','filter','READ','ALLOW','ROLE','employee'),(170,'WorkerTimeControl','addTime','WRITE','ALLOW','ROLE','employee'),(171,'TicketServiceType','*','WRITE','ALLOW','ROLE','administrative'),(172,'Sms','*','READ','ALLOW','ROLE','employee'),(173,'Sms','send','WRITE','ALLOW','ROLE','employee'),(174,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(175,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(176,'Device','*','*','ALLOW','ROLE','employee'),(177,'Device','*','*','ALLOW','ROLE','employee'),(178,'WorkerTimeControl','*','*','ALLOW','ROLE','employee'),(179,'ItemLog','*','READ','ALLOW','ROLE','employee'),(180,'RouteLog','*','READ','ALLOW','ROLE','employee'),(181,'Dms','removeFile','WRITE','ALLOW','ROLE','employee'),(182,'Dms','uploadFile','WRITE','ALLOW','ROLE','employee'),(183,'Dms','downloadFile','READ','ALLOW','ROLE','employee'),(184,'Client','uploadFile','WRITE','ALLOW','ROLE','employee'),(185,'ClientDms','removeFile','WRITE','ALLOW','ROLE','employee'),(186,'ClientDms','*','READ','ALLOW','ROLE','employee'),(187,'Ticket','uploadFile','WRITE','ALLOW','ROLE','employee'),(188,'TicketDms','removeFile','WRITE','ALLOW','ROLE','employee'),(189,'TicketDms','*','READ','ALLOW','ROLE','employee'),(190,'Route','updateVolume','WRITE','ALLOW','ROLE','deliveryBoss'),(191,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(192,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(194,'Postcode','*','WRITE','ALLOW','ROLE','employee'),(195,'Ticket','addSale','WRITE','ALLOW','ROLE','employee'),(196,'Dms','updateFile','WRITE','ALLOW','ROLE','employee'),(197,'Dms','*','READ','ALLOW','ROLE','employee'),(198,'ClaimDms','removeFile','WRITE','ALLOW','ROLE','employee'),(199,'ClaimDms','*','READ','ALLOW','ROLE','employee'),(200,'Claim','uploadFile','WRITE','ALLOW','ROLE','employee'),(201,'Sale','updateConcept','WRITE','ALLOW','ROLE','employee'),(202,'Claim','updateClaimAction','WRITE','ALLOW','ROLE','salesAssistant'),(203,'UserPhone','*','*','ALLOW','ROLE','employee'),(204,'WorkerDms','removeFile','WRITE','ALLOW','ROLE','hr'),(205,'WorkerDms','*','READ','ALLOW','ROLE','hr'),(206,'Chat','*','*','ALLOW','ROLE','employee'),(207,'Chat','sendMessage','*','ALLOW','ROLE','employee'),(208,'Sale','recalculatePrice','WRITE','ALLOW','ROLE','employee'),(209,'Ticket','recalculateComponents','WRITE','ALLOW','ROLE','employee'),(211,'TravelLog','*','READ','ALLOW','ROLE','buyer'),(212,'Thermograph','*','*','ALLOW','ROLE','buyer'),(213,'TravelThermograph','*','*','ALLOW','ROLE','buyer'),(214,'Entry','*','*','ALLOW','ROLE','buyer'),(215,'TicketWeekly','*','WRITE','ALLOW','ROLE','buyer'),(216,'TravelThermograph','*','READ','ALLOW','ROLE','employee'),(217,'CustomsAgent','*','*','ALLOW','ROLE','employee'),(218,'Intrastat','*','*','ALLOW','ROLE','buyer'); /*!40000 ALTER TABLE `ACL` ENABLE KEYS */; UNLOCK TABLES; @@ -142,7 +142,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-02-13 9:07:05 +-- Dump completed on 2020-02-27 13:26:25 USE `vn`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -227,7 +227,7 @@ UNLOCK TABLES; LOCK TABLES `tag` WRITE; /*!40000 ALTER TABLE `tag` DISABLE KEYS */; -INSERT INTO `tag` VALUES (1,'color','Color',0,0,'ink',NULL,NULL),(2,'','Forma',1,0,NULL,NULL,NULL),(3,'','Material',1,0,NULL,NULL,NULL),(4,'','Longitud',1,1,NULL,'mm',NULL),(5,'','Diámetro',1,1,NULL,'mm',NULL),(6,'','Perímetro',1,1,NULL,'mm',NULL),(7,'','Ancho de la base',1,1,NULL,'mm',NULL),(8,'','Altura',1,1,NULL,'mm',NULL),(9,'','Volumen',1,1,NULL,'ml',NULL),(10,'','Densidad',1,1,NULL,NULL,NULL),(11,'','Calidad',1,0,NULL,NULL,NULL),(12,'','Textura',1,0,NULL,NULL,NULL),(13,'','Material del mango',1,0,NULL,NULL,NULL),(14,'','Compra mínima',1,0,NULL,NULL,NULL),(15,'','Nº pétalos',1,1,NULL,NULL,NULL),(16,'','Ancho',1,1,NULL,'mm',NULL),(18,'','Profundidad',1,1,NULL,'mm',NULL),(19,'','Largo',1,1,NULL,'mm',NULL),(20,'','Ancho superior',1,1,NULL,'mm',NULL),(21,'','Ancho inferior',1,1,NULL,'mm',NULL),(22,'','Gramaje',1,1,NULL,'g',NULL),(23,'stems','Tallos',1,1,NULL,NULL,NULL),(24,'','Estado',1,0,NULL,NULL,NULL),(25,'','Color principal',0,0,'ink',NULL,NULL),(26,'','Color secundario',0,0,'ink',NULL,NULL),(27,'','Longitud(cm)',1,1,NULL,'cm',NULL),(28,'','Diámetro base',1,1,'','mm',NULL),(29,'','Colección',1,0,NULL,NULL,NULL),(30,'','Uds / caja',1,1,NULL,NULL,NULL),(31,'','Contenido',1,0,NULL,NULL,NULL),(32,'','Peso',1,1,NULL,'g',NULL),(33,'','Grosor',1,1,NULL,'mm',NULL),(34,'','Marca',1,0,NULL,NULL,NULL),(35,'origin','Origen',0,0,'origin',NULL,NULL),(36,'','Proveedor',1,0,NULL,NULL,NULL),(37,'producer','Productor',0,0,'producer',NULL,NULL),(38,'','Duración',1,1,NULL,'s',NULL),(39,'','Flor',1,0,NULL,NULL,NULL),(40,'','Soporte',1,0,NULL,NULL,NULL),(41,'','Tamaño flor',1,0,NULL,NULL,NULL),(42,'','Apertura',1,0,NULL,NULL,NULL),(43,'','Tallo',1,0,NULL,NULL,NULL),(44,'','Nº hojas',1,1,NULL,NULL,NULL),(45,'','Dimensiones',1,0,NULL,NULL,NULL),(46,'','Diámetro boca',1,1,NULL,'mm',NULL),(47,'','Nº flores',1,1,NULL,NULL,NULL),(48,'','Uds / paquete',1,1,NULL,NULL,NULL),(49,'','Maceta',1,1,NULL,'cm',NULL),(50,'','Textura flor',1,0,NULL,NULL,NULL),(51,'','Textura hoja',1,0,NULL,NULL,NULL),(52,'','Tipo de IVA',1,0,NULL,NULL,NULL),(53,'','Tronco',1,0,NULL,NULL,NULL),(54,'','Hoja',1,0,NULL,NULL,NULL),(55,'','Formato',1,0,NULL,NULL,NULL),(56,'','Genero',1,0,NULL,NULL,NULL),(57,'','Especie',1,0,NULL,NULL,NULL),(58,'','Variedad',1,0,NULL,NULL,NULL),(59,'','Medida grande',1,0,NULL,NULL,NULL),(60,'','Medida mediano',1,0,NULL,NULL,NULL),(61,'','Medida pequeño',1,0,NULL,NULL,NULL),(62,'','Medida pequeño',1,0,NULL,NULL,NULL),(63,'','Recipiente interior',1,0,NULL,NULL,NULL),(64,'','Material secundario',1,0,NULL,NULL,NULL),(65,'','Colores',1,0,NULL,NULL,NULL),(66,'','Referencia',1,0,NULL,NULL,NULL),(67,'','Categoria',1,0,NULL,NULL,NULL),(68,'','Amb',1,0,NULL,NULL,NULL),(69,'','Anchura',1,1,NULL,'cm',NULL),(70,'','Hueco interior',1,0,NULL,NULL,NULL),(71,'','Tamaño',1,0,NULL,NULL,NULL),(72,'','Color botón',1,0,NULL,NULL,NULL),(73,'','Tamaño minimo del botón',1,0,NULL,NULL,NULL),(74,'','Obtentor',1,0,NULL,NULL,NULL),(75,'','Longitud del brote',1,0,NULL,NULL,NULL),(76,'','Tallos / u.v.',1,0,NULL,NULL,NULL),(77,'','Madera de',1,0,NULL,NULL,NULL),(78,'','Unidad de venta',1,0,NULL,NULL,NULL),(79,'','Temporal',1,0,NULL,NULL,NULL),(80,'','Gramaje/tallo',1,1,NULL,'g',NULL),(81,'','Peso/paquete',1,1,NULL,'g',NULL),(82,'','Flexibilidad del tallo',1,0,NULL,NULL,NULL),(83,'','Nº planchas',1,1,NULL,NULL,NULL),(84,'','Nº páginas',1,1,NULL,NULL,NULL),(85,'','Editorial',1,0,NULL,NULL,NULL),(86,'','Idioma',1,0,NULL,NULL,NULL),(87,'','Fecha publicación',1,0,NULL,NULL,NULL),(88,'','Cubierta',1,0,NULL,NULL,NULL),(89,'','Encuadernación',1,0,NULL,NULL,NULL),(90,'','Autor',1,0,NULL,NULL,NULL),(91,'','Envoltorio',1,0,NULL,NULL,NULL),(92,'','Nombre temporal',1,0,NULL,NULL,NULL),(93,'','Modelo',1,0,NULL,NULL,NULL),(94,'','Producto',1,0,NULL,NULL,NULL),(95,'','Título',1,0,NULL,NULL,NULL),(96,'','Tomo',1,0,NULL,NULL,NULL),(97,'','Articulo',1,0,NULL,NULL,NULL),(98,'','Metodo de cultivo',1,0,NULL,NULL,NULL),(99,'','Edad',1,0,NULL,NULL,NULL),(100,'','Agotado',1,0,NULL,NULL,NULL),(101,'','Altura con asa',1,1,NULL,'cm',NULL),(102,'','Nº tallos',1,1,NULL,NULL,NULL),(103,'','Cultivo',1,0,NULL,NULL,NULL),(104,'','Sabor',1,0,NULL,NULL,NULL),(105,'','Talla',1,0,NULL,NULL,NULL),(106,'','Calibre',1,1,NULL,NULL,NULL),(107,'','Dulzura',1,1,NULL,'bx',NULL),(108,'','Piezas',1,0,NULL,NULL,NULL),(109,'','Altura con patas',1,0,NULL,NULL,NULL),(110,'','Envase',1,0,NULL,NULL,NULL),(111,'','Nº piezas',1,0,NULL,NULL,NULL),(112,'','Uso',1,0,NULL,'cm',NULL); +INSERT INTO `tag` VALUES (1,'color','Color',0,0,'ink',NULL,NULL),(2,'','Forma',1,0,NULL,NULL,NULL),(3,'','Material',1,0,NULL,NULL,NULL),(4,'','Longitud',1,1,NULL,'mm',NULL),(5,'','Diámetro',1,1,NULL,'mm',NULL),(6,'','Perímetro',1,1,NULL,'mm',NULL),(7,'','Ancho de la base',1,1,NULL,'mm',NULL),(8,'','Altura',1,1,NULL,'mm',NULL),(9,'','Volumen',1,1,NULL,'ml',NULL),(10,'','Densidad',1,1,NULL,NULL,NULL),(11,'','Calidad',1,0,NULL,NULL,NULL),(12,'','Textura',1,0,NULL,NULL,NULL),(13,'','Material del mango',1,0,NULL,NULL,NULL),(14,'','Compra mínima',1,0,NULL,NULL,NULL),(15,'','Nº pétalos',1,1,NULL,NULL,NULL),(16,'','Ancho',1,1,NULL,'mm',NULL),(18,'','Profundidad',1,1,NULL,'mm',NULL),(19,'','Largo',1,1,NULL,'mm',NULL),(20,'','Ancho superior',1,1,NULL,'mm',NULL),(21,'','Ancho inferior',1,1,NULL,'mm',NULL),(22,'','Gramaje',1,1,NULL,'g',NULL),(23,'stems','Tallos',1,1,NULL,NULL,NULL),(24,'','Estado',1,0,NULL,NULL,NULL),(25,'','Color principal',0,0,'ink',NULL,NULL),(26,'','Color secundario',0,0,'ink',NULL,NULL),(27,'','Longitud(cm)',1,1,NULL,'cm',NULL),(28,'','Diámetro base',1,1,'','mm',NULL),(29,'','Colección',1,0,NULL,NULL,NULL),(30,'','Uds / caja',1,1,NULL,NULL,NULL),(31,'','Contenido',1,0,NULL,NULL,NULL),(32,'','Peso',1,1,NULL,'g',NULL),(33,'','Grosor',1,1,NULL,'mm',NULL),(34,'','Marca',1,0,NULL,NULL,NULL),(35,'origin','Origen',0,0,'origin',NULL,NULL),(36,'','Proveedor',1,0,NULL,NULL,NULL),(37,'producer','Productor',0,0,'producer',NULL,NULL),(38,'','Duración',1,1,NULL,'s',NULL),(39,'','Flor',1,0,NULL,NULL,NULL),(40,'','Soporte',1,0,NULL,NULL,NULL),(41,'','Tamaño flor',1,0,NULL,NULL,NULL),(42,'','Apertura',1,0,NULL,NULL,NULL),(43,'','Tallo',1,0,NULL,NULL,NULL),(44,'','Nº hojas',1,1,NULL,NULL,NULL),(45,'','Dimensiones',1,0,NULL,NULL,NULL),(46,'','Diámetro boca',1,1,NULL,'mm',NULL),(47,'','Nº flores',1,1,NULL,NULL,NULL),(48,'','Uds / paquete',1,1,NULL,NULL,NULL),(49,'','Maceta',1,1,NULL,'cm',NULL),(50,'','Textura flor',1,0,NULL,NULL,NULL),(51,'','Textura hoja',1,0,NULL,NULL,NULL),(52,'','Tipo de IVA',1,0,NULL,NULL,NULL),(53,'','Tronco',1,0,NULL,NULL,NULL),(54,'','Hoja',1,0,NULL,NULL,NULL),(55,'','Formato',1,0,NULL,NULL,NULL),(56,'','Genero',1,0,NULL,NULL,NULL),(57,'','Especie',1,0,NULL,NULL,NULL),(58,'','Variedad',1,0,NULL,NULL,NULL),(59,'','Medida grande',1,0,NULL,NULL,NULL),(60,'','Medida mediano',1,0,NULL,NULL,NULL),(61,'','Medida pequeño',1,0,NULL,NULL,NULL),(62,'','Medida pequeño',1,0,NULL,NULL,NULL),(63,'','Recipiente interior',1,0,NULL,NULL,NULL),(64,'','Material secundario',1,0,NULL,NULL,NULL),(65,'','Colores',1,0,NULL,NULL,NULL),(66,'','Referencia',1,0,NULL,NULL,NULL),(67,'','Categoria',1,0,NULL,NULL,NULL),(68,'','Amb',1,0,NULL,NULL,NULL),(69,'','Anchura',1,1,NULL,'cm',NULL),(70,'','Hueco interior',1,0,NULL,NULL,NULL),(71,'','Tamaño',1,0,NULL,NULL,NULL),(72,'','Color botón',1,0,NULL,NULL,NULL),(73,'','Tamaño minimo del botón',1,0,NULL,NULL,NULL),(74,'','Obtentor',1,0,NULL,NULL,NULL),(75,'','Longitud del brote',1,0,NULL,NULL,NULL),(76,'','Tallos / u.v.',1,0,NULL,NULL,NULL),(77,'','Madera de',1,0,NULL,NULL,NULL),(78,'','Unidad de venta',1,0,NULL,NULL,NULL),(79,'','Temporal',1,0,NULL,NULL,NULL),(80,'','Gramaje/tallo',1,1,NULL,'g',NULL),(81,'','Peso/paquete',1,1,NULL,'g',NULL),(82,'','Flexibilidad del tallo',1,0,NULL,NULL,NULL),(83,'','Nº planchas',1,1,NULL,NULL,NULL),(84,'','Nº páginas',1,1,NULL,NULL,NULL),(85,'','Editorial',1,0,NULL,NULL,NULL),(86,'','Idioma',1,0,NULL,NULL,NULL),(87,'','Fecha publicación',1,0,NULL,NULL,NULL),(88,'','Cubierta',1,0,NULL,NULL,NULL),(89,'','Encuadernación',1,0,NULL,NULL,NULL),(90,'','Autor',1,0,NULL,NULL,NULL),(91,'','Envoltorio',1,0,NULL,NULL,NULL),(92,'','Nombre temporal',1,0,NULL,NULL,NULL),(93,'','Modelo',1,0,NULL,NULL,NULL),(94,'','Producto',1,0,NULL,NULL,NULL),(95,'','Título',1,0,NULL,NULL,NULL),(96,'','Tomo',1,0,NULL,NULL,NULL),(97,'','Articulo',1,0,NULL,NULL,NULL),(98,'','Metodo de cultivo',1,0,NULL,NULL,NULL),(99,'','Edad',1,0,NULL,NULL,NULL),(100,'','Agotado',1,0,NULL,NULL,NULL),(101,'','Altura con asa',1,1,NULL,'cm',NULL),(102,'','Nº tallos',1,1,NULL,NULL,NULL),(103,'','Cultivo',1,0,NULL,NULL,NULL),(104,'','Sabor',1,0,NULL,NULL,NULL),(105,'','Talla',1,0,NULL,NULL,NULL),(106,'','Calibre',1,1,NULL,NULL,NULL),(107,'','Dulzura',1,1,NULL,'bx',NULL),(108,'','Piezas',1,0,NULL,NULL,NULL),(109,'','Altura con patas',1,0,NULL,NULL,NULL),(110,'','Envase',1,0,NULL,NULL,NULL),(111,'','Nº piezas',1,0,NULL,NULL,NULL),(112,'','Uso',1,0,NULL,'cm',NULL),(113,'','Color luz',1,0,NULL,NULL,NULL),(114,'','Capacidad',1,0,NULL,NULL,NULL); /*!40000 ALTER TABLE `tag` ENABLE KEYS */; UNLOCK TABLES; @@ -277,7 +277,7 @@ UNLOCK TABLES; LOCK TABLES `ticketUpdateAction` WRITE; /*!40000 ALTER TABLE `ticketUpdateAction` DISABLE KEYS */; -INSERT INTO `ticketUpdateAction` VALUES (1,'Cambiar los precios en el ticket'),(3,'Convertir en maná'); +INSERT INTO `ticketUpdateAction` VALUES (1,'Cambiar los precios en el ticket','changePrice'),(3,'Convertir en maná','turnInMana'); /*!40000 ALTER TABLE `ticketUpdateAction` ENABLE KEYS */; UNLOCK TABLES; @@ -287,7 +287,7 @@ UNLOCK TABLES; LOCK TABLES `state` WRITE; /*!40000 ALTER TABLE `state` DISABLE KEYS */; -INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING',NULL,1,0,0,0,0),(2,'Libre',1,0,'FREE',NULL,2,0,0,0,0),(3,'OK',3,0,'OK',3,28,1,0,0,0),(4,'Impreso',4,1,'PRINTED',2,29,1,0,1,0),(5,'Preparación',5,1,'ON_PREPARATION',7,5,0,0,0,2),(6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0,1,0,3),(7,'Sin Acabar',2,0,'NOT_READY',NULL,7,0,0,0,0),(8,'Revisado',8,1,'CHECKED',NULL,8,0,1,0,3),(9,'Encajando',9,2,'PACKING',NULL,9,0,1,0,0),(10,'Encajado',10,2,'PACKED',NULL,10,0,1,0,0),(11,'Facturado',0,0,'INVOICED',NULL,11,0,1,0,0),(12,'Bloqueado',0,0,'BLOCKED',NULL,12,0,0,0,0),(13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0,1,0,0),(14,'Preparado',6,1,'PREPARED',NULL,14,0,1,0,2),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0,1,0,0),(16,'Entregado',13,3,'DELIVERED',NULL,16,0,1,0,0),(17,'Eliminado',14,3,'ERASED',NULL,17,0,0,0,0),(20,'Asignado',4,1,'PICKER_DESIGNED',NULL,20,1,0,0,0),(21,'Retornado',4,1,'PRINTED_BACK',6,21,0,0,0,0),(22,'¿Fecha?',2,0,'WRONG_DATE',NULL,22,0,0,0,0),(23,'URGENTE',2,0,'LAST_CALL',NULL,23,1,0,0,0),(24,'Encadenado',3,0,'CHAINED',4,24,0,0,0,0),(25,'Embarcando',3,0,'BOARDING',5,25,0,0,0,0),(26,'Prep Previa',5,1,'PREVIOUS_PREPARATION',1,26,0,0,0,1),(27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0,0,0,0),(28,'Previa OK',3,1,'OK PREVIOUS',3,28,1,0,0,1),(29,'Previa Impreso',4,1,'PRINTED PREVIOUS',2,29,1,0,1,1),(30,'Embarcado',4,0,'BOARD',5,30,0,0,0,2); +INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING',NULL,1,0,0,0,0,0),(2,'Libre',2,0,'FREE',NULL,2,0,0,0,0,1),(3,'OK',3,0,'OK',3,28,1,0,0,0,1),(4,'Impreso',4,1,'PRINTED',2,29,1,0,1,0,0),(5,'Preparación',5,1,'ON_PREPARATION',7,5,0,0,0,2,0),(6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0,1,0,3,0),(7,'Sin Acabar',1,0,'NOT_READY',NULL,7,0,0,0,0,1),(8,'Revisado',8,1,'CHECKED',NULL,8,0,1,0,3,0),(9,'Encajando',9,2,'PACKING',NULL,9,0,1,0,0,0),(10,'Encajado',10,2,'PACKED',NULL,10,0,1,0,0,0),(11,'Facturado',0,0,'INVOICED',NULL,11,0,1,0,0,0),(12,'Bloqueado',0,0,'BLOCKED',NULL,12,0,0,0,0,0),(13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0,1,0,0,0),(14,'Preparado',6,1,'PREPARED',NULL,14,0,1,0,2,0),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0,1,0,0,0),(16,'Entregado',13,3,'DELIVERED',NULL,16,0,1,0,0,0),(17,'Eliminado',14,3,'ERASED',NULL,17,0,0,0,0,0),(20,'Asignado',4,1,'PICKER_DESIGNED',NULL,20,1,0,0,0,0),(21,'Retornado',4,1,'PRINTED_BACK',6,21,0,0,0,0,0),(22,'¿Fecha?',2,0,'WRONG_DATE',NULL,22,0,0,0,0,0),(23,'URGENTE',2,0,'LAST_CALL',NULL,23,1,0,0,0,0),(24,'Encadenado',4,0,'CHAINED',4,24,0,0,0,0,0),(25,'Embarcando',3,0,'BOARDING',5,25,0,0,0,0,0),(26,'Prep Previa',5,1,'PREVIOUS_PREPARATION',1,26,0,0,0,1,0),(27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0,0,0,0,0),(28,'Previa OK',3,1,'OK PREVIOUS',3,28,1,0,0,1,1),(29,'Previa Impreso',4,1,'PRINTED PREVIOUS',2,29,1,0,1,1,0),(30,'Embarcado',4,0,'BOARD',5,30,0,0,0,2,0); /*!40000 ALTER TABLE `state` ENABLE KEYS */; UNLOCK TABLES; @@ -297,7 +297,7 @@ UNLOCK TABLES; LOCK TABLES `sample` WRITE; /*!40000 ALTER TABLE `sample` DISABLE KEYS */; -INSERT INTO `sample` VALUES (1,'Carta_1','Aviso inicial por saldo deudor',0,'0'),(2,'Carta_2','Reiteracion de aviso por saldo deudor',0,'0'),(3,'Cred_Up','Notificación de aumento de crédito',0,'0'),(4,'Cred_down','Notificación de reducción de crédito',0,'0'),(5,'Pet_CC','Petición de datos bancarios B2B',0,'0'),(6,'SolCredito','Solicitud de crédito',0,'0'),(7,'LeyPago','Ley de pagos',0,'0'),(8,'Pet_CC_Core','Petición de datos bancarios CORE',0,'0'),(9,'nueva_alta','Documento de nueva alta de cliente',0,'0'),(10,'client_welcome','Email de bienvenida para nuevo cliente',0,'0'),(11,'setup_printer','Email de instalación de impresora',0,'0'),(12,'client-welcome','Bienvenida como nuevo cliente',1,'0'),(13,'printer-setup','Instalación y configuración de impresora de coronas',1,'0'),(14,'sepa-core','Solicitud de domiciliación bancaria',1,'1'),(15,'letter-debtor-st','Aviso inicial por saldo deudor',1,'1'),(16,'letter-debtor-nd','Aviso reiterado por saldo deudor',1,'1'),(17,'client-lcr','Email de solicitud de datos bancarios LCR',0,'1'); +INSERT INTO `sample` VALUES (1,'Carta_1','Aviso inicial por saldo deudor',0,0,1),(2,'Carta_2','Reiteracion de aviso por saldo deudor',0,0,1),(3,'Cred_Up','Notificación de aumento de crédito',0,0,1),(4,'Cred_down','Notificación de reducción de crédito',0,0,1),(5,'Pet_CC','Petición de datos bancarios B2B',0,0,1),(6,'SolCredito','Solicitud de crédito',0,0,1),(7,'LeyPago','Ley de pagos',0,0,1),(8,'Pet_CC_Core','Petición de datos bancarios CORE',0,0,1),(9,'nueva_alta','Documento de nueva alta de cliente',0,0,1),(10,'client_welcome','Email de bienvenida para nuevo cliente',0,0,1),(11,'setup_printer','Email de instalación de impresora',0,0,1),(12,'client-welcome','Bienvenida como nuevo cliente',1,0,1),(13,'printer-setup','Instalación y configuración de impresora de coronas',1,0,1),(14,'sepa-core','Solicitud de domiciliación bancaria',1,1,0),(15,'letter-debtor-st','Aviso inicial por saldo deudor',1,1,1),(16,'letter-debtor-nd','Aviso reiterado por saldo deudor',1,1,1),(17,'client-lcr','Email de solicitud de datos bancarios LCR',0,1,1); /*!40000 ALTER TABLE `sample` ENABLE KEYS */; UNLOCK TABLES; @@ -307,7 +307,7 @@ UNLOCK TABLES; LOCK TABLES `department` WRITE; /*!40000 ALTER TABLE `department` DISABLE KEYS */; -INSERT INTO `department` VALUES (1,'VERDNATURA',1,2,763,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(22,'COMPRAS',3,4,NULL,72,596,2,5,0,0,0,0,NULL,'/',NULL),(23,'CAMARA',5,6,NULL,72,604,2,6,1,0,0,0,NULL,'/',NULL),(31,'INFORMATICA',7,8,NULL,72,127,3,9,0,0,0,0,NULL,'/','informatica'),(34,'CONTABILIDAD',9,10,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(35,'FINANZAS',11,12,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(36,'LABORAL',13,14,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(37,'PRODUCCION',15,24,NULL,72,230,3,11,0,0,0,4,NULL,'/',NULL),(38,'SACADO',16,17,NULL,72,230,4,14,1,0,1,0,37,'/37/',NULL),(39,'ENCAJADO',18,19,NULL,72,230,4,12,1,0,1,0,37,'/37/',NULL),(41,'ADMINISTRACION',25,26,NULL,72,599,3,8,0,0,0,0,NULL,'/',NULL),(43,'VENTAS',27,48,NULL,0,NULL,NULL,NULL,0,0,0,10,NULL,'/',NULL),(44,'GERENCIA',49,50,NULL,72,300,2,7,0,0,0,0,NULL,'/',NULL),(45,'LOGISTICA',51,52,NULL,72,596,3,19,0,0,0,0,NULL,'/',NULL),(46,'REPARTO',20,21,NULL,72,659,3,10,0,0,1,0,37,'/37/',NULL),(48,'ALMACENAJE',53,54,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(49,'PROPIEDAD',55,56,NULL,72,1008,1,1,0,0,0,0,NULL,'/',NULL),(52,'CARGA AEREA',57,58,NULL,72,163,4,28,0,0,0,0,NULL,'/',NULL),(53,'MARKETING Y COMUNICACIÓN',59,60,NULL,72,1238,0,0,0,0,0,0,NULL,'/',NULL),(54,'ORNAMENTALES',61,62,NULL,72,433,3,21,0,0,0,0,NULL,'/',NULL),(55,'TALLER NATURAL',63,64,NULL,72,695,2,23,0,0,0,0,NULL,'/',NULL),(56,'TALLER ARTIFICIAL',65,66,NULL,72,1780,2,24,0,0,0,0,NULL,'/',NULL),(58,'CAMPOS',67,68,NULL,72,225,2,2,0,0,0,0,NULL,'/',NULL),(59,'MANTENIMIENTO',69,70,NULL,72,1907,4,16,0,0,0,0,NULL,'/',NULL),(60,'RECLAMACIONES',71,72,NULL,72,563,3,20,0,0,0,0,NULL,'/',NULL),(61,'VNH',73,74,NULL,73,1297,3,17,0,0,0,0,NULL,'/',NULL),(63,'VENTAS FRANCIA',28,29,NULL,72,277,2,27,0,0,1,0,43,'/43/',NULL),(66,'VERDNAMADRID',75,76,NULL,72,163,3,18,0,0,0,0,NULL,'/',NULL),(68,'COMPLEMENTOS',77,78,NULL,72,617,3,26,1,0,0,0,NULL,'/',NULL),(69,'VERDNABARNA',79,80,NULL,74,432,3,22,0,0,0,0,NULL,'/',NULL),(77,'PALETIZADO',22,23,NULL,72,230,4,15,1,0,1,0,37,'/37/',NULL),(80,'EQUIPO J VALLES',30,31,NULL,72,693,3,4,0,0,1,0,43,'/43/','jvp_equipo'),(86,'LIMPIEZA',81,82,NULL,72,599,0,0,0,0,0,0,NULL,'/',NULL),(89,'COORDINACION',83,84,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL),(90,'TRAILER',85,86,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(91,'ARTIFICIAL',87,88,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL),(92,'EQUIPO SILVERIO',32,33,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','sdc_equipo'),(93,'CONFECCION',89,90,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(94,'EQUIPO J BROCAL',34,35,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jes_equipo'),(95,'EQUIPO C ZAMBRANO',36,37,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','czg_equipo'),(96,'EQUIPO C LOPEZ',38,39,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','cla_equipo'),(97,'EQUIPO D SARRION',40,41,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','dsr_equipo'),(98,'EQUIPO RODRIGO',42,43,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','rhr_equipo'),(99,'EQUIPO MANOLI',44,45,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','man_equipo'),(101,'EQUIPO J IBAÑEZ',46,47,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jmi_equipo'); +INSERT INTO `department` VALUES (1,'VERDNATURA',1,2,763,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(22,'COMPRAS',3,4,NULL,72,596,2,5,0,0,0,0,NULL,'/',NULL),(23,'CAMARA',5,6,NULL,72,604,2,6,1,0,0,0,NULL,'/',NULL),(31,'INFORMATICA',7,8,NULL,72,127,3,9,0,0,0,0,NULL,'/','informatica'),(34,'CONTABILIDAD',9,10,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(35,'FINANZAS',11,12,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(36,'LABORAL',13,14,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(37,'PRODUCCION',15,42,NULL,72,230,3,11,0,0,0,13,NULL,'/',NULL),(38,'SACADO',16,17,NULL,72,230,4,14,1,0,1,0,37,'/37/',NULL),(39,'ENCAJADO',18,19,NULL,72,230,4,12,1,0,1,0,37,'/37/',NULL),(41,'ADMINISTRACION',43,44,NULL,72,599,3,8,0,0,0,0,NULL,'/',NULL),(43,'VENTAS',45,66,NULL,0,NULL,NULL,NULL,0,0,0,10,NULL,'/',NULL),(44,'GERENCIA',67,68,NULL,72,300,2,7,0,0,0,0,NULL,'/',NULL),(45,'LOGISTICA',69,70,NULL,72,596,3,19,0,0,0,0,NULL,'/',NULL),(46,'REPARTO',20,21,NULL,72,659,3,10,0,0,1,0,37,'/37/',NULL),(48,'ALMACENAJE',71,72,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(49,'PROPIEDAD',73,74,NULL,72,1008,1,1,0,0,0,0,NULL,'/',NULL),(52,'CARGA AEREA',75,76,NULL,72,163,4,28,0,0,0,0,NULL,'/',NULL),(53,'MARKETING Y COMUNICACIÓN',77,78,NULL,72,1238,0,0,0,0,0,0,NULL,'/',NULL),(54,'ORNAMENTALES',79,80,NULL,72,433,3,21,0,0,0,0,NULL,'/',NULL),(55,'TALLER NATURAL',81,82,NULL,72,695,2,23,0,0,0,0,NULL,'/',NULL),(56,'TALLER ARTIFICIAL',83,84,NULL,72,1780,2,24,0,0,0,0,NULL,'/',NULL),(58,'CAMPOS',85,86,NULL,72,225,2,2,0,0,0,0,NULL,'/',NULL),(59,'MANTENIMIENTO',87,88,NULL,72,1907,4,16,0,0,0,0,NULL,'/',NULL),(60,'RECLAMACIONES',89,90,NULL,72,563,3,20,0,0,0,0,NULL,'/',NULL),(61,'VNH',91,92,NULL,73,1297,3,17,0,0,0,0,NULL,'/',NULL),(63,'VENTAS FRANCIA',46,47,NULL,72,277,2,27,0,0,1,0,43,'/43/',NULL),(66,'VERDNAMADRID',93,94,NULL,72,163,3,18,0,0,0,0,NULL,'/',NULL),(68,'COMPLEMENTOS',95,96,NULL,72,617,3,26,1,0,0,0,NULL,'/',NULL),(69,'VERDNABARNA',97,98,NULL,74,432,3,22,0,0,0,0,NULL,'/',NULL),(77,'PALETIZADO',22,23,NULL,72,230,4,15,1,0,1,0,37,'/37/',NULL),(80,'EQUIPO J VALLES',48,49,NULL,72,693,3,4,0,0,1,0,43,'/43/','jvp_equipo'),(86,'LIMPIEZA',99,100,NULL,72,599,0,0,0,0,0,0,NULL,'/',NULL),(89,'COORDINACION',101,102,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL),(90,'TRAILER',103,104,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(91,'ARTIFICIAL',105,106,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL),(92,'EQUIPO SILVERIO',50,51,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','sdc_equipo'),(93,'CONFECCION',107,108,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(94,'EQUIPO J BROCAL',52,53,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jes_equipo'),(95,'EQUIPO C ZAMBRANO',54,55,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','czg_equipo'),(96,'EQUIPO C LOPEZ',56,57,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','cla_equipo'),(97,'EQUIPO D SARRION',58,59,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','dsr_equipo'),(98,'EQUIPO RODRIGO',60,61,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','rhr_equipo'),(99,'EQUIPO MANOLI',62,63,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','man_equipo'),(101,'EQUIPO J IBAÑEZ',64,65,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jmi_equipo'),(102,'EQ ROJO FV RUBEN C',24,25,NULL,0,NULL,NULL,NULL,0,0,1,0,37,'/37/',NULL),(103,'EQ AZUL FV A FOLQUES',26,27,NULL,0,NULL,NULL,NULL,0,0,1,0,37,'/37/',NULL),(104,'EQ AMARILLO FV NORMAN G',28,29,NULL,0,NULL,NULL,NULL,0,0,1,0,37,'/37/',NULL),(105,'EQ MORADO FV MATOU',30,31,NULL,0,NULL,NULL,NULL,0,0,1,0,37,'/37/',NULL),(106,'EQ VERDE PCA KEVIN GIMENEZ',32,33,NULL,0,NULL,NULL,NULL,0,0,1,0,37,'/37/',NULL),(107,'EQ NARANJA PCA RUBEN ZANON',34,35,NULL,0,NULL,NULL,NULL,0,0,1,0,37,'/37/',NULL),(109,'EQ MARRON PCA JC ESTELLES',36,37,NULL,0,NULL,NULL,NULL,0,0,1,0,37,'/37/',NULL),(110,'EQ ROSA PCA J BONDIA',38,39,NULL,0,NULL,NULL,NULL,0,0,1,0,37,'/37/',NULL),(111,'EQ REPONEDOR CAJAS',40,41,NULL,0,NULL,NULL,NULL,0,0,1,0,37,'/37/',NULL); /*!40000 ALTER TABLE `department` ENABLE KEYS */; UNLOCK TABLES; @@ -340,7 +340,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-02-13 9:07:05 +-- Dump completed on 2020-02-27 13:26:25 USE `cache`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -378,7 +378,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-02-13 9:07:05 +-- Dump completed on 2020-02-27 13:26:26 USE `hedera`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -436,7 +436,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-02-13 9:07:06 +-- Dump completed on 2020-02-27 13:26:26 USE `postgresql`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -491,7 +491,7 @@ UNLOCK TABLES; LOCK TABLES `professional_category` WRITE; /*!40000 ALTER TABLE `professional_category` DISABLE KEYS */; -INSERT INTO `professional_category` VALUES (1,'Mozos',5,1,27.5),(2,'Encargados',3,1,27.5),(4,'Comprador',3,1,27.5),(5,'Aux Administracion',NULL,1,27.5),(6,'Of Administracion',3,1,27.5),(7,'Jefe Administracion',2,1,27.5),(8,'Informatico',3,1,27.5),(9,'Directivo',1,0,27.5),(10,'Aux Ventas',4,1,27.5),(11,'Vendedor',4,1,27.5),(12,'Jefe de Ventas',4,0,27.5),(13,'Repartidor',5,1,27.5),(14,'Aprendices',NULL,1,27.5),(15,'Técnicos',2,1,27.5),(16,'Aux Florista',5,1,27.5),(17,'Florista',4,1,27.5),(18,'Jefe Floristas',2,1,27.5),(19,'Técnico marketing',3,1,27.5),(20,'Auxiliar marketing',4,1,27.5),(21,'Aux Informática',4,1,27.5),(22,'Peón agrícola',5,1,27.5),(23,'Oficial mantenimiento',4,1,27.5),(24,'Aux mantenimiento',5,1,27.5),(25,'Mozo Aeropuerto',5,1,27.5),(26,'Coordinador',2,1,27.5),(28,'Aux Logistica',4,1,27.5),(29,'Oficial Logistica',3,1,27.5),(30,'Subencargado',4,1,27.5),(31,'Conductor +3500kg',NULL,1,NULL); +INSERT INTO `professional_category` VALUES (1,'Mozos',5,1,27.5,NULL),(2,'Encargados',3,1,27.5,NULL),(4,'Comprador',3,1,27.5,NULL),(5,'Aux Administracion',NULL,1,27.5,NULL),(6,'Of Administracion',3,1,27.5,NULL),(7,'Jefe Administracion',2,1,27.5,NULL),(8,'Informatico',3,1,27.5,NULL),(9,'Directivo',1,0,27.5,NULL),(10,'Aux Ventas',4,1,27.5,NULL),(11,'Vendedor',4,1,27.5,NULL),(12,'Jefe de Ventas',4,0,27.5,NULL),(13,'Repartidor',5,1,27.5,NULL),(14,'Aprendices',NULL,1,27.5,NULL),(15,'Técnicos',2,1,27.5,NULL),(16,'Aux Florista',5,1,27.5,NULL),(17,'Florista',4,1,27.5,NULL),(18,'Jefe Floristas',2,1,27.5,NULL),(19,'Técnico marketing',3,1,27.5,NULL),(20,'Auxiliar marketing',4,1,27.5,NULL),(21,'Aux Informática',4,1,27.5,NULL),(22,'Peón agrícola',5,1,27.5,NULL),(23,'Oficial mantenimiento',4,1,27.5,NULL),(24,'Aux mantenimiento',5,1,27.5,NULL),(25,'Mozo Aeropuerto',5,1,27.5,NULL),(26,'Coordinador',2,1,27.5,NULL),(28,'Aux Logistica',4,1,27.5,NULL),(29,'Oficial Logistica',3,1,27.5,NULL),(30,'Subencargado',4,1,27.5,NULL),(31,'Conductor +3500kg',NULL,1,27.5,32400),(32,'Oficial 1ª',NULL,1,27.5,NULL),(33,'Oficial 2ª',NULL,1,27.5,NULL),(34,'Supervisor',NULL,1,27.5,NULL); /*!40000 ALTER TABLE `professional_category` ENABLE KEYS */; UNLOCK TABLES; @@ -524,4 +524,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-02-13 9:07:06 +-- Dump completed on 2020-02-27 13:26:27 diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 2f3a9378d9..3dff43eb79 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -39,8 +39,8 @@ INSERT INTO `account`.`user`(`id`,`name`, `nickname`, `password`,`role`,`active` FROM `account`.`role` WHERE id <> 20 ORDER BY id; -INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `userFk`, `bossFk`) - SELECT id,UPPER(LPAD(role, 3, '0')), name, name, id, 9 +INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `userFk`, `bossFk`, `email`) + SELECT id,UPPER(LPAD(role, 3, '0')), name, name, id, 9, 'test@nightmare.es' FROM `vn`.`user`; UPDATE `vn`.`worker` SET bossFk = NULL WHERE id = 20; @@ -68,13 +68,13 @@ INSERT INTO `account`.`user`(`id`,`name`,`nickname`, `password`,`role`,`active`, (111, 'Missing', 'Missing', 'ac754a330530832ba1bf7687f577da91', 2, 0, NULL, 'en'), (112, 'Trash', 'Trash', 'ac754a330530832ba1bf7687f577da91', 2, 0, NULL, 'en'); -INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossFk`, `phone`) +INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossFk`, `phone`, `email`) VALUES - (106, 'LGN', 'David Charles', 'Haller', 106, 19, 432978106), - (107, 'ANT', 'Hank' , 'Pym' , 107, 19, 432978107), - (108, 'DCX', 'Charles' , 'Xavier', 108, 19, 432978108), - (109, 'HLK', 'Bruce' , 'Banner', 109, 19, 432978109), - (110, 'JJJ', 'Jessica' , 'Jones' , 110, 19, 432978110); + (106, 'LGN', 'David Charles', 'Haller', 106, 19, 432978106, 'test@nightmare.es'), + (107, 'ANT', 'Hank' , 'Pym' , 107, 19, 432978107, 'test@nightmare.es'), + (108, 'DCX', 'Charles' , 'Xavier', 108, 19, 432978108, 'test@nightmare.es'), + (109, 'HLK', 'Bruce' , 'Banner', 109, 19, 432978109, 'test@nightmare.es'), + (110, 'JJJ', 'Jessica' , 'Jones' , 110, 19, 432978110, 'test@nightmare.es'); INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`, `ibanLength`) VALUES @@ -1580,6 +1580,13 @@ INSERT INTO `postgresql`.`business_labour`(`business_id`, `notes`, `department_i SELECT b.business_id, NULL, 23, 1, 0, 1, 1, 1, 1 FROM `postgresql`.`business` `b`; +UPDATE `postgresql`.`business_labour` bl + JOIN `postgresql`.`business` b ON b.business_id = bl.business_id + JOIN `postgresql`.`profile` pr ON pr.profile_id = b.client_id + JOIN `postgresql`.`person` p ON p.person_id = pr.person_id + SET bl.`professional_category_id` = 31 + WHERE p.`Id_trabajador` = 110; + INSERT INTO `postgresql`.`media`(`media_id`, `media_type_id`, `value`, `sort`) VALUES (1, 10, 600123321, 0), @@ -1951,9 +1958,9 @@ INSERT INTO `vn`.`queuePriority`(`id`, `priority`) (2, 'Normal'), (3, 'Baja'); -INSERT INTO `vn`.`workerTimeControlParams` (`id`, `dayBreak`, `weekBreak`, `weekScope`, `dayWorkMax`, `dayStayMax`) +INSERT INTO `vn`.`workerTimeControlParams` (`id`, `dayBreak`, `weekBreak`, `weekScope`, `dayWorkMax`, `dayStayMax`, `weekMaxBreak`, `weekMaxScope`, `askInOut`) VALUES - (1, 43200, 129600, 734400, 43200, 50400); + (1, 43200, 129600, 734400, 43200, 50400, 259200, 1296000, 36000); INSERT IGNORE INTO `vn`.`greugeConfig` (`id`, `freightPickUpPrice`) VALUES ('1', '11'); @@ -1973,11 +1980,21 @@ INSERT INTO `vn`.`travelThermograph`(`thermographFk`, `created`, `warehouseFk`, ('138350-0', DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 1, 'WARM', NULL, 5), ('138350-0', CURDATE(), 1, NULL, 'COOL', NULL, NULL); -REPLACE INTO `vn`.`incoterms` (`code`, `name`) +REPLACE INTO `vn`.`incoterms`(`code`, `name`) VALUES ('FAS', 'Free Alongside Ship'); -REPLACE INTO `vn`.`customsAgent` (`id`, `fiscalName`, `street`, `nif`, `phone`, `email`) +REPLACE INTO `vn`.`customsAgent`(`id`, `fiscalName`, `street`, `nif`, `phone`, `email`) VALUES (1, 'Agent one', '1007 Mountain Drive, Gotham', 'N1111111111', '111111111', 'agentone@gotham.com'), - (2, 'Agent two', '1007 Mountain Drive, Gotham', 'N2222222222', '222222222', 'agenttwo@gotham.com'); \ No newline at end of file + (2, 'Agent two', '1007 Mountain Drive, Gotham', 'N2222222222', '222222222', 'agenttwo@gotham.com'); + +INSERT INTO `vn`.`tabletDepartment`(`tabletFk`, `departmentFk`) + VALUES + (1, 23), + (2, 1); + +INSERT INTO `vn`.`tablet`(`uuid`, `name`, `place`, `macwifi`) + VALUES + ('1', 'TEST', 'ON THE FIXTURES', '0'), + ('2', 'DEV', 'OTHER TABLET', '0'); diff --git a/db/dump/structure.sql b/db/dump/structure.sql index 35cb82fd4a..c008cb055f 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -1948,6 +1948,22 @@ CREATE TABLE `compradores_evolution` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `conveyorStats` +-- + +DROP TABLE IF EXISTS `conveyorStats`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `conveyorStats` ( + `created` datetime NOT NULL, + `saturacion` int(11) DEFAULT NULL, + `velocidad` int(11) DEFAULT NULL, + `rutas` int(11) DEFAULT NULL, + PRIMARY KEY (`created`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `defaulter` -- @@ -8028,7 +8044,8 @@ CREATE TABLE `supplyResponse` ( `MarketFormCode` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '"002" Standard Sales\n"005" Catalogue (optional)\n"001" Committed (optional)\n"003" Buffer (optional, Clock Pre Sales) ', PRIMARY KEY (`ID`), UNIQUE KEY `ID_UNIQUE` (`ID`), - KEY `IX_TransNumber` (`TransactionNumber`) COMMENT 'Agregado por Ernesto 11.6.2019\nSe ejecutaba 1 consulta por segundo desde MAIL y consumia un 20% de CPU de todo el servidor !!!!!\nCPU usada es mas estable que Indice en SendererID, cpu vs espacio que ocupa?\n' + KEY `IX_TransNumber` (`TransactionNumber`) COMMENT 'Agregado por Ernesto 11.6.2019\nSe ejecutaba 1 consulta por segundo desde MAIL y consumia un 20% de CPU de todo el servidor !!!!!\nCPU usada es mas estable que Indice en SendererID, cpu vs espacio que ocupa?\n', + KEY `supplyResponse_Ix1` (`Item_ArticleCode`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -11896,7 +11913,8 @@ BEGIN * * @param vSelf The order identifier */ - CALL order_confirmWithUser(vSelf, account.userGetId()); + DECLARE vUser INT DEFAULT account.userGetId(); + CALL order_confirmWithUser(vSelf, vUser); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -14833,6 +14851,8 @@ CREATE TABLE `calendar_state` ( `permissionRate` decimal(3,2) DEFAULT NULL, `code` varchar(45) DEFAULT NULL, `isAllowedToWork` tinyint(4) NOT NULL DEFAULT '0', + `isPrintable` tinyint(1) NOT NULL DEFAULT '0', + `discountRate` decimal(3,2) DEFAULT NULL, PRIMARY KEY (`calendar_state_id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -15038,6 +15058,7 @@ CREATE TABLE `professional_category` ( `professional_levels_id` int(11) DEFAULT NULL, `fichajes` tinyint(4) NOT NULL DEFAULT '1', `holiday_days` decimal(3,1) DEFAULT NULL, + `dayBreak` int(11) DEFAULT NULL, PRIMARY KEY (`professional_category_id`), UNIQUE KEY `professional_category_name_category_key` (`category_name`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8; @@ -17626,6 +17647,43 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `procNoOverlap` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`jenkins`@`172.16.%.%` PROCEDURE `procNoOverlap`(procName VARCHAR(255)) + SQL SECURITY INVOKER +proc: BEGIN +/** + * call procedure without overlap + */ + DECLARE vIsChanged BOOL; + + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION + BEGIN + DO RELEASE_LOCK(procName); + RESIGNAL; + END; + + IF !GET_LOCK(procName, 0) THEN + LEAVE proc; + END IF; + + CALL exec(CONCAT('CALL ', procName)); + + DO RELEASE_LOCK(procName); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `proc_changedPrivs` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -17979,6 +18037,8 @@ CREATE TABLE `address` ( `latitude` decimal(11,7) DEFAULT NULL, `codPosOld` char(5) COLLATE utf8_unicode_ci DEFAULT NULL, `isEqualizated` tinyint(1) DEFAULT NULL, + `customsAgentFk` int(11) DEFAULT NULL, + `incotermsFk` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `Id_Agencia` (`agencyModeFk`), KEY `Id_cliente` (`clientFk`), @@ -17987,10 +18047,14 @@ CREATE TABLE `address` ( KEY `telefono` (`phone`), KEY `movil` (`mobile`), KEY `CODPOSTAL` (`postalCode`), + KEY `address_customsAgentFk_idx` (`customsAgentFk`), + KEY `address_incotermsFk_idx` (`incotermsFk`), CONSTRAINT `address_customer_id` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE, + CONSTRAINT `address_customsAgentFk` FOREIGN KEY (`customsAgentFk`) REFERENCES `customsAgent` (`id`) ON UPDATE CASCADE, CONSTRAINT `address_ibfk_1` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `address_ibfk_3` FOREIGN KEY (`provinceFk`) REFERENCES `province` (`id`) ON UPDATE CASCADE, - CONSTRAINT `address_ibfk_4` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE + CONSTRAINT `address_ibfk_4` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE, + CONSTRAINT `address_incotermsFk` FOREIGN KEY (`incotermsFk`) REFERENCES `incoterms` (`code`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -19462,6 +19526,48 @@ CREATE TABLE `clientManaCache` ( CONSTRAINT `cliente_fk` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`clientManaCache_AFTER_INSERT` AFTER INSERT ON `clientManaCache` FOR EACH ROW +BEGIN + IF NEW.clientFk = 7157 THEN + INSERT INTO mail(sender, replyTo, `subject`, body) + SELECT 'carlosap@verdnatura.es','carlosap@verdnatura.es','Mana cliente 7157 ', CONCAT(current_user(), USER()); + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`clientManaCache_AFTER_UPDATE` AFTER UPDATE ON `clientManaCache` FOR EACH ROW +BEGIN + IF NEW.clientFk = 7157 THEN + INSERT INTO mail(sender, replyTo, `subject`, body) + SELECT 'carlosap@verdnatura.es','carlosap@verdnatura.es','Mana cliente 7157 ', CONCAT(current_user(), USER()); + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; -- -- Temporary table structure for view `clientManaCache__` @@ -20121,6 +20227,7 @@ CREATE TABLE `conveyorExpedition` ( `x` int(11) NOT NULL DEFAULT '1', `y` int(11) NOT NULL DEFAULT '1', `routeFk` int(11) NOT NULL, + `isBuilt` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`expeditionFk`), KEY `conveyorExpedition_fk1_idx` (`conveyorFk`), KEY `conveyorExpedition_fk2_idx` (`conveyorBuildingClassFk`), @@ -20129,6 +20236,21 @@ CREATE TABLE `conveyorExpedition` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `conveyorMode` +-- + +DROP TABLE IF EXISTS `conveyorMode`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `conveyorMode` ( + `code` varchar(20) COLLATE utf8_unicode_ci NOT NULL, + `saturacion` int(11) NOT NULL, + `gap` int(11) NOT NULL, + PRIMARY KEY (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `conveyorType` -- @@ -20473,6 +20595,25 @@ CREATE TABLE `currency` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `customsAgent` +-- + +DROP TABLE IF EXISTS `customsAgent`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `customsAgent` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `fiscalName` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, + `street` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `nif` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, + `phone` varchar(16) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `email` varchar(150) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `nif_UNIQUE` (`nif`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `dayMinute` -- @@ -20880,6 +21021,23 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +-- +-- Table structure for table `dmsRecover` +-- + +DROP TABLE IF EXISTS `dmsRecover`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `dmsRecover` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `ticketFk` int(11) DEFAULT NULL, + `sign` text COLLATE utf8_unicode_ci, + PRIMARY KEY (`id`), + KEY `ticketFk_idx` (`ticketFk`), + CONSTRAINT `ticketFk` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `dmsType` -- @@ -21823,45 +21981,59 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `holidayDetail` +-- Temporary table structure for view `holidayDetail__` -- -DROP TABLE IF EXISTS `holidayDetail`; -/*!50001 DROP VIEW IF EXISTS `holidayDetail`*/; +DROP TABLE IF EXISTS `holidayDetail__`; +/*!50001 DROP VIEW IF EXISTS `holidayDetail__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `holidayDetail` AS SELECT +/*!50001 CREATE VIEW `holidayDetail__` AS SELECT 1 AS `id`, 1 AS `description`*/; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `holidayLegend` +-- Temporary table structure for view `holidayLegend__` -- -DROP TABLE IF EXISTS `holidayLegend`; -/*!50001 DROP VIEW IF EXISTS `holidayLegend`*/; +DROP TABLE IF EXISTS `holidayLegend__`; +/*!50001 DROP VIEW IF EXISTS `holidayLegend__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `holidayLegend` AS SELECT +/*!50001 CREATE VIEW `holidayLegend__` AS SELECT 1 AS `id`, 1 AS `description`*/; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `holidayType` +-- Temporary table structure for view `holidayType__` -- -DROP TABLE IF EXISTS `holidayType`; -/*!50001 DROP VIEW IF EXISTS `holidayType`*/; +DROP TABLE IF EXISTS `holidayType__`; +/*!50001 DROP VIEW IF EXISTS `holidayType__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `holidayType` AS SELECT +/*!50001 CREATE VIEW `holidayType__` AS SELECT 1 AS `id`, 1 AS `name`, 1 AS `rgb`*/; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `incoterms` +-- + +DROP TABLE IF EXISTS `incoterms`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `incoterms` ( + `code` varchar(3) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', + `name` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + PRIMARY KEY (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Internacional Commercial Terms'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `ink` -- @@ -22324,7 +22496,7 @@ CREATE TABLE `item` ( `image` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `inkFk` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, `niche` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `intrastatFk` int(8) unsigned zerofill DEFAULT NULL, + `intrastatFk` int(8) unsigned zerofill NOT NULL DEFAULT '06039010', `hasMinPrice` tinyint(1) NOT NULL DEFAULT '0', `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `isOnOffer` tinyint(4) NOT NULL DEFAULT '0', @@ -22990,9 +23162,7 @@ CREATE TABLE `itemShelving` ( DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`itemShelving_BEFORE_INSERT` BEFORE INSERT ON `itemShelving` FOR EACH ROW BEGIN - SET NEW.userFk = account.userGetId(); - END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -23008,11 +23178,9 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`z-developer`@`%`*/ /*!50003 TRIGGER `vn`.`itemShelving_BEFORE_UPDATE` BEFORE UPDATE ON `itemShelving` FOR EACH ROW +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`itemShelving_BEFORE_UPDATE` BEFORE UPDATE ON `itemShelving` FOR EACH ROW BEGIN - SET NEW.userFk = account.userGetId(); - END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -23638,6 +23806,19 @@ CREATE TABLE `labourTree` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Temporary table structure for view `lastHourProduction` +-- + +DROP TABLE IF EXISTS `lastHourProduction`; +/*!50001 DROP VIEW IF EXISTS `lastHourProduction`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `lastHourProduction` AS SELECT + 1 AS `warehouseFk`, + 1 AS `m3`*/; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `lastTopClaims` -- @@ -25076,6 +25257,7 @@ CREATE TABLE `route` ( `m3` decimal(10,1) unsigned DEFAULT NULL, `description` text COLLATE utf8_unicode_ci, `zoneFk` int(11) DEFAULT NULL, + `priority` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `Id_Agencia` (`agencyModeFk`), KEY `Fecha` (`created`), @@ -25090,6 +25272,26 @@ CREATE TABLE `route` ( /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`route_AFTER_INSERT` AFTER INSERT ON `route` FOR EACH ROW +BEGIN + IF NEW.kmEnd < NEW.kmStart AND NEW.kmEnd <> 0 THEN + CALL util.throw ('KmEnd menor que kmStart'); + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8mb4 */ ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_general_ci */ ; @@ -25104,7 +25306,11 @@ BEGIN FROM vn.saleVolume s JOIN vn.ticket t ON s.ticketFk = t.id WHERE t.routeFk = NEW.id); - END IF; + END IF; + + IF NEW.kmEnd < NEW.kmStart AND NEW.kmEnd <> 0 THEN + CALL util.throw ('KmEnd menor que kmStart'); + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -25200,7 +25406,6 @@ CREATE TABLE `routeGate` ( `lastScanned` datetime DEFAULT NULL, `ready` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`deviceId`), - UNIQUE KEY `routeFk_UNIQUE` (`routeFk`), KEY `routeGate_fk1_idx` (`gateAreaFk`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -25478,7 +25683,7 @@ CREATE TABLE `saleComponent` ( `saleFk` int(11) NOT NULL, `componentFk` int(11) NOT NULL, `value` double NOT NULL, - `isGreuge` tinyint(4) NOT NULL DEFAULT '0', + `isGreuge` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Indica si ya se ha tenido en cuenta para calcular el greuge', `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`saleFk`,`componentFk`), KEY `fk_mov_comp_idx` (`componentFk`), @@ -25488,14 +25693,14 @@ CREATE TABLE `saleComponent` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `saleFreight` +-- Temporary table structure for view `saleFreight__` -- -DROP TABLE IF EXISTS `saleFreight`; -/*!50001 DROP VIEW IF EXISTS `saleFreight`*/; +DROP TABLE IF EXISTS `saleFreight__`; +/*!50001 DROP VIEW IF EXISTS `saleFreight__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `saleFreight` AS SELECT +/*!50001 CREATE VIEW `saleFreight__` AS SELECT 1 AS `ticketFk`, 1 AS `clientFk`, 1 AS `routeFk`, @@ -25504,8 +25709,7 @@ SET character_set_client = utf8; 1 AS `companyFk`, 1 AS `shipped`, 1 AS `price`, - 1 AS `freight`, - 1 AS `volume`*/; + 1 AS `freight`*/; SET character_set_client = @saved_cs_client; -- @@ -25635,7 +25839,45 @@ SET character_set_client = utf8; 1 AS `volume`, 1 AS `physicalWeight`, 1 AS `weight`, - 1 AS `physicalVolume`*/; + 1 AS `physicalVolume`, + 1 AS `freight`, + 1 AS `zoneFk`, + 1 AS `clientFk`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `saleVolume__` +-- + +DROP TABLE IF EXISTS `saleVolume__`; +/*!50001 DROP VIEW IF EXISTS `saleVolume__`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `saleVolume__` AS SELECT + 1 AS `ticketFk`, + 1 AS `saleFk`, + 1 AS `litros`, + 1 AS `routeFk`, + 1 AS `shipped`, + 1 AS `volume`, + 1 AS `physicalWeight`, + 1 AS `weight`, + 1 AS `physicalVolume`, + 1 AS `freight`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `sale_freightComponent` +-- + +DROP TABLE IF EXISTS `sale_freightComponent`; +/*!50001 DROP VIEW IF EXISTS `sale_freightComponent`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `sale_freightComponent` AS SELECT + 1 AS `ticketFk`, + 1 AS `amount`, + 1 AS `shipped`*/; SET character_set_client = @saved_cs_client; -- @@ -25649,8 +25891,9 @@ CREATE TABLE `sample` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `code` varchar(20) CHARACTER SET utf8 NOT NULL, `description` varchar(105) COLLATE utf8_unicode_ci NOT NULL, - `isVisible` tinyint(4) NOT NULL DEFAULT '1', - `hasCompany` varchar(45) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0', + `isVisible` tinyint(1) unsigned NOT NULL DEFAULT '1', + `hasCompany` tinyint(1) unsigned NOT NULL DEFAULT '0', + `hasPreview` tinyint(1) unsigned NOT NULL DEFAULT '1', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -26048,6 +26291,7 @@ CREATE TABLE `state` ( `isPicked` tinyint(1) NOT NULL DEFAULT '0', `isPreparable` tinyint(1) NOT NULL DEFAULT '0', `semaphore` int(11) NOT NULL DEFAULT '0', + `isPrintable` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `code_UNIQUE` (`code`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -26244,7 +26488,7 @@ CREATE TABLE `tabletDepartment` ( `departmentFk` int(11) NOT NULL, PRIMARY KEY (`tabletFk`,`departmentFk`), KEY `departmentFk_idx` (`departmentFk`), - CONSTRAINT `departmentFk` FOREIGN KEY (`departmentFk`) REFERENCES `department` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION + CONSTRAINT `departmentFk` FOREIGN KEY (`departmentFk`) REFERENCES `department` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -26462,6 +26706,8 @@ CREATE TABLE `ticket` ( `isDeleted` tinyint(2) NOT NULL DEFAULT '0', `zoneFk` int(11) DEFAULT NULL, `collectionFk` int(11) DEFAULT NULL, + `zonePrice` decimal(10,2) DEFAULT NULL, + `zoneBonus` decimal(10,2) DEFAULT NULL, PRIMARY KEY (`id`), KEY `Id_Cliente` (`clientFk`), KEY `Id_Consigna` (`addressFk`), @@ -26535,9 +26781,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -27192,6 +27438,7 @@ DROP TABLE IF EXISTS `ticketUpdateAction`; CREATE TABLE `ticketUpdateAction` ( `id` int(11) NOT NULL AUTO_INCREMENT, `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `code` varchar(45) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='En esta tabla pondremos las distintas opciones que se ofrecen al comecial o al cliente al cambiar alguno de los parametros básicos de un ticket'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -28089,6 +28336,7 @@ CREATE TABLE `workerDocument` ( `id` int(11) NOT NULL AUTO_INCREMENT, `worker` int(10) unsigned DEFAULT NULL, `document` int(11) DEFAULT NULL, + `isReadableByWorker` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Indica si el empleado tiene permiso para acceder al documento', PRIMARY KEY (`id`), KEY `workerDocument_ibfk_1` (`worker`), KEY `workerDocument_ibfk_2` (`document`), @@ -28368,6 +28616,9 @@ CREATE TABLE `workerTimeControlParams` ( `weekScope` int(11) NOT NULL, `dayWorkMax` int(11) NOT NULL, `dayStayMax` int(11) NOT NULL, + `weekMaxBreak` int(11) NOT NULL, + `weekMaxScope` int(11) NOT NULL, + `askInOut` int(11) NOT NULL COMMENT 'Tiempo desde la última fichada que determinará si se pregunta al usuario por la dirección de la fichada', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='All values in seconds'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -28743,6 +28994,7 @@ CREATE TABLE `zoneEvent` ( `travelingDays` int(11) DEFAULT NULL, `price` decimal(10,2) DEFAULT NULL, `bonus` decimal(10,2) DEFAULT NULL, + `m3Max` decimal(10,2) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `zoneFk` (`zoneFk`), CONSTRAINT `zoneEvent_ibfk_1` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE @@ -28882,6 +29134,25 @@ CREATE TABLE `zoneWarehouse` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Temporary table structure for view `zone_ETD` +-- + +DROP TABLE IF EXISTS `zone_ETD`; +/*!50001 DROP VIEW IF EXISTS `zone_ETD`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `zone_ETD` AS SELECT + 1 AS `zoneFk`, + 1 AS `HoraTeórica`, + 1 AS `volumenTotal`, + 1 AS `volumenPendiente`, + 1 AS `velocidad`, + 1 AS `HoraPráctica`, + 1 AS `minutesLess`, + 1 AS `etc`*/; +SET character_set_client = @saved_cs_client; + -- -- Dumping events for database 'vn' -- @@ -29266,6 +29537,8 @@ CREATE DEFINER=`root`@`%` FUNCTION `bionicCalcReverse`(vWarehouse INT, vAgencyMode INT) RETURNS decimal(10,3) DETERMINISTIC BEGIN + + -- OBSOLETO usar catalog_componentReverse JGF 2020-02-26 DECLARE vGeneralInflationCoeficient INT; DECLARE vVerdnaturaVolumeBox BIGINT; DECLARE vClientFk INT; @@ -29278,107 +29551,8 @@ BEGIN DECLARE vItem INT DEFAULT 98; DECLARE vItemCarryBox INT; - SELECT generalInflationCoeFicient, verdnaturaVolumeBox, itemCarryBox - INTO vGeneralInflationCoeficient, vVerdnaturaVolumeBox, vItemCarryBox - FROM bionicConfig; + CALL util.throw('Obsoleto hablar con Informática'); - SELECT clientFk INTO vClientFk FROM address WHERE id = vAddress; - - -- Creamos la tabla tmp.bionicComponent - DROP TEMPORARY TABLE IF EXISTS tmp.bionicComponent; - CREATE TEMPORARY TABLE tmp.bionicComponent( - `warehouseFk` smallint(5) unsigned NOT NULL, - `itemFk` int(11) NOT NULL, - `componentFk` int(10) unsigned NOT NULL, - `value` decimal(10,4) NOT NULL, - UNIQUE KEY `itemWarehouseComponent` (`itemFk`,`warehouseFk`,`componentFk`) USING HASH, - KEY `itemWarehouse` (`itemFk`,`warehouseFk`) USING BTREE - ) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; - - -- Margin - INSERT INTO tmp.bionicComponent (warehouseFk, itemFk, componentFk, `value`) - SELECT vWarehouse, vItem, id, vMargin - FROM component - WHERE code = vComponentMargin; - - -- Recobro - INSERT INTO tmp.bionicComponent (warehouseFk, itemFk, componentFk, `value`) - SELECT vWarehouse, vItem, c.id, ROUND(LEAST(cr.recobro,0.25), 3) - FROM bi.claims_ratio cr - JOIN component c ON c.code = vComponentRecovery - WHERE cr.Id_Cliente = vClientFk AND cr.recobro > 0.009; - - -- Componente de maná automático, en función del maná acumulado por el comercial. - INSERT INTO tmp.bionicComponent (warehouseFk, itemFk, componentFk, `value`) - SELECT vWarehouse, vItem, co.id, ROUND(ms.prices_modifier_rate, 3) - FROM client c - JOIN bs.mana_spellers ms ON c.salesPersonFk = ms.Id_Trabajador - JOIN component co ON co.code = vComponentMana - WHERE ms.prices_modifier_activated AND c.id = vClientFk LIMIT 1; - - -- Reparto - INSERT INTO tmp.bionicComponent (warehouseFk, itemFk, componentFk, `value`) - SELECT vWarehouse, vItem, co.id, vGeneralInflationCoeficient - * ROUND( - vM3 - * az.price - * az.inflation - / vVerdnaturaVolumeBox, 4 - ) - FROM agencyMode ag - JOIN address a ON a.id = vAddress AND ag.id = vAgencyMode - JOIN agencyProvince ap ON ap.agencyFk = ag.agencyFk - AND ap.warehouseFk = vWarehouse AND ap.provinceFk = a.provinceFk - JOIN agencyModeZone az ON az.agencyModeFk = vAgencyMode - AND az.zone = ap.zone AND az.itemFk = 71 AND az.warehouseFk = vWarehouse - JOIN component co ON co.code = vComponentPort; - - -- Coste - SELECT vRetailedPrice - SUM(`value`) INTO vComponentCostValue - FROM tmp.bionicComponent; - - INSERT INTO tmp.bionicComponent (warehouseFk, itemFk, componentFk, `value`) - SELECT vWarehouse, vItem, id,vComponentCostValue - FROM component - WHERE code = vComponentCost; - - RETURN vComponentCostValue; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP FUNCTION IF EXISTS `bionicCalcReverse__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` FUNCTION `bionicCalcReverse__`(vWarehouse INT, - vMargin DECIMAL(10,3), - vRetailedPrice DECIMAL(10,3), - vM3 DECIMAL(10,3), - vAddress INT, - vAgencyMode INT) RETURNS decimal(10,3) - DETERMINISTIC -BEGIN - DECLARE vGeneralInflationCoeficient INT; - DECLARE vVerdnaturaVolumeBox BIGINT; - DECLARE vClientFk INT; - DECLARE vComponentRecovery VARCHAR(50) DEFAULT 'debtCollection'; - DECLARE vComponentMana VARCHAR(50) DEFAULT 'autoMana'; - DECLARE vComponentPort VARCHAR(50) DEFAULT 'delivery'; - DECLARE vComponentMargin VARCHAR(50) DEFAULT 'margin'; - DECLARE vComponentCost VARCHAR(50) DEFAULT 'purchaseValue'; - DECLARE vComponentCostValue DECIMAL(10,2); - DECLARE vItem INT DEFAULT 98; - DECLARE vItemCarryBox INT; - SELECT generalInflationCoeFicient, verdnaturaVolumeBox, itemCarryBox INTO vGeneralInflationCoeficient, vVerdnaturaVolumeBox, vItemCarryBox FROM bionicConfig; @@ -30045,7 +30219,7 @@ BEGIN l: LOOP SELECT workerSubstitute INTO vWorkerSubstituteFk FROM sharingCart - WHERE vDated BETWEEN started AND ended + WHERE curdate() BETWEEN started AND ended AND workerFk = vSalesPersonFk ORDER BY id LIMIT 1; @@ -31172,17 +31346,17 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP FUNCTION IF EXISTS `hasZone` */; +/*!50003 DROP FUNCTION IF EXISTS `hasZone__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` FUNCTION `hasZone`(vLanded DATE, vAddress INT, vAgencyModeFk INT) RETURNS tinyint(1) +CREATE DEFINER=`root`@`%` FUNCTION `hasZone__`(vLanded DATE, vAddress INT, vAgencyModeFk INT) RETURNS tinyint(1) DETERMINISTIC BEGIN DECLARE vHasZone BOOLEAN DEFAULT FALSE; @@ -32523,6 +32697,75 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP FUNCTION IF EXISTS `workerTimeControl_addDirection` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` FUNCTION `workerTimeControl_addDirection`( vUserFk INT, vWarehouseFk INT, vTimed DATETIME, vIsManual BOOL) RETURNS int(11) + DETERMINISTIC +BEGIN + DECLARE vDirection VARCHAR(6); + DECLARE vLastIn DATETIME; + DECLARE vDayStayMax INT; + DECLARE vHasDirectionOut INT; + DECLARE vLastInsertedId INT; + + SELECT dayStayMax INTO vDayStayMax + FROM workerTimeControlParams; + + SELECT timeWorkerControl_getDirection(vUserFk,vTimed) INTO vDirection; + + IF vDirection = 'out' THEN + + SELECT MAX(timed) INTO vLastIn + FROM workerTimeControl + WHERE userFk = vUserFk + AND direction = 'in' + AND timed < vTimed; + + UPDATE workerTimeControl wtc + SET wtc.direction = 'middle' + WHERE userFk = vUserFk + AND direction = 'out' + AND timed BETWEEN vLastIn AND vTimed; + + ELSE IF vDirection = 'in' THEN + + SELECT COUNT(*) INTO vHasDirectionOut + FROM workerTimeControl wtc + WHERE userFk = vUserFk + AND direction = 'out' + AND timed BETWEEN vTimed AND TIMESTAMPADD(SECOND, 50400, vTimed); + + UPDATE workerTimeControl wtc + SET wtc.direction = IF (vHasDirectionOut,'middle','out') + WHERE userFk = vUserFk + AND direction = 'in' + AND timed BETWEEN vTimed AND TIMESTAMPADD(SECOND, 50400, vTimed); + + END IF; + END IF; + + INSERT INTO workerTimeControl(userFk, timed, warehouseFk, direction, manual) + VALUES(vUserFk, vTimed, vWarehouseFk, vDirection, vIsManual); + + SET vLastInsertedId = LAST_INSERT_ID(); + + CALL workerTimeControlSOWP(vUserFk, vTimed); + + RETURN vLastInsertedId; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP FUNCTION IF EXISTS `worker_isWorking` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -35283,239 +35526,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `collectionPlacement_get_beta` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `collectionPlacement_get_beta`(vCollectionFk INT) -BEGIN - - DECLARE vCalcFk INT; - DECLARE vWarehouseFk INT; - DECLARE vWarehouseAliasFk INT; - - SELECT t.warehouseFk, w.aliasFk - INTO vWarehouseFk, vWarehouseAliasFk - FROM vn.ticket t - JOIN vn.ticketCollection tc ON tc.ticketFk = t.id - JOIN vn.warehouse w ON w.id = t.warehouseFk - WHERE tc.collectionFk = vCollectionFk - LIMIT 1; - - CALL cache.visible_refresh(vCalcFk,FALSE,vWarehouseFk); - - DROP TEMPORARY TABLE IF EXISTS tmp.parked; - CREATE TEMPORARY TABLE tmp.parked - ENGINE MEMORY - SELECT s.itemFk, 0 as quantity - FROM vn.ticketCollection tc - JOIN vn.sale s ON s.ticketFk = tc.ticketFk - WHERE tc.collectionFk = vCollectionFk; - - UPDATE tmp.parked pk - JOIN ( SELECT itemFk, sum(visible) as visible - FROM vn.itemShelvingStock iss - JOIN vn.warehouse w ON w.id = iss.warehouseFk - WHERE w.aliasFk = vWarehouseAliasFk - GROUP BY iss.itemFk ) iss ON iss.itemFk = pk.itemFk - SET pk.quantity = iss.visible; - - DROP TEMPORARY TABLE IF EXISTS tmp.`grouping`; - CREATE TEMPORARY TABLE tmp.`grouping` - ENGINE MEMORY - SELECT itemFk, `grouping` - FROM ( - SELECT itemFk, - CASE groupingMode - WHEN 0 THEN 1 - WHEN 2 THEN packing - ELSE `grouping` - END AS `grouping` - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel tr ON tr.id = e.travelFk - WHERE tr.warehouseInFk = vWarehouseFk - AND landed BETWEEN (SELECT FechaInventario FROM vn2008.tblContadores LIMIT 1) AND CURDATE() - AND b.isIgnored = FALSE - ORDER BY tr.landed DESC - ) sub - GROUP BY sub.itemFk ; - - DROP TEMPORARY TABLE IF EXISTS tmp.grouping2; - CREATE TEMPORARY TABLE tmp.grouping2 - ENGINE MEMORY - SELECT * FROM tmp.`grouping`; - - SELECT s.id as saleFk, s.itemFk, - p.code COLLATE utf8_general_ci as placement , - sh.code COLLATE utf8_general_ci as shelving, - ish.created, - ish.visible, - IFNULL(cpd.id,0) as `order`, - IF(sc.isPreviousPreparedByPacking, ish.packing, g.`grouping`) as `grouping` - FROM vn.ticketCollection tc - JOIN vn.sale s ON s.ticketFk = tc.ticketFk - JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk - JOIN vn.shelving sh ON sh.code = ish.shelvingFk - JOIN vn.parking p ON p.id = sh.parkingFk - LEFT JOIN vn.coolerPathDetail cpd ON CAST(cpd.hallway AS DECIMAL(3,0)) = p.column - JOIN vn.sector sc ON sc.id = p.sectorFk - JOIN vn.warehouse w ON w.id = sc.warehouseFk - JOIN tmp.`grouping` g ON g.itemFk = s.itemFk - WHERE tc.collectionFk = vCollectionFk - AND w.aliasFk = vWarehouseAliasFk - AND ish.visible > 0 - UNION ALL - SELECT s.id as saleFk, s.itemFk, - ip.code COLLATE utf8_general_ci as placement, - '' COLLATE utf8_general_ci as shelving, - modificationDate as created, - v.visible - p.quantity as visible, - IFNULL(cpd.id,0) as `order`, - g.`grouping` - FROM vn.ticketCollection tc - JOIN vn.sale s ON s.ticketFk = tc.ticketFk - JOIN vn.itemPlacement ip ON ip.itemFk = s.itemFk AND ip.warehouseFk = vWarehouseFk - LEFT JOIN vn.coolerPathDetail cpd ON cpd.hallway = LEFT(ip.`code`,3) - JOIN tmp.parked p ON p.itemFk = s.itemFk - JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vCalcFk - LEFT JOIN tmp.grouping2 g ON g.itemFk = s.itemFk - WHERE tc.collectionFk = vCollectionFk - AND v.visible - p.quantity > 0 - AND IFNULL(cpd.id,0); - - DROP TEMPORARY TABLE - tmp.parked, - tmp.`grouping`, - tmp.grouping2; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `collectionPlacement_get__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `collectionPlacement_get__`(vCollectionFk INT) -BEGIN - - DECLARE vCalcFk INT; - DECLARE vWarehouseFk INT; - DECLARE vWarehouseAliasFk INT; - - SELECT t.warehouseFk, w.aliasFk - INTO vWarehouseFk, vWarehouseAliasFk - FROM vn.ticket t - JOIN vn.ticketCollection tc ON tc.ticketFk = t.id - JOIN vn.warehouse w ON w.id = t.warehouseFk - WHERE tc.collectionFk = vCollectionFk - LIMIT 1; - - CALL cache.visible_refresh(vCalcFk,FALSE,vWarehouseFk); - - DROP TEMPORARY TABLE IF EXISTS tmp.parked; - CREATE TEMPORARY TABLE tmp.parked - ENGINE MEMORY - SELECT s.itemFk, 0 as quantity - FROM vn.ticketCollection tc - JOIN vn.sale s ON s.ticketFk = tc.ticketFk - WHERE tc.collectionFk = vCollectionFk; - - UPDATE tmp.parked pk - JOIN ( SELECT itemFk, sum(visible) as visible - FROM vn.itemShelvingStock iss - JOIN vn.warehouse w ON w.id = iss.warehouseFk - WHERE w.aliasFk = vWarehouseAliasFk - GROUP BY iss.itemFk ) iss ON iss.itemFk = pk.itemFk - SET pk.quantity = iss.visible; - - DROP TEMPORARY TABLE IF EXISTS tmp.`grouping`; - CREATE TEMPORARY TABLE tmp.`grouping` - ENGINE MEMORY - SELECT itemFk, `grouping` - FROM ( - SELECT itemFk, - CASE groupingMode - WHEN 0 THEN 1 - WHEN 2 THEN packing - ELSE `grouping` - END AS `grouping` - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel tr ON tr.id = e.travelFk - WHERE tr.warehouseInFk = vWarehouseFk - AND landed BETWEEN (SELECT FechaInventario FROM vn2008.tblContadores LIMIT 1) AND CURDATE() - AND b.isIgnored = FALSE - ORDER BY tr.landed DESC - ) sub - GROUP BY sub.itemFk ; - - DROP TEMPORARY TABLE IF EXISTS tmp.grouping2; - CREATE TEMPORARY TABLE tmp.grouping2 - ENGINE MEMORY - SELECT * FROM tmp.`grouping`; - - SELECT s.id as saleFk, s.itemFk, - p.code COLLATE utf8_general_ci as placement , - sh.code COLLATE utf8_general_ci as shelving, - ish.created, - ish.visible, - IFNULL(p.pickingOrder,0) as `order`, - IF(sc.isPreviousPreparedByPacking, ish.packing, g.`grouping`) as `grouping` - FROM vn.ticketCollection tc - JOIN vn.sale s ON s.ticketFk = tc.ticketFk - JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk - JOIN vn.shelving sh ON sh.code = ish.shelvingFk - JOIN vn.parking p ON p.id = sh.parkingFk - JOIN vn.sector sc ON sc.id = p.sectorFk - JOIN vn.warehouse w ON w.id = sc.warehouseFk - JOIN tmp.`grouping` g ON g.itemFk = s.itemFk - WHERE tc.collectionFk = vCollectionFk - AND w.aliasFk = vWarehouseAliasFk - AND ish.visible > 0 - UNION ALL - SELECT s.id as saleFk, s.itemFk, - ip.code COLLATE utf8_general_ci as placement, - '' COLLATE utf8_general_ci as shelving, - modificationDate as created, - v.visible - p.quantity as visible, - IFNULL(cpd.hallway * 100,0) as `order`, - g.`grouping` - FROM vn.ticketCollection tc - JOIN vn.sale s ON s.ticketFk = tc.ticketFk - JOIN vn.itemPlacement ip ON ip.itemFk = s.itemFk AND ip.warehouseFk = vWarehouseFk - LEFT JOIN vn.coolerPathDetail cpd ON cpd.hallway = LEFT(ip.`code`,3) - JOIN tmp.parked p ON p.itemFk = s.itemFk - JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vCalcFk - LEFT JOIN tmp.grouping2 g ON g.itemFk = s.itemFk - WHERE tc.collectionFk = vCollectionFk - AND v.visible - p.quantity > 0 - AND IFNULL(cpd.id,0); - - DROP TEMPORARY TABLE - tmp.parked, - tmp.`grouping`, - tmp.grouping2; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `collectionSale_get` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -35608,37 +35618,6 @@ BEGIN LEFT JOIN vn.state st ON st.id = ts.stateFk WHERE tc.collectionFk = vCollectionFk; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `collectionStickers_print` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `collectionStickers_print`(vCollectionFk INT) -BEGIN - - UPDATE vn.ticket t - JOIN vn.ticketCollection tc ON tc.ticketFk = t.id - SET t.notes = CONCAT('COL ',vCollectionFk,'-',tc.`level`) - WHERE tc.collectionFk = vCollectionFk; - - INSERT INTO vn.printServerQueue(reportFk, param1, workerFk) - SELECT w.labelReport, tc.ticketFk, getUser() - FROM vn.ticketCollection tc - JOIN vn.ticket t ON t.id = tc.ticketFk - JOIN vn.warehouse w ON w.id = t.warehouseFk - WHERE tc.collectionFk = vCollectionFk; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -35671,9 +35650,16 @@ BEGIN IF vLabelReport THEN - INSERT INTO vn.printServerQueue(reportFk, param1, workerFk) - SELECT vLabelReport, ticketFk, getUser() - FROM vn.ticketCollection + INSERT INTO vn.ticketTrolley(ticket, labelCount) + SELECT ticketFk, 1 + FROM vn.ticketCollection + WHERE collectionFk = vCollectionFk + ON DUPLICATE KEY UPDATE labelCount = labelCount + 1; + + INSERT INTO vn.printServerQueue(reportFk, param1, workerFk,param2) + SELECT vLabelReport, tc.ticketFk, getUser(), tt.labelCount + FROM vn.ticketCollection tc + LEFT JOIN vn.ticketTrolley tt ON tt.ticket = tc.ticketFk WHERE collectionFk = vCollectionFk; END IF; @@ -35700,11 +35686,14 @@ BEGIN SELECT tc.ticketFk, tc.level, am.name as agencyName, - t.warehouseFk + t.warehouseFk , + w.id as salesPersonFk FROM vn.ticketCollection tc JOIN vn.ticket t ON t.id = tc.ticketFk LEFT JOIN vn.zone z ON z.id = t.zoneFk LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk + LEFT JOIN vn.client c ON c.id = t.clientFk + LEFT JOIN vn.worker w ON w.id = c.salesPersonFk WHERE tc.collectionFk = vCollectionFk; END ;; @@ -35735,6 +35724,9 @@ proc:BEGIN DECLARE vWorkerCode VARCHAR(3); DECLARE vShelve INT; DECLARE vTicket INT; + DECLARE myUserIsSalesPersonRole BOOLEAN; + DECLARE vPrintedTickets INT; + DECLARE vMaxTicketPrinted INT DEFAULT 10; -- Establecemos el almacén y si es un sector de preparación previa, así como el estado para los tickets que se vayan preparando SELECT isPreviousPrepared, warehouseFk @@ -35755,6 +35747,13 @@ proc:BEGIN END IF; + -- Averiguamos si es comercial el usuario + SELECT (r.name = 'salesPerson') + INTO myUserIsSalesPersonRole + FROM account.user u + JOIN account.role r ON r.id = u.role + WHERE u.id = vn.getUser(); + -- Obtenemos el código del usuario SELECT w.code INTO vWorkerCode @@ -35769,16 +35768,58 @@ proc:BEGIN CALL vn2008.production_control_source(vWarehouseFk, 0); + SELECT COUNT(*) INTO vPrintedTickets + FROM tmp.production_buffer pb + JOIN vn.state s ON s.id = pb.state + WHERE pb.Fecha = CURDATE() + AND s.isPreparable; + + SET vMaxTicketPrinted = vMaxTicketPrinted - vPrintedTickets; + + -- AutoPRINT + + IF vMaxTicketPrinted > 0 THEN + + INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) + SELECT s2.id, pb.Id_Ticket, vn.getUser() + FROM tmp.production_buffer pb + JOIN vn.agency a ON a.id = pb.agency_id + JOIN vn.state s ON s.id = pb.state + JOIN vn.state s2 ON s2.code = 'PRINTED' + LEFT JOIN vn.route r ON r.id = pb.Id_Ruta + WHERE pb.Fecha = CURDATE() + AND NOT pb.problems + AND a.name != 'REC_SILLA' + AND (pb.ubicacion IS NOT NULL OR a.isOwn = FALSE) + AND s.isPrintable + AND (pb.m3 > 0.05 OR s.code = 'OK') + ORDER BY (Hora - 1) * 60 + minuto > hour(now()) * 60 + minute(now()) , + s.order DESC, + Hora, + minuto, + IFNULL(r.priority,99999), + pb.m3 DESC + LIMIT vMaxTicketPrinted; + + END IF; + + -- SELECT vMaxTicketPrinted; -- Se seleccionan los primeros tickets, asignando colección para dejarlos bloqueados a otros sacadores. - INSERT IGNORE INTO vn.ticketCollection(ticketFk, collectionFk) + + INSERT IGNORE INTO vn.ticketCollection(ticketFk, collectionFk) SELECT pb.Id_Ticket, vCollectionFk FROM tmp.production_buffer pb JOIN vn.state s ON s.id = pb.state WHERE pb.collectionFk IS NULL - AND (s.isPreparable OR (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode)) + AND ( + (s.isPreparable AND NOT myUserIsSalesPersonRole AND pb.Agencia != 'REC_SILLA') + OR + (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) + ) ORDER BY (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) DESC, pb.Hora, pb.Minuto LIMIT vMaxTickets; + -- Creamos una tabla temporal con los datos que necesitamos para depurar la colección DROP TEMPORARY TABLE IF EXISTS tmp.ticket; @@ -35939,307 +35980,6 @@ proc:BEGIN SELECT vCollectionFk; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `collection_new__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `collection_new__`(vSectorFk INT) -proc:BEGIN - - DECLARE vIsPreviousPrepared BOOLEAN; - DECLARE vCollectionFk INT; - DECLARE vWarehouseFk INT; - - DECLARE vTicketLiters INT; - DECLARE vTicketLines INT; - DECLARE vTicketFk INT; - DECLARE vTicketHeight INT; - DECLARE vTicketHeightTop INT; - DECLARE vTicketHeightFloor INT; - DECLARE vIsTicketCollected BOOLEAN; - DECLARE vMaxTickets INT; - DECLARE vStateFk INT; - DECLARE vTopTicketFk INT; - DECLARE vFloorTicketFk INT; - - DECLARE vVolumetryLiters INT; - DECLARE vVolumetryLines INT; - DECLARE vVolumetryFk INT; - DECLARE vVolumetryLevel INT; - DECLARE vVolumetryHeight INT; - DECLARE vVolumetryLitersMax INT; - DECLARE vVolumetryLinesMax INT; - DECLARE vVolumetryHeightTop INT; - DECLARE vVolumetryHeightFloor INT; - - DECLARE vDone BOOLEAN DEFAULT FALSE; - DECLARE vWorkerCode VARCHAR(3); - - DECLARE cVolumetry CURSOR FOR - SELECT level, liters, `lines`, height - FROM vn.collectionVolumetry - ORDER BY `level`; - - DECLARE cTicket CURSOR FOR - SELECT * - FROM tmp.ticket - ORDER BY height DESC; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - - -- Reenvio a la version beta si el sector es el de pruebas - IF vSectorFk IN (17,18) THEN - - CALL vn.collection_new_beta(vSectorFk); - LEAVE proc; - - END IF; - - SELECT isPreviousPrepared, warehouseFk - INTO vIsPreviousPrepared, vWarehouseFk - FROM vn.sector - WHERE id = vSectorFk; - - SELECT w.code - INTO vWorkerCode - FROM vn.worker w - WHERE w.id = account.myUserGetId(); - - IF vIsPreviousPrepared THEN - - SELECT id INTO vStateFk - FROM vn.state - WHERE `code` = 'PREVIOUS_PREPARATION'; - ELSE - - SELECT id INTO vStateFk - FROM vn.state - WHERE `code` = 'ON_PREPARATION'; - - END IF; - - SELECT COUNT(*), sum(liters), sum(`lines`) - INTO vMaxTickets, vVolumetryLitersMax, vVolumetryLinesMax - FROM vn.collectionVolumetry; - - CALL vn2008.production_control_source(vWarehouseFk, 0); - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket; - - -- Recogida Silla requiere carros individuales - - IF (SELECT pb.Agencia - FROM tmp.production_buffer pb - JOIN vn.state s ON s.id = pb.state - LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = pb.Id_Ticket - WHERE pb.problems = 0 - AND tc.ticketFk IS NULL - AND (s.isPreparable OR (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode)) - ORDER BY (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) DESC, pb.Hora, pb.Minuto, m3 DESC, pb.lines DESC - LIMIT 1) = 'REC_SILLA' THEN - - CREATE TEMPORARY TABLE tmp.ticket - SELECT pb.Id_Ticket ticketFk, - pb.lines, - pb.m3 * 1000 liters, - 0 as height - FROM tmp.production_buffer pb - JOIN vn.state s ON s.id = pb.state - LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = pb.Id_Ticket - WHERE pb.problems = 0 - AND pb.Agencia = 'REC_SILLA' - AND tc.ticketFk IS NULL - AND (s.isPreparable OR (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode)) - ORDER BY (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) DESC, pb.Hora, pb.Minuto, m3 DESC, pb.lines DESC - LIMIT 1; - - ELSE - - CREATE TEMPORARY TABLE tmp.ticket - SELECT pb.Id_Ticket ticketFk, - pb.lines, - pb.m3 * 1000 liters, - 0 as height - FROM tmp.production_buffer pb - JOIN vn.state s ON s.id = pb.state - LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = pb.Id_Ticket - WHERE pb.problems = 0 - AND pb.Agencia != 'REC_SILLA' - AND tc.ticketFk IS NULL - AND (s.isPreparable OR (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode)) - ORDER BY (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) DESC, pb.Hora, pb.Minuto, m3 DESC, pb.lines DESC - LIMIT vMaxTickets; - - -- Establece altura máxima por pedido, porque las plantas no se pueden recostar. - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket2; - CREATE TEMPORARY TABLE tmp.ticket2 - SELECT MAX(i.size) maxHeigth, t.ticketFk - FROM tmp.ticket t - JOIN vn.sale s ON s.ticketFk = t.ticketFk - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.itemCategory ic ON ic.id = it.categoryFk - WHERE ic.isReclining = FALSE - GROUP BY t.ticketFk; - - UPDATE tmp.ticket t - JOIN tmp.ticket2 t2 ON t2.ticketFk = t.ticketFk - SET t.height = t2.maxHeigth; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket2; - -- Si hay un ticket con una planta que supera la máxima altura para la bandeja superior, el pedido ha de ser único. Por tanto, eliminamos el resto. - -- Si hay dos tickets con plantas que superen la medida inferior, el carro llevará una bandeja. Hay que eliminar los otros dos. - - SELECT height, ticketFk - INTO vTicketHeightTop, vTopTicketFk - FROM tmp.ticket - ORDER BY height DESC - LIMIT 1; - - SELECT max(height) - INTO vVolumetryHeightTop - FROM vn.collectionVolumetry; - - SELECT height, ticketFk - INTO vTicketHeightFloor, vFloorTicketFk - FROM tmp.ticket - WHERE ticketFk != vTopTicketFk - ORDER BY height DESC - LIMIT 1; - - SELECT height - INTO vVolumetryHeightFloor - FROM vn.collectionVolumetry - WHERE level = 1; - /* - IF vTicketHeightTop > vVolumetryHeightTop - OR vTicketHeightFloor > vVolumetryHeightFloor THEN - - DELETE FROM tmp.ticket WHERE ticketFk != vTopTicketFk; - - ELSEIF vTicketHeightFloor <= vVolumetryHeightFloor THEN - - DELETE FROM tmp.ticket WHERE ticketFk NOT IN (vTopTicketFk, vFloorTicketFk); - - END IF; - */ - - - END IF; - - - -- Empieza el bucle - OPEN cVolumetry; - OPEN cTicket; - - FETCH cTicket INTO vTicketFk, vTicketLines, vTicketLiters, vTicketHeight; - FETCH cVolumetry INTO vVolumetryLevel, vVolumetryLiters, vVolumetryLines, vVolumetryHeight; - - IF NOT vDone THEN - - INSERT INTO vn.collection - SET workerFk = account.myUserGetId(); - - SELECT LAST_INSERT_ID() INTO vCollectionFk; - - END IF; - - bucle:WHILE NOT vDone DO - - IF (vVolumetryLitersMax < vTicketLiters OR vVolumetryLinesMax < vTicketLines) AND vVolumetryLevel > 1 THEN - - LEAVE bucle; - - END IF; - - SELECT COUNT(*) INTO vIsTicketCollected - FROM vn.ticketCollection - WHERE ticketFk = vTicketFk - AND collectionFk = vCollectionFk; - - IF vIsTicketCollected THEN - - UPDATE vn.ticketCollection - SET level = CONCAT(level, vVolumetryLevel) - WHERE ticketFk = vTicketFk - AND collectionFk = vCollectionFk; - - ELSE - - INSERT INTO vn.ticketCollection - SET collectionFk = vCollectionFk, - ticketFk = vTicketFk, - level = vVolumetryLevel; - - INSERT INTO vncontrol.inter - SET state_id = vStateFk, - Id_Ticket = vTicketFk, - Id_Trabajador = account.myUserGetId(); - - END IF; - - SET vVolumetryLitersMax = GREATEST(0,vVolumetryLitersMax - vVolumetryLiters); - SET vVolumetryLinesMax = GREATEST(0,vVolumetryLinesMax - vVolumetryLines); - SET vTicketLiters = GREATEST(0,vTicketLiters - vVolumetryLiters); - SET vTicketLines = GREATEST(0,vTicketLines - vVolumetryLines); - - IF vVolumetryLitersMax = 0 OR vVolumetryLinesMax = 0 THEN - - LEAVE bucle; - - END IF; - - IF vTicketLiters > 0 OR vTicketLines > 0 THEN - - FETCH cVolumetry INTO vVolumetryLevel, vVolumetryLiters, vVolumetryLines, vVolumetryHeight; - - ELSE - - FETCH cTicket INTO vTicketFk, vTicketLines, vTicketLiters, vTicketHeight; - FETCH cVolumetry INTO vVolumetryLevel, vVolumetryLiters, vVolumetryLines, vVolumetryHeight; - - END IF; - - END WHILE; - - - UPDATE vn.collection c - JOIN vn.state st ON st.code = 'ON_PREPARATION' - SET c.stateFk = st.id - WHERE c.id = vCollectionFk; - - INSERT IGNORE INTO vn.ticketDown(ticketFk) - SELECT DISTINCT tc.ticketFk - FROM vn.ticketCollection tc - JOIN vncontrol.inter vi ON vi.Id_Ticket = tc.ticketFk - JOIN vn.state st ON st.id = vi.state_id - JOIN vn.ticket t ON t.id = tc.ticketFk - JOIN vn.warehouse w ON w.id = t.warehouseFk - WHERE tc.collectionFk = vCollectionFk - AND w.name = 'Silla FV' - AND st.code = 'PREVIOUS_PREPARATION'; - - - SELECT vCollectionFk; - - CLOSE cVolumetry; - CLOSE cTicket; - -- DROP TEMPORARY TABLE IF EXISTS tmp.ticket; - -- DROP TEMPORARY TABLE IF EXISTS tmp.ticket2; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -36279,6 +36019,74 @@ BEGIN WHERE id = vCollectionFk; END IF; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `conveyorExpedition_Add` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `conveyorExpedition_Add`(vDate DATE) +BEGIN + + DELETE FROM vn.conveyorExpedition + WHERE date(created) = vDate; + + INSERT INTO vn.conveyorExpedition( expeditionFk, + created, + conveyorBuildingClassFk, + length, + width, + height, + routeFk) + SELECT e.id, + e.created, + IF(e.itemFk = 94,1,4), + IF(e.itemFk = 94,1200,1000), + IF(e.itemFk = 94,500,300), + IF(e.itemFk = 94,250,300), + IFNULL(t.routeFk,am.agencyFk) routeFk + FROM vn.expedition e + JOIN vn.ticket t ON t.id = e.ticketFk + LEFT JOIN vn.zone z ON z.id = t.zoneFk + LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk + WHERE DATE(e.created) = vDate + AND t.warehouseFk = 1 + AND e.isBox = 71; + + INSERT INTO vn.conveyorExpedition( expeditionFk, + created, + conveyorBuildingClassFk, + length, + width, + height, + routeFk) + SELECT e.id, + e.created, + 5, + IF(e.itemFk = 94,600,400), + IF(e.itemFk = 94,320,250), + IF(e.itemFk = 94,900,600), + IFNULL(t.routeFk,am.agencyFk) routeFk + FROM vn.expedition e + JOIN vn.ticket t ON t.id = e.ticketFk + LEFT JOIN vn.zone z ON z.id = t.zoneFk + LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk + WHERE DATE(e.created) = vDate + AND t.warehouseFk = 44 + AND e.isBox = 71; + + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -38675,13 +38483,24 @@ proc: BEGIN UPDATE config SET inventoried = vDate; SET @isModeInventory := FALSE; - DELETE e, t + DROP TEMPORARY TABLE IF EXISTS tmp.entryToDelete; + CREATE TEMPORARY TABLE tmp.entryToDelete + (INDEX(entryId) USING BTREE) ENGINE = MEMORY + SELECT e.id as entryId, + t.id as travelId + FROM vn.travel t + JOIN vn.entry e ON e.travelFk = t.id + WHERE e.supplierFk = 4 + AND t.shipped <= TIMESTAMPADD(DAY, -2, TIMESTAMPADD(DAY, -10, CURDATE())) + AND (DAY(t.shipped) <> 1 OR shipped < TIMESTAMPADD(MONTH, -12, CURDATE())); + + DELETE e + FROM vn.entry e + JOIN tmp.entryToDelete tmp ON tmp.entryId = e.id; + + DELETE IGNORE t FROM vn.travel t - JOIN vn.entry e ON e.travelFk = t.id - WHERE e.supplierFk = 4 - AND t.shipped <= vDeleteDate - AND (DAY(t.shipped) <> 1 OR shipped < TIMESTAMPADD(MONTH, -12, CURDATE())); - + JOIN tmp.entryToDelete tmp ON tmp.travelId = t.id; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -41611,9 +41430,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -41648,7 +41467,7 @@ BEGIN LEFT JOIN origin o ON o.id = i.originFk ) ON it.id = i.typeFk LEFT JOIN edi.ekt ek ON b.ektFk = ek.id - WHERE b.itemFk = vItem And tr.shipped BETWEEN vDays AND CURDATE() + WHERE b.itemFk = vItem And tr.shipped BETWEEN vDays AND DATE_ADD(CURDATE(), INTERVAl + 10 DAY) ORDER BY tr.landed DESC , b.id DESC; END ;; DELIMITER ; @@ -43593,13 +43412,208 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `item_ValuateInventory`(IN vDated DATE, IN vIsDetailed BOOLEAN) +BEGIN + + DECLARE vInventoried DATE; + DECLARE vHasNotInventory BOOLEAN DEFAULT FALSE; + DECLARE vInventoried2 DATE; + DECLARE vDateDayEnd DATETIME; + + SET vDateDayEnd = util.dayEnd(vDated); + SELECT landed INTO vInventoried + FROM travel tr + JOIN entry E ON E.travelFk = tr.id + WHERE landed <= vDateDayEnd + AND E.supplierFk = 4 + ORDER BY landed DESC + LIMIT 1; + + SET vHasNotInventory = IF (vInventoried is null, TRUE, FALSE); + + IF vHasNotInventory THEN + + SELECT landed INTO vInventoried2 + FROM travel tr + JOIN entry E ON E.travelFk = tr.id + WHERE landed >= vDated + AND E.supplierFk = 4 + ORDER BY landed ASC + LIMIT 1; + + SET vInventoried = TIMESTAMPADD(DAY,1,vDated); + SET vDateDayEnd = vInventoried2; + + END IF; + + DROP TEMPORARY TABLE IF EXISTS inv; + + CREATE TEMPORARY TABLE inv + (warehouseFk SMALLINT, + Id_Article BIGINT, + cantidad INT, + coste DOUBLE DEFAULT 0, + total DOUBLE DEFAULT 0, + Almacen VARCHAR(20), + PRIMARY KEY (Almacen, Id_Article) USING HASH) + ENGINE = MEMORY; + + IF vHasNotInventory = TRUE THEN + + INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen) + SELECT tr.warehouseInFk, b.itemFk, SUM(b.quantity), w.`name` + FROM buy b + JOIN item i ON i.id = b.itemFk + JOIN entry e ON e.id = b.entryFk + JOIN travel tr ON tr.id = e.travelFk + JOIN itemType t ON t.id = i.typeFk + JOIN warehouse w ON w.id = warehouseInFk + WHERE landed = vDateDayEnd + AND e.supplierFk = 4 + AND w.valuatedInventory + AND t.isInventory + GROUP BY tr.warehouseInFk, b.itemFk; + + END IF; + + INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen) + SELECT tr.warehouseInFk, b.itemFk, b.quantity * IF(vHasNotInventory,-1,1), w.`name` + FROM buy b + JOIN item i ON i.id = b.itemFk + JOIN entry e ON e.id = b.entryFk + JOIN travel tr ON tr.id = e.travelFk + JOIN itemType t ON t.id = i.typeFk + JOIN warehouse w ON w.id = tr.warehouseInFk + WHERE tr.landed BETWEEN vInventoried AND vDateDayEnd + AND IF(tr.landed = CURDATE(), tr.isReceived, trUE) + AND NOT e.isRaid + AND w.valuatedInventory + AND t.isInventory + ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + (b.quantity * IF(vHasNotInventory,-1,1)); + + INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen) + SELECT tr.warehouseOutFk, b.itemFk, b.quantity * IF(vHasNotInventory,1,-1), w.`name` + FROM buy b + JOIN item i ON i.id = b.itemFk + JOIN entry e ON e.id = b.entryFk + JOIN travel tr ON tr.id = e.travelFk + JOIN itemType t ON t.id = i.typeFk + JOIN warehouse w ON w.id = tr.warehouseOutFk + WHERE tr.shipped BETWEEN vInventoried AND vDateDayEnd + AND NOT e.isRaid + AND w.valuatedInventory + AND t.isInventory + ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + (b.quantity * IF(vHasNotInventory,1,-1)); + + INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen) + SELECT w.id, s.itemFk, s.quantity * IF(vHasNotInventory,1,-1), w.`name` + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN `client` c ON c.id = t.clientFk + JOIN item i ON i.id = s.itemFk + JOIN itemType it ON it.id = i.typeFk + JOIN warehouse w ON w.id = t.warehouseFk + WHERE t.shipped BETWEEN vInventoried AND vDateDayEnd + AND w.valuatedInventory + AND it.isInventory + ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + s.quantity * IF(vHasNotInventory,1,-1); + + IF vDated = CURDATE() THEN -- volver a poner lo que esta aun en las estanterias + + INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen) + SELECT w.id, s.itemFk, s.quantity * IF(vHasNotInventory,0,1), w.`name` + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN `client` c ON c.id = t.clientFk + JOIN item i ON i.id = s.itemFk + JOIN itemType it ON it.id = i.typeFk + JOIN warehouse w ON w.id = t.warehouseFk + WHERE t.shipped BETWEEN vDated AND vDateDayEnd + AND (s.isPicked <> 0 or t.isLabeled <> 0 ) + AND w.valuatedInventory + AND it.isInventory + ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + s.quantity * IF(vHasNotInventory,0,1); + + END IF; + + -- Mercancia en transito + INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen) + SELECT tr.warehouseInFk, b.itemFk, b.quantity, CONCAT(wOut.`name`,' - ', wIn.`name`) + FROM buy b + JOIN item i ON i.id = b.itemFk + JOIN entry e ON e.id = b.entryFk + JOIN travel tr ON tr.id = e.travelFk + JOIN itemType t ON t.id = i.typeFk + JOIN warehouse wIn ON wIn.id = tr.warehouseInFk + JOIN warehouse wOut ON wOut.id = tr.warehouseOutFk + WHERE vDated >= tr.shipped AND vDated < tr.landed + AND NOT isRaid + -- AND wIn.valuatedInventory + AND t.isInventory + -- AND e.isConfirmed + ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + (b.quantity); + + CALL vn.buyUltimate(NULL,vDateDayEnd); + + UPDATE inv i + JOIN tmp.buyUltimate bu ON i.warehouseFk = bu.warehouseFk AND i.Id_Article = bu.itemFk + JOIN buy b ON b.id = bu.buyFk + SET total = i.cantidad * (ifnull(b.buyingValue,0) + IFNULL(b.packageValue,0) + IFNULL(b.freightValue,0) + IFNULL(b.comissionValue,0)), + coste = ifnull(b.buyingValue,0) + IFNULL(b.packageValue,0) + IFNULL(b.freightValue,0) + IFNULL(b.comissionValue,0) + WHERE i.cantidad <> 0; + + DELETE FROM inv WHERE Cantidad IS NULL or Cantidad = 0; + + IF vIsDetailed THEN + + SELECT inv.warehouseFk, i.id, i.name, i.size, inv.Cantidad, tp.code, + tp.categoryFk, inv.coste, cast(inv.total as decimal(10,2)) total,Almacen + FROM inv + JOIN warehouse w on w.id = warehouseFk + JOIN item i ON i.id = inv.Id_Article + JOIN itemType tp ON tp.id = i.typeFk + WHERE w.valuatedInventory + and inv.total > 0 + order by inv.total desc; + + ELSE + + SELECT i.Almacen, ic.name as Reino, cast(i.total as decimal(10,2)) as Euros, w.code as Comprador,it.id + FROM inv i + JOIN warehouse wh on wh.id = warehouseFk + JOIN item it ON it.id = i.Id_Article + JOIN itemType itp ON itp.id = it.typeFk + LEFT JOIN worker w ON w.id = itp.workerFk + JOIN itemCategory ic ON ic.id = itp.categoryFk + WHERE wh.valuatedInventory + AND i.total > 0; + + END IF; + DROP TEMPORARY TABLE tmp.buyUltimate; + DROP TEMPORARY TABLE inv; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `item_ValuateInventory__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `item_ValuateInventory__`(IN vDated DATE, IN vIsDetailed BOOLEAN) BEGIN DECLARE vInventoried DATE; @@ -45103,10 +45117,9 @@ BEGIN JOIN vn.item i ON i.id = isa.itemFk JOIN vn.sector s ON s.id = isa.sectorFk AND s.warehouseFk = isa.warehouseFk WHERE IF(s.isPreviousPreparedByPacking, (MOD(TRUNCATE(isa.quantity,0), isa.packing)= 0 ), TRUE) - AND isa.isPreviousPreparable = TRUE + -- AND isa.isPreviousPreparable = TRUE AND isa.sectorFk = vSectorFk AND isa.quantity > 0 - AND isa.sectorFk = vSectorFk GROUP BY saleFk HAVING isa.quantity <= totalAvailable ) sub2 @@ -45394,7 +45407,7 @@ BEGIN UPDATE vn.routeGate rg LEFT JOIN vn.routesControl rc ON rg.routeFk = rc.routeFk LEFT JOIN vn.route r ON r.id = rg.routeFk - LEFT JOIN vn2008.Agencias a ON a.Id_Agencia = r.agencyModeFk + LEFT JOIN vn.agencyMode a ON a.id = r.agencyModeFk LEFT JOIN ( SELECT Id_Ruta, count(*) AS pedidosLibres @@ -45509,9 +45522,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -45628,8 +45641,8 @@ BEGIN -- Coste TEORICO de una caja "virtual" para cada ruta, teniendo en cuenta que hay carros, pallets, etc UPDATE bi.rutasBoard r JOIN ( - SELECT t.routeFk, - SUM(z.price/ ebv.ratio)/ count(*) AS BultoTeoricoMedio + SELECT t.routeFk, + SUM(t.zonePrice/ ebv.ratio)/ count(*) AS BultoTeoricoMedio FROM vn.ticket t JOIN vn.route r ON r.id = t.routeFk JOIN vn.time tm ON tm.dated = r.created @@ -45637,7 +45650,7 @@ BEGIN JOIN vn.expeditionBoxVol ebv ON ebv.boxFk = e.isBox JOIN vn.address ad ON ad.id = t.addressFk JOIN vn.client c ON c.id = ad.clientFk - JOIN vn.zone z ON z.id = t.zoneFk + LEFT JOIN vn.zone z ON z.id = t.zoneFk WHERE tm.year = vYear AND tm.month = vMonth AND z.isVolumetric = FALSE @@ -45652,8 +45665,8 @@ BEGIN FROM vn.ticket t JOIN vn.route r ON r.id = t.routeFk JOIN vn.time tm ON tm.dated = r.created - JOIN vn.saleFreight sf ON sf.ticketFk = t.id - JOIN vn.client c ON c.id = sf.clientFk + JOIN vn.saleVolume sf ON sf.ticketFk = t.id + JOIN vn.client c ON c.id = t.clientFk JOIN vn.zone z ON z.id = t.zoneFk WHERE tm.year = vYear AND tm.month = vMonth @@ -48058,6 +48071,63 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `ticketClosureMultiWarehouse`(vDateTo DATE) BEGIN +/** + * Inserta los tickets de todos los almacenes en la tabla temporal + * para ser cerrados. + * + * @param vDate Fecha del cierre + */ + DECLARE vDateToEndDay DATETIME DEFAULT util.dayEnd(vDateTo); + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketClosure; + + CREATE TEMPORARY TABLE tmp.ticketClosure ENGINE = MEMORY ( + SELECT + t.id AS ticketFk + FROM expedition e + INNER JOIN ticket t ON t.id = e.ticketFk + INNER JOIN warehouse w ON w.id = t.warehouseFk AND hasComission + LEFT JOIN ticketState ts ON ts.ticketFk = t.id + WHERE + ts.alertLevel = 2 + AND DATE(t.shipped) BETWEEN DATE_ADD(vDateTo, INTERVAL -2 DAY) AND vDateTo + AND t.refFk IS NULL + GROUP BY e.ticketFk); + + CALL ticketClosure(); + + INSERT INTO mail (sender, replyTo, subject, body) + SELECT 'jgallego@verdnatura.es', 'jgallego@verdnatura.es', 'Tickets enrutados y NO preparados', + GROUP_CONCAT(ticketFk) tickets + FROM ticket t + JOIN ticketState ts ON t.id = ts.ticketFk + JOIN alertLevel al ON al.alertLevel = ts.alertLevel + JOIN agencyMode am ON am.id = t.agencyModeFk + JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk + WHERE shipped BETWEEN vDateTo AND vDateToEndDay + AND al.code NOT IN('DELIVERED','PACKED') + AND t.routeFk + HAVING tickets IS NOT NULL; + + DROP TEMPORARY TABLE tmp.ticketClosure; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticketClosureMultiWarehouse__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `ticketClosureMultiWarehouse__`(vDateTo DATE) +BEGIN /** * Inserta los tickets de todos los almacenes en la tabla temporal * para ser cerrados. @@ -48082,6 +48152,19 @@ BEGIN CALL ticketClosure(); + INSERT INTO mail (sender, replyTo, subject, body) + SELECT 'jgallego@verdnatura.es', 'jgallego@verdnatura.es', 'Tickets enrutados y NO preparados', + GROUP_CONCAT(ticketFk) tickets + FROM ticket t + JOIN ticketState ts ON t.id = ts.ticketFk + JOIN alertLevel al ON al.alertLevel = ts.alertLevel + JOIN agencyMode am ON am.id = t.agencyModeFk + JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk + WHERE shipped = TIMESTAMPADD(DAY, -1, CURDATE()) + AND al.code NOT IN('DELIVERED','PACKED') + AND t.routeFk + HAVING tickets IS NOT NULL; + DROP TEMPORARY TABLE tmp.ticketClosure; END ;; DELIMITER ; @@ -48244,491 +48327,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `ticketComponentCalculate__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ticketComponentCalculate__`( - vAddressFk INT, - vAgencyModeFk INT) -proc: BEGIN --- OBSOLETO usar catalog_componentCalculate -/** - * Calcula los componentes de un ticket - * - * @param vAddressFk Id del consignatario - * @param vAgencyModeFk Id del modo de agencia - * @return tmp.ticketComponent(itemFk, warehouseFk, available, rate2, rate3, minPrice, - * packing, grouping, groupingMode, buyFk, typeFk) - * @return tmp.ticketComponentPrice (warehouseFk, itemFk, rate, grouping, price) - */ - - DECLARE vClientFk INT; - DECLARE vGeneralInflationCoefficient INT DEFAULT 1; - DECLARE vMinimumDensityWeight INT DEFAULT 167; - DECLARE vBoxFreightItem INT DEFAULT 71; - DECLARE vBoxVolume BIGINT; -- DEFAULT 138000; - DECLARE vSpecialPriceComponent INT DEFAULT 10; - DECLARE vDeliveryComponent INT DEFAULT 15; - DECLARE vRecoveryComponent INT DEFAULT 17; - DECLARE vSellByPacketComponent INT DEFAULT 22; - DECLARE vBuyValueComponent INT DEFAULT 28; - DECLARE vMarginComponent INT DEFAULT 29; - DECLARE vDiscountLastItemComponent INT DEFAULT 32; - DECLARE vExtraBaggedComponent INT DEFAULT 38; - DECLARE vManaAutoComponent INT DEFAULT 39; - - - - SELECT volume INTO vBoxVolume - FROM vn.packaging - WHERE id = '94'; - - SELECT clientFk INTO vClientFK - FROM address - WHERE id = vAddressFk; - - SET @rate2 := 0; - SET @rate3 := 0; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentCalculate; - CREATE TEMPORARY TABLE tmp.ticketComponentCalculate - (PRIMARY KEY (itemFk, warehouseFk)) - ENGINE = MEMORY - SELECT - tl.itemFk, tl.warehouseFk, tl.available, - IF((@rate2 := IFNULL(pf.rate2, b.price2)) < i.minPrice AND i.hasMinPrice, i.minPrice, @rate2) * 1.0 rate2, - IF((@rate3 := IFNULL(pf.rate3, b.price3)) < i.minPrice AND i.hasMinPrice, i.minPrice, @rate3) * 1.0 rate3, - IFNULL(pf.rate3, 0) AS minPrice, - IFNULL(pf.packing, b.packing) packing, - IFNULL(pf.`grouping`, b.`grouping`) `grouping`, - ABS(IFNULL(pf.box, b.groupingMode)) groupingMode, - tl.buyFk, - i.typeFk, - IF(i.hasKgPrice,b.weight / b.packing, NULL) weightGrouping - FROM tmp.ticketLot tl - JOIN buy b ON b.id = tl.buyFk - JOIN item i ON i.id = tl.itemFk - JOIN itemType it ON it.id = i.typeFk - LEFT JOIN itemCategory ic ON ic.id = it.categoryFk - LEFT JOIN specialPrice sp ON sp.itemFk = i.id AND sp.clientFk = vClientFk - LEFT JOIN ( - SELECT * FROM ( - SELECT pf.itemFk, pf.`grouping`, pf.packing, pf.box, pf.rate2, pf.rate3, aho.warehouseFk - FROM priceFixed pf - JOIN tmp.zoneGetShipped aho ON pf.warehouseFk = aho.warehouseFk OR pf.warehouseFk = 0 - WHERE aho.shipped BETWEEN pf.started AND pf.ended ORDER BY pf.itemFk, pf.warehouseFk DESC - ) tpf - GROUP BY tpf.itemFk, tpf.warehouseFk - ) pf ON pf.itemFk = tl.itemFk AND pf.warehouseFk = tl.warehouseFk - WHERE b.buyingValue + b.freightValue + b.packageValue + b.comissionValue > 0.01 AND ic.display <> 0; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent; - CREATE TEMPORARY TABLE tmp.ticketComponent ( - `warehouseFk` INT UNSIGNED NOT NULL, - `itemFk` INT NOT NULL, - `componentFk` INT UNSIGNED NOT NULL, - `cost` DECIMAL(10,4) NOT NULL, - INDEX `itemWarehouse` USING BTREE (`itemFk` ASC, `warehouseFk` ASC), - UNIQUE INDEX `itemWarehouseComponent` (`itemFk` ASC, `warehouseFk` ASC, `componentFk` ASC)); - - INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) - SELECT - tcc.warehouseFk, - tcc.itemFk, - vBuyValueComponent, - b.buyingValue + b.freightValue + b.packageValue + b.comissionValue - FROM tmp.ticketComponentCalculate tcc - JOIN buy b ON b.id = tcc.buyFk; - - INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) - SELECT - tcc.warehouseFk, - tcc.itemFk, - vMarginComponent, - tcc.rate3 - b.buyingValue - b.freightValue - b.packageValue - b.comissionValue - FROM tmp.ticketComponentCalculate tcc - JOIN buy b ON b.id = tcc.buyFk; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentBase; - CREATE TEMPORARY TABLE tmp.ticketComponentBase ENGINE = MEMORY - SELECT tc.itemFk, ROUND(SUM(tc.cost), 4) AS base, tc.warehouseFk - FROM tmp.ticketComponent tc - GROUP BY tc.itemFk, warehouseFk; - - INSERT INTO tmp.ticketComponent - SELECT tcb.warehouseFk, tcb.itemFk, vRecoveryComponent, ROUND(tcb.base * LEAST(cr.recobro, 0.25), 3) - FROM tmp.ticketComponentBase tcb - JOIN bi.claims_ratio cr ON cr.Id_Cliente = vClientFk - WHERE cr.recobro > 0.009; - - INSERT INTO tmp.ticketComponent - SELECT tcb.warehouseFk, tcb.itemFk, vManaAutoComponent, ROUND(base * (0.01 + prices_modifier_rate), 3) as manaAuto - FROM tmp.ticketComponentBase tcb - JOIN `client` c on c.id = vClientFk - JOIN bs.mana_spellers ms ON c.salesPersonFk = ms.Id_Trabajador - WHERE ms.prices_modifier_activated - HAVING manaAuto <> 0; - - INSERT INTO tmp.ticketComponent - SELECT tcb.warehouseFk, - tcb.itemFk, - cr.id, - GREATEST(IFNULL(ROUND(tcb.base * cr.tax, 4), 0), tcc.minPrice - tcc.rate3) - FROM tmp.ticketComponentBase tcb - JOIN componentRate cr - JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tcb.itemFk AND tcc.warehouseFk = tcb.warehouseFk - LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk - WHERE cr.id = vDiscountLastItemComponent AND cr.tax <> 0 AND tcc.minPrice < tcc.rate3 AND sp.value IS NULL; - - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFk, tcc.itemFk, vSellByPacketComponent, tcc.rate2 - tcc.rate3 - FROM tmp.ticketComponentCalculate tcc - JOIN buy b ON b.id = tcc.buyFk - LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk - WHERE sp.value IS NULL; - - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFK, - tcc.itemFk, - vDeliveryComponent, - vGeneralInflationCoefficient - * ROUND(( - i.compression - * r.cm3 - * IF(am.deliveryMethodFk = 1, (GREATEST(i.density, vMinimumDensityWeight) / vMinimumDensityWeight), 1) - * IFNULL((z.price - z.bonus) - * 1/*amz.inflation*/ , 50)) / vBoxVolume, 4 - ) cost - FROM tmp.ticketComponentCalculate tcc - JOIN item i ON i.id = tcc.itemFk - JOIN agencyMode am ON am.id = vAgencyModeFk - JOIN `address` a ON a.id = vAddressFk - JOIN tmp.zoneGetShipped zgs ON zgs.warehouseFk = tcc.warehouseFk - JOIN zone z ON z.id = zgs.id - LEFT JOIN bi.rotacion r ON r.warehouse_id = tcc.warehouseFk - AND r.Id_Article = tcc.itemFk - HAVING cost <> 0; - - IF (SELECT COUNT(*) FROM vn.addressForPackaging WHERE addressFk = vAddressFk) THEN - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFk, b.itemFk, vExtraBaggedComponent, ap.packagingValue cost - FROM tmp.ticketComponentCalculate tcc - JOIN vn.addressForPackaging ap - WHERE ap.addressFk = vAddressFk; - END IF; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentCopy; - CREATE TEMPORARY TABLE tmp.ticketComponentCopy ENGINE = MEMORY - SELECT * FROM tmp.ticketComponent; - - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFk, - tcc.itemFk, - vSpecialPriceComponent, - sp.value - SUM(tcc.cost) sumCost - FROM tmp.ticketComponentCopy tcc - JOIN componentRate cr ON cr.id = tcc.componentFk - JOIN specialPrice sp ON sp.clientFk = vClientFK AND sp.itemFk = tcc.itemFk - WHERE cr.classRate IS NULL - GROUP BY tcc.itemFk, tcc.warehouseFk - HAVING ABS(sumCost) > 0.001; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentSum; - CREATE TEMPORARY TABLE tmp.ticketComponentSum - (INDEX (itemFk, warehouseFk)) - ENGINE = MEMORY - SELECT SUM(cost) sumCost, tc.itemFk, tc.warehouseFk, cr.classRate - FROM tmp.ticketComponent tc - JOIN componentRate cr ON cr.id = tc.componentFk - GROUP BY tc.itemFk, tc.warehouseFk, cr.classRate; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentRate; - CREATE TEMPORARY TABLE tmp.ticketComponentRate ENGINE = MEMORY - SELECT tcc.warehouseFk, - tcc.itemFk, - 1 rate, - IF(tcc.groupingMode = 1, tcc.`grouping`, 1) `grouping`, - CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) price, - CAST(SUM(tcs.sumCost) / weightGrouping AS DECIMAL(10,2)) priceKg - FROM tmp.ticketComponentCalculate tcc - JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk - AND tcs.warehouseFk = tcc.warehouseFk - WHERE IFNULL(tcs.classRate, 1) = 1 - AND tcc.groupingMode < 2 AND (tcc.packing > tcc.`grouping` or tcc.groupingMode = 0) - GROUP BY tcs.warehouseFk, tcs.itemFk; - - INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg) - SELECT - tcc.warehouseFk, - tcc.itemFk, - 2 rate, - tcc.packing `grouping`, - SUM(tcs.sumCost) price, - SUM(tcs.sumCost) / weightGrouping priceKg - FROM tmp.ticketComponentCalculate tcc - JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk - AND tcs.warehouseFk = tcc.warehouseFk - WHERE tcc.available IS NULL OR (IFNULL(tcs.classRate, 2) = 2 - AND tcc.packing > 0 AND tcc.available >= tcc.packing) - GROUP BY tcs.warehouseFk, tcs.itemFk; - - INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg) - SELECT - tcc.warehouseFk, - tcc.itemFk, - 3 rate, - tcc.available `grouping`, - SUM(tcs.sumCost) price, - SUM(tcs.sumCost) / weightGrouping priceKg - FROM tmp.ticketComponentCalculate tcc - JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk - AND tcs.warehouseFk = tcc.warehouseFk - WHERE IFNULL(tcs.classRate, 3) = 3 - GROUP BY tcs.warehouseFk, tcs.itemFk; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentPrice; - CREATE TEMPORARY TABLE tmp.ticketComponentPrice ENGINE = MEMORY - SELECT * FROM ( - SELECT * FROM tmp.ticketComponentRate ORDER BY price - ) t - GROUP BY itemFk, warehouseFk, `grouping`; - - DROP TEMPORARY TABLE - tmp.ticketComponentCalculate, - tmp.ticketComponentSum, - tmp.ticketComponentBase, - tmp.ticketComponentRate, - tmp.ticketComponentCopy; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `ticketComponentMakeUpdate__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ticketComponentMakeUpdate__`( - vTicketFk INT, - vClientFk INT, - vAgencyModeFk INT, - vAddressFk INT, - vWarehouseFk TINYINT, - vCompanyFk SMALLINT, - vShipped DATETIME, - vLanded DATE, - vIsDeleted BOOLEAN, - vHasToBeUnrouted BOOLEAN, - vOption INT) -BEGIN - - - CALL vn.ticketComponentPreview (vTicketFk, vLanded, vAddressFk, vAgencyModeFk, vWarehouseFk); - CALL vn.ticketComponentUpdate ( - vTicketFk, - vClientFk, - vAgencyModeFk, - vAddressFk, - vWarehouseFk, - vCompanyFk, - vShipped, - vLanded, - vIsDeleted, - vHasToBeUnrouted, - vOption - ); - - DROP TEMPORARY TABLE - tmp.ticketComponent, - tmp.ticketComponentPrice; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `ticketComponentPreview__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ticketComponentPreview__`( - vTicketFk INT, - vLanded DATE, - vAddressFk INT, - vAgencyModeFk INT, - vWarehouseFk SMALLINT) -BEGIN --- OBSOLETO usar ticket_componentPreview - DECLARE vShipped DATE; - DECLARE vBuyOrderItem INT DEFAULT 100; - - DECLARE vHasDataChanged BOOL DEFAULT FALSE; - DECLARE vHasAddressChanged BOOL; - DECLARE vHasAgencyModeChanged BOOL DEFAULT FALSE; - DECLARE vHasWarehouseChanged BOOL DEFAULT FALSE; - - DECLARE vAddressTypeRateFk INT DEFAULT NULL; - DECLARE vAgencyModeTypeRateFk INT DEFAULT NULL; - - DECLARE vHasChangeAll BOOL DEFAULT FALSE; - - SELECT DATE(landed) <> vLanded, - addressFk <> vAddressFk, - agencyModeFk <> vAgencyModeFk, - warehouseFk <> vWarehouseFk - INTO - vHasDataChanged, - vHasAddressChanged, - vHasAgencyModeChanged, - vHasWarehouseChanged - FROM vn.ticket t - WHERE t.id = vTicketFk; - - IF vHasDataChanged OR vHasWarehouseChanged THEN - SET vHasChangeAll = TRUE; - END IF; - - IF vHasAddressChanged THEN - SET vAddressTypeRateFk = 5; - END IF; - - IF vHasAgencyModeChanged THEN - SET vAgencyModeTypeRateFk = 6; - END IF; - - CALL zoneGetShippedWarehouse(vLanded, vAddressFk, vAgencyModeFk); - - SELECT shipped INTO vShipped - FROM tmp.zoneGetShipped - WHERE warehouseFk = vWarehouseFk; - - CALL buyUltimate(vWarehouseFk, vShipped); - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; - CREATE TEMPORARY TABLE tmp.ticketLot ENGINE = MEMORY ( - SELECT - vWarehouseFk AS warehouseFk, - NULL AS available, - s.itemFk, - bu.buyFk - FROM sale s - LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk - WHERE s.ticketFk = vTicketFk - AND s.itemFk != vBuyOrderItem - GROUP BY bu.warehouseFk, bu.itemFk); - - CALL ticketComponentCalculate(vAddressFk, vAgencyModeFk); - - REPLACE INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) - SELECT t.warehouseFk, s.itemFk, sc.componentFk, sc.value - FROM saleComponent sc - JOIN sale s ON s.id = sc.saleFk - JOIN ticket t ON t.id = s.ticketFk - JOIN componentRate cr ON cr.id = sc.componentFk - WHERE s.ticketFk = vTicketFk - AND (cr.isRenewable = FALSE - OR - (NOT vHasChangeAll - AND (NOT (cr.componentTypeRate <=> vAddressTypeRateFk - OR cr.componentTypeRate <=> vAgencyModeTypeRateFk)))); - - SET @shipped = vShipped; - - DROP TEMPORARY TABLE - tmp.zoneGetShipped, - tmp.buyUltimate, - tmp.ticketLot; - - IF IFNULL(vShipped, CURDATE() - 1) < CURDATE() THEN - CALL util.throw('NO_AGENCY_AVAILABLE'); - END IF; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `ticketComponentPriceDifference__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ticketComponentPriceDifference__`( - vTicketFk INT, - vLanded DATE, - vAddressFk INT, - vAgencyModeFk INT, - vWarehouseFk INT) -BEGIN -/** - * Devuelve las diferencias de precio - * de los movimientos de un ticket. - * - * @param vTicketFk Id del ticket - * @param vLanded Fecha de recepcion - * @param vAddressFk Id del consignatario - * @param vAgencyModeFk Id del modo de agencia - * @param vWarehouseFk Id del almacén - */ - CALL vn.ticketComponentPreview(vTicketFk, vLanded, vAddressFk, vAgencyModeFk, vWarehouseFk); - - SELECT s.itemFk, - i.name, - i.size, - i.category, - IFNULL(s.quantity, 0) AS quantity, - IFNULL(s.price, 0) AS price, - ROUND(SUM(tc.cost), 2) AS newPrice, - s.quantity * (s.price - ROUND(SUM(tc.cost), 2)) difference, - s.id AS saleFk - FROM sale s - JOIN item i ON i.id = s.itemFk - JOIN ticket t ON t.id = s.ticketFk - LEFT JOIN tmp.ticketComponent tc ON tc.itemFk = s.itemFk - AND tc.warehouseFk = t.warehouseFk - LEFT JOIN saleComponent sc ON sc.saleFk = s.id - AND sc.componentFk = tc.componentFk - LEFT JOIN componentRate cr ON cr.id = tc.componentFk - WHERE - t.id = vTicketFk - AND IF(sc.componentFk IS NULL - AND cr.classRate IS NOT NULL, FALSE, TRUE) - GROUP BY s.id ORDER BY s.id; - - DROP TEMPORARY TABLE - tmp.ticketComponent, - tmp.ticketComponentPrice; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketComponentUpdate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -49117,6 +48715,8 @@ CREATE DEFINER=`root`@`%` PROCEDURE `ticketCreateWithUser`( BEGIN DECLARE vZoneFk INT; + DECLARE vPrice DECIMAL(10,2); + DECLARE vBonus DECIMAL(10,2); IF vClientId IS NULL THEN CALL util.throw ('CLIENT_NOT_ESPECIFIED'); @@ -49132,7 +48732,8 @@ BEGIN CALL vn.zone_getShippedWarehouse(vlanded, vAddressFk, vAgencyModeFk); - SELECT zoneFk INTO vZoneFk FROM tmp.zoneGetShipped + SELECT zoneFk, price, bonus INTO vZoneFk, vPrice, vBonus + FROM tmp.zoneGetShipped WHERE shipped = vShipped AND warehouseFk = vWarehouseFk LIMIT 1; IF vZoneFk IS NULL OR vZoneFk = 0 THEN @@ -49149,7 +48750,9 @@ BEGIN routeFk, companyFk, landed, - zoneFk + zoneFk, + zonePrice, + zoneBonus ) SELECT vClientId, @@ -49161,7 +48764,9 @@ BEGIN IF(vRouteFk,vRouteFk,NULL), vCompanyFk, vlanded, - vZoneFk + vZoneFk, + vPrice, + vBonus FROM address a JOIN agencyMode am ON am.id = a.agencyModeFk WHERE a.id = vAddressFk; @@ -50662,7 +50267,8 @@ CREATE DEFINER=`root`@`%` PROCEDURE `ticket_componentUpdate`( vHasToBeUnrouted BOOLEAN, vOption INT) BEGIN - + DECLARE vPrice DECIMAL(10,2); + DECLARE vBonus DECIMAL(10,2); DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN ROLLBACK; @@ -50680,12 +50286,20 @@ BEGIN END IF; + CALL vn.zone_getShippedWarehouse(vlanded, vAddressFk, vAgencyModeFk); + + SELECT zoneFk, price, bonus INTO vZoneFk, vPrice, vBonus + FROM tmp.zoneGetShipped + WHERE shipped = vShipped AND warehouseFk = vWarehouseFk LIMIT 1; + UPDATE ticket t SET t.clientFk = vClientFk, t.agencyModeFk = vAgencyModeFk, t.addressFk = vAddressFk, t.zoneFk = vZoneFk, + t.zonePrice = vPrice, + t.zoneBonus = vBonus, t.warehouseFk = vWarehouseFk, t.companyFk = vCompanyFk, t.landed = vLanded, @@ -50850,13 +50464,13 @@ BEGIN DECLARE vWarehouseFk INT; DECLARE vCursor CURSOR FOR SELECT id, landed, addressFk, agencyModeFk, warehouseFk - FROM vn.ticket WHERE shipped BETWEEN '2019-01-01' and '2019-02-01' AND zoneFk is null; + FROM vn.ticket WHERE shipped BETWEEN '2019-10-20' and '2019-11-01' AND zoneFk is null; DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET vDone = 1; OPEN vCursor; REPEAT FETCH vCursor INTO vFechedTicket, vLanded, vAddressFk, vAgencyModeFk, vWarehouseFk; - CALL zoneGetShippedWarehouse(vLanded, vAddressFk, vAgencyModeFk); + CALL zone_getShippedWarehouse(vLanded, vAddressFk, vAgencyModeFk); UPDATE vn.ticket t JOIN tmp.zoneGetShipped zgs ON zgs.warehouseFk = vWarehouseFk SET t.zoneFk = zgs.zoneFk @@ -50864,6 +50478,7 @@ BEGIN UNTIL vDone END REPEAT; DROP TEMPORARY TABLE tmp.zoneGetShipped; + CLOSE vCursor; END ;; DELIMITER ; @@ -50970,7 +50585,7 @@ proc: BEGIN FROM ticket WHERE id = vTicketFk; - CALL zoneGetShippedWarehouse(vLanded, vAddressFk , vAgencyModeFk); + CALL zone_getShippedWarehouse(vLanded, vAddressFk , vAgencyModeFk); CALL vn.buyUltimate (vWarehouseFk, vShipped); -- rellena la tabla buyUltimate con la ultima compra @@ -50996,7 +50611,7 @@ proc: BEGIN IF vLanded IS NULL THEN - CALL zoneGetLanded(vShipped, vAddressFk, vAgencyModeFk, vWarehouseFk); + CALL zone_getLanded(vShipped, vAddressFk, vAgencyModeFk, vWarehouseFk); UPDATE vn2008.Tickets t SET t.landing = (SELECT landed FROM tmp.zoneGetLanded) @@ -51054,7 +50669,7 @@ proc: BEGIN FROM ticket WHERE id = vTicketFk; - CALL zoneGetShippedWarehouse(vLanded, vAddressFk , vAgencyModeFk); + CALL zone_getShippedWarehouse(vLanded, vAddressFk , vAgencyModeFk); CALL vn.buyUltimate (vWarehouseFk, vShipped); -- rellena la tabla buyUltimate con la ultima compra @@ -51080,7 +50695,7 @@ proc: BEGIN IF vLanded IS NULL THEN - CALL zoneGetLanded(vShipped, vAddressFk, vAgencyModeFk, vWarehouseFk); + CALL zone_getLanded(vShipped, vAddressFk, vAgencyModeFk, vWarehouseFk); UPDATE vn2008.Tickets t SET t.landing = (SELECT landed FROM tmp.zoneGetLanded) @@ -51174,9 +50789,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -51190,8 +50805,7 @@ BEGIN * @table tmp.user(userFk) * @return tmp.timeBusinessCalculate */ - DECLARE vHoursFullTime INT DEFAULT 40; - + DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate; DROP TEMPORARY TABLE IF EXISTS tmp.businessFullTime; @@ -51211,17 +50825,19 @@ BEGIN SEC_TO_TIME(timeWorkSeconds) timeBusinessSexagesimal, timeWorkSeconds / 3600 timeBusinessDecimal, type, - permissionrate, - hoursWeek + permissionRate, + hoursWeek, + discountRate FROM(SELECT rd.dated, b.business_id businessFk, w.userFk, bl.department_id departmentFk, - IF(cl.hours_week = vHoursFullTime, NULL, GROUP_CONCAT(DISTINCT LEFT(j.start,2) ORDER BY j.start ASC SEPARATOR '-')) hourStart , - IF(cl.hours_week = vHoursFullTime, NULL, GROUP_CONCAT(DISTINCT LEFT(j.end,2) ORDER BY j.end ASC SEPARATOR '-')) hourEnd, - IF(cl.hours_week = vHoursFullTime, 0, IFNULL(SUM(TIME_TO_SEC(j.end)) - SUM(TIME_TO_SEC(j.start)),0)) timeWorkSeconds, + IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.start,2) ORDER BY j.start ASC SEPARATOR '-')) hourStart , + IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.end,2) ORDER BY j.end ASC SEPARATOR '-')) hourEnd, + IF(j.start = NULL, 0, IFNULL(SUM(TIME_TO_SEC(j.end)) - SUM(TIME_TO_SEC(j.start)),0)) timeWorkSeconds, cs.type, cs.permissionRate, + cs.discountRate, cl.hours_week hoursWeek FROM tmp.rangeDate rd LEFT JOIN postgresql.business b ON rd.dated BETWEEN b.date_start AND ifnull(b.date_end, vDatedTo ) @@ -51243,19 +50859,20 @@ BEGIN UPDATE tmp.timeBusinessCalculate t - SET t.timeWorkSeconds = vHoursFullTime / 5 * 3600, - t.timeWorkSexagesimal = SEC_TO_TIME( vHoursFullTime / 5 * 3600), - t.timeWorkDecimal = vHoursFullTime / 5, - t.timeBusinessSeconds = vHoursFullTime / 5 * 3600, - t.timeBusinessSexagesimal = SEC_TO_TIME( vHoursFullTime / 5 * 3600), - t.timeBusinessDecimal = vHoursFullTime / 5 - WHERE DAYOFWEEK(t.dated) IN(2,3,4,5,6) AND hoursWeek = vHoursFullTime ; + 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.timeWorkSeconds - (t.timeWorkSeconds * permissionrate)), - t.timeWorkDecimal = t.timeWorkDecimal - (t.timeWorkDecimal * permissionrate) - WHERE permissionrate <> 0; + SET t.timeWorkSeconds = t.timeWorkSeconds - (t.timeWorkSeconds * permissionRate) , + t.timeWorkSexagesimal = SEC_TO_TIME(t.timeWorkSeconds - (t.timeWorkSeconds * permissionRate)), + t.timeWorkDecimal = t.timeWorkDecimal - (t.timeWorkDecimal * permissionRate) + WHERE permissionRate <> 0; UPDATE tmp.timeBusinessCalculate t JOIN postgresql.calendar_labour cl ON cl.day = t.dated @@ -51263,7 +50880,7 @@ BEGIN SET t.timeWorkSeconds = 0, t.timeWorkSexagesimal = 0, t.timeWorkDecimal = 0, - t.permissionrate = 1, + t.permissionRate = 1, t.type = 'Festivo' WHERE t.type IS NULL; @@ -53080,6 +52697,190 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControl_check`(vUserFk INT, vDated DATE,vTabletFk VARCHAR(100)) proc: BEGIN +/** + * Verifica si el empleado puede fichar en el momento actual, si puede fichar llama a vn.workerTimeControlAdd + * + * @param vUserFk Identificador del trabajador + * @return Retorna si encuentra un problema 'odd','maxTimeWork','breakDay','breakWeek' ; + * En caso de tener algun problema retorna el primero que encuentra + */ + DECLARE vLastIn DATETIME ; + DECLARE vLastOut DATETIME ; + DECLARE vDayWorkMax INT; + DECLARE vDayBreak INT; + DECLARE vWeekBreak INT ; + DECLARE vWeekScope INT; + DECLARE vDayStayMax INT; + DECLARE vProblem VARCHAR(20) DEFAULT NULL; + DECLARE vTimedWorked INT; + DECLARE vCalendarStateType VARCHAR(20) DEFAULT NULL; + DECLARE vTo VARCHAR(50) DEFAULT NULL; + DECLARE vUserName VARCHAR(50) DEFAULT NULL; + DECLARE vBody VARCHAR(255) DEFAULT NULL; + + SELECT dayBreak, weekBreak, weekScope, dayWorkMax, dayStayMax + INTO vDayBreak, vWeekBreak, vWeekScope, vDayWorkMax, vDayStayMax + FROM vn.workerTimeControlParams; + + SELECT MAX(timed) INTO vLastIn + FROM vn.workerTimeControl + WHERE userFk = vUserFk + AND direction = 'in'; + + SELECT MAX(timed) INTO vLastOut + FROM vn.workerTimeControl + WHERE userFk = vUserFk + AND direction = 'out'; + + SELECT email INTO vTo + FROM vn.worker w + WHERE w.id = (SELECT bossFk FROM vn.worker WHERE id = vUserFk); + + SELECT CONCAT(firstName,' ',lastName) INTO vUserName + FROM vn.worker w + WHERE w.id = vUserFk; + + + IF UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(vLastIn) > vDayStayMax THEN -- NUEVA JORNADA + + -- VERIFICAR DESCANSO DIARIO + IF UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(vLastOut) < vDayBreak THEN + SELECT "Descansos 12 h" AS problem; + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"Descansos 12 h") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + LEAVE proc; + END IF; + + -- VERIFICAR FICHADAS IMPARES DEL ÚLTIMO DÍA QUE SE FICHÓ + IF (SELECT MOD(COUNT(*),2) -- <>0 + FROM vn.workerTimeControl + WHERE userFk = vUserFk + AND timed >= vLastIn + ) THEN + SELECT "Dias con fichadas impares" AS problem; + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"Dias con fichadas impares") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + LEAVE proc; + END IF; + + -- VERIFICAR VACACIONES + SELECT cs.type INTO vCalendarStateType + FROM postgresql.calendar_employee ce + JOIN postgresql.business b USING(business_id) + JOIN postgresql.profile pr ON pr.profile_id = b.client_id + JOIN postgresql.person p ON p.person_id = pr.person_id + JOIN postgresql.calendar_state cs USING(calendar_state_id) + JOIN vn.worker w ON w.id = p.id_trabajador + WHERE ce.date = CURDATE() + AND cs.isAllowedToWork = FALSE + AND w.userFk = vUserFk + LIMIT 1; + + IF(LENGTH(vCalendarStateType)) THEN + SELECT vCalendarStateType AS problem; + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"Vacaciones") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + LEAVE proc; + + END IF; + + + -- VERIFICAR CONTRATO EN VIGOR + IF (SELECT COUNT(*) + FROM postgresql.business b + JOIN postgresql.profile pr ON pr.profile_id = b.client_id + JOIN postgresql.person p ON p.person_id = pr.person_id + JOIN vn.worker w ON w.id = p.id_trabajador + WHERE w.userFk = vUserFk + AND b.date_start <= vDated + AND IFNULL(b.date_end,vDated) >= vDated + ) = 0 THEN + SELECT "No hay un contrato en vigor" AS problem; + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"No hay un contrato en vigor") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + LEAVE proc; + + END IF; + + -- VERIFICAR DESCANSO SEMANAL + SET @vHasBreakWeek:= FALSE; + SET @vLastTimed:= UNIX_TIMESTAMP((NOW() - INTERVAL vWeekScope SECOND)); + + DROP TEMPORARY TABLE IF EXISTS tmp.trash; + CREATE TEMPORARY TABLE tmp.trash + SELECT IF(vWeekBreak-(UNIX_TIMESTAMP(timed)-@vLastTimed) <= 0, @vHasBreakWeek:=TRUE, TRUE) alias, + @vLastTimed:= UNIX_TIMESTAMP(timed) + FROM workerTimeControl + WHERE timed>= (NOW() - INTERVAL vWeekScope SECOND) + AND userFk= vUserFk + AND direction IN ('in','out') + ORDER BY timed ASC; + + IF UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(vLastOut) < vWeekBreak AND @vHasBreakWeek = FALSE THEN -- REVISA SI EL DESCANSO SE HA REALIZADO DESPUÉS DE LA ÚLTIMA FICHADA + SELECT "Descansos 36 h" AS problem; + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"Descansos 36 h") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + LEAVE proc; + END IF; + + DROP TEMPORARY TABLE tmp.trash; + + ELSE -- DIA ACTUAL + + -- VERIFICA QUE EL TIEMPO EFECTIVO NO SUPERE EL MÁXIMO + SELECT IFNULL(SUM(if( mod(wtc.order,2)=1, -UNIX_TIMESTAMP(timed), UNIX_TIMESTAMP(timed))),0) - IF( MOD(COUNT(*),2), UNIX_TIMESTAMP(NOW()), 0) INTO vTimedWorked + FROM vn.workerTimeControl wtc + WHERE userFk = vUserFk + AND timed >= vLastIn + ORDER BY timed; + + IF vTimedWorked > vDayWorkMax THEN + SELECT "Jornadas" AS problem; + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"Jornadas") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + LEAVE proc; + END IF; + + END IF; + + -- VERIFICAR DEPARTAMENTO + IF vTabletFk IS NOT NULL THEN + IF ( SELECT COUNT(*) + FROM vn.tabletDepartment td + JOIN vn.workerTimeControlUserInfo wtcu ON wtcu.departmentFk = td.departmentFk + WHERE td.tabletFk = vTabletFk AND wtcu.userFk = vUserFk + ) = 0 THEN + SELECT "No perteneces a este departamento." AS problem; + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"No perteneces a este departamento.") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + LEAVE proc; + END IF; + END IF; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_check_` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControl_check_`(vUserFk INT, vDated DATE,vTabletFk VARCHAR(100)) +proc: BEGIN /** * Verifica si el empleado puede fichar en el momento actual, si puede fichar llama a vn.workerTimeControlAdd * @@ -54009,15 +53810,14 @@ proc: BEGIN TRUNCATE TABLE zoneClosure; - REPEAT + WHILE vCounter <= vScope DO CALL zone_getOptionsForShipment(vShipped, TRUE); INSERT INTO zoneClosure(zoneFk, dated, `hour`) SELECT zoneFk, vShipped, `hour` FROM tmp.zoneOption; SET vCounter = vCounter + 1; SET vShipped = TIMESTAMPADD(DAY, 1, vShipped); - UNTIL vCounter > vScope - END REPEAT; + END WHILE; DROP TEMPORARY TABLE tmp.zone; DO RELEASE_LOCK('vn.zoneClosure_recalc'); @@ -54292,7 +54092,7 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `zoneGetAgency` */; +/*!50003 DROP PROCEDURE IF EXISTS `zoneGetAgency__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -54302,7 +54102,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetAgency`(vAddress INT, vLanded DATE) +CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetAgency__`(vAddress INT, vLanded DATE) BEGIN /** * Devuelve el listado de agencias disponibles para la fecha @@ -54320,7 +54120,7 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `zoneGetLanded` */; +/*!50003 DROP PROCEDURE IF EXISTS `zoneGetLanded__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -54330,7 +54130,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetLanded`(vShipped DATE, vAddressFk INT, vAgencyModeFk INT, vWarehouseFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetLanded__`(vShipped DATE, vAddressFk INT, vAgencyModeFk INT, vWarehouseFk INT) BEGIN /** * JGF procedimiento TEMPORAL @@ -54369,7 +54169,7 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `zoneGetShipped` */; +/*!50003 DROP PROCEDURE IF EXISTS `zoneGetShippedWarehouse__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -54379,7 +54179,34 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetShipped`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT, vWarehouseFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetShippedWarehouse__`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT) +BEGIN +/** + * Devuelve la mínima fecha de envío para cada warehouse + * + * @param vLanded La fecha de recepcion + * @param vAddressFk Id del consignatario + * @param vAgencyModeFk Id de la agencia + * @return tmp.zoneGetShipped + */ + CALL zone_getShippedWarehouse(vLanded, vAddressFk, vAgencyModeFk); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `zoneGetShipped__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetShipped__`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT, vWarehouseFk INT) BEGIN /** * OBSOLETO usar zone_getShippedWarehouse @@ -54400,7 +54227,7 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `zoneGetShippedWarehouse` */; +/*!50003 DROP PROCEDURE IF EXISTS `zoneGetWarehouse__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -54410,34 +54237,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetShippedWarehouse`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT) -BEGIN -/** - * Devuelve la mínima fecha de envío para cada warehouse - * - * @param vLanded La fecha de recepcion - * @param vAddressFk Id del consignatario - * @param vAgencyModeFk Id de la agencia - * @return tmp.zoneGetShipped - */ - CALL zone_getShippedWarehouse(vLanded, vAddressFk, vAgencyModeFk); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `zoneGetWarehouse` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetWarehouse`(vAddress INT, vLanded DATE, vWarehouse INT) +CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetWarehouse__`(vAddress INT, vLanded DATE, vWarehouse INT) BEGIN /** * Devuelve el listado de agencias disponibles para la fecha, @@ -54491,7 +54291,7 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `zoneGetWarehouse__` */; +/*!50003 DROP PROCEDURE IF EXISTS `zone_doCalcInitialize` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -54501,53 +54301,55 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetWarehouse__`(vAddress INT, vLanded DATE, vWarehouse INT) -BEGIN +CREATE DEFINER=`root`@`%` PROCEDURE `zone_doCalcInitialize`() +proc: BEGIN /** -* Devuelve el listado de agencias disponibles para la fecha, - * dirección y warehouse pasadas - * - * @param vAddress - * @param vWarehouse warehouse - * @param vLanded Fecha de recogida - * @select Listado de agencias disponibles + * Initialize ticket + * si en 01-07-20 aun esta este proc, kkear */ - - DECLARE vGeoFk INT; - - SELECT p.geoFk INTO vGeoFk - FROM address a - JOIN town t ON t.provinceFk = a.provinceFk - JOIN postCode p ON p.townFk = t.id AND p.code = a.postalCode - WHERE a.id = vAddress - ORDER BY (a.city SOUNDS LIKE t.`name`) DESC - LIMIT 1; + DECLARE vDone BOOL; + DECLARE vTicketFk INT; + DECLARE vLanded DATE; + DECLARE vZoneFk INT; - SELECT * FROM ( - SELECT * FROM ( - SELECT am.id agencyModeFk, - am.name agencyMode, - am.description, - am.deliveryMethodFk, - TIMESTAMPADD(DAY,-z.travelingDays, vLanded) shipped, - z.warehouseFk, - zi.isIncluded, - z.id zoneFk - FROM zoneGeo zgSon - JOIN zoneGeo zgFather ON zgSon.lft BETWEEN zgFather.lft AND zgFather.rgt - JOIN zoneIncluded zi ON zi.geoFk = zgFather.id - JOIN zone z ON z.id = zi.zoneFk - JOIN zoneCalendar zc ON zc.zoneFk = z.id - JOIN agencyMode am ON am.id = z.agencyModeFk - WHERE zgSon.`id` = vGeoFk - AND delivered = vLanded - AND z.warehouseFk = vWarehouse - AND IF(TIMESTAMPADD(DAY,-z.travelingDays, vLanded) = CURDATE(), hour(now()) < hour(z.`hour`),TRUE) - ORDER BY z.id, zgFather.depth DESC) t - GROUP BY zoneFk - HAVING isIncluded > 0) t - GROUP BY agencyModeFk; + DECLARE cCur CURSOR FOR + SELECT t.id, t.landed, t.zoneFk + FROM ticket t + WHERE shipped >= '2020-01-01' AND shipped <= '2020-01-31' + AND zoneFk in (34, 43,51,55,66) + GROUP BY landed, zoneFk; + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET vDone = TRUE; + + OPEN cCur; + + myLoop: LOOP + SET vDone = FALSE; + FETCH cCur INTO vTicketFk, vLanded, vZoneFk; + + IF vDone THEN + LEAVE myLoop; + END IF; + + DROP TEMPORARY TABLE IF EXISTS tmp.zone; + CREATE TEMPORARY TABLE tmp.zone + (INDEX (id)) + ENGINE = MEMORY + SELECT vZoneFk id; + + CALL zone_getOptionsForLanding(vLanded, TRUE); + + UPDATE ticket t + LEFT JOIN tmp.zoneOption zo ON TRUE + SET zonePrice = zo.price, zoneBonus = zo.bonus + WHERE t.zoneFk = vZoneFk AND landed = vLanded; + + + END LOOP; + + CLOSE cCur; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -54576,7 +54378,7 @@ BEGIN */ CALL zone_getFromGeo(address_getGeo(vAddress)); - CALL zone_getOptionsForLanding(vLanded); + CALL zone_getOptionsForLanding(vLanded, FALSE); DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetAgency; CREATE TEMPORARY TABLE tmp.zoneGetAgency @@ -54615,11 +54417,8 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `zone_getAvailable`(vAddress INT, vLanded DATE) BEGIN - -/* JGF esta trabajando en este archivo, si se modifica avisadme 2020-02-12*/ - CALL zone_getFromGeo(address_getGeo(vAddress)); - CALL zone_getOptionsForLanding(vLanded); + CALL zone_getOptionsForLanding(vLanded, FALSE); SELECT * FROM tmp.zoneOption; @@ -54909,13 +54708,13 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `zone_getOptionsForLanding`(vLanded DATE) +CREATE DEFINER=`root`@`%` PROCEDURE `zone_getOptionsForLanding`(vLanded DATE, vShowExpiredZones BOOLEAN) BEGIN /** * Gets computed options for the passed zones and delivery date. @@ -54968,9 +54767,11 @@ BEGIN JOIN zoneExclusion e ON e.zoneFk = t.zoneFk AND e.`dated` = vLanded; - DELETE FROM tmp.zoneOption - WHERE shipped < CURDATE() - OR (shipped = CURDATE() AND CURTIME() > `hour`); + IF NOT vShowExpiredZones THEN + DELETE FROM tmp.zoneOption + WHERE shipped < CURDATE() + OR (shipped = CURDATE() AND CURTIME() > `hour`); + END IF; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -55240,7 +55041,7 @@ DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `zone_getShippedWarehouse`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT) BEGIN /** - * Devuelve la mínima fecha de envío para cada warehouse + * Devuelve la mínima fecha de envío para cada warehouse * * @param vLanded La fecha de recepcion * @param vAddressFk Id del consignatario @@ -55249,7 +55050,7 @@ BEGIN */ CALL zone_getFromGeo(address_getGeo(vAddressFk)); - CALL zone_getOptionsForLanding(vLanded); + CALL zone_getOptionsForLanding(vLanded,TRUE); DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetShipped; CREATE TEMPORARY TABLE tmp.zoneGetShipped @@ -55257,8 +55058,11 @@ BEGIN SELECT * FROM ( SELECT zo.zoneFk, TIMESTAMPADD(DAY,-zo.travelingDays, vLanded) shipped, + zo.`hour`, zw.warehouseFk, - z.agencyModeFk + z.agencyModeFk, + zo.price, + zo.bonus FROM tmp.zoneOption zo JOIN zoneWarehouse zw ON zw.zoneFk = zo.zoneFk JOIN zone z ON z.id = zo.zoneFk @@ -55287,9 +55091,6 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `zone_getWarehouse`(vAddress INT, vLanded DATE, vWarehouse INT) BEGIN - -/* JGF esta trabajando en este archivo, si se modifica avisadme 2020-02-12*/ - /** * Devuelve el listado de agencias disponibles para la fecha, * dirección y almacén pasados. @@ -55301,7 +55102,7 @@ BEGIN */ CALL zone_getFromGeo(address_getGeo(vAddress)); - CALL zone_getOptionsForLanding(vLanded); + CALL zone_getOptionsForLanding(vLanded, FALSE); SELECT am.id agencyModeFk, am.name agencyMode, @@ -56801,28 +56602,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `holidayDetail` +-- Final view structure for view `holidayDetail__` -- -/*!50001 DROP VIEW IF EXISTS `holidayDetail`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8 */; -/*!50001 SET character_set_results = utf8 */; -/*!50001 SET collation_connection = utf8_general_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `holidayDetail` AS select `cll`.`calendar_labour_legend_id` AS `id`,`cll`.`descripcion` AS `description` from `postgresql`.`calendar_labour_legend` `cll` */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - --- --- Final view structure for view `holidayLegend` --- - -/*!50001 DROP VIEW IF EXISTS `holidayLegend`*/; +/*!50001 DROP VIEW IF EXISTS `holidayDetail__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -56831,25 +56614,43 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `holidayLegend` AS select `cll`.`calendar_labour_legend_id` AS `id`,`cll`.`descripcion` AS `description` from `postgresql`.`calendar_labour_legend` `cll` */; +/*!50001 VIEW `holidayDetail__` AS select `cll`.`calendar_labour_legend_id` AS `id`,`cll`.`descripcion` AS `description` from `postgresql`.`calendar_labour_legend` `cll` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `holidayType` +-- Final view structure for view `holidayLegend__` -- -/*!50001 DROP VIEW IF EXISTS `holidayType`*/; +/*!50001 DROP VIEW IF EXISTS `holidayLegend__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8 */; -/*!50001 SET character_set_results = utf8 */; -/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `holidayType` AS select `cf`.`calendar_free_id` AS `id`,`cf`.`type` AS `name`,`cf`.`rgb` AS `rgb` from `postgresql`.`calendar_free` `cf` */; +/*!50001 VIEW `holidayLegend__` AS select `cll`.`calendar_labour_legend_id` AS `id`,`cll`.`descripcion` AS `description` from `postgresql`.`calendar_labour_legend` `cll` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `holidayType__` +-- + +/*!50001 DROP VIEW IF EXISTS `holidayType__`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `holidayType__` AS select `cf`.`calendar_free_id` AS `id`,`cf`.`type` AS `name`,`cf`.`rgb` AS `rgb` from `postgresql`.`calendar_free` `cf` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -57029,7 +56830,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemShelvingAvailable` AS select `s`.`id` AS `saleFk`,`tst`.`updated` AS `Modificado`,`s`.`ticketFk` AS `ticketFk`,0 AS `isPicked`,`s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`i`.`size` AS `size`,`st`.`name` AS `Estado`,`st`.`sectorProdPriority` AS `sectorProdPriority`,`stock`.`visible` AS `available`,`stock`.`sectorFk` AS `sectorFk`,`stock`.`shelvingFk` AS `matricula`,`stock`.`parkingFk` AS `parking`,`stock`.`itemShelvingFk` AS `itemShelving`,`am`.`name` AS `Agency`,`t`.`shipped` AS `shipped`,`stock`.`grouping` AS `grouping`,`stock`.`packing` AS `packing`,`z`.`hour` AS `hour`,`st`.`isPreviousPreparable` AS `isPreviousPreparable`,`sv`.`physicalVolume` AS `physicalVolume`,`t`.`warehouseFk` AS `warehouseFk` from (((((((((`vn`.`sale` `s` join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`agencyMode` `am` on((`am`.`id` = `t`.`agencyModeFk`))) join `vn`.`ticketStateToday` `tst` on((`tst`.`ticket` = `t`.`id`))) join `vn`.`state` `st` on((`st`.`id` = `tst`.`state`))) join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`itemShelvingStock` `stock` on((`stock`.`itemFk` = `i`.`id`))) left join `vn`.`saleTracking` `stk` on((`stk`.`saleFk` = `s`.`id`))) left join `vn`.`zone` `z` on((`z`.`id` = `t`.`zoneFk`))) left join `vn`.`saleVolume` `sv` on((`sv`.`saleFk` = `s`.`id`))) where ((`t`.`shipped` between `util`.`yesterday`() and `util`.`dayend`(curdate())) and isnull(`stk`.`id`) and (`stock`.`visible` > 0) and isnull(`stk`.`saleFk`) and `st`.`sectorProdPriority`) */; +/*!50001 VIEW `itemShelvingAvailable` AS select `s`.`id` AS `saleFk`,`tst`.`updated` AS `Modificado`,`s`.`ticketFk` AS `ticketFk`,0 AS `isPicked`,`s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`i`.`size` AS `size`,`st`.`name` AS `Estado`,`st`.`sectorProdPriority` AS `sectorProdPriority`,`stock`.`visible` AS `available`,`stock`.`sectorFk` AS `sectorFk`,`stock`.`shelvingFk` AS `matricula`,`stock`.`parkingFk` AS `parking`,`stock`.`itemShelvingFk` AS `itemShelving`,`am`.`name` AS `Agency`,`t`.`shipped` AS `shipped`,`stock`.`grouping` AS `grouping`,`stock`.`packing` AS `packing`,`z`.`hour` AS `hour`,`st`.`isPreviousPreparable` AS `isPreviousPreparable`,`sv`.`physicalVolume` AS `physicalVolume`,`t`.`warehouseFk` AS `warehouseFk` from (((((((((`vn`.`sale` `s` join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`agencyMode` `am` on((`am`.`id` = `t`.`agencyModeFk`))) join `vn`.`ticketStateToday` `tst` on((`tst`.`ticket` = `t`.`id`))) join `vn`.`state` `st` on((`st`.`id` = `tst`.`state`))) join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`itemShelvingStock` `stock` on((`stock`.`itemFk` = `i`.`id`))) left join `vn`.`saleTracking` `stk` on((`stk`.`saleFk` = `s`.`id`))) left join `vn`.`zone` `z` on((`z`.`id` = `t`.`zoneFk`))) left join `vn`.`saleVolume` `sv` on((`sv`.`saleFk` = `s`.`id`))) where ((`t`.`shipped` between `util`.`yesterday`() and `util`.`dayend`(curdate())) and isnull(`stk`.`id`) and (`stock`.`visible` > 0) and isnull(`stk`.`saleFk`) and `st`.`isPreviousPreparable`) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -57214,6 +57015,24 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `lastHourProduction` +-- + +/*!50001 DROP VIEW IF EXISTS `lastHourProduction`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `lastHourProduction` AS select `t`.`warehouseFk` AS `warehouseFk`,greatest(10,cast(sum(`sv`.`volume`) as decimal(5,1))) AS `m3` from (((((((`vn`.`saleTracking` `st` join `vn`.`saleVolume` `sv` on((`sv`.`saleFk` = `st`.`saleFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `sv`.`ticketFk`))) join `vn`.`state` `s` on((`s`.`id` = `st`.`stateFk`))) join `account`.`user` `u` on((`u`.`id` = `st`.`workerFk`))) join `account`.`role` `r` on((`r`.`id` = `u`.`role`))) join `vn`.`warehouse` `w` on((`w`.`id` = `t`.`warehouseFk`))) join `vn`.`warehouseAlias` `wa` on((`wa`.`id` = `w`.`aliasFk`))) where ((`st`.`created` > (now() + interval -(1) hour)) and (`s`.`code` = 'CHECKED') and (`r`.`name` <> 'salesPerson') and (`wa`.`name` = 'Silla')) */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `lastTopClaims` -- @@ -57305,19 +57124,19 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `saleFreight` +-- Final view structure for view `saleFreight__` -- -/*!50001 DROP VIEW IF EXISTS `saleFreight`*/; +/*!50001 DROP VIEW IF EXISTS `saleFreight__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8mb4 */; -/*!50001 SET character_set_results = utf8mb4 */; -/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleFreight` AS select `s`.`ticketFk` AS `ticketFk`,`t`.`clientFk` AS `clientFk`,`t`.`routeFk` AS `routeFk`,`s`.`id` AS `saleFk`,`t`.`zoneFk` AS `zoneFk`,`t`.`companyFk` AS `companyFk`,`t`.`shipped` AS `shipped`,`zc`.`price` AS `price`,((((`s`.`quantity` * `r`.`cm3`) * `zc`.`price`) * `i`.`compression`) / `cb`.`volume`) AS `freight`,(((`s`.`quantity` * `r`.`cm3`) * `i`.`compression`) / 1000000) AS `volume` from (((((`vn`.`sale` `s` join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`packaging` `cb` on((`cb`.`id` = '94'))) join `bi`.`rotacion` `r` on(((`r`.`Id_Article` = `s`.`itemFk`) and (`r`.`warehouse_id` = `t`.`warehouseFk`)))) join `vn`.`zoneCalendar` `zc` on(((`zc`.`zoneFk` = `t`.`zoneFk`) and (`zc`.`delivered` = `t`.`landed`)))) */; +/*!50001 VIEW `saleFreight__` AS select `s`.`ticketFk` AS `ticketFk`,`t`.`clientFk` AS `clientFk`,`t`.`routeFk` AS `routeFk`,`s`.`id` AS `saleFk`,`t`.`zoneFk` AS `zoneFk`,`t`.`companyFk` AS `companyFk`,`t`.`shipped` AS `shipped`,`t`.`zonePrice` AS `price`,((((`s`.`quantity` * `r`.`cm3`) * `t`.`zonePrice`) * `i`.`compression`) / `cb`.`volume`) AS `freight` from ((((`vn`.`sale` `s` join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`packaging` `cb` on((`cb`.`id` = '94'))) join `bi`.`rotacion` `r` on(((`r`.`Id_Article` = `s`.`itemFk`) and (`r`.`warehouse_id` = `t`.`warehouseFk`)))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -57353,7 +57172,43 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleVolume` AS select `s`.`ticketFk` AS `ticketFk`,`s`.`id` AS `saleFk`,ifnull(round(((((`i`.`compression` * (greatest(`i`.`density`,167) / 167)) * `ic`.`cm3`) * `s`.`quantity`) / 1000),2),0) AS `litros`,`t`.`routeFk` AS `routeFk`,`t`.`shipped` AS `shipped`,(((`s`.`quantity` * `ic`.`cm3`) * `i`.`compression`) / 1000000) AS `volume`,((((`s`.`quantity` * `ic`.`cm3`) * `i`.`compression`) * (greatest(`i`.`density`,167) / 167)) / 1000000) AS `physicalWeight`,(((`s`.`quantity` * `ic`.`cm3`) * `i`.`density`) / 1000000) AS `weight`,(((`s`.`quantity` * `ic`.`cm3`) * `i`.`compression`) / 1000000) AS `physicalVolume` from (((`sale` `s` join `item` `i` on((`i`.`id` = `s`.`itemFk`))) join `ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `itemCost` `ic` on(((`ic`.`itemFk` = `s`.`itemFk`) and (`ic`.`warehouseFk` = `t`.`warehouseFk`)))) */; +/*!50001 VIEW `saleVolume` AS select `s`.`ticketFk` AS `ticketFk`,`s`.`id` AS `saleFk`,ifnull(round(((((`i`.`compression` * (greatest(`i`.`density`,167) / 167)) * `ic`.`cm3`) * `s`.`quantity`) / 1000),2),0) AS `litros`,`t`.`routeFk` AS `routeFk`,`t`.`shipped` AS `shipped`,(((`s`.`quantity` * `ic`.`cm3`) * `i`.`compression`) / 1000000) AS `volume`,((((`s`.`quantity` * `ic`.`cm3`) * `i`.`compression`) * (greatest(`i`.`density`,167) / 167)) / 1000000) AS `physicalWeight`,(((`s`.`quantity` * `ic`.`cm3`) * `i`.`density`) / 1000000) AS `weight`,(((`s`.`quantity` * `ic`.`cm3`) * `i`.`compression`) / 1000000) AS `physicalVolume`,((((`s`.`quantity` * `ic`.`cm3`) * `t`.`zonePrice`) * `i`.`compression`) / `cb`.`volume`) AS `freight`,`t`.`zoneFk` AS `zoneFk`,`t`.`clientFk` AS `clientFk` from ((((`sale` `s` join `item` `i` on((`i`.`id` = `s`.`itemFk`))) join `ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `packaging` `cb` on((`cb`.`id` = '94'))) join `itemCost` `ic` on(((`ic`.`itemFk` = `s`.`itemFk`) and (`ic`.`warehouseFk` = `t`.`warehouseFk`)))) */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `saleVolume__` +-- + +/*!50001 DROP VIEW IF EXISTS `saleVolume__`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `saleVolume__` AS select `s`.`ticketFk` AS `ticketFk`,`s`.`id` AS `saleFk`,ifnull(round(((((`i`.`compression` * (greatest(`i`.`density`,167) / 167)) * `ic`.`cm3`) * `s`.`quantity`) / 1000),2),0) AS `litros`,`t`.`routeFk` AS `routeFk`,`t`.`shipped` AS `shipped`,(((`s`.`quantity` * `ic`.`cm3`) * `i`.`compression`) / 1000000) AS `volume`,((((`s`.`quantity` * `ic`.`cm3`) * `i`.`compression`) * (greatest(`i`.`density`,167) / 167)) / 1000000) AS `physicalWeight`,(((`s`.`quantity` * `ic`.`cm3`) * `i`.`density`) / 1000000) AS `weight`,(((`s`.`quantity` * `ic`.`cm3`) * `i`.`compression`) / 1000000) AS `physicalVolume`,((((`s`.`quantity` * `ic`.`cm3`) * `t`.`zonePrice`) * `i`.`compression`) / `cb`.`volume`) AS `freight` from ((((`sale` `s` join `item` `i` on((`i`.`id` = `s`.`itemFk`))) join `ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `packaging` `cb` on((`cb`.`id` = '94'))) join `itemCost` `ic` on(((`ic`.`itemFk` = `s`.`itemFk`) and (`ic`.`warehouseFk` = `t`.`warehouseFk`)))) */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `sale_freightComponent` +-- + +/*!50001 DROP VIEW IF EXISTS `sale_freightComponent`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `sale_freightComponent` AS select `t`.`id` AS `ticketFk`,(`sc`.`value` * `s`.`quantity`) AS `amount`,`t`.`shipped` AS `shipped` from ((((`ticket` `t` straight_join `sale` `s` on((`t`.`id` = `s`.`ticketFk`))) join `saleComponent` `sc` on((`sc`.`saleFk` = `s`.`id`))) join `component` `c` on((`c`.`id` = `sc`.`componentFk`))) join `componentType` `ct` on(((`ct`.`id` = `c`.`typeFk`) and (`ct`.`type` = 'agencia')))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -57700,6 +57555,24 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `zone_ETD` +-- + +/*!50001 DROP VIEW IF EXISTS `zone_ETD`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `zone_ETD` AS select `t`.`zoneFk` AS `zoneFk`,cast((curdate() + interval ((hour(`zc`.`hour`) * 60) + minute(`zc`.`hour`)) minute) as time) AS `HoraTeórica`,cast(sum(`sv`.`volume`) as decimal(5,1)) AS `volumenTotal`,cast(sum(if((`s`.`alertLevel` < 2),`sv`.`volume`,0)) as decimal(5,1)) AS `volumenPendiente`,`lhp`.`m3` AS `velocidad`,cast((`zc`.`hour` + interval ((-(sum(if((`s`.`alertLevel` < 2),`sv`.`volume`,0))) * 60) / `lhp`.`m3`) minute) as time) AS `HoraPráctica`,floor(((-(sum(if((`s`.`alertLevel` < 2),`sv`.`volume`,0))) * 60) / `lhp`.`m3`)) AS `minutesLess`,cast((`zc`.`hour` + interval ((-(sum(if((`s`.`alertLevel` < 2),`sv`.`volume`,0))) * 60) / `lhp`.`m3`) minute) as time) AS `etc` from (((((((`vn`.`ticket` `t` join `vn`.`ticketStateToday` `tst` on((`tst`.`ticket` = `t`.`id`))) join `vn`.`state` `s` on((`s`.`id` = `tst`.`state`))) join `vn`.`saleVolume` `sv` on((`sv`.`ticketFk` = `t`.`id`))) join `vn`.`lastHourProduction` `lhp` on((`lhp`.`warehouseFk` = `t`.`warehouseFk`))) join `vn`.`warehouse` `w` on((`w`.`id` = `t`.`warehouseFk`))) join `vn`.`warehouseAlias` `wa` on((`wa`.`id` = `w`.`aliasFk`))) join `vn`.`zoneClosure` `zc` on(((`zc`.`zoneFk` = `t`.`zoneFk`) and (`zc`.`dated` = curdate())))) where ((`wa`.`name` = 'Silla') and (cast(`t`.`shipped` as date) = curdate())) group by `t`.`zoneFk` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Current Database: `vncontrol` -- @@ -57715,4 +57588,4 @@ USE `vncontrol`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-02-13 9:07:01 +-- Dump completed on 2020-02-27 13:42:11 diff --git a/db/tests/vn/workerTimeControlCheck.spec.js b/db/tests/vn/workerTimeControlCheck.spec.js new file mode 100644 index 0000000000..81ddc9be29 --- /dev/null +++ b/db/tests/vn/workerTimeControlCheck.spec.js @@ -0,0 +1,398 @@ +const app = require('vn-loopback/server/server'); +const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; + +fdescribe('worker workerTimeControl_check()', () => { + it('should throw an error if the worker does not belong to this department', async() => { + let stmts = []; + let stmt; + const workerId = 110; + const tabletId = 2; + let err; + stmts.push('START TRANSACTION'); + try { + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerId, + tabletId + ]); + stmts.push(stmt); + + stmts.push('ROLLBACK'); + + let sql = ParameterizedSQL.join(stmts, ';'); + await app.models.Worker.rawStmt(sql); + } catch (e) { + err = e; + } + + expect(err.sqlMessage).toEqual('No perteneces a este departamento.'); + }); + + it('should EL TRABAJDOR ESTA EN EL DEPARTAMENTO Y TABLET CORRECTO', async() => { + let stmts = []; + let stmt; + const workerId = 110; + const tabletId = 1; + let err; + stmts.push('START TRANSACTION'); + try { + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerId, + tabletId + ]); + stmts.push(stmt); + + stmts.push('ROLLBACK'); + + let sql = ParameterizedSQL.join(stmts, ';'); + await app.models.Worker.rawStmt(sql); + } catch (e) { + err = e; + } + + expect(err).not.toBeDefined(); + }); + + it('should throw an error if the worker NO HA CUMPLIDO EL DESCANSO DE 9h', async() => { + const workerIdBreak9Hours = 110; + const tabletId = 1; + let stmts = []; + let stmt; + let sql; + let error; + + stmts.push('START TRANSACTION'); + stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction) + VALUES + (?,TIMESTAMPADD(HOUR,-17,NOW()),0,"in"), + (?,TIMESTAMPADD(SECOND,-32399,NOW()),0,"out")`, [ + workerIdBreak9Hours, + workerIdBreak9Hours + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerIdBreak9Hours, + tabletId + ]); + stmts.push(stmt); + stmts.push('ROLLBACK'); + sql = ParameterizedSQL.join(stmts, ';'); + + try { + await app.models.Worker.rawStmt(sql); + } catch (e) { + await app.models.Worker.rawSql('ROLLBACK'); + error = e; + } + + expect(error.sqlMessage).toEqual('Descansos 9 h'); + }); + + it('should throw an error if the worker HA CUMPLIDO EL DESCANSO de 9h', async() => { + const workerIdBreak9Hours = 110; + const tabletId = 1; + let stmts = []; + let stmt; + let err; + stmts.push('START TRANSACTION'); + stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction) + VALUES + (?,TIMESTAMPADD(HOUR,-17,NOW()),0,"in"), + (?,TIMESTAMPADD(SECOND,-32401,NOW()),0,"out")`, [ + workerIdBreak9Hours, + workerIdBreak9Hours + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerIdBreak9Hours, + tabletId + ]); + stmts.push(stmt); + stmts.push('ROLLBACK'); + + let sql = ParameterizedSQL.join(stmts, ';'); + + try { + await app.models.Worker.rawStmt(sql); + } catch (e) { + await app.models.Worker.rawSql('ROLLBACK'); + err = e; + } + + expect(err).not.toBeDefined(); + }); + + it('should throw an error if the worker NO HA CUMPLIDO EL DESCANSO DE 12h', async() => { + const workerIdBreak12Hours = 109; + const tabletId = 1; + let stmts = []; + let stmt; + let sql; + let error; + + stmts.push('START TRANSACTION'); + stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction) + VALUES + (?,TIMESTAMPADD(HOUR,-20,NOW()),0,"in"), + (?,TIMESTAMPADD(SECOND,-43199,NOW()),0,"out")`, [ + workerIdBreak12Hours, + workerIdBreak12Hours + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerIdBreak12Hours, + tabletId + ]); + stmts.push(stmt); + stmts.push('ROLLBACK'); + sql = ParameterizedSQL.join(stmts, ';'); + + try { + await app.models.Worker.rawStmt(sql); + } catch (e) { + await app.models.Worker.rawSql('ROLLBACK'); + error = e; + } + + expect(error.sqlMessage).toEqual('Descansos 12 h'); + }); + + it('should throw an error if the worker HA CUMPLIDO EL DESCANSO de 12h', async() => { + const workerIdBreak12Hours = 109; + const tabletId = 1; + let stmts = []; + let stmt; + let err; + stmts.push('START TRANSACTION'); + stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction) + VALUES + (?,TIMESTAMPADD(HOUR,-20,NOW()),0,"in"), + (?,TIMESTAMPADD(SECOND,-43201,NOW()),0,"out")`, [ + workerIdBreak12Hours, + workerIdBreak12Hours + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerIdBreak12Hours, + tabletId + ]); + stmts.push(stmt); + stmts.push('ROLLBACK'); + + let sql = ParameterizedSQL.join(stmts, ';'); + + try { + await app.models.Worker.rawStmt(sql); + } catch (e) { + await app.models.Worker.rawSql('ROLLBACK'); + err = e; + } + + expect(err).not.toBeDefined(); + }); + + it('should throw an error if FICHADAS IMPARES', async() => { + const workerIdBreak12Hours = 109; + const tabletId = 1; + let stmts = []; + let stmt; + let err; + stmts.push('START TRANSACTION'); + stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction) + VALUES + (?,TIMESTAMPADD(HOUR,-24,NOW()),0,"in")`, [ + workerIdBreak12Hours + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerIdBreak12Hours, + tabletId + ]); + stmts.push(stmt); + stmts.push('ROLLBACK'); + + let sql = ParameterizedSQL.join(stmts, ';'); + + try { + await app.models.Worker.rawStmt(sql); + } catch (e) { + await app.models.Worker.rawSql('ROLLBACK'); + err = e; + } + + expect(err.sqlMessage).toEqual('Dias con fichadas impares'); + }); + + it('should throw an error if ESTA DE VACACIONES', async() => { + const workerIdBreak12Hours = 109; + const tabletId = 1; + let stmts = []; + let stmt; + let err; + + stmts.push('START TRANSACTION'); + + stmt = new ParameterizedSQL(`INSERT INTO postgresql.calendar_employee(business_id,calendar_state_id,date) + VALUES + (?,1,CURDATE())`, [ + workerIdBreak12Hours + ]); + stmts.push(stmt); + stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction) + VALUES + (?,TIMESTAMPADD(HOUR,-24,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-20,NOW()),0,"out")`, [ + workerIdBreak12Hours, + workerIdBreak12Hours + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerIdBreak12Hours, + tabletId + ]); + stmts.push(stmt); + stmts.push('ROLLBACK'); + + let sql = ParameterizedSQL.join(stmts, ';'); + + try { + await app.models.Worker.rawStmt(sql); + } catch (e) { + await app.models.Worker.rawSql('ROLLBACK'); + err = e; + } + + expect(err.sqlMessage).toEqual('Holidays'); + }); + + it('should throw an error if EL CONTRATO NO ESTA EN VIGOR', async() => { + const workerIdBreak12Hours = 109; + const tabletId = 1; + let stmts = []; + let stmt; + let err; + + stmts.push('START TRANSACTION'); + + stmt = new ParameterizedSQL(`UPDATE postgresql.business SET date_end=DATE_ADD(CURDATE(), INTERVAL -1 DAY) WHERE business_id=?`, [ + workerIdBreak12Hours + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction) + VALUES + (?,TIMESTAMPADD(HOUR,-24,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-20,NOW()),0,"out")`, [ + workerIdBreak12Hours, + workerIdBreak12Hours + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerIdBreak12Hours, + tabletId + ]); + stmts.push(stmt); + stmts.push('ROLLBACK'); + + let sql = ParameterizedSQL.join(stmts, ';'); + + try { + await app.models.Worker.rawStmt(sql); + } catch (e) { + await app.models.Worker.rawSql('ROLLBACK'); + err = e; + } + + expect(err.sqlMessage).toEqual('No hay un contrato en vigor'); + }); + + it('should throw an error if NO TIENE DESCANSO SEMANAL', async() => { + const workerIdBreak12Hours = 109; + const tabletId = 1; + let stmts = []; + let stmt; + let err; + + stmts.push('START TRANSACTION'); + + stmt = new ParameterizedSQL(`UPDATE postgresql.business SET date_end=DATE_ADD(CURDATE(), INTERVAL -1 DAY) WHERE business_id=?`, [ + workerIdBreak12Hours + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction) + VALUES + (?,TIMESTAMPADD(HOUR,-24,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-20,NOW()),0,"out")`, [ + workerIdBreak12Hours, + workerIdBreak12Hours + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerIdBreak12Hours, + tabletId + ]); + stmts.push(stmt); + stmts.push('ROLLBACK'); + + let sql = ParameterizedSQL.join(stmts, ';'); + + try { + await app.models.Worker.rawStmt(sql); + } catch (e) { + await app.models.Worker.rawSql('ROLLBACK'); + err = e; + } + + expect(err.sqlMessage).toEqual('No hay un contrato en vigor'); + }); + + it('should DESCANSO 32h', async() => { + const workerIdBreak12Hours = 109; + const tabletId = 1; + let stmts = []; + let stmt; + let err; + + stmts.push('START TRANSACTION'); + + stmt = new ParameterizedSQL(`UPDATE postgresql.business SET date_end=DATE_ADD(CURDATE(), INTERVAL -1 DAY) WHERE business_id=?`, [ + workerIdBreak12Hours + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction) + VALUES + (?,TIMESTAMPADD(HOUR,-24,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-20,NOW()),0,"out")`, [ + workerIdBreak12Hours, + workerIdBreak12Hours + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerIdBreak12Hours, + tabletId + ]); + stmts.push(stmt); + stmts.push('ROLLBACK'); + + let sql = ParameterizedSQL.join(stmts, ';'); + + try { + await app.models.Worker.rawStmt(sql); + } catch (e) { + await app.models.Worker.rawSql('ROLLBACK'); + err = e; + } + + expect(err.sqlMessage).toEqual('No hay un contrato en vigor'); + }); +}); From 0d23a3894fe19edbd19f15db0aac4bfe37874473 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Mon, 2 Mar 2020 09:28:08 +0100 Subject: [PATCH 06/93] entry log --- modules/entry/back/models/entry.json | 3 +++ modules/entry/front/index.js | 1 + modules/entry/front/log/index.html | 1 + modules/entry/front/log/index.js | 15 +++++++++++++++ modules/entry/front/routes.json | 6 ++++++ 5 files changed, 26 insertions(+) create mode 100644 modules/entry/front/log/index.html create mode 100644 modules/entry/front/log/index.js diff --git a/modules/entry/back/models/entry.json b/modules/entry/back/models/entry.json index c2a7d7c42f..6d38dbba10 100644 --- a/modules/entry/back/models/entry.json +++ b/modules/entry/back/models/entry.json @@ -1,6 +1,9 @@ { "name": "Entry", "base": "VnModel", + "log": { + "model":"EntryLog" + }, "options": { "mysql": { "table": "entry" diff --git a/modules/entry/front/index.js b/modules/entry/front/index.js index 25e054a717..0679b946b8 100644 --- a/modules/entry/front/index.js +++ b/modules/entry/front/index.js @@ -6,3 +6,4 @@ import './search-panel'; import './descriptor'; import './card'; import './summary'; +import './log'; diff --git a/modules/entry/front/log/index.html b/modules/entry/front/log/index.html new file mode 100644 index 0000000000..4932965d1d --- /dev/null +++ b/modules/entry/front/log/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/modules/entry/front/log/index.js b/modules/entry/front/log/index.js new file mode 100644 index 0000000000..a5fb6c6682 --- /dev/null +++ b/modules/entry/front/log/index.js @@ -0,0 +1,15 @@ +import ngModule from '../module'; + +class Controller { + constructor($scope, $stateParams) { + this.$scope = $scope; + this.$stateParams = $stateParams; + } +} + +Controller.$inject = ['$scope', '$stateParams']; + +ngModule.component('vnEntryLog', { + template: require('./index.html'), + controller: Controller, +}); diff --git a/modules/entry/front/routes.json b/modules/entry/front/routes.json index 612edc157a..0d3e2cf14c 100644 --- a/modules/entry/front/routes.json +++ b/modules/entry/front/routes.json @@ -9,6 +9,7 @@ {"state": "entry.index", "icon": "icon-entry"} ], "card": [ + {"state": "travel.card.log", "icon": "history"}, ] }, "routes": [ @@ -36,6 +37,11 @@ "params": { "entry": "$ctrl.entry" } + }, { + "url" : "/log", + "state": "entry.card.log", + "component": "vn-entry-log", + "description": "Log" } ] } \ No newline at end of file From 04917f980facfdab194187db601f4b20f22de168 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Mon, 2 Mar 2020 09:30:54 +0100 Subject: [PATCH 07/93] Updated E2E --- db/dump/fixtures.sql | 6 +- e2e/helpers/selectors.js | 12 ++-- e2e/paths/02-client/01_create_client.spec.js | 2 +- .../02-client/03_edit_fiscal_data.spec.js | 3 +- e2e/paths/02-client/05_add_address.spec.js | 14 +++- .../client/front/address/create/index.html | 48 ++++++------- modules/client/front/address/edit/index.html | 47 ++++++------ modules/client/front/create/index.html | 69 +++++++++--------- modules/client/front/fiscal-data/index.html | 71 +++++++++---------- 9 files changed, 136 insertions(+), 136 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 2f3a9378d9..a62edad467 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -197,14 +197,16 @@ INSERT INTO `vn`.`town`(`id`, `name`, `provinceFk`) (1, 'Valencia', 1), (2, 'Silla', 1), (3, 'Algemesi', 1), - (4, 'Alzira', 1); + (4, 'Alzira', 1), + (5, 'Quito', 5); INSERT INTO `vn`.`postCode`(`code`, `townFk`, `geoFk`) VALUES ('46000', 1, 6), ('46460', 2, 6), ('46680', 3, 6), - ('46600', 4, 7); + ('46600', 4, 7), + ('EC170150', 5, 8); INSERT INTO `vn`.`clientType`(`id`, `code`, `type`) VALUES diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 7e3e726e42..0f31b2e0cc 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -43,8 +43,8 @@ export default { taxNumber: 'vn-client-create vn-textfield[ng-model="$ctrl.client.fi"]', socialName: 'vn-client-create vn-textfield[ng-model="$ctrl.client.socialName"]', street: 'vn-client-create vn-textfield[ng-model="$ctrl.client.street"]', - postcode: 'vn-client-create vn-textfield[ng-model="$ctrl.client.postcode"]', - city: 'vn-client-create vn-textfield[ng-model="$ctrl.client.city"]', + postcode: 'vn-client-create vn-datalist[ng-model="$ctrl.client.postcode"]', + city: 'vn-client-create vn-datalist[ng-model="$ctrl.client.city"]', province: 'vn-client-create vn-autocomplete[ng-model="$ctrl.client.provinceFk"]', country: 'vn-client-create vn-autocomplete[ng-model="$ctrl.client.countryFk"]', userName: 'vn-client-create vn-textfield[ng-model="$ctrl.client.userName"]', @@ -75,8 +75,8 @@ export default { equalizationTaxCheckbox: 'vn-client-fiscal-data vn-check[ng-model="$ctrl.client.isEqualizated"]', acceptPropagationButton: '.vn-confirm.shown button[response=accept]', address: 'vn-client-fiscal-data vn-textfield[ng-model="$ctrl.client.street"]', - postcode: 'vn-client-fiscal-data vn-textfield[ng-model="$ctrl.client.postcode"]', - city: 'vn-client-fiscal-data vn-textfield[ng-model="$ctrl.client.city"]', + postcode: 'vn-client-fiscal-data vn-datalist[ng-model="$ctrl.client.postcode"]', + city: 'vn-client-fiscal-data vn-datalist[ng-model="$ctrl.client.city"]', province: 'vn-client-fiscal-data vn-autocomplete[ng-model="$ctrl.client.provinceFk"]', country: 'vn-client-fiscal-data vn-autocomplete[ng-model="$ctrl.client.countryFk"]', activeCheckbox: 'vn-client-fiscal-data vn-check[label="Active"]', @@ -113,8 +113,8 @@ export default { defaultCheckbox: 'vn-check[label="Default"]', consignee: 'vn-textfield[ng-model="$ctrl.address.nickname"]', streetAddress: 'vn-textfield[ng-model="$ctrl.address.street"]', - postcode: 'vn-textfield[ng-model="$ctrl.address.postalCode"]', - city: 'vn-textfield[ng-model="$ctrl.address.city"]', + postcode: 'vn-datalist[ng-model="$ctrl.address.postalCode"]', + city: 'vn-datalist[ng-model="$ctrl.address.city"]', province: 'vn-autocomplete[ng-model="$ctrl.address.provinceId"]', agency: 'vn-autocomplete[ng-model="$ctrl.address.agencyModeId"]', phone: 'vn-textfield[ng-model="$ctrl.address.phone"]', diff --git a/e2e/paths/02-client/01_create_client.spec.js b/e2e/paths/02-client/01_create_client.spec.js index 27ed5049ae..65db9e7c6a 100644 --- a/e2e/paths/02-client/01_create_client.spec.js +++ b/e2e/paths/02-client/01_create_client.spec.js @@ -87,7 +87,7 @@ describe('Client create path', async() => { .waitToGetProperty(selectors.createClientView.country, 'value'); expect(clientCity).toEqual('Valencia'); - expect(clientProvince).toEqual('Province one'); + expect(clientProvince).toContain('Province one'); expect(clientCountry).toEqual('España'); }); diff --git a/e2e/paths/02-client/03_edit_fiscal_data.spec.js b/e2e/paths/02-client/03_edit_fiscal_data.spec.js index f7d6cbe920..4cd54b87d0 100644 --- a/e2e/paths/02-client/03_edit_fiscal_data.spec.js +++ b/e2e/paths/02-client/03_edit_fiscal_data.spec.js @@ -198,11 +198,10 @@ describe('Client Edit fiscalData path', () => { expect(result).toEqual('Valencia'); }); - it(`should confirm the province have been autocompleted`, async() => { const result = await page.waitToGetProperty(selectors.clientFiscalData.province, 'value'); - expect(result).toEqual('Province one'); + expect(result).toContain('Province one'); }); it('should confirm the country have been autocompleted', async() => { diff --git a/e2e/paths/02-client/05_add_address.spec.js b/e2e/paths/02-client/05_add_address.spec.js index 737d6b05bb..c9228e1cff 100644 --- a/e2e/paths/02-client/05_add_address.spec.js +++ b/e2e/paths/02-client/05_add_address.spec.js @@ -25,9 +25,7 @@ describe('Client Add address path', () => { it('should receive an error after clicking save button as consignee, street and town fields are empty', async() => { await page.waitToClick(selectors.clientAddresses.defaultCheckbox); - await page.autocompleteSearch(selectors.clientAddresses.province, 'Province five'); - await page.write(selectors.clientAddresses.city, 'Valencia'); - await page.write(selectors.clientAddresses.postcode, '46000'); + await page.write(selectors.clientAddresses.postcode, 'EC170150'); await page.autocompleteSearch(selectors.clientAddresses.agency, 'Entanglement'); await page.write(selectors.clientAddresses.phone, '999887744'); await page.write(selectors.clientAddresses.mobileInput, '999887744'); @@ -37,6 +35,16 @@ describe('Client Add address path', () => { expect(result).toEqual('Some fields are invalid'); }); + it('should confirm that the city and province are propertly filled', async() => { + const city = await page + .waitToGetProperty(selectors.clientAddresses.city, 'value'); + + const province = await page + .waitToGetProperty(selectors.clientAddresses.province, 'value'); + + expect(city).toEqual('Quito'); + expect(province).toContain('Province five'); + }); it(`should receive an error after clicking save button as consignee, incoterms and customsAgent are empty`, async() => { await page.write(selectors.clientAddresses.consignee, 'Bruce Bunner'); diff --git a/modules/client/front/address/create/index.html b/modules/client/front/address/create/index.html index 383f37d0a1..ef4c869f12 100644 --- a/modules/client/front/address/create/index.html +++ b/modules/client/front/address/create/index.html @@ -39,37 +39,12 @@
- - {{name}} ({{country.country}}) - - - - {{name}}, {{province.name}} - ({{province.country.country}}) - - + + + {{name}}, {{province.name}} + ({{province.country.country}}) + + + + {{name}} ({{country.country}}) + - - - - - {{name}}, {{province.name}} - ({{province.country.country}}) - - + + + {{name}}, {{province.name}} + ({{province.country.country}}) + + + + {{name}} ({{country.country}}) + - - - - {{name}} ({{country.country}}) - - - - - - {{name}}, {{province.name}} - ({{province.country.country}}) - - + + + {{name}}, {{province.name}} + ({{province.country.country}}) + + + + + + {{name}} ({{country.country}}) + + + - - - - {{name}} ({{country.country}}) - - - - - - {{name}}, {{province.name}} - ({{province.country.country}}) - - + + + {{name}}, {{province.name}} + ({{province.country.country}}) + + + + + + {{name}} ({{country.country}}) + + + Date: Mon, 2 Mar 2020 11:57:09 +0100 Subject: [PATCH 08/93] entryLog section --- db/changes/10161-postValentineDay/00-ACL.sql | 2 + modules/entry/back/model-config.json | 3 ++ modules/entry/back/models/entry-log.json | 43 ++++++++++++++++++++ modules/entry/front/routes.json | 2 +- modules/travel/back/model-config.json | 12 ++++-- 5 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 db/changes/10161-postValentineDay/00-ACL.sql create mode 100644 modules/entry/back/models/entry-log.json diff --git a/db/changes/10161-postValentineDay/00-ACL.sql b/db/changes/10161-postValentineDay/00-ACL.sql new file mode 100644 index 0000000000..a7ac794864 --- /dev/null +++ b/db/changes/10161-postValentineDay/00-ACL.sql @@ -0,0 +1,2 @@ +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES ('EntryLog', '*', 'READ', 'ALLOW', 'ROLE', 'buyer'); diff --git a/modules/entry/back/model-config.json b/modules/entry/back/model-config.json index cd763c4ea2..c8c8babadc 100644 --- a/modules/entry/back/model-config.json +++ b/modules/entry/back/model-config.json @@ -1,5 +1,8 @@ { "Entry": { "dataSource": "vn" + }, + "EntryLog": { + "dataSource": "vn" } } diff --git a/modules/entry/back/models/entry-log.json b/modules/entry/back/models/entry-log.json new file mode 100644 index 0000000000..4d1a74578f --- /dev/null +++ b/modules/entry/back/models/entry-log.json @@ -0,0 +1,43 @@ +{ + "name": "EntryLog", + "base": "VnModel", + "options": { + "mysql": { + "table": "entryLog" + } + }, + "properties": { + "id": { + "id": true, + "type": "Number", + "forceId": false + }, + "originFk": { + "type": "Number", + "required": true + }, + "userFk": { + "type": "Number" + }, + "action": { + "type": "String", + "required": true + }, + "creationDate": { + "type": "Date" + }, + "description": { + "type": "String" + } + }, + "relations": { + "user": { + "type": "belongsTo", + "model": "Account", + "foreignKey": "userFk" + } + }, + "scope": { + "order": ["creationDate DESC", "id DESC"] + } +} diff --git a/modules/entry/front/routes.json b/modules/entry/front/routes.json index 0d3e2cf14c..92d8930442 100644 --- a/modules/entry/front/routes.json +++ b/modules/entry/front/routes.json @@ -9,7 +9,7 @@ {"state": "entry.index", "icon": "icon-entry"} ], "card": [ - {"state": "travel.card.log", "icon": "history"}, + {"state": "entry.card.log", "icon": "history"} ] }, "routes": [ diff --git a/modules/travel/back/model-config.json b/modules/travel/back/model-config.json index 03307bd459..b06d00f06f 100644 --- a/modules/travel/back/model-config.json +++ b/modules/travel/back/model-config.json @@ -1,13 +1,17 @@ { "Travel": { "dataSource": "vn" - },"TravelLog": { + }, + "TravelLog": { "dataSource": "vn" - },"Currency": { + }, + "Currency": { "dataSource": "vn" - },"Thermograph": { + }, + "Thermograph": { "dataSource": "vn" - },"TravelThermograph": { + }, + "TravelThermograph": { "dataSource": "vn" } } From 15bedc5f1294b1854d7007399f2b0150b1df0f2a Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Tue, 3 Mar 2020 15:03:54 +0100 Subject: [PATCH 09/93] Updated unit tests --- loopback/locale/en.json | 3 +- .../client/front/address/create/index.spec.js | 47 ++++++++++- modules/client/front/address/edit/index.js | 6 +- modules/client/front/create/index.spec.js | 60 +++++++++++++- modules/client/front/fiscal-data/index.js | 11 +-- .../client/front/fiscal-data/index.spec.js | 83 +++++++++++++++++++ modules/client/front/postcode/index.spec.js | 4 +- .../back/methods/travel/createThermograph.js | 2 +- .../back/methods/travel/updateThermograph.js | 2 +- 9 files changed, 194 insertions(+), 24 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 49cd0f1719..b8c31020bc 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -64,5 +64,6 @@ "Sent units from ticket": "I sent *{{quantity}}* units of [{{concept}} (#{{itemId}})]({{{itemUrl}}}) to *\"{{nickname}}\"* coming from ticket id [#{{ticketId}}]({{{ticketUrl}}})", "Customs agent is required for a non UEE member": "Customs agent is required for a non UEE member", "Incoterms is required for a non UEE member": "Incoterms is required for a non UEE member", - "Client checked as validated despite of duplication": "Client checked as validated despite of duplication from client id {{clientId}}" + "Client checked as validated despite of duplication": "Client checked as validated despite of duplication from client id {{clientId}}", + "Landing cannot be lesser than shipment": "Landing cannot be lesser than shipment" } \ No newline at end of file diff --git a/modules/client/front/address/create/index.spec.js b/modules/client/front/address/create/index.spec.js index 289e0572d5..fb6567dcef 100644 --- a/modules/client/front/address/create/index.spec.js +++ b/modules/client/front/address/create/index.spec.js @@ -53,9 +53,48 @@ describe('Client', () => { }); }); - describe('postcodeSelection() setter', () => { - it(`should set the town, province and contry properties`, () => { - controller.postcodeSelection = { + describe('town() setter', () => { + it(`should set provinceId property`, () => { + controller.town = { + provinceFk: 1, + code: 46001, + province: { + id: 1, + name: 'New york', + country: { + id: 2, + name: 'USA' + } + }, + postcodes: [] + }; + + expect(controller.address.provinceId).toEqual(1); + }); + + it(`should set provinceId property and fill the postalCode if there's just one`, () => { + controller.town = { + provinceFk: 1, + code: 46001, + province: { + id: 1, + name: 'New york', + country: { + id: 2, + name: 'USA' + } + }, + postcodes: [{code: '46001'}] + }; + + expect(controller.address.provinceId).toEqual(1); + expect(controller.address.postalCode).toEqual('46001'); + }); + }); + + describe('postcode() setter', () => { + it(`should set the town and province properties`, () => { + controller.postcode = { townFk: 1, code: 46001, town: { @@ -73,7 +112,7 @@ describe('Client', () => { }; expect(controller.address.city).toEqual('New York'); - expect(controller.address.provinceFk).toEqual(1); + expect(controller.address.provinceId).toEqual(1); }); }); diff --git a/modules/client/front/address/edit/index.js b/modules/client/front/address/edit/index.js index 8e43c27b16..f310b7250e 100644 --- a/modules/client/front/address/edit/index.js +++ b/modules/client/front/address/edit/index.js @@ -45,8 +45,7 @@ export default class Controller extends Component { const oldValue = this._town; this._town = selection; - if (!selection || oldValue === null || oldValue === undefined) - return; + if (!oldValue) return; const province = selection.province; const postcodes = selection.postcodes; @@ -66,8 +65,7 @@ export default class Controller extends Component { const oldValue = this._postcode; this._postcode = selection; - if (!selection || oldValue === null || oldValue === undefined) - return; + if (!oldValue) return; const town = selection.town; const province = town.province; diff --git a/modules/client/front/create/index.spec.js b/modules/client/front/create/index.spec.js index 656392e3d0..c297b0545d 100644 --- a/modules/client/front/create/index.spec.js +++ b/modules/client/front/create/index.spec.js @@ -40,9 +40,63 @@ describe('Client', () => { }); }); - describe('postcodeSelection() setter', () => { - it(`should set the town, province and contry properties`, () => { - controller.postcodeSelection = { + describe('province() setter', () => { + it(`should set countryFk property`, () => { + controller.province = { + id: 1, + name: 'New york', + country: { + id: 2, + name: 'USA' + } + }; + + expect(controller.client.countryFk).toEqual(2); + }); + }); + + describe('town() setter', () => { + it(`should set provinceFk property`, () => { + controller.town = { + provinceFk: 1, + code: 46001, + province: { + id: 1, + name: 'New york', + country: { + id: 2, + name: 'USA' + } + }, + postcodes: [] + }; + + expect(controller.client.provinceFk).toEqual(1); + }); + + it(`should set provinceFk property and fill the postalCode if there's just one`, () => { + controller.town = { + provinceFk: 1, + code: 46001, + province: { + id: 1, + name: 'New york', + country: { + id: 2, + name: 'USA' + } + }, + postcodes: [{code: '46001'}] + }; + + expect(controller.client.provinceFk).toEqual(1); + expect(controller.client.postcode).toEqual('46001'); + }); + }); + + describe('postcode() setter', () => { + it(`should set the town, provinceFk and contryFk properties`, () => { + controller.postcode = { townFk: 1, code: 46001, town: { diff --git a/modules/client/front/fiscal-data/index.js b/modules/client/front/fiscal-data/index.js index f118dbaae9..4450f2e32b 100644 --- a/modules/client/front/fiscal-data/index.js +++ b/modules/client/front/fiscal-data/index.js @@ -87,8 +87,7 @@ export default class Controller extends Component { const oldValue = this._province; this._province = selection; - if (!selection || oldValue === undefined) - return; + if (!oldValue) return; const country = selection.country; @@ -104,8 +103,7 @@ export default class Controller extends Component { const oldValue = this._town; this._town = selection; - if (!selection || oldValue === undefined) - return; + if (!oldValue) return; const province = selection.province; const country = province.country; @@ -126,11 +124,8 @@ export default class Controller extends Component { set postcode(selection) { const oldValue = this._postcode; this._postcode = selection; - console.log(oldValue); - if (!selection || oldValue === undefined) - return; - console.log('setter'); + if (!oldValue) return; const town = selection.town; const province = town.province; diff --git a/modules/client/front/fiscal-data/index.spec.js b/modules/client/front/fiscal-data/index.spec.js index 52c2ee29ef..6e8d6a8f0a 100644 --- a/modules/client/front/fiscal-data/index.spec.js +++ b/modules/client/front/fiscal-data/index.spec.js @@ -25,6 +25,10 @@ describe('Client', () => { isEqualizated: false, isTaxDataChecked: false }; + + controller.province = {}; + controller.town = {}; + controller.postcode = {}; })); describe('onSubmit()', () => { @@ -107,5 +111,84 @@ describe('Client', () => { $httpBackend.flush(); }); }); + + describe('province() setter', () => { + it(`should set countryFk property`, () => { + controller.province = { + id: 1, + name: 'New york', + country: { + id: 2, + name: 'USA' + } + }; + + expect(controller.client.countryFk).toEqual(2); + }); + }); + + describe('town() setter', () => { + it(`should set provinceFk property`, () => { + controller.town = { + provinceFk: 1, + code: 46001, + province: { + id: 1, + name: 'New york', + country: { + id: 2, + name: 'USA' + } + }, + postcodes: [] + }; + + expect(controller.client.provinceFk).toEqual(1); + }); + + it(`should set provinceFk property and fill the postalCode if there's just one`, () => { + controller.town = { + provinceFk: 1, + code: 46001, + province: { + id: 1, + name: 'New york', + country: { + id: 2, + name: 'USA' + } + }, + postcodes: [{code: '46001'}] + }; + + expect(controller.client.provinceFk).toEqual(1); + expect(controller.client.postcode).toEqual('46001'); + }); + }); + + describe('postcode() setter', () => { + it(`should set the town, provinceFk and contryFk properties`, () => { + controller.postcode = { + townFk: 1, + code: 46001, + town: { + id: 1, + name: 'New York', + province: { + id: 1, + name: 'New york', + country: { + id: 2, + name: 'USA' + } + } + } + }; + + expect(controller.client.city).toEqual('New York'); + expect(controller.client.provinceFk).toEqual(1); + expect(controller.client.countryFk).toEqual(2); + }); + }); }); }); diff --git a/modules/client/front/postcode/index.spec.js b/modules/client/front/postcode/index.spec.js index 04f1a8924d..a5e5db9d56 100644 --- a/modules/client/front/postcode/index.spec.js +++ b/modules/client/front/postcode/index.spec.js @@ -15,7 +15,7 @@ describe('Client', () => { controller.client = {id: 101}; })); - describe('onResponse()', () => { + describe('onAccept()', () => { it('should perform a POST query and show a success snackbar', () => { let params = {townFk: 1, provinceFk: 1, countryFk: 1, code: '46460'}; controller.data = {townFk: 1, provinceFk: 1, countryFk: 1, code: '46460'}; @@ -24,7 +24,7 @@ describe('Client', () => { $httpBackend.when('PATCH', `postcodes`, params).respond(200, params); $httpBackend.expect('PATCH', `postcodes`, params).respond(params); - controller.onResponse('accept'); + controller.onAccept(); $httpBackend.flush(); expect(controller.vnApp.showMessage).toHaveBeenCalledWith('The postcode has been saved'); diff --git a/modules/travel/back/methods/travel/createThermograph.js b/modules/travel/back/methods/travel/createThermograph.js index d5388295a2..974b679238 100644 --- a/modules/travel/back/methods/travel/createThermograph.js +++ b/modules/travel/back/methods/travel/createThermograph.js @@ -2,7 +2,7 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethodCtx('createThermograph', { - description: 'Upload and attach a document', + description: 'Creates a new travel thermograph', accessType: 'WRITE', accepts: [{ arg: 'id', diff --git a/modules/travel/back/methods/travel/updateThermograph.js b/modules/travel/back/methods/travel/updateThermograph.js index efad606eb1..d89725920c 100644 --- a/modules/travel/back/methods/travel/updateThermograph.js +++ b/modules/travel/back/methods/travel/updateThermograph.js @@ -2,7 +2,7 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethodCtx('updateThermograph', { - description: 'updates a file properties or file', + description: 'Updates a travel thermograph', accessType: 'WRITE', accepts: [{ arg: 'id', From 0f7ed5bbfa9c3e0ccff4397d90d85852fb74753a Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Tue, 3 Mar 2020 15:14:28 +0100 Subject: [PATCH 10/93] get worked hours unit test --- .../back/methods/worker/mySubordinates.js | 1 - .../methods/worker/specs/getWorkedHours.spec.js | 17 +++++++++++++++++ .../worker/back/methods/worker/timeControl.js | 1 - 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 modules/worker/back/methods/worker/specs/getWorkedHours.spec.js diff --git a/modules/worker/back/methods/worker/mySubordinates.js b/modules/worker/back/methods/worker/mySubordinates.js index bf1cd1be80..cf45d3a9d2 100644 --- a/modules/worker/back/methods/worker/mySubordinates.js +++ b/modules/worker/back/methods/worker/mySubordinates.js @@ -35,7 +35,6 @@ module.exports = Self => { let sql = ParameterizedSQL.join(stmts, ';'); let result = await conn.executeStmt(sql); - return result[1]; }; }; diff --git a/modules/worker/back/methods/worker/specs/getWorkedHours.spec.js b/modules/worker/back/methods/worker/specs/getWorkedHours.spec.js new file mode 100644 index 0000000000..148b8467e3 --- /dev/null +++ b/modules/worker/back/methods/worker/specs/getWorkedHours.spec.js @@ -0,0 +1,17 @@ +const app = require('vn-loopback/server/server'); + +describe('Worker getWorkedHours()', () => { + it(`should return the expected hours and the worked hours of a given date`, async() => { + const workerID = 106; + let started = new Date(); + started.setHours(0, 0, 0, 0); + + let ended = new Date(); + ended.setHours(0, 0, 0, 0); + + const [result] = await app.models.Worker.getWorkedHours(workerID, started, ended); + + expect(result.expectedHours).toEqual(28800); // 8:00 hours seconds + expect(result.workedHours).toEqual(29400); // 8:10 hours in seconds + }); +}); diff --git a/modules/worker/back/methods/worker/timeControl.js b/modules/worker/back/methods/worker/timeControl.js index bc88197fe1..9479ff0a18 100644 --- a/modules/worker/back/methods/worker/timeControl.js +++ b/modules/worker/back/methods/worker/timeControl.js @@ -44,7 +44,6 @@ module.exports = Self => { let sql = ParameterizedSQL.join(stmts, ';'); let result = await conn.executeStmt(sql); - return result[0]; }; }; From ced8c6e96319f507ed04608554585674058dd4ad Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Wed, 4 Mar 2020 07:49:21 +0100 Subject: [PATCH 11/93] traductions --- modules/entry/front/log/locale/es.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 modules/entry/front/log/locale/es.yml diff --git a/modules/entry/front/log/locale/es.yml b/modules/entry/front/log/locale/es.yml new file mode 100644 index 0000000000..094615b472 --- /dev/null +++ b/modules/entry/front/log/locale/es.yml @@ -0,0 +1 @@ +Date: Fecha \ No newline at end of file From e40575cc1fae05f513ead06103649bc37efa962c Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Wed, 4 Mar 2020 08:58:57 +0100 Subject: [PATCH 12/93] fix model entry log --- modules/entry/back/models/entry-log.json | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/entry/back/models/entry-log.json b/modules/entry/back/models/entry-log.json index 4d1a74578f..daeab1eac3 100644 --- a/modules/entry/back/models/entry-log.json +++ b/modules/entry/back/models/entry-log.json @@ -9,8 +9,7 @@ "properties": { "id": { "id": true, - "type": "Number", - "forceId": false + "type": "Number" }, "originFk": { "type": "Number", @@ -35,9 +34,9 @@ "type": "belongsTo", "model": "Account", "foreignKey": "userFk" - } + } }, "scope": { "order": ["creationDate DESC", "id DESC"] } -} +} \ No newline at end of file From d6278e0df906d4d8b46c815cddd52baa481639fd Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 4 Mar 2020 09:26:12 +0100 Subject: [PATCH 13/93] 2164 - Show confirmation only when data is not empty --- db/dump/fixtures.sql | 48 +++++++++---------- modules/client/front/fiscal-data/index.js | 15 +++++- .../client/front/fiscal-data/index.spec.js | 24 +++++++++- .../methods/ticket/specs/makeInvoice.spec.js | 12 ++++- 4 files changed, 70 insertions(+), 29 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 9d9b84da46..1f34738e0a 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -554,30 +554,30 @@ INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `des INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `workerFk`, `created`) VALUES - (1, 16, 5 , DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), - (2, 16, 5 , DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), - (3, 16, 5 , DATE_ADD(CURDATE(), INTERVAL -2 MONTH)), - (4, 16, 5 , DATE_ADD(CURDATE(), INTERVAL -3 MONTH)), - (5, 16, 18, DATE_ADD(CURDATE(), INTERVAL -4 MONTH)), - (6, 16, 18, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), - (7, 10, 18, CURDATE()), - (8, 5, 19, CURDATE()), - (9, 5, 19, CURDATE()), - (10, 5, 19, CURDATE()), - (11, 3, 19, CURDATE()), - (12, 3, 19, CURDATE()), - (13, 3, 19, CURDATE()), - (14, 3, 19, CURDATE()), - (15, 3, 19, CURDATE()), - (16, 3, 19, CURDATE()), - (17, 3, 19, CURDATE()), - (18, 3, 19, CURDATE()), - (19, 17, 19, CURDATE()), - (20, 1, 19, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), - (21, 1, 19, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), - (22, 1, 19, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), - (23, 16, 21, CURDATE()), - (24, 16, 21, CURDATE()); + (1, 16, 5 , DATE_ADD(NOW(), INTERVAL -1 MONTH)), + (2, 16, 5 , DATE_ADD(NOW(), INTERVAL -1 MONTH)), + (3, 16, 5 , DATE_ADD(NOW(), INTERVAL -2 MONTH)), + (4, 16, 5 , DATE_ADD(NOW(), INTERVAL -3 MONTH)), + (5, 16, 18, DATE_ADD(NOW(), INTERVAL -4 MONTH)), + (6, 16, 18, DATE_ADD(NOW(), INTERVAL -1 MONTH)), + (7, 10, 18, NOW()), + (8, 5, 19, NOW()), + (9, 5, 19, NOW()), + (10, 5, 19, NOW()), + (11, 3, 19, NOW()), + (12, 3, 19, NOW()), + (13, 3, 19, NOW()), + (14, 3, 19, NOW()), + (15, 3, 19, NOW()), + (16, 3, 19, NOW()), + (17, 3, 19, NOW()), + (18, 3, 19, NOW()), + (19, 17, 19, NOW()), + (20, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)), + (21, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)), + (22, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)), + (23, 16, 21, NOW()), + (24, 16, 21, NOW()); INSERT INTO `vn`.`stowaway`(`id`, `shipFk`, `created`) VALUES diff --git a/modules/client/front/fiscal-data/index.js b/modules/client/front/fiscal-data/index.js index b2602f7a4c..b5cd9ce3d5 100644 --- a/modules/client/front/fiscal-data/index.js +++ b/modules/client/front/fiscal-data/index.js @@ -5,16 +5,27 @@ export default class Controller extends Component { onSubmit() { const orgData = this.$.watcher.orgData; delete this.client.despiteOfClient; - if (!orgData.isTaxDataChecked && this.client.isTaxDataChecked) + const hasContactData = this.client.email || this.client.phone || this.client.mobile; + if (!orgData.isTaxDataChecked && this.client.isTaxDataChecked && hasContactData) this.checkExistingClient(); else this.save(); } checkExistingClient() { + const findParams = []; + if (this.client.email) + findParams.push({email: this.client.email}); + + if (this.client.phone) + findParams.push({phone: this.client.phone}); + + if (this.client.mobile) + findParams.push({mobile: this.client.mobile}); + const filterObj = { where: { and: [ - {or: [{email: this.client.email}, {phone: this.client.phone}]}, + {or: findParams}, {id: {neq: this.client.id}} ] } diff --git a/modules/client/front/fiscal-data/index.spec.js b/modules/client/front/fiscal-data/index.spec.js index 52c2ee29ef..7b92fb3083 100644 --- a/modules/client/front/fiscal-data/index.spec.js +++ b/modules/client/front/fiscal-data/index.spec.js @@ -49,9 +49,31 @@ describe('Client', () => { }); describe('checkExistingClient()', () => { - it('should show a save confirmation when a duplicated client is found and then set the despiteOfClient property', () => { + it(`should make a HTTP GET query filtering by email, phone and mobile`, () => { + controller.client.mobile = 222222222; + const filterObj = { + where: { + and: [ + {or: [ + {email: controller.client.email}, + {phone: controller.client.phone}, + {mobile: controller.client.mobile} + ]}, + {id: {neq: controller.client.id}} + ] + } + }; + const expectedClient = {id: 102}; + const filter = encodeURIComponent(JSON.stringify(filterObj)); + $httpBackend.expect('GET', `Clients/findOne?filter=${filter}`).respond(expectedClient); + controller.checkExistingClient(); + $httpBackend.flush(); + }); + + it(`should show a save confirmation and then set the despiteOfClient property`, () => { controller.$.confirmDuplicatedClient = {show: () => {}}; jest.spyOn(controller.$.confirmDuplicatedClient, 'show'); + const filterObj = { where: { and: [ diff --git a/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js b/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js index 247e7e6213..62bc3b5cd6 100644 --- a/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js +++ b/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js @@ -8,8 +8,16 @@ describe('ticket makeInvoice()', () => { let ticket = await app.models.Ticket.findById(11); await ticket.updateAttributes({refFk: null}); - let ticketTracking = await app.models.TicketTracking.findOne({order: 'id DESC', limit: 1}); - await ticketTracking.destroy(); + let ticketTrackings = await app.models.TicketTracking.find({ + where: { + ticketFk: ticketId, + stateFk: {neq: 3} + }, + order: 'id DESC' + }); + + for (let state of ticketTrackings) + await state.destroy(); let invoiceOut = await app.models.InvoiceOut.findById(invoice.invoiceFk); await invoiceOut.destroy(); From df3fbf291b6a31ce06d79e3a17204bddf8e3acbc Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 4 Mar 2020 09:32:18 +0100 Subject: [PATCH 14/93] Changed format --- modules/client/front/fiscal-data/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/client/front/fiscal-data/index.js b/modules/client/front/fiscal-data/index.js index b5cd9ce3d5..8afa022887 100644 --- a/modules/client/front/fiscal-data/index.js +++ b/modules/client/front/fiscal-data/index.js @@ -5,8 +5,10 @@ export default class Controller extends Component { onSubmit() { const orgData = this.$.watcher.orgData; delete this.client.despiteOfClient; + const hasContactData = this.client.email || this.client.phone || this.client.mobile; - if (!orgData.isTaxDataChecked && this.client.isTaxDataChecked && hasContactData) + const isDataChecked = !orgData.isTaxDataChecked && this.client.isTaxDataChecked; + if (isDataChecked && hasContactData) this.checkExistingClient(); else this.save(); } From 24becf78727a1bc096b3feb9999379df28dbeb4f Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 4 Mar 2020 11:17:35 +0100 Subject: [PATCH 15/93] Updated var names --- modules/client/front/fiscal-data/index.js | 4 ++-- modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/client/front/fiscal-data/index.js b/modules/client/front/fiscal-data/index.js index 8afa022887..f8e93ab9fe 100644 --- a/modules/client/front/fiscal-data/index.js +++ b/modules/client/front/fiscal-data/index.js @@ -7,8 +7,8 @@ export default class Controller extends Component { delete this.client.despiteOfClient; const hasContactData = this.client.email || this.client.phone || this.client.mobile; - const isDataChecked = !orgData.isTaxDataChecked && this.client.isTaxDataChecked; - if (isDataChecked && hasContactData) + const hasChangedTaxData = !orgData.isTaxDataChecked && this.client.isTaxDataChecked; + if (hasChangedTaxData && hasContactData) this.checkExistingClient(); else this.save(); } diff --git a/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js b/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js index 62bc3b5cd6..b91751d5df 100644 --- a/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js +++ b/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js @@ -3,6 +3,7 @@ const app = require('vn-loopback/server/server'); describe('ticket makeInvoice()', () => { let invoice; let ticketId = 11; + const okState = 3; afterAll(async done => { let ticket = await app.models.Ticket.findById(11); @@ -11,7 +12,7 @@ describe('ticket makeInvoice()', () => { let ticketTrackings = await app.models.TicketTracking.find({ where: { ticketFk: ticketId, - stateFk: {neq: 3} + stateFk: {neq: okState} }, order: 'id DESC' }); From 5da1c4147635248ace0aeb9601222a5764f32ac3 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 4 Mar 2020 12:51:29 +0100 Subject: [PATCH 16/93] Added ACL --- modules/client/front/address/create/index.html | 4 +++- modules/client/front/address/edit/index.html | 6 ++++-- modules/client/front/create/index.html | 4 +++- modules/client/front/fiscal-data/index.html | 4 +++- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/modules/client/front/address/create/index.html b/modules/client/front/address/create/index.html index ef4c869f12..519638d48d 100644 --- a/modules/client/front/address/create/index.html +++ b/modules/client/front/address/create/index.html @@ -57,7 +57,9 @@ + ng-click="postcode.open()" + vn-acl="deliveryBoss" + vn-acl-action="remove"> diff --git a/modules/client/front/address/edit/index.html b/modules/client/front/address/edit/index.html index 8775993774..70b3523c5c 100644 --- a/modules/client/front/address/edit/index.html +++ b/modules/client/front/address/edit/index.html @@ -71,10 +71,12 @@ {{town.province.country.country}}) - + ng-click="postcode.open()" + vn-acl="deliveryBoss" + vn-acl-action="remove"> diff --git a/modules/client/front/create/index.html b/modules/client/front/create/index.html index 8d44aaae00..b2ef42beb2 100644 --- a/modules/client/front/create/index.html +++ b/modules/client/front/create/index.html @@ -67,7 +67,9 @@ + ng-click="postcode.open()" + vn-acl="deliveryBoss" + vn-acl-action="remove"> diff --git a/modules/client/front/fiscal-data/index.html b/modules/client/front/fiscal-data/index.html index 1cda1fc8ad..0339090a2a 100644 --- a/modules/client/front/fiscal-data/index.html +++ b/modules/client/front/fiscal-data/index.html @@ -51,7 +51,9 @@ + ng-click="postcode.open()" + vn-acl="deliveryBoss" + vn-acl-action="remove"> From 80248238d2f6951333af1c99b83e02eec8f502fa Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 4 Mar 2020 09:26:12 +0100 Subject: [PATCH 17/93] 2164 - Show confirmation only when data is not empty --- db/dump/fixtures.sql | 48 +++++++++---------- modules/client/front/fiscal-data/index.js | 15 +++++- .../client/front/fiscal-data/index.spec.js | 26 +++++++++- .../methods/ticket/specs/makeInvoice.spec.js | 12 ++++- 4 files changed, 71 insertions(+), 30 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 498a9dc7ca..31040955ce 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -554,30 +554,30 @@ INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `des INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `workerFk`, `created`) VALUES - (1, 16, 5 , DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), - (2, 16, 5 , DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), - (3, 16, 5 , DATE_ADD(CURDATE(), INTERVAL -2 MONTH)), - (4, 16, 5 , DATE_ADD(CURDATE(), INTERVAL -3 MONTH)), - (5, 16, 18, DATE_ADD(CURDATE(), INTERVAL -4 MONTH)), - (6, 16, 18, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), - (7, 10, 18, CURDATE()), - (8, 5, 19, CURDATE()), - (9, 5, 19, CURDATE()), - (10, 5, 19, CURDATE()), - (11, 3, 19, CURDATE()), - (12, 3, 19, CURDATE()), - (13, 3, 19, CURDATE()), - (14, 3, 19, CURDATE()), - (15, 3, 19, CURDATE()), - (16, 3, 19, CURDATE()), - (17, 3, 19, CURDATE()), - (18, 3, 19, CURDATE()), - (19, 17, 19, CURDATE()), - (20, 1, 19, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), - (21, 1, 19, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), - (22, 1, 19, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), - (23, 16, 21, CURDATE()), - (24, 16, 21, CURDATE()); + (1, 16, 5 , DATE_ADD(NOW(), INTERVAL -1 MONTH)), + (2, 16, 5 , DATE_ADD(NOW(), INTERVAL -1 MONTH)), + (3, 16, 5 , DATE_ADD(NOW(), INTERVAL -2 MONTH)), + (4, 16, 5 , DATE_ADD(NOW(), INTERVAL -3 MONTH)), + (5, 16, 18, DATE_ADD(NOW(), INTERVAL -4 MONTH)), + (6, 16, 18, DATE_ADD(NOW(), INTERVAL -1 MONTH)), + (7, 10, 18, NOW()), + (8, 5, 19, NOW()), + (9, 5, 19, NOW()), + (10, 5, 19, NOW()), + (11, 3, 19, NOW()), + (12, 3, 19, NOW()), + (13, 3, 19, NOW()), + (14, 3, 19, NOW()), + (15, 3, 19, NOW()), + (16, 3, 19, NOW()), + (17, 3, 19, NOW()), + (18, 3, 19, NOW()), + (19, 17, 19, NOW()), + (20, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)), + (21, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)), + (22, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)), + (23, 16, 21, NOW()), + (24, 16, 21, NOW()); INSERT INTO `vn`.`stowaway`(`id`, `shipFk`, `created`) VALUES diff --git a/modules/client/front/fiscal-data/index.js b/modules/client/front/fiscal-data/index.js index b2602f7a4c..b5cd9ce3d5 100644 --- a/modules/client/front/fiscal-data/index.js +++ b/modules/client/front/fiscal-data/index.js @@ -5,16 +5,27 @@ export default class Controller extends Component { onSubmit() { const orgData = this.$.watcher.orgData; delete this.client.despiteOfClient; - if (!orgData.isTaxDataChecked && this.client.isTaxDataChecked) + const hasContactData = this.client.email || this.client.phone || this.client.mobile; + if (!orgData.isTaxDataChecked && this.client.isTaxDataChecked && hasContactData) this.checkExistingClient(); else this.save(); } checkExistingClient() { + const findParams = []; + if (this.client.email) + findParams.push({email: this.client.email}); + + if (this.client.phone) + findParams.push({phone: this.client.phone}); + + if (this.client.mobile) + findParams.push({mobile: this.client.mobile}); + const filterObj = { where: { and: [ - {or: [{email: this.client.email}, {phone: this.client.phone}]}, + {or: findParams}, {id: {neq: this.client.id}} ] } diff --git a/modules/client/front/fiscal-data/index.spec.js b/modules/client/front/fiscal-data/index.spec.js index 1e92426ec6..1895d231e0 100644 --- a/modules/client/front/fiscal-data/index.spec.js +++ b/modules/client/front/fiscal-data/index.spec.js @@ -49,9 +49,31 @@ describe('Client', () => { }); describe('checkExistingClient()', () => { - it('should show a save confirmation when a duplicated client is found and then set the despiteOfClient property', () => { + it(`should make a HTTP GET query filtering by email, phone and mobile`, () => { + controller.client.mobile = 222222222; + const filterObj = { + where: { + and: [ + {or: [ + {email: controller.client.email}, + {phone: controller.client.phone}, + {mobile: controller.client.mobile} + ]}, + {id: {neq: controller.client.id}} + ] + } + }; + const expectedClient = {id: 102}; + const filter = encodeURIComponent(JSON.stringify(filterObj)); + $httpBackend.expect('GET', `Clients/findOne?filter=${filter}`).respond(expectedClient); + controller.checkExistingClient(); + $httpBackend.flush(); + }); + + it(`should show a save confirmation and then set the despiteOfClient property`, () => { controller.$.confirmDuplicatedClient = {show: () => {}}; - spyOn(controller.$.confirmDuplicatedClient, 'show'); + jest.spyOn(controller.$.confirmDuplicatedClient, 'show'); + const filterObj = { where: { and: [ diff --git a/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js b/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js index 247e7e6213..62bc3b5cd6 100644 --- a/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js +++ b/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js @@ -8,8 +8,16 @@ describe('ticket makeInvoice()', () => { let ticket = await app.models.Ticket.findById(11); await ticket.updateAttributes({refFk: null}); - let ticketTracking = await app.models.TicketTracking.findOne({order: 'id DESC', limit: 1}); - await ticketTracking.destroy(); + let ticketTrackings = await app.models.TicketTracking.find({ + where: { + ticketFk: ticketId, + stateFk: {neq: 3} + }, + order: 'id DESC' + }); + + for (let state of ticketTrackings) + await state.destroy(); let invoiceOut = await app.models.InvoiceOut.findById(invoice.invoiceFk); await invoiceOut.destroy(); From 2f511d17182676ecd6fdb3ece7cee46bac7f125d Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 4 Mar 2020 09:32:18 +0100 Subject: [PATCH 18/93] Changed format --- modules/client/front/fiscal-data/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/client/front/fiscal-data/index.js b/modules/client/front/fiscal-data/index.js index b5cd9ce3d5..8afa022887 100644 --- a/modules/client/front/fiscal-data/index.js +++ b/modules/client/front/fiscal-data/index.js @@ -5,8 +5,10 @@ export default class Controller extends Component { onSubmit() { const orgData = this.$.watcher.orgData; delete this.client.despiteOfClient; + const hasContactData = this.client.email || this.client.phone || this.client.mobile; - if (!orgData.isTaxDataChecked && this.client.isTaxDataChecked && hasContactData) + const isDataChecked = !orgData.isTaxDataChecked && this.client.isTaxDataChecked; + if (isDataChecked && hasContactData) this.checkExistingClient(); else this.save(); } From 46f04fa802a0819b3f6fd82efd56fca7a9375902 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 4 Mar 2020 11:17:35 +0100 Subject: [PATCH 19/93] Updated var names --- modules/client/front/fiscal-data/index.js | 4 ++-- modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/client/front/fiscal-data/index.js b/modules/client/front/fiscal-data/index.js index 8afa022887..f8e93ab9fe 100644 --- a/modules/client/front/fiscal-data/index.js +++ b/modules/client/front/fiscal-data/index.js @@ -7,8 +7,8 @@ export default class Controller extends Component { delete this.client.despiteOfClient; const hasContactData = this.client.email || this.client.phone || this.client.mobile; - const isDataChecked = !orgData.isTaxDataChecked && this.client.isTaxDataChecked; - if (isDataChecked && hasContactData) + const hasChangedTaxData = !orgData.isTaxDataChecked && this.client.isTaxDataChecked; + if (hasChangedTaxData && hasContactData) this.checkExistingClient(); else this.save(); } diff --git a/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js b/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js index 62bc3b5cd6..b91751d5df 100644 --- a/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js +++ b/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js @@ -3,6 +3,7 @@ const app = require('vn-loopback/server/server'); describe('ticket makeInvoice()', () => { let invoice; let ticketId = 11; + const okState = 3; afterAll(async done => { let ticket = await app.models.Ticket.findById(11); @@ -11,7 +12,7 @@ describe('ticket makeInvoice()', () => { let ticketTrackings = await app.models.TicketTracking.find({ where: { ticketFk: ticketId, - stateFk: {neq: 3} + stateFk: {neq: okState} }, order: 'id DESC' }); From f168734b8c025e6c560df7343d3524fd3d822d58 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 4 Mar 2020 13:54:17 +0100 Subject: [PATCH 20/93] Updated E2E --- modules/client/front/fiscal-data/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/client/front/fiscal-data/index.js b/modules/client/front/fiscal-data/index.js index ec918fc663..7fdb03dda3 100644 --- a/modules/client/front/fiscal-data/index.js +++ b/modules/client/front/fiscal-data/index.js @@ -100,7 +100,7 @@ export default class Controller extends Component { const oldValue = this._province; this._province = selection; - if (!oldValue) return; + if (!selection || !oldValue) return; const country = selection.country; @@ -116,7 +116,7 @@ export default class Controller extends Component { const oldValue = this._town; this._town = selection; - if (!oldValue) return; + if (!selection || !oldValue) return; const province = selection.province; const country = province.country; @@ -138,7 +138,7 @@ export default class Controller extends Component { const oldValue = this._postcode; this._postcode = selection; - if (!oldValue) return; + if (!selection || !oldValue) return; const town = selection.town; const province = town.province; From 0179461cb3ffbaf58a4f607d6e0b2cdebcee2a03 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Wed, 4 Mar 2020 15:12:36 +0100 Subject: [PATCH 21/93] timeBusiness and timeControl db tests --- db/dump/fixtures.sql | 4 +- db/tests/vn/ticketCreateWithUser.spec.js | 1 - .../vn/timeBusiness_calculateByUser.spec.js | 40 +++++++ .../vn/timeControl_calculateByUser.spec.js | 107 ++++++++++++++++++ 4 files changed, 149 insertions(+), 3 deletions(-) create mode 100644 db/tests/vn/timeBusiness_calculateByUser.spec.js create mode 100644 db/tests/vn/timeControl_calculateByUser.spec.js diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 9d9b84da46..696bfdbfdb 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1677,12 +1677,12 @@ INSERT INTO `vn`.`zoneIncluded` (`zoneFk`, `geoFk`, `isIncluded`) INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `dated`) VALUES - (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=2, 2, 9 ) - DAYOFWEEK(CURDATE())) DAY)), + (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=2, 2, 9) - DAYOFWEEK(CURDATE())) DAY)), (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=3, 3, 10) - DAYOFWEEK(CURDATE())) DAY)), (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=4, 4, 11) - DAYOFWEEK(CURDATE())) DAY)), (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=5, 5, 12) - DAYOFWEEK(CURDATE())) DAY)), (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=6, 6, 13) - DAYOFWEEK(CURDATE())) DAY)), - (2, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=2, 2, 9 ) - DAYOFWEEK(CURDATE())) DAY)), + (2, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=2, 2, 9) - DAYOFWEEK(CURDATE())) DAY)), (2, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=3, 3, 10) - DAYOFWEEK(CURDATE())) DAY)), (2, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=4, 4, 11) - DAYOFWEEK(CURDATE())) DAY)), (2, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=5, 5, 12) - DAYOFWEEK(CURDATE())) DAY)), diff --git a/db/tests/vn/ticketCreateWithUser.spec.js b/db/tests/vn/ticketCreateWithUser.spec.js index 51ebfe0007..6728eb2da3 100644 --- a/db/tests/vn/ticketCreateWithUser.spec.js +++ b/db/tests/vn/ticketCreateWithUser.spec.js @@ -43,7 +43,6 @@ describe('ticket ticketCreateWithUser()', () => { let ticketResult = result[ticketResultIndex][0]; - expect(ticketResult.id).toBeGreaterThan(21); expect(ticketResult.clientFk).toEqual(params.clientFk); expect(ticketResult.warehouseFk).toEqual(params.warehouseFk); diff --git a/db/tests/vn/timeBusiness_calculateByUser.spec.js b/db/tests/vn/timeBusiness_calculateByUser.spec.js new file mode 100644 index 0000000000..0b09447ef5 --- /dev/null +++ b/db/tests/vn/timeBusiness_calculateByUser.spec.js @@ -0,0 +1,40 @@ +const app = require('vn-loopback/server/server'); +const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; + +describe('timeBusiness_calculateByUser()', () => { + it('should return the expected hours for today', async() => { + let start = new Date(); + start.setHours(0, 0, 0, 0); + let end = new Date(); + end.setHours(0, 0, 0, 0); + + let stmts = []; + let stmt; + + stmts.push('START TRANSACTION'); + + let params = { + workerID: 106, + start: start, + end: end + }; + + stmt = new ParameterizedSQL('CALL vn.timeBusiness_calculateByUser(?, ?, ?)', [ + params.workerID, + params.start, + params.end + ]); + stmts.push(stmt); + + let tableIndex = stmts.push('SELECT * FROM tmp.timeBusinessCalculate') - 1; + + stmts.push('ROLLBACK'); + + let sql = ParameterizedSQL.join(stmts, ';'); + let result = await app.models.Ticket.rawStmt(sql); + + let [timeBusinessCalculateTable] = result[tableIndex]; + + expect(timeBusinessCalculateTable.timeBusinessSeconds).toEqual(28800); + }); +}); diff --git a/db/tests/vn/timeControl_calculateByUser.spec.js b/db/tests/vn/timeControl_calculateByUser.spec.js new file mode 100644 index 0000000000..ac442ab7b3 --- /dev/null +++ b/db/tests/vn/timeControl_calculateByUser.spec.js @@ -0,0 +1,107 @@ +const app = require('vn-loopback/server/server'); +const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; + +describe('timeControl_calculateByUser()', () => { + it(`should return today's worked hours`, async() => { + let start = new Date(); + start.setHours(0, 0, 0, 0); + start.setDate(start.getDate() - 1); + + let end = new Date(); + end.setHours(0, 0, 0, 0); + end.setDate(end.getDate() + 1); + + let stmts = []; + let stmt; + + stmts.push('START TRANSACTION'); + + stmts.push(` + DROP TEMPORARY TABLE IF EXISTS + tmp.timeControlCalculate, + tmp.timeBusinessCalculate + `); + + let params = { + workerID: 106, + start: start, + end: end + }; + + stmt = new ParameterizedSQL('CALL vn.timeControl_calculateByUser(?, ?, ?)', [ + params.workerID, + params.start, + params.end + ]); + stmts.push(stmt); + + let tableIndex = stmts.push('SELECT * FROM tmp.timeControlCalculate') - 1; + + stmts.push('ROLLBACK'); + + let sql = ParameterizedSQL.join(stmts, ';'); + let result = await app.models.Ticket.rawStmt(sql); + + let [timeControlCalculateTable] = result[tableIndex]; + + expect(timeControlCalculateTable.timeWorkSeconds).toEqual(29400); + }); + + it(`should return the worked hours between last sunday and monday`, async() => { + let lastSunday = new Date(); + let daysSinceSunday = lastSunday.getDay(); + if (daysSinceSunday === 0) // this means today is sunday but you need the previous sunday :) + daysSinceSunday = 7; + lastSunday.setHours(23, 0, 0, 0); + lastSunday.setDate(lastSunday.getDate() - daysSinceSunday); + + let monday = new Date(); + let daysSinceMonday = daysSinceSunday - 1; // aiming for monday (today could be monday) + monday.setHours(7, 0, 0, 0); + monday.setDate(monday.getDate() - daysSinceMonday); + + let stmts = []; + let stmt; + + stmts.push('START TRANSACTION'); + + stmts.push(` + DROP TEMPORARY TABLE IF EXISTS + tmp.timeControlCalculate, + tmp.timeBusinessCalculate + `); + + const workerID = 107; + + stmt = new ParameterizedSQL(` + INSERT INTO vn.workerTimeControl(userFk, timed, manual, direction) + VALUES + (?, ?, 1, 'in'), + (?, ?, 1, 'out') + `, [ + workerID, + lastSunday, + workerID, + monday + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.timeControl_calculateByUser(?, ?, ?)', [ + workerID, + lastSunday, + monday + ]); + stmts.push(stmt); + + let tableIndex = stmts.push('SELECT * FROM tmp.timeControlCalculate') - 1; + + stmts.push('ROLLBACK'); + + let sql = ParameterizedSQL.join(stmts, ';'); + let result = await app.models.Ticket.rawStmt(sql); + + let [timeControlCalculateTable] = result[tableIndex]; + + expect(timeControlCalculateTable.timeWorkSeconds).toEqual(30000); + }); +}); From 675fa807e6d4e5f92cb44356c017c3dc2f0f88c8 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 5 Mar 2020 09:28:20 +0100 Subject: [PATCH 22/93] Added authentication --- print/boot.js | 2 -- print/core/router.js | 57 ++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/print/boot.js b/print/boot.js index ae604db2c5..02bb278173 100644 --- a/print/boot.js +++ b/print/boot.js @@ -52,5 +52,3 @@ module.exports = app => { }); }); }; - - diff --git a/print/core/router.js b/print/core/router.js index f015ac03b5..a96f770cf7 100644 --- a/print/core/router.js +++ b/print/core/router.js @@ -1,6 +1,55 @@ +const path = require('path'); +const fs = require('fs'); +const db = require('./database'); + module.exports = app => { - // Import methods - require('../methods/closure')(app); - require('../methods/report')(app); - require('../methods/email')(app); + const methodsPath = path.resolve(__dirname, '../methods'); + const methodsDir = fs.readdirSync(methodsPath); + const methods = []; + + // Get all methods + methodsDir.forEach(method => { + methods.push(method.replace('.js', '')); + }); + + // Auth middleware + const paths = []; + for (let method of methods) + paths.push(`/api/${method}/*`); + + app.use(paths, async function(request, response, next) { + const authorization = getToken(request); + const query = `SELECT userId, ttl, created + FROM salix.AccessToken WHERE id = ?`; + console.log('auth'); + + try { + const authToken = await db.findOne(query, [authorization]); + + if (!authToken || isTokenExpired(authToken.created, authToken.ttl)) + throw new Error('Invalid authorization token'); + + next(); + } catch (error) { + next(error); + } + }); + + function getToken(request) { + return request.headers.authorization || request.query.authorization; + } + + function isTokenExpired(created, ttl) { + let date = new Date(created); + let currentDate = new Date(); + + date.setSeconds(date.getSeconds() + ttl); + + if (currentDate > date) + return true; + } + + // Mount methods + for (let method of methods) + require(`../methods/${method}`)(app); }; From f062c802ae49451799c9c79257b54e2e15cb4bae Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 5 Mar 2020 10:08:02 +0100 Subject: [PATCH 23/93] Unit test --- front/core/directives/http-click.js | 2 +- .../core/directives/specs/http-click.spec.js | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 front/core/directives/specs/http-click.spec.js diff --git a/front/core/directives/http-click.js b/front/core/directives/http-click.js index 4fd9322896..c994878eec 100644 --- a/front/core/directives/http-click.js +++ b/front/core/directives/http-click.js @@ -17,7 +17,7 @@ export function directive($parse) { const controller = element.$ctrl; controller.$oldDisabled = controller.disabled; controller.disabled = true; - + console.log(cb()); cb($scope).finally(() => { if (!controller.$oldDisabled) controller.disabled = false; diff --git a/front/core/directives/specs/http-click.spec.js b/front/core/directives/specs/http-click.spec.js new file mode 100644 index 0000000000..e509251776 --- /dev/null +++ b/front/core/directives/specs/http-click.spec.js @@ -0,0 +1,46 @@ +fdescribe('Directive http-click', () => { + let $scope; + let $element; + let element; + let compile; + let controller; + + beforeEach(ngModule('vnCore')); + + compile = (_element, _childElement) => { + inject(($componentController, $compile, $rootScope) => { + $scope = $rootScope.$new(); + element = angular.element(_element); + $compile(element)($scope); + + /* controller = element.controller('vnHttpClick'); + controller.myEvent = () => { + return Promise.resolve('hola'); + }; */ + + controller = $componentController('vnHttpClick', {$element: element, $scope: $scope}); + controller.myEvent = () => { + return Promise.resolve('hola'); + }; + + $scope.$digest(); + }); + }; + + beforeEach(angular.mock.inject(($rootScope, $compile) => { + $element = $compile('')($rootScope); + controller = $element.controller('vnHttpClick'); + })); + + it('should call focus function on the element', () => { + // jest.spyOn(controller, 'myEvent').mockReturnValue(Promise.resolve()); + + let html = ``; + compile(html); + + element[0].$ctrl = {}; + element[0].click(); + + // expect($element[0].focus).toHaveBeenCalledWith(); + }); +}); From f3e4bc7aeb684ac48d4ee2b0a03087de2fe30c1c Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Thu, 5 Mar 2020 10:50:07 +0100 Subject: [PATCH 24/93] workerTImeControlCheck test --- db/tests/vn/workerTimeControlCheck.spec.js | 247 ++++++++++++++++++--- 1 file changed, 218 insertions(+), 29 deletions(-) diff --git a/db/tests/vn/workerTimeControlCheck.spec.js b/db/tests/vn/workerTimeControlCheck.spec.js index 81ddc9be29..69e702213e 100644 --- a/db/tests/vn/workerTimeControlCheck.spec.js +++ b/db/tests/vn/workerTimeControlCheck.spec.js @@ -27,7 +27,7 @@ fdescribe('worker workerTimeControl_check()', () => { expect(err.sqlMessage).toEqual('No perteneces a este departamento.'); }); - it('should EL TRABAJDOR ESTA EN EL DEPARTAMENTO Y TABLET CORRECTO', async() => { + it('should EL TRABAJADOR ESTA EN EL DEPARTAMENTO Y TABLET CORRECTO', async() => { let stmts = []; let stmt; const workerId = 110; @@ -62,7 +62,7 @@ fdescribe('worker workerTimeControl_check()', () => { stmts.push('START TRANSACTION'); stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction) - VALUES + VALUES (?,TIMESTAMPADD(HOUR,-17,NOW()),0,"in"), (?,TIMESTAMPADD(SECOND,-32399,NOW()),0,"out")`, [ workerIdBreak9Hours, @@ -133,7 +133,7 @@ fdescribe('worker workerTimeControl_check()', () => { stmts.push('START TRANSACTION'); stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction) - VALUES + VALUES (?,TIMESTAMPADD(HOUR,-20,NOW()),0,"in"), (?,TIMESTAMPADD(SECOND,-43199,NOW()),0,"out")`, [ workerIdBreak12Hours, @@ -312,24 +312,46 @@ fdescribe('worker workerTimeControl_check()', () => { expect(err.sqlMessage).toEqual('No hay un contrato en vigor'); }); - it('should throw an error if NO TIENE DESCANSO SEMANAL', async() => { + it('should throw an error if NO TIENE DESCANSO SEMANAL 36h', async() => { const workerIdBreak12Hours = 109; const tabletId = 1; let stmts = []; let stmt; - let err; stmts.push('START TRANSACTION'); - stmt = new ParameterizedSQL(`UPDATE postgresql.business SET date_end=DATE_ADD(CURDATE(), INTERVAL -1 DAY) WHERE business_id=?`, [ - workerIdBreak12Hours - ]); - stmts.push(stmt); - stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction) VALUES (?,TIMESTAMPADD(HOUR,-24,NOW()),0,"in"), - (?,TIMESTAMPADD(HOUR,-20,NOW()),0,"out")`, [ + (?,TIMESTAMPADD(HOUR,-16,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-48,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-40,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-72,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-64,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-96,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-88,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-120,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-112,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-144,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-136,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-168,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-160,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-192,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-184,NOW()),0,"out")`, [ + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, workerIdBreak12Hours, workerIdBreak12Hours ]); @@ -342,36 +364,37 @@ fdescribe('worker workerTimeControl_check()', () => { stmts.push(stmt); stmts.push('ROLLBACK'); + let warningMessageIndex = stmts.push('SELECT @warn AS warning') - 1; let sql = ParameterizedSQL.join(stmts, ';'); + let result = await app.models.Worker.rawStmt(sql); - try { - await app.models.Worker.rawStmt(sql); - } catch (e) { - await app.models.Worker.rawSql('ROLLBACK'); - err = e; - } - - expect(err.sqlMessage).toEqual('No hay un contrato en vigor'); + expect(result[warningMessageIndex][0].warning).toEqual('Descansos 36 h'); }); - it('should DESCANSO 32h', async() => { + it('should throw an error if CUMPLE DESCANSO SEMANAL 36h', async() => { const workerIdBreak12Hours = 109; const tabletId = 1; let stmts = []; let stmt; - let err; stmts.push('START TRANSACTION'); - stmt = new ParameterizedSQL(`UPDATE postgresql.business SET date_end=DATE_ADD(CURDATE(), INTERVAL -1 DAY) WHERE business_id=?`, [ - workerIdBreak12Hours - ]); - stmts.push(stmt); - stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction) VALUES - (?,TIMESTAMPADD(HOUR,-24,NOW()),0,"in"), - (?,TIMESTAMPADD(HOUR,-20,NOW()),0,"out")`, [ + (?,TIMESTAMPADD(HOUR,-24,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-16,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-48,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-40,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-72,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-64,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-96,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-88,NOW()),0,"out")`, [ + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, workerIdBreak12Hours, workerIdBreak12Hours ]); @@ -384,6 +407,90 @@ fdescribe('worker workerTimeControl_check()', () => { stmts.push(stmt); stmts.push('ROLLBACK'); + let warningMessageIndex = stmts.push('SELECT @warn AS warning') - 1; + + let sql = ParameterizedSQL.join(stmts, ';'); + let result = await app.models.Worker.rawStmt(sql); + + console.log('warningMessageIndex', result[warningMessageIndex][0]); + // HABLAR CON CARLOS, falla aeatoriamente + expect(result[warningMessageIndex][0].warning).toBe(null); + }); + + it('should throw an error if NO TIENE DESCANSO SEMANAL 72h', async() => { + const workerIdBreak12Hours = 109; + const tabletId = 1; + let stmts = []; + let stmt; + let err; + stmts.push('START TRANSACTION'); + + stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction) + VALUES + (?,TIMESTAMPADD(HOUR,-24,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-16,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-48,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-40,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-72,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-64,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-96,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-88,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-120,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-112,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-144,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-136,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-168,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-160,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-192,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-184,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-216,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-208,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-240,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-232,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-264,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-256,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-288,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-280,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-312,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-304,NOW()),0,"out")`, [ + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerIdBreak12Hours, + tabletId + ]); + stmts.push(stmt); + stmts.push('ROLLBACK'); + + stmts.push('SELECT @warn AS warning') - 1; + let sql = ParameterizedSQL.join(stmts, ';'); try { @@ -393,6 +500,88 @@ fdescribe('worker workerTimeControl_check()', () => { err = e; } - expect(err.sqlMessage).toEqual('No hay un contrato en vigor'); + expect(err.sqlMessage).toEqual('Descansos 72 h'); + }); + + it('should throw an error if CUMPLE DESCANSO QUINCENAL 72h', async() => { + const workerIdBreak12Hours = 109; + const tabletId = 1; + let stmts = []; + let stmt; + let err; + stmts.push('START TRANSACTION'); + + stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction) + VALUES + (?,TIMESTAMPADD(HOUR,-24,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-16,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-48,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-40,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-72,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-64,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-96,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-88,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-120,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-112,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-144,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-136,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-168,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-160,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-192,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-184,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-216,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-208,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-240,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-232,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-264,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-256,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-288,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-280,NOW()),0,"out")`, [ + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours, + workerIdBreak12Hours + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerIdBreak12Hours, + tabletId + ]); + stmts.push(stmt); + stmts.push('ROLLBACK'); + + stmts.push('SELECT @warn AS warning') - 1; + + let sql = ParameterizedSQL.join(stmts, ';'); + + try { + await app.models.Worker.rawStmt(sql); + } catch (e) { + await app.models.Worker.rawSql('ROLLBACK'); + err = e; + } + + expect(err).not.toBeDefined(); }); }); From 1f714718bb7c296c568479f4745f8e7650aae36e Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 5 Mar 2020 13:56:45 +0100 Subject: [PATCH 25/93] =?UTF-8?q?1878=20-=20Implementar=20autenticaci?= =?UTF-8?q?=C3=B3n=20en=20servicio=20print?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/core/lib/component.js | 15 ++++++++-- modules/claim/front/action/index.js | 1 - modules/claim/front/descriptor/index.js | 28 ++++++++----------- modules/client/back/models/client.js | 13 +++++---- modules/client/front/descriptor/index.js | 10 +++++-- modules/entry/front/descriptor/index.js | 7 +++-- modules/route/front/descriptor/index.js | 19 ++++++------- modules/ticket/front/descriptor/index.js | 9 +++--- print/core/filters/index.js | 2 ++ print/core/filters/number.js | 10 +++++++ print/core/router.js | 15 +++++++--- .../letter-debtor-nd/letter-debtor-nd.js | 3 ++ .../letter-debtor-st/letter-debtor-st.js | 5 +++- .../claim-pickup-order.html | 4 +-- .../reports/entry-order/entry-order.html | 14 +++++----- 15 files changed, 96 insertions(+), 59 deletions(-) create mode 100644 print/core/filters/number.js diff --git a/front/core/lib/component.js b/front/core/lib/component.js index b9f04dba60..4552dfbe73 100644 --- a/front/core/lib/component.js +++ b/front/core/lib/component.js @@ -108,7 +108,10 @@ function runFn( $filter, $interpolate, $window, - vnApp) { + vnApp, + vnToken, + vnConfig, + aclService) { Object.assign(Component.prototype, { $translate, $q, @@ -121,7 +124,10 @@ function runFn( $filter, $interpolate, $window, - vnApp + vnApp, + vnToken, + vnConfig, + aclService }); } runFn.$inject = [ @@ -136,7 +142,10 @@ runFn.$inject = [ '$filter', '$interpolate', '$window', - 'vnApp' + 'vnApp', + 'vnToken', + 'vnConfig', + 'aclService' ]; ngModule.run(runFn); diff --git a/modules/claim/front/action/index.js b/modules/claim/front/action/index.js index 7a04f95d5e..dc22cb4be6 100644 --- a/modules/claim/front/action/index.js +++ b/modules/claim/front/action/index.js @@ -155,7 +155,6 @@ class Controller { }); } - onUpdateGreugeResponse(response) { if (response == 'accept') { const promises = []; diff --git a/modules/claim/front/descriptor/index.js b/modules/claim/front/descriptor/index.js index 7bc9c831ae..fd00368b8c 100644 --- a/modules/claim/front/descriptor/index.js +++ b/modules/claim/front/descriptor/index.js @@ -1,14 +1,11 @@ import ngModule from '../module'; +import Component from 'core/lib/component'; -class Controller { - constructor($scope, $state, $http, $translate, vnApp, aclService, $httpParamSerializer) { - this.$scope = $scope; - this.$state = $state; - this.$http = $http; - this.$translate = $translate; - this.vnApp = vnApp; - this.aclService = aclService; +class Controller extends Component { + constructor($element, $scope, $httpParamSerializer) { + super($element, $scope); this.$httpParamSerializer = $httpParamSerializer; + this.moreOptions = [ {callback: this.showPickupOrder, name: 'Show Pickup order'}, {callback: this.confirmPickupOrder, name: 'Send Pickup order'}, @@ -22,7 +19,7 @@ class Controller { return !hasAclProperty || (hasAclProperty && this.aclService.hasAny([option.acl])); }); - this.$scope.moreButton.data = options; + this.$.moreButton.data = options; } onMoreChange(callback) { @@ -63,7 +60,8 @@ class Controller { showPickupOrder() { const params = { clientId: this.claim.clientFk, - claimId: this.claim.id + claimId: this.claim.id, + authorization: this.vnToken.token }; const serializedParams = this.$httpParamSerializer(params); let url = `api/report/claim-pickup-order?${serializedParams}`; @@ -71,7 +69,7 @@ class Controller { } confirmPickupOrder() { - this.$scope.confirmPickupOrder.show(); + this.$.confirmPickupOrder.show(); } sendPickupOrder(response) { @@ -81,16 +79,14 @@ class Controller { clientId: this.claim.clientFk, claimId: this.claim.id }; - const serializedParams = this.$httpParamSerializer(params); - const url = `email/claim-pickup-order?${serializedParams}`; - this.$http.get(url).then( + this.$http.get(`email/claim-pickup-order`, {params}).then( () => this.vnApp.showMessage(this.$translate.instant('Notification sent!')) ); } } confirmDeleteClaim() { - this.$scope.confirmDeleteClaim.show(); + this.$.confirmDeleteClaim.show(); } deleteClaim(response) { @@ -103,7 +99,7 @@ class Controller { } } -Controller.$inject = ['$scope', '$state', '$http', '$translate', 'vnApp', 'aclService', '$httpParamSerializer']; +Controller.$inject = ['$element', '$scope', '$httpParamSerializer']; ngModule.component('vnClaimDescriptor', { template: require('./index.html'), diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index 367e0f0ebd..417370e9ea 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -191,7 +191,6 @@ module.exports = Self => { if (socialNameChanged && !isAlpha(changes.socialName)) throw new UserError('The socialName has an invalid format'); - if (changes.salesPerson === null) { changes.credit = 0; changes.discount = 0; @@ -238,7 +237,9 @@ module.exports = Self => { const httpCtx = {req: loopBackContext.active}; const httpRequest = httpCtx.req.http.req; const $t = httpRequest.__; - const origin = httpRequest.headers.origin; + const headers = httpRequest.headers; + const origin = headers.origin; + const authorization = headers.authorization; const salesPersonId = instance.salesPersonFk; @@ -254,12 +255,14 @@ module.exports = Self => { // Send email to client if (!instance.email) return; - const serializedParams = httpParamSerializer({ + const params = { + authorization: authorization, clientId: instance.id, recipient: instance.email + }; + await request.get(`${origin}/api/email/payment-update`, { + qs: params }); - const query = `${origin}/api/email/payment-update?${serializedParams}`; - await request.get(query); } }); diff --git a/modules/client/front/descriptor/index.js b/modules/client/front/descriptor/index.js index 95754b4df9..4cf35d1e93 100644 --- a/modules/client/front/descriptor/index.js +++ b/modules/client/front/descriptor/index.js @@ -5,6 +5,7 @@ class Controller extends Component { constructor($element, $, $httpParamSerializer) { super($element, $); this.$httpParamSerializer = $httpParamSerializer; + this.moreOptions = [ {name: 'Simple ticket', callback: this.newTicket}, {name: 'Send SMS', callback: this.showSMSDialog}, @@ -72,8 +73,13 @@ class Controller extends Component { sendConsumerReport(response) { if (response === 'accept') { - const data = {from: this.from, to: this.to, clientId: this.client.id}; - const serializedParams = this.$httpParamSerializer(data); + const params = { + authorization: this.vnToken.token, + clientId: this.client.id, + from: this.from, + to: this.to, + }; + const serializedParams = this.$httpParamSerializer(params); const url = `api/report/campaign-metrics?${serializedParams}`; window.open(url); } diff --git a/modules/entry/front/descriptor/index.js b/modules/entry/front/descriptor/index.js index 8f51308f29..7b004754c2 100644 --- a/modules/entry/front/descriptor/index.js +++ b/modules/entry/front/descriptor/index.js @@ -2,10 +2,10 @@ import ngModule from '../module'; import Component from 'core/lib/component'; class Controller extends Component { - constructor($element, $, $httpParamSerializer, vnConfig) { + constructor($element, $, $httpParamSerializer) { super($element, $); - this.vnConfig = vnConfig; this.$httpParamSerializer = $httpParamSerializer; + this.moreOptions = [ {name: 'Show entry report', callback: this.showEntryReport} ]; @@ -59,6 +59,7 @@ class Controller extends Component { showEntryReport() { const params = { + authorization: this.vnToken.token, clientId: this.vnConfig.storage.currentUserWorkerId, entryId: this.entry.id }; @@ -68,7 +69,7 @@ class Controller extends Component { } } -Controller.$inject = ['$element', '$scope', '$httpParamSerializer', 'vnConfig']; +Controller.$inject = ['$element', '$scope', '$httpParamSerializer']; ngModule.component('vnEntryDescriptor', { template: require('./index.html'), diff --git a/modules/route/front/descriptor/index.js b/modules/route/front/descriptor/index.js index 1beb7e0950..e28654b99a 100644 --- a/modules/route/front/descriptor/index.js +++ b/modules/route/front/descriptor/index.js @@ -1,12 +1,10 @@ import ngModule from '../module'; +import Component from 'core/lib/component'; + +class Controller extends Component { + constructor($element, $scope, $httpParamSerializer) { + super($element, $scope); -class Controller { - constructor($, $http, vnApp, $translate, aclService, $httpParamSerializer) { - this.$http = $http; - this.vnApp = vnApp; - this.$translate = $translate; - this.$ = $; - this.aclService = aclService; this.$httpParamSerializer = $httpParamSerializer; this.moreOptions = [ {callback: this.showRouteReport, name: 'Show route report'}, @@ -39,6 +37,7 @@ class Controller { showRouteReport() { const user = this.route.worker.user; const params = { + authorization: this.vnToken.token, clientId: user.id, routeId: this.route.id }; @@ -54,9 +53,7 @@ class Controller { clientId: user.id, routeId: this.route.id }; - const serializedParams = this.$httpParamSerializer(params); - const url = `email/driver-route?${serializedParams}`; - this.$http.get(url).then(() => { + this.$http.get(`email/driver-route`, {params}).then(() => { this.vnApp.showSuccess(this.$translate.instant('Report sent')); }); } @@ -76,7 +73,7 @@ class Controller { } } -Controller.$inject = ['$scope', '$http', 'vnApp', '$translate', 'aclService', '$httpParamSerializer']; +Controller.$inject = ['$element', '$scope', '$httpParamSerializer']; ngModule.component('vnRouteDescriptor', { template: require('./index.html'), diff --git a/modules/ticket/front/descriptor/index.js b/modules/ticket/front/descriptor/index.js index d804a2eb23..c633dd3c1e 100644 --- a/modules/ticket/front/descriptor/index.js +++ b/modules/ticket/front/descriptor/index.js @@ -2,10 +2,10 @@ import ngModule from '../module'; import Component from 'core/lib/component'; class Controller extends Component { - constructor($element, $, aclService, $httpParamSerializer) { + constructor($element, $, $httpParamSerializer) { super($element, $); - this.aclService = aclService; this.$httpParamSerializer = $httpParamSerializer; + this.moreOptions = [ { name: 'Add turn', @@ -220,7 +220,8 @@ class Controller extends Component { showDeliveryNote() { const params = { clientId: this.ticket.client.id, - ticketId: this.ticket.id + ticketId: this.ticket.id, + authorization: this.vnToken.token }; const serializedParams = this.$httpParamSerializer(params); let url = `api/report/delivery-note?${serializedParams}`; @@ -332,7 +333,7 @@ class Controller extends Component { } } -Controller.$inject = ['$element', '$scope', 'aclService', '$httpParamSerializer']; +Controller.$inject = ['$element', '$scope', '$httpParamSerializer']; ngModule.component('vnTicketDescriptor', { template: require('./index.html'), diff --git a/print/core/filters/index.js b/print/core/filters/index.js index 1d2eb182c5..bfd99c5048 100644 --- a/print/core/filters/index.js +++ b/print/core/filters/index.js @@ -3,3 +3,5 @@ require('./date'); require('./uppercase'); require('./currency'); require('./percentage'); +require('./number'); + diff --git a/print/core/filters/number.js b/print/core/filters/number.js new file mode 100644 index 0000000000..c785706fe4 --- /dev/null +++ b/print/core/filters/number.js @@ -0,0 +1,10 @@ +const Vue = require('vue'); +const config = require('../config'); +const defaultLocale = config.i18n.locale; + +Vue.filter('number', function(value, locale = defaultLocale) { + if (!locale) locale = defaultLocale; + return new Intl.NumberFormat(locale, { + style: 'decimal' + }).format(parseFloat(value)); +}); diff --git a/print/core/router.js b/print/core/router.js index a96f770cf7..3be6cdd35b 100644 --- a/print/core/router.js +++ b/print/core/router.js @@ -21,7 +21,6 @@ module.exports = app => { const authorization = getToken(request); const query = `SELECT userId, ttl, created FROM salix.AccessToken WHERE id = ?`; - console.log('auth'); try { const authToken = await db.findOne(query, [authorization]); @@ -36,17 +35,25 @@ module.exports = app => { }); function getToken(request) { - return request.headers.authorization || request.query.authorization; + const headers = request.headers; + const params = request.query; + + if (headers.authorization) + params.authorization = headers.authorization; + + return headers.authorization || params.authorization; } function isTokenExpired(created, ttl) { - let date = new Date(created); - let currentDate = new Date(); + const date = new Date(created); + const currentDate = new Date(); date.setSeconds(date.getSeconds() + ttl); if (currentDate > date) return true; + + return false; } // Mount methods diff --git a/print/templates/email/letter-debtor-nd/letter-debtor-nd.js b/print/templates/email/letter-debtor-nd/letter-debtor-nd.js index 7d7cc84ef9..b2809ac284 100755 --- a/print/templates/email/letter-debtor-nd/letter-debtor-nd.js +++ b/print/templates/email/letter-debtor-nd/letter-debtor-nd.js @@ -37,6 +37,9 @@ module.exports = { 'attachment': attachment.build() }, props: { + authorization: { + required: true + }, clientId: { required: true }, diff --git a/print/templates/email/letter-debtor-st/letter-debtor-st.js b/print/templates/email/letter-debtor-st/letter-debtor-st.js index c34a9320a3..61f3c01adb 100755 --- a/print/templates/email/letter-debtor-st/letter-debtor-st.js +++ b/print/templates/email/letter-debtor-st/letter-debtor-st.js @@ -37,11 +37,14 @@ module.exports = { 'attachment': attachment.build() }, props: { + authorization: { + required: true + }, clientId: { required: true }, companyId: { required: true - } + }, } }; diff --git a/print/templates/reports/claim-pickup-order/claim-pickup-order.html b/print/templates/reports/claim-pickup-order/claim-pickup-order.html index c5e2d05f30..f23ee34014 100644 --- a/print/templates/reports/claim-pickup-order/claim-pickup-order.html +++ b/print/templates/reports/claim-pickup-order/claim-pickup-order.html @@ -61,7 +61,7 @@ {{$t('reference')}} {{$t('quantity')}} {{$t('claims')}} - {{$t('concept')}} + {{$t('concept')}} @@ -69,7 +69,7 @@ {{sale.id}} {{sale.quantity}} {{sale.claimQuantity}} - {{sale.concept}} + {{sale.concept}} diff --git a/print/templates/reports/entry-order/entry-order.html b/print/templates/reports/entry-order/entry-order.html index 094936fd07..5ee45787c9 100644 --- a/print/templates/reports/entry-order/entry-order.html +++ b/print/templates/reports/entry-order/entry-order.html @@ -63,12 +63,12 @@ - + - - - + + + @@ -76,9 +76,9 @@ - - - + + +
{{$t('boxes')}}{{$t('boxes')}} {{$t('packing')}} {{$t('concept')}}{{$t('quantity')}}{{$t('price')}}{{$t('amount')}}{{$t('quantity')}}{{$t('price')}}{{$t('amount')}}
{{buy.box}} {{buy.packing}} {{buy.itemName}}{{buy.quantity}}{{buy.buyingValue | currency('EUR', locale)}}{{buy.buyingValue * buy.quantity | currency('EUR', locale)}}{{buy.quantity | number}}{{buy.buyingValue | currency('EUR', locale)}}{{buy.buyingValue * buy.quantity | currency('EUR', locale)}}
From 63faeab909304bb9caf9bb479c1d27f121be552c Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Thu, 5 Mar 2020 14:06:55 +0100 Subject: [PATCH 26/93] fix db test --- db/tests/vn/workerTimeControlCheck.spec.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/db/tests/vn/workerTimeControlCheck.spec.js b/db/tests/vn/workerTimeControlCheck.spec.js index 69e702213e..8c365417c9 100644 --- a/db/tests/vn/workerTimeControlCheck.spec.js +++ b/db/tests/vn/workerTimeControlCheck.spec.js @@ -318,6 +318,8 @@ fdescribe('worker workerTimeControl_check()', () => { let stmts = []; let stmt; + stmts.push('SET @warn := NULL'); + stmts.push('START TRANSACTION'); stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction) @@ -362,9 +364,9 @@ fdescribe('worker workerTimeControl_check()', () => { tabletId ]); stmts.push(stmt); - stmts.push('ROLLBACK'); let warningMessageIndex = stmts.push('SELECT @warn AS warning') - 1; + stmts.push('ROLLBACK'); let sql = ParameterizedSQL.join(stmts, ';'); let result = await app.models.Worker.rawStmt(sql); @@ -377,6 +379,8 @@ fdescribe('worker workerTimeControl_check()', () => { let stmts = []; let stmt; + stmts.push('SET @warn := NULL'); + stmts.push('START TRANSACTION'); stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction) From 30d5370080eb24155609e81d672233fcdd94d2e3 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 5 Mar 2020 14:37:52 +0100 Subject: [PATCH 27/93] Rmoved space --- print/core/email.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/print/core/email.js b/print/core/email.js index 25d44df653..ab09eab98f 100644 --- a/print/core/email.js +++ b/print/core/email.js @@ -19,7 +19,6 @@ class Email extends Component { return `../templates/email/${this.name}`; } - async getSubject() { if (!this.lang) await this.getLang(); const locale = this.locale.messages; @@ -81,6 +80,7 @@ class Email extends Component { const localeSubject = await this.getSubject(); const options = { to: this.args.recipient, + replyTo: this.args.replyTo, subject: localeSubject, html: rendered, attachments: attachments From fddc8e7ed1369d83c7ee0bfd49a81ce5bc2787fe Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 5 Mar 2020 14:49:41 +0100 Subject: [PATCH 28/93] Updated unit test --- modules/claim/front/descriptor/index.spec.js | 17 +++++++++++------ modules/worker/front/time-control/index.spec.js | 3 +-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/modules/claim/front/descriptor/index.spec.js b/modules/claim/front/descriptor/index.spec.js index a64d5ecc1b..4a78bda5a0 100644 --- a/modules/claim/front/descriptor/index.spec.js +++ b/modules/claim/front/descriptor/index.spec.js @@ -3,14 +3,19 @@ import './index.js'; describe('Item Component vnClaimDescriptor', () => { let $httpParamSerializer; let $httpBackend; + let $element; + let $scope; let controller; beforeEach(ngModule('claim')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_, _$httpParamSerializer_) => { + beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { $httpBackend = _$httpBackend_; $httpParamSerializer = _$httpParamSerializer_; - controller = $componentController('vnClaimDescriptor'); + $scope = $rootScope.$new(); + + $element = angular.element(''); + controller = $componentController('vnClaimDescriptor', {$element, $scope}); controller.claim = {id: 2, clientFk: 101, client: {email: 'client@email'}}; })); @@ -31,13 +36,13 @@ describe('Item Component vnClaimDescriptor', () => { describe('confirmPickupOrder()', () => { it('should call confirmPickupOrder.show()', () => { - controller.$scope.confirmPickupOrder = { + controller.$.confirmPickupOrder = { show: jasmine.createSpy('show') }; controller.claim = {id: 2}; controller.confirmPickupOrder(); - expect(controller.$scope.confirmPickupOrder.show).toHaveBeenCalledWith(); + expect(controller.$.confirmPickupOrder.show).toHaveBeenCalledWith(); }); }); @@ -63,13 +68,13 @@ describe('Item Component vnClaimDescriptor', () => { describe('confirmDeleteClaim()', () => { it('should call confirmDeleteClaim.show()', () => { - controller.$scope.confirmDeleteClaim = { + controller.$.confirmDeleteClaim = { show: jasmine.createSpy('show') }; controller.claim = {id: 2}; controller.confirmDeleteClaim(); - expect(controller.$scope.confirmDeleteClaim.show).toHaveBeenCalledWith(); + expect(controller.$.confirmDeleteClaim.show).toHaveBeenCalledWith(); }); }); diff --git a/modules/worker/front/time-control/index.spec.js b/modules/worker/front/time-control/index.spec.js index 7987c6a50a..5194468641 100644 --- a/modules/worker/front/time-control/index.spec.js +++ b/modules/worker/front/time-control/index.spec.js @@ -1,6 +1,5 @@ import './index.js'; - describe('Component vnWorkerTimeControl', () => { let $httpBackend; let $scope; @@ -9,7 +8,7 @@ describe('Component vnWorkerTimeControl', () => { beforeEach(ngModule('worker')); - beforeEach(angular.mock.inject(($componentController, $compile, $rootScope, $stateParams, _$httpBackend_) => { + beforeEach(angular.mock.inject(($componentController, $rootScope, $stateParams, _$httpBackend_) => { $stateParams.id = 1; $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); From 85ac133d00d59dcc29b09e54588982f36d403326 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Thu, 5 Mar 2020 15:01:03 +0100 Subject: [PATCH 29/93] update db test --- .../10161-postValentineDay/00-workerTimeControlCheck.sql | 2 +- db/tests/vn/workerTimeControlCheck.spec.js | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/db/changes/10161-postValentineDay/00-workerTimeControlCheck.sql b/db/changes/10161-postValentineDay/00-workerTimeControlCheck.sql index 19cd9c4e9d..31bc4922bc 100644 --- a/db/changes/10161-postValentineDay/00-workerTimeControlCheck.sql +++ b/db/changes/10161-postValentineDay/00-workerTimeControlCheck.sql @@ -78,7 +78,7 @@ BEGIN WHERE td.tabletFk = vTabletFk AND wtcu.userFk = vUserFk ) = 0 THEN -- ENVIAMOS CORREO AL BOSSFK - SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"No perteneces a este departamento.") INTO vBody; + SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"No perteneces a este departamento.") INTO vBody; CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); CALL util.throw("No perteneces a este departamento."); END IF; diff --git a/db/tests/vn/workerTimeControlCheck.spec.js b/db/tests/vn/workerTimeControlCheck.spec.js index 8c365417c9..dc55c66fbb 100644 --- a/db/tests/vn/workerTimeControlCheck.spec.js +++ b/db/tests/vn/workerTimeControlCheck.spec.js @@ -453,12 +453,8 @@ fdescribe('worker workerTimeControl_check()', () => { (?,TIMESTAMPADD(HOUR,-232,NOW()),0,"out"), (?,TIMESTAMPADD(HOUR,-264,NOW()),0,"in"), (?,TIMESTAMPADD(HOUR,-256,NOW()),0,"out"), - (?,TIMESTAMPADD(HOUR,-288,NOW()),0,"in"), - (?,TIMESTAMPADD(HOUR,-280,NOW()),0,"out"), - (?,TIMESTAMPADD(HOUR,-312,NOW()),0,"in"), - (?,TIMESTAMPADD(HOUR,-304,NOW()),0,"out")`, [ - workerIdBreak12Hours, - workerIdBreak12Hours, + (?,TIMESTAMPADD(HOUR,-289,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-280,NOW()),0,"out")`, [ workerIdBreak12Hours, workerIdBreak12Hours, workerIdBreak12Hours, From 0f8d199d2f6c54166060e158dec8ede3f44c090f Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Fri, 6 Mar 2020 07:14:40 +0100 Subject: [PATCH 30/93] workerTimeControlCheck dbTest fix --- db/tests/vn/workerTimeControlCheck.spec.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/db/tests/vn/workerTimeControlCheck.spec.js b/db/tests/vn/workerTimeControlCheck.spec.js index dc55c66fbb..4e088b3693 100644 --- a/db/tests/vn/workerTimeControlCheck.spec.js +++ b/db/tests/vn/workerTimeControlCheck.spec.js @@ -416,8 +416,6 @@ fdescribe('worker workerTimeControl_check()', () => { let sql = ParameterizedSQL.join(stmts, ';'); let result = await app.models.Worker.rawStmt(sql); - console.log('warningMessageIndex', result[warningMessageIndex][0]); - // HABLAR CON CARLOS, falla aeatoriamente expect(result[warningMessageIndex][0].warning).toBe(null); }); From 666ccbf370fcba2692c3e4b9f07f10b0ce246fba Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Fri, 6 Mar 2020 08:38:03 +0100 Subject: [PATCH 31/93] ticket.basicData address --- .../ticket/front/basic-data/step-one/index.js | 16 ++++++--- .../front/basic-data/step-one/index.spec.js | 34 ++++++++++++------- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/modules/ticket/front/basic-data/step-one/index.js b/modules/ticket/front/basic-data/step-one/index.js index 820d3d2c6b..120140c3d6 100644 --- a/modules/ticket/front/basic-data/step-one/index.js +++ b/modules/ticket/front/basic-data/step-one/index.js @@ -22,7 +22,7 @@ class Controller { if (!value || !value.id) return; - this.onChangeClient(value.clientFk); + this.clientAddressesList(value.clientFk); } get clientId() { @@ -33,7 +33,8 @@ class Controller { this.ticket.clientFk = value; this.ticket.addressFk = null; - this.onChangeClient(value); + this.getClientDefaultAddress(value); + this.clientAddressesList(value); } get addressId() { @@ -68,7 +69,6 @@ class Controller { } } - get shipped() { return this.ticket && this.ticket.shipped; } @@ -127,7 +127,7 @@ class Controller { /* * Autocompletes address on client change */ - onChangeClient(value) { + clientAddressesList(value) { let filter = { include: [ { @@ -153,6 +153,14 @@ class Controller { }); } + getClientDefaultAddress(value) { + let query = `Clients/${value}`; + this.$http.get(query).then(res => { + if (res.data) + this.ticket.addressFk = res.data.defaultAddressFk; + }); + } + /* * Gets an agency from an specified zone */ diff --git a/modules/ticket/front/basic-data/step-one/index.spec.js b/modules/ticket/front/basic-data/step-one/index.spec.js index 86977a738a..b1931d0bb0 100644 --- a/modules/ticket/front/basic-data/step-one/index.spec.js +++ b/modules/ticket/front/basic-data/step-one/index.spec.js @@ -22,18 +22,18 @@ describe('Ticket', () => { })); describe('ticket() setter', () => { - it('should set ticket property and call onChangeClient() method', () => { - jest.spyOn(controller, 'onChangeClient'); + it('should set ticket property and call clientAddressesList() method', () => { + jest.spyOn(controller, 'clientAddressesList'); controller.ticket = {id: 1, clientFk: 101}; - expect(controller.onChangeClient).toHaveBeenCalledWith(101); + expect(controller.clientAddressesList).toHaveBeenCalledWith(101); }); - it(`should not call onChangeClient() method as the ticket doesn't have an ID`, () => { - jest.spyOn(controller, 'onChangeClient'); + it(`should not call clientAddressesList() method as the ticket doesn't have an ID`, () => { + jest.spyOn(controller, 'clientAddressesList'); controller.ticket = {}; - expect(controller.onChangeClient).not.toHaveBeenCalledWith(); + expect(controller.clientAddressesList).not.toHaveBeenCalledWith(); }); }); @@ -46,12 +46,12 @@ describe('Ticket', () => { }); describe('clientId() setter', () => { - it('should set clientId property and call onChangeClient() method ', () => { - jest.spyOn(controller, 'onChangeClient'); + it('should set clientId property and call clientAddressesList() method ', () => { + jest.spyOn(controller, 'clientAddressesList'); controller.ticket = {id: 1, clientId: 101}; controller.clientId = 102; - expect(controller.onChangeClient).toHaveBeenCalledWith(102); + expect(controller.clientAddressesList).toHaveBeenCalledWith(102); }); }); @@ -155,7 +155,6 @@ describe('Ticket', () => { }; controller.landed = landed; - expect(controller.getShipped).toHaveBeenCalledWith(expectedResult); }); }); @@ -230,7 +229,7 @@ describe('Ticket', () => { }); }); - describe('onChangeClient()', () => { + describe('clientAddressesList()', () => { it('should return a list of addresses from choosed client', async() => { const clientId = 102; let filter = { @@ -253,7 +252,18 @@ describe('Ticket', () => { $httpBackend.when('GET', `Clients/${clientId}/addresses?filter=${filter}`).respond(200); $httpBackend.expect('GET', `Clients/${clientId}/addresses?filter=${filter}`); - controller.onChangeClient(clientId); + controller.clientAddressesList(clientId); + $httpBackend.flush(); + }); + }); + + describe('getClientDefaultAddress()', () => { + it('should return the default address from choosed client', async() => { + const clientId = 102; + + $httpBackend.when('GET', `Clients/${clientId}`).respond(200); + $httpBackend.expect('GET', `Clients/${clientId}`); + controller.getClientDefaultAddress(clientId); $httpBackend.flush(); }); }); From 1951e8bcf93d975ae1bcb2bb8d738951826c4b14 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Fri, 6 Mar 2020 08:50:55 +0100 Subject: [PATCH 32/93] fix setter client --- modules/ticket/front/basic-data/step-one/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/ticket/front/basic-data/step-one/index.js b/modules/ticket/front/basic-data/step-one/index.js index 120140c3d6..b8fffd2c1c 100644 --- a/modules/ticket/front/basic-data/step-one/index.js +++ b/modules/ticket/front/basic-data/step-one/index.js @@ -33,6 +33,8 @@ class Controller { this.ticket.clientFk = value; this.ticket.addressFk = null; + if (!value) return; + this.getClientDefaultAddress(value); this.clientAddressesList(value); } From 11bd861224e8aaaef3d708046f91d5259376692a Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Fri, 6 Mar 2020 09:57:05 +0100 Subject: [PATCH 33/93] section bases --- modules/entry/front/buy/index.html | 68 +++++++++++++++++++++++++++ modules/entry/front/buy/index.js | 35 ++++++++++++++ modules/entry/front/buy/locale/es.yml | 1 + modules/entry/front/index.js | 1 + modules/entry/front/routes.json | 11 ++++- 5 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 modules/entry/front/buy/index.html create mode 100644 modules/entry/front/buy/index.js create mode 100644 modules/entry/front/buy/locale/es.yml diff --git a/modules/entry/front/buy/index.html b/modules/entry/front/buy/index.html new file mode 100644 index 0000000000..af9eae30cf --- /dev/null +++ b/modules/entry/front/buy/index.html @@ -0,0 +1,68 @@ + +
Entry #{{$ctrl.entryData.id}} - {{$ctrl.entryData.supplier.nickname}}
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/modules/entry/front/buy/index.js b/modules/entry/front/buy/index.js new file mode 100644 index 0000000000..36e353229e --- /dev/null +++ b/modules/entry/front/buy/index.js @@ -0,0 +1,35 @@ +import ngModule from '../module'; +import Component from 'core/lib/component'; + +class Controller extends Component { + constructor($element, $) { + super($element, $); + } + + get entry() { + return this._entry; + } + + set entry(value) { + this._entry = value; + + if (value && value.id) + this.getEntryData(); + } + + getEntryData() { + return this.$http.get(`/api/Entries/${this.entry.id}/getEntry`).then(response => { + this.entryData = response.data; + }); + } +} + +Controller.$inject = ['$element', '$scope']; + +ngModule.component('vnEntryBuy', { + template: require('./index.html'), + controller: Controller, + bindings: { + entry: '<' + } +}); diff --git a/modules/entry/front/buy/locale/es.yml b/modules/entry/front/buy/locale/es.yml new file mode 100644 index 0000000000..8f2be1e447 --- /dev/null +++ b/modules/entry/front/buy/locale/es.yml @@ -0,0 +1 @@ +Buy: Lineas de entrada \ No newline at end of file diff --git a/modules/entry/front/index.js b/modules/entry/front/index.js index 0679b946b8..f0c845b149 100644 --- a/modules/entry/front/index.js +++ b/modules/entry/front/index.js @@ -7,3 +7,4 @@ import './descriptor'; import './card'; import './summary'; import './log'; +import './buy'; diff --git a/modules/entry/front/routes.json b/modules/entry/front/routes.json index 92d8930442..3dff616416 100644 --- a/modules/entry/front/routes.json +++ b/modules/entry/front/routes.json @@ -9,7 +9,8 @@ {"state": "entry.index", "icon": "icon-entry"} ], "card": [ - {"state": "entry.card.log", "icon": "history"} + {"state": "entry.card.log", "icon": "history"}, + {"state": "entry.card.buy", "icon": "icon-lines"} ] }, "routes": [ @@ -42,6 +43,14 @@ "state": "entry.card.log", "component": "vn-entry-log", "description": "Log" + }, { + "url" : "/buy", + "state": "entry.card.buy", + "component": "vn-entry-buy", + "description": "Buy", + "params": { + "entry": "$ctrl.entry" + } } ] } \ No newline at end of file From 5f0ace8f29a8565e86d6324aa4a8790ef394900f Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Fri, 6 Mar 2020 10:21:42 +0100 Subject: [PATCH 34/93] removed unused code --- modules/entry/front/buy/index.html | 69 +----------------------------- modules/entry/front/buy/index.js | 17 -------- modules/entry/front/routes.json | 4 +- 3 files changed, 3 insertions(+), 87 deletions(-) diff --git a/modules/entry/front/buy/index.html b/modules/entry/front/buy/index.html index af9eae30cf..8b13789179 100644 --- a/modules/entry/front/buy/index.html +++ b/modules/entry/front/buy/index.html @@ -1,68 +1 @@ - -
Entry #{{$ctrl.entryData.id}} - {{$ctrl.entryData.supplier.nickname}}
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ diff --git a/modules/entry/front/buy/index.js b/modules/entry/front/buy/index.js index 36e353229e..bc8788239a 100644 --- a/modules/entry/front/buy/index.js +++ b/modules/entry/front/buy/index.js @@ -5,23 +5,6 @@ class Controller extends Component { constructor($element, $) { super($element, $); } - - get entry() { - return this._entry; - } - - set entry(value) { - this._entry = value; - - if (value && value.id) - this.getEntryData(); - } - - getEntryData() { - return this.$http.get(`/api/Entries/${this.entry.id}/getEntry`).then(response => { - this.entryData = response.data; - }); - } } Controller.$inject = ['$element', '$scope']; diff --git a/modules/entry/front/routes.json b/modules/entry/front/routes.json index 3dff616416..084ff7bb22 100644 --- a/modules/entry/front/routes.json +++ b/modules/entry/front/routes.json @@ -9,8 +9,8 @@ {"state": "entry.index", "icon": "icon-entry"} ], "card": [ - {"state": "entry.card.log", "icon": "history"}, - {"state": "entry.card.buy", "icon": "icon-lines"} + {"state": "entry.card.buy", "icon": "icon-lines"}, + {"state": "entry.card.log", "icon": "history"} ] }, "routes": [ From b650643b38420f5412bff894d78b31af0d94c87e Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 6 Mar 2020 11:19:18 +0100 Subject: [PATCH 35/93] Removed param --- print/core/email.js | 1 - 1 file changed, 1 deletion(-) diff --git a/print/core/email.js b/print/core/email.js index ab09eab98f..faf744e772 100644 --- a/print/core/email.js +++ b/print/core/email.js @@ -80,7 +80,6 @@ class Email extends Component { const localeSubject = await this.getSubject(); const options = { to: this.args.recipient, - replyTo: this.args.replyTo, subject: localeSubject, html: rendered, attachments: attachments From ead7a20ecd779ff5b399b670b05514b564194a5a Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Fri, 6 Mar 2020 11:47:14 +0100 Subject: [PATCH 36/93] traductions --- db/tests/vn/workerTimeControlCheck.spec.js | 248 +++++++++++---------- 1 file changed, 125 insertions(+), 123 deletions(-) diff --git a/db/tests/vn/workerTimeControlCheck.spec.js b/db/tests/vn/workerTimeControlCheck.spec.js index 4e088b3693..620377291e 100644 --- a/db/tests/vn/workerTimeControlCheck.spec.js +++ b/db/tests/vn/workerTimeControlCheck.spec.js @@ -1,8 +1,8 @@ const app = require('vn-loopback/server/server'); const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; -fdescribe('worker workerTimeControl_check()', () => { - it('should throw an error if the worker does not belong to this department', async() => { +describe('worker workerTimeControl_check()', () => { + it(`should throw an error if the worker can't sign on that tablet`, async() => { let stmts = []; let stmt; const workerId = 110; @@ -27,7 +27,7 @@ fdescribe('worker workerTimeControl_check()', () => { expect(err.sqlMessage).toEqual('No perteneces a este departamento.'); }); - it('should EL TRABAJADOR ESTA EN EL DEPARTAMENTO Y TABLET CORRECTO', async() => { + it('should check that the worker can sign on that tablet', async() => { let stmts = []; let stmt; const workerId = 110; @@ -52,8 +52,9 @@ fdescribe('worker workerTimeControl_check()', () => { expect(err).not.toBeDefined(); }); - it('should throw an error if the worker NO HA CUMPLIDO EL DESCANSO DE 9h', async() => { - const workerIdBreak9Hours = 110; + it('should throw an error if the worker with a special category has not finished the 9h break', async() => { + // dayBreak to 9h in postgresql.professional_category + const workerId = 110; const tabletId = 1; let stmts = []; let stmt; @@ -65,13 +66,13 @@ fdescribe('worker workerTimeControl_check()', () => { VALUES (?,TIMESTAMPADD(HOUR,-17,NOW()),0,"in"), (?,TIMESTAMPADD(SECOND,-32399,NOW()),0,"out")`, [ - workerIdBreak9Hours, - workerIdBreak9Hours + workerId, + workerId ]); stmts.push(stmt); stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ - workerIdBreak9Hours, + workerId, tabletId ]); stmts.push(stmt); @@ -88,8 +89,9 @@ fdescribe('worker workerTimeControl_check()', () => { expect(error.sqlMessage).toEqual('Descansos 9 h'); }); - it('should throw an error if the worker HA CUMPLIDO EL DESCANSO de 9h', async() => { - const workerIdBreak9Hours = 110; + it('should check f the worker with a special category has finished the 9h break', async() => { + // dayBreak to 9h in postgresql.professional_category + const workerId = 110; const tabletId = 1; let stmts = []; let stmt; @@ -99,13 +101,13 @@ fdescribe('worker workerTimeControl_check()', () => { VALUES (?,TIMESTAMPADD(HOUR,-17,NOW()),0,"in"), (?,TIMESTAMPADD(SECOND,-32401,NOW()),0,"out")`, [ - workerIdBreak9Hours, - workerIdBreak9Hours + workerId, + workerId ]); stmts.push(stmt); stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ - workerIdBreak9Hours, + workerId, tabletId ]); stmts.push(stmt); @@ -123,8 +125,8 @@ fdescribe('worker workerTimeControl_check()', () => { expect(err).not.toBeDefined(); }); - it('should throw an error if the worker NO HA CUMPLIDO EL DESCANSO DE 12h', async() => { - const workerIdBreak12Hours = 109; + it('should throw an error if the worker has not finished the 12h break', async() => { + const workerId = 109; const tabletId = 1; let stmts = []; let stmt; @@ -136,13 +138,13 @@ fdescribe('worker workerTimeControl_check()', () => { VALUES (?,TIMESTAMPADD(HOUR,-20,NOW()),0,"in"), (?,TIMESTAMPADD(SECOND,-43199,NOW()),0,"out")`, [ - workerIdBreak12Hours, - workerIdBreak12Hours + workerId, + workerId ]); stmts.push(stmt); stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ - workerIdBreak12Hours, + workerId, tabletId ]); stmts.push(stmt); @@ -159,8 +161,8 @@ fdescribe('worker workerTimeControl_check()', () => { expect(error.sqlMessage).toEqual('Descansos 12 h'); }); - it('should throw an error if the worker HA CUMPLIDO EL DESCANSO de 12h', async() => { - const workerIdBreak12Hours = 109; + it('should throw an error if the worker has finished the 12h break', async() => { + const workerId = 109; const tabletId = 1; let stmts = []; let stmt; @@ -170,13 +172,13 @@ fdescribe('worker workerTimeControl_check()', () => { VALUES (?,TIMESTAMPADD(HOUR,-20,NOW()),0,"in"), (?,TIMESTAMPADD(SECOND,-43201,NOW()),0,"out")`, [ - workerIdBreak12Hours, - workerIdBreak12Hours + workerId, + workerId ]); stmts.push(stmt); stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ - workerIdBreak12Hours, + workerId, tabletId ]); stmts.push(stmt); @@ -194,8 +196,8 @@ fdescribe('worker workerTimeControl_check()', () => { expect(err).not.toBeDefined(); }); - it('should throw an error if FICHADAS IMPARES', async() => { - const workerIdBreak12Hours = 109; + it('should throw an error if the worker has odd entry records', async() => { + const workerId = 109; const tabletId = 1; let stmts = []; let stmt; @@ -204,12 +206,12 @@ fdescribe('worker workerTimeControl_check()', () => { stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction) VALUES (?,TIMESTAMPADD(HOUR,-24,NOW()),0,"in")`, [ - workerIdBreak12Hours + workerId ]); stmts.push(stmt); stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ - workerIdBreak12Hours, + workerId, tabletId ]); stmts.push(stmt); @@ -227,8 +229,8 @@ fdescribe('worker workerTimeControl_check()', () => { expect(err.sqlMessage).toEqual('Dias con fichadas impares'); }); - it('should throw an error if ESTA DE VACACIONES', async() => { - const workerIdBreak12Hours = 109; + it('should throw an error if the worker try to sign on a holiday day', async() => { + const workerId = 109; const tabletId = 1; let stmts = []; let stmt; @@ -239,20 +241,20 @@ fdescribe('worker workerTimeControl_check()', () => { stmt = new ParameterizedSQL(`INSERT INTO postgresql.calendar_employee(business_id,calendar_state_id,date) VALUES (?,1,CURDATE())`, [ - workerIdBreak12Hours + workerId ]); stmts.push(stmt); stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction) VALUES (?,TIMESTAMPADD(HOUR,-24,NOW()),0,"in"), (?,TIMESTAMPADD(HOUR,-20,NOW()),0,"out")`, [ - workerIdBreak12Hours, - workerIdBreak12Hours + workerId, + workerId ]); stmts.push(stmt); stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ - workerIdBreak12Hours, + workerId, tabletId ]); stmts.push(stmt); @@ -270,8 +272,8 @@ fdescribe('worker workerTimeControl_check()', () => { expect(err.sqlMessage).toEqual('Holidays'); }); - it('should throw an error if EL CONTRATO NO ESTA EN VIGOR', async() => { - const workerIdBreak12Hours = 109; + it('should throw an error if the worker try to sign with your contract ended', async() => { + const workerId = 109; const tabletId = 1; let stmts = []; let stmt; @@ -280,7 +282,7 @@ fdescribe('worker workerTimeControl_check()', () => { stmts.push('START TRANSACTION'); stmt = new ParameterizedSQL(`UPDATE postgresql.business SET date_end=DATE_ADD(CURDATE(), INTERVAL -1 DAY) WHERE business_id=?`, [ - workerIdBreak12Hours + workerId ]); stmts.push(stmt); @@ -288,13 +290,13 @@ fdescribe('worker workerTimeControl_check()', () => { VALUES (?,TIMESTAMPADD(HOUR,-24,NOW()),0,"in"), (?,TIMESTAMPADD(HOUR,-20,NOW()),0,"out")`, [ - workerIdBreak12Hours, - workerIdBreak12Hours + workerId, + workerId ]); stmts.push(stmt); stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ - workerIdBreak12Hours, + workerId, tabletId ]); stmts.push(stmt); @@ -312,8 +314,8 @@ fdescribe('worker workerTimeControl_check()', () => { expect(err.sqlMessage).toEqual('No hay un contrato en vigor'); }); - it('should throw an error if NO TIENE DESCANSO SEMANAL 36h', async() => { - const workerIdBreak12Hours = 109; + it('should throw an error if the worker has not finished the 36h weekly break', async() => { + const workerId = 109; const tabletId = 1; let stmts = []; let stmt; @@ -340,27 +342,27 @@ fdescribe('worker workerTimeControl_check()', () => { (?,TIMESTAMPADD(HOUR,-160,NOW()),0,"out"), (?,TIMESTAMPADD(HOUR,-192,NOW()),0,"in"), (?,TIMESTAMPADD(HOUR,-184,NOW()),0,"out")`, [ - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId ]); stmts.push(stmt); stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ - workerIdBreak12Hours, + workerId, tabletId ]); stmts.push(stmt); @@ -373,8 +375,8 @@ fdescribe('worker workerTimeControl_check()', () => { expect(result[warningMessageIndex][0].warning).toEqual('Descansos 36 h'); }); - it('should throw an error if CUMPLE DESCANSO SEMANAL 36h', async() => { - const workerIdBreak12Hours = 109; + it('should check if the worker has finished the 36h weekly break', async() => { + const workerId = 109; const tabletId = 1; let stmts = []; let stmt; @@ -393,19 +395,19 @@ fdescribe('worker workerTimeControl_check()', () => { (?,TIMESTAMPADD(HOUR,-64,NOW()),0,"out"), (?,TIMESTAMPADD(HOUR,-96,NOW()),0,"in"), (?,TIMESTAMPADD(HOUR,-88,NOW()),0,"out")`, [ - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId ]); stmts.push(stmt); stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ - workerIdBreak12Hours, + workerId, tabletId ]); stmts.push(stmt); @@ -419,8 +421,8 @@ fdescribe('worker workerTimeControl_check()', () => { expect(result[warningMessageIndex][0].warning).toBe(null); }); - it('should throw an error if NO TIENE DESCANSO SEMANAL 72h', async() => { - const workerIdBreak12Hours = 109; + it('should throw an error if the worker has not finished the 72h biweekly break', async() => { + const workerId = 109; const tabletId = 1; let stmts = []; let stmt; @@ -453,35 +455,35 @@ fdescribe('worker workerTimeControl_check()', () => { (?,TIMESTAMPADD(HOUR,-256,NOW()),0,"out"), (?,TIMESTAMPADD(HOUR,-289,NOW()),0,"in"), (?,TIMESTAMPADD(HOUR,-280,NOW()),0,"out")`, [ - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId ]); stmts.push(stmt); stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ - workerIdBreak12Hours, + workerId, tabletId ]); stmts.push(stmt); @@ -501,8 +503,8 @@ fdescribe('worker workerTimeControl_check()', () => { expect(err.sqlMessage).toEqual('Descansos 72 h'); }); - it('should throw an error if CUMPLE DESCANSO QUINCENAL 72h', async() => { - const workerIdBreak12Hours = 109; + it('should check if the worker has finished the 72h biweekly break', async() => { + const workerId = 109; const tabletId = 1; let stmts = []; let stmt; @@ -535,35 +537,35 @@ fdescribe('worker workerTimeControl_check()', () => { (?,TIMESTAMPADD(HOUR,-256,NOW()),0,"out"), (?,TIMESTAMPADD(HOUR,-288,NOW()),0,"in"), (?,TIMESTAMPADD(HOUR,-280,NOW()),0,"out")`, [ - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours, - workerIdBreak12Hours + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId ]); stmts.push(stmt); stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ - workerIdBreak12Hours, + workerId, tabletId ]); stmts.push(stmt); From da6b3bc5c89e563f3e960a6cc145039ae77bf096 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Fri, 6 Mar 2020 12:01:42 +0100 Subject: [PATCH 37/93] fix test --- .../back/methods/client/specs/activeWorkersWithRole.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/client/back/methods/client/specs/activeWorkersWithRole.spec.js b/modules/client/back/methods/client/specs/activeWorkersWithRole.spec.js index 0004b2156b..8e9af247af 100644 --- a/modules/client/back/methods/client/specs/activeWorkersWithRole.spec.js +++ b/modules/client/back/methods/client/specs/activeWorkersWithRole.spec.js @@ -7,7 +7,7 @@ describe('Client activeWorkersWithRole', () => { let isSalesPerson = await app.models.Account.hasRole(result[0].id, 'salesPerson'); - expect(result.length).toEqual(14); + expect(result.length).toEqual(15); expect(isSalesPerson).toBeTruthy(); }); @@ -17,7 +17,7 @@ describe('Client activeWorkersWithRole', () => { let isBuyer = await app.models.Account.hasRole(result[0].id, 'buyer'); - expect(result.length).toEqual(11); + expect(result.length).toEqual(13); expect(isBuyer).toBeTruthy(); }); }); From 6aa1a5137b394521719184550396a5486facad6b Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Fri, 6 Mar 2020 13:00:03 +0100 Subject: [PATCH 38/93] fix report --- print/templates/reports/driver-route/driver-route.js | 1 - 1 file changed, 1 deletion(-) diff --git a/print/templates/reports/driver-route/driver-route.js b/print/templates/reports/driver-route/driver-route.js index 498666cc63..8785527bc5 100755 --- a/print/templates/reports/driver-route/driver-route.js +++ b/print/templates/reports/driver-route/driver-route.js @@ -32,7 +32,6 @@ module.exports = { LEFT JOIN agencyMode am ON am.id = r.agencyModeFk WHERE r.id = :routeId`, {routeId: id}); }, - // Redmine #1855 Replace function Averiguar_ComercialCliente_Id() fetchTickets(routeId) { return db.rawSql( `SELECT From 3c41c4656b47eab40559674d5c66e45a324c49bf Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 6 Mar 2020 13:06:01 +0100 Subject: [PATCH 39/93] 2111 - Drop tickets to route ticket list --- loopback/locale/es.json | 3 +- modules/client/front/fiscal-data/index.js | 3 +- .../client/front/fiscal-data/index.spec.js | 3 +- modules/route/front/tickets/index.html | 6 +- modules/route/front/tickets/index.js | 57 ++++++++---- modules/route/front/tickets/index.spec.js | 86 ++++++++++++++++--- modules/route/front/tickets/locale/es.yml | 3 +- modules/travel/front/summary/index.spec.js | 1 - 8 files changed, 127 insertions(+), 35 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 7577c5349a..06c708981e 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -127,5 +127,6 @@ "Sent units from ticket": "Envio *{{quantity}}* unidades de [{{concept}} (#{{itemId}})]({{{itemUrl}}}) a *\"{{nickname}}\"* provenientes del ticket id [#{{ticketId}}]({{{ticketUrl}}})", "Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}", "ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto", - "Distance must be lesser than 1000": "La distancia debe ser inferior a 1000" + "Distance must be lesser than 1000": "La distancia debe ser inferior a 1000", + "This ticket is deleted": "This ticket is deleted" } \ No newline at end of file diff --git a/modules/client/front/fiscal-data/index.js b/modules/client/front/fiscal-data/index.js index 7fdb03dda3..f302606dd0 100644 --- a/modules/client/front/fiscal-data/index.js +++ b/modules/client/front/fiscal-data/index.js @@ -45,7 +45,8 @@ export default class Controller extends Component { this.$.confirmDuplicatedClient.show(); }).catch(error => { if (error.status == 404) - this.save(); + return this.save(); + throw error; }); } diff --git a/modules/client/front/fiscal-data/index.spec.js b/modules/client/front/fiscal-data/index.spec.js index 30ff80d043..a884f3e97a 100644 --- a/modules/client/front/fiscal-data/index.spec.js +++ b/modules/client/front/fiscal-data/index.spec.js @@ -67,9 +67,8 @@ describe('Client', () => { ] } }; - const expectedClient = {id: 102}; const filter = encodeURIComponent(JSON.stringify(filterObj)); - $httpBackend.expect('GET', `Clients/findOne?filter=${filter}`).respond(expectedClient); + $httpBackend.expect('GET', `Clients/findOne?filter=${filter}`).respond(404); controller.checkExistingClient(); $httpBackend.flush(); }); diff --git a/modules/route/front/tickets/index.html b/modules/route/front/tickets/index.html index 4a0e581126..c4e4f8d7e4 100644 --- a/modules/route/front/tickets/index.html +++ b/modules/route/front/tickets/index.html @@ -1,6 +1,6 @@ @@ -23,7 +23,7 @@ - + @@ -86,7 +86,7 @@ diff --git a/modules/route/front/tickets/index.js b/modules/route/front/tickets/index.js index e516a5fa6e..f363302359 100644 --- a/modules/route/front/tickets/index.js +++ b/modules/route/front/tickets/index.js @@ -1,26 +1,24 @@ import ngModule from '../module'; +import Section from 'salix/components/section'; import './style.scss'; -class Controller { - constructor($stateParams, $scope, $translate, $http, vnApp, $filter) { - this.$translate = $translate; - this.$stateParams = $stateParams; - this.$ = $scope; - this.$http = $http; - this.vnApp = vnApp; +class Controller extends Section { + constructor($element, $scope, $filter) { + super($element, $scope); + this.$filter = $filter; } + get route() { + return this._route; + } + set route(value) { this._route = value; if (value) this.buildPossibleTicketsFilter(); } - get route() { - return this._route; - } - get isChecked() { if (this.tickets) { for (let instance of this.tickets) @@ -104,7 +102,6 @@ class Controller { }); } - showDeleteConfirm(id) { this.selectedTicket = id; this.$.confirm.show(); @@ -122,7 +119,7 @@ class Controller { } updateVolume() { - let url = `Routes/${this.$stateParams.id}/updateVolume`; + let url = `Routes/${this.$params.id}/updateVolume`; this.$http.post(url).then(() => { this.card.reload(); this.$.model.refresh(); @@ -130,7 +127,7 @@ class Controller { } guessPriority() { - let query = `Routes/${this.$stateParams.id}/guessPriority/`; + let query = `Routes/${this.$params.id}/guessPriority/`; this.$http.get(query).then(() => { this.vnApp.showSuccess(this.$translate.instant('Order changed')); this.$.model.refresh(); @@ -171,9 +168,39 @@ class Controller { } return Promise.resolve(); } + + onDrop($event) { + const ticketId = $event.dataTransfer.getData('Text'); + + if (isNaN(ticketId)) { + const regexp = new RegExp(/\/ticket\/([0-9]+)\//i); + const matches = ticketId.match(regexp); + + if (matches && matches.length) + this.insert(matches[1]); + else + this.vnApp.showError(this.$translate.instant('Ticket not found')); + } + + if (!isNaN(ticketId)) + this.insert(ticketId); + } + + insert(id) { + const params = {routeFk: this.route.id}; + this.$http.patch(`Tickets/${id}`, params).then(() => { + this.vnApp.showSuccess(this.$translate.instant('Data saved!')); + this.$.model.refresh(); + this.card.reload(); + }).catch(error => { + if (error.status == 404) + return this.vnApp.showError(this.$translate.instant('Ticket not found')); + throw error; + }); + } } -Controller.$inject = ['$stateParams', '$scope', '$translate', '$http', 'vnApp', '$filter']; +Controller.$inject = ['$element', '$scope', '$filter']; ngModule.component('vnRouteTickets', { template: require('./index.html'), diff --git a/modules/route/front/tickets/index.spec.js b/modules/route/front/tickets/index.spec.js index d1313dd659..f3c02cf511 100644 --- a/modules/route/front/tickets/index.spec.js +++ b/modules/route/front/tickets/index.spec.js @@ -1,14 +1,20 @@ -import './index.js'; +import './index'; describe('Route', () => { let controller; let $httpBackend; + let $scope; beforeEach(ngModule('route')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => { + beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { $httpBackend = _$httpBackend_; - controller = $componentController('vnRouteTickets'); + $scope = $rootScope.$new(); + const $element = angular.element(''); + controller = $componentController('vnRouteTickets', {$element, $scope}); + controller.route = {id: 1}; + controller.$.model = {refresh: () => {}}; + controller.card = {reload: () => {}}; })); describe('route setter/getter', () => { @@ -86,7 +92,6 @@ describe('Route', () => { describe('setPriority()', () => { it('should set a ticket priority', () => { - controller.$.model = {refresh: () => {}}; jest.spyOn(controller.$.model, 'refresh'); jest.spyOn(controller.vnApp, 'showSuccess'); const ticketId = 1; @@ -175,16 +180,14 @@ describe('Route', () => { describe('updateVolume()', () => { it('should perform a POST query then call both reload and refresh methods', () => { - controller.$.model = {refresh: () => {}}; - controller.card = {reload: () => {}}; - controller.$stateParamds = {id: 999}; + controller.$params = {id: 999}; jest.spyOn(controller.$.model, 'refresh'); jest.spyOn(controller.card, 'reload'); let ticketId = 1; controller.selectedTicket = ticketId; - const url = `Routes/${controller.$stateParams.id}/updateVolume`; + const url = `Routes/${controller.$params.id}/updateVolume`; $httpBackend.expectPOST(url).respond('ok'); controller.updateVolume(); $httpBackend.flush(); @@ -196,12 +199,11 @@ describe('Route', () => { describe('guessPriority()', () => { it('should perform a GET query then call both refresh and showSuccess methods', () => { - controller.$.model = {refresh: () => {}}; jest.spyOn(controller.$.model, 'refresh'); jest.spyOn(controller.vnApp, 'showSuccess'); - controller.$stateParams = {id: 99}; + controller.$params = {id: 99}; - const url = `Routes/${controller.$stateParams.id}/guessPriority/`; + const url = `Routes/${controller.$params.id}/guessPriority/`; $httpBackend.expectGET(url).respond('ok'); controller.guessPriority(); $httpBackend.flush(); @@ -288,4 +290,66 @@ describe('Route', () => { expect(controller.setTicketsRoute('cancel')).toEqual(jasmine.any(Promise)); }); }); + + describe('onDrop()', () => { + it('should call the insert method when dragging a ticket number', () => { + jest.spyOn(controller, 'insert'); + + const expectedTicketId = '11'; + const draggedElement = '11'; + const $event = { + dataTransfer: { + getData: () => draggedElement + } + }; + controller.onDrop($event); + + expect(controller.insert).toHaveBeenCalledWith(expectedTicketId); + }); + + it('should call the insert method when dragging a ticket link', () => { + jest.spyOn(controller, 'insert'); + + const expectedTicketId = '11'; + const draggedElement = 'http://arkamcity.com/#!/ticket/11/summary'; + const $event = { + dataTransfer: { + getData: () => draggedElement + } + }; + controller.onDrop($event); + + expect(controller.insert).toHaveBeenCalledWith(expectedTicketId); + }); + + it('should throw an error when dragging an invalid ticket link', () => { + jest.spyOn(controller.vnApp, 'showError'); + + const draggedElement = 'http://arkamcity.com/#!/item/11/summary'; + const $event = { + dataTransfer: { + getData: () => draggedElement + } + }; + controller.onDrop($event); + + expect(controller.vnApp.showError).toHaveBeenCalledWith('Ticket not found'); + }); + }); + + describe('insert()', () => { + it('should make a HTTP patch query and then call both refresh and showSuccess methods', () => { + jest.spyOn(controller.$.model, 'refresh').mockReturnThis(); + jest.spyOn(controller.vnApp, 'showSuccess'); + + const ticketId = 11; + + $httpBackend.expect('PATCH', `Tickets/11`).respond({id: 11}); + controller.insert(ticketId); + $httpBackend.flush(); + + expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); + expect(controller.$.model.refresh).toHaveBeenCalledWith(); + }); + }); }); diff --git a/modules/route/front/tickets/locale/es.yml b/modules/route/front/tickets/locale/es.yml index 02f9eed08c..b9892a2997 100644 --- a/modules/route/front/tickets/locale/es.yml +++ b/modules/route/front/tickets/locale/es.yml @@ -5,4 +5,5 @@ Order changed: Orden cambiado Delete ticket from route?: ¿Quitar el ticket de la ruta? Sort routes: Ordenar rutas Add ticket: Añadir ticket -Tickets to add: Tickets a añadir \ No newline at end of file +Tickets to add: Tickets a añadir +Ticket not found: No se ha encontrado el ticket \ No newline at end of file diff --git a/modules/travel/front/summary/index.spec.js b/modules/travel/front/summary/index.spec.js index 202c666377..9b041f22b9 100644 --- a/modules/travel/front/summary/index.spec.js +++ b/modules/travel/front/summary/index.spec.js @@ -26,7 +26,6 @@ describe('component vnTravelSummary', () => { jest.spyOn(controller, 'getThermographs'); controller.travel = {id: 99}; - expect(controller._travel.id).toEqual(99); expect(controller.getTravel).toHaveBeenCalledWith(); expect(controller.getEntries).toHaveBeenCalledWith(); From 0d7e41b38bfb6ab3006f209d041e9631cbc296b7 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 6 Mar 2020 13:28:31 +0100 Subject: [PATCH 40/93] Added translation --- loopback/locale/es.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 06c708981e..fe95bc0650 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -128,5 +128,5 @@ "Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}", "ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto", "Distance must be lesser than 1000": "La distancia debe ser inferior a 1000", - "This ticket is deleted": "This ticket is deleted" + "This ticket is deleted": "Este ticket está eliminado" } \ No newline at end of file From e0f87b4b06306556cfcb907daee1355783d08c03 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Sun, 8 Mar 2020 17:42:49 +0100 Subject: [PATCH 41/93] http-click unit test --- front/core/directives/http-click.js | 2 +- .../core/directives/specs/http-click.spec.js | 70 ++++++++++++------- 2 files changed, 46 insertions(+), 26 deletions(-) diff --git a/front/core/directives/http-click.js b/front/core/directives/http-click.js index c994878eec..4fd9322896 100644 --- a/front/core/directives/http-click.js +++ b/front/core/directives/http-click.js @@ -17,7 +17,7 @@ export function directive($parse) { const controller = element.$ctrl; controller.$oldDisabled = controller.disabled; controller.disabled = true; - console.log(cb()); + cb($scope).finally(() => { if (!controller.$oldDisabled) controller.disabled = false; diff --git a/front/core/directives/specs/http-click.spec.js b/front/core/directives/specs/http-click.spec.js index e509251776..d6b3d9e3b2 100644 --- a/front/core/directives/specs/http-click.spec.js +++ b/front/core/directives/specs/http-click.spec.js @@ -1,46 +1,66 @@ fdescribe('Directive http-click', () => { let $scope; - let $element; let element; let compile; - let controller; beforeEach(ngModule('vnCore')); compile = (_element, _childElement) => { - inject(($componentController, $compile, $rootScope) => { + inject(($compile, $rootScope) => { $scope = $rootScope.$new(); element = angular.element(_element); $compile(element)($scope); - - /* controller = element.controller('vnHttpClick'); - controller.myEvent = () => { - return Promise.resolve('hola'); - }; */ - - controller = $componentController('vnHttpClick', {$element: element, $scope: $scope}); - controller.myEvent = () => { - return Promise.resolve('hola'); - }; - $scope.$digest(); }); }; - beforeEach(angular.mock.inject(($rootScope, $compile) => { - $element = $compile('')($rootScope); - controller = $element.controller('vnHttpClick'); - })); - - it('should call focus function on the element', () => { - // jest.spyOn(controller, 'myEvent').mockReturnValue(Promise.resolve()); - - let html = ``; + xit('should call click function on the element, disable it and then enable it again', () => { + let html = ``; compile(html); - element[0].$ctrl = {}; + const myPromise = new Promise(resolve => resolve()); + $scope.myEvent = () => { + return myPromise; + }; + + element[0].$ctrl = {disabled: false}; element[0].click(); - // expect($element[0].focus).toHaveBeenCalledWith(); + expect(element[0].$ctrl.disabled).toEqual(true); + + let finalValue; + myPromise.then(() => { + finalValue = 'called!'; + + expect(element[0].$ctrl.disabled).toEqual(false); + }).finally(() => { + expect(finalValue).toEqual('called!'); + }); + }); + + it('should call click function on the element and not disable it', () => { + let html = ``; + compile(html); + + const myPromise = new Promise(resolve => resolve()); + $scope.myEvent = () => { + return myPromise; + }; + + element[0].$ctrl = {disabled: true}; + element[0].click(); + + expect(element[0].$ctrl.disabled).toEqual(true); + + let finalValue; + myPromise.then(() => { + finalValue = 'called!'; + + expect(element[0].$ctrl.disabled).toEqual(false); + }).finally(() => { + expect(finalValue).toEqual('called!'); + }).catch(err => { + console.log(err); + }); }); }); From d173ab6a2be019dda2d99bf85d171d14df6996f4 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Mon, 9 Mar 2020 11:50:23 +0100 Subject: [PATCH 42/93] =?UTF-8?q?2171=20-=20Mostrar=20bot=C3=B3n=20"Pago?= =?UTF-8?q?=20a=20cuenta"=20en=20=C3=ADndice=20de=20tickets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/core/components/button/style.scss | 27 +++++++++++ modules/client/back/methods/sms/send.js | 1 - modules/ticket/front/index/index.html | 40 +++++++++-------- modules/ticket/front/index/index.js | 57 +++++++++++++++--------- modules/ticket/front/index/index.spec.js | 30 +++++++++++-- 5 files changed, 111 insertions(+), 44 deletions(-) diff --git a/front/core/components/button/style.scss b/front/core/components/button/style.scss index 032c88cbb8..f799a21ae9 100644 --- a/front/core/components/button/style.scss +++ b/front/core/components/button/style.scss @@ -50,6 +50,17 @@ } } } + &.message { + color: white; + background-color: $color-bg-dark; + + &:not(.disabled) { + &:hover, + &:focus { + background-color: lighten($color-bg-dark, 10%); + } + } + } &.flat { color: $color-button; background-color: transparent; @@ -75,6 +86,22 @@ & > button > span { display: none; } + + &.xs { + font-size: 0.5em; + } + + &.sm { + font-size: 0.7em; + } + + &.md { + font-size: 0.9em; + } + + &.lg { + font-size: 1.2em; + } } &.disabled { opacity: .7; diff --git a/modules/client/back/methods/sms/send.js b/modules/client/back/methods/sms/send.js index af956650d5..153036e058 100644 --- a/modules/client/back/methods/sms/send.js +++ b/modules/client/back/methods/sms/send.js @@ -47,7 +47,6 @@ module.exports = Self => { let xmlParsed; let status; - try { if (process.env.NODE_ENV !== 'production') { status = { diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html index b303c3ae70..ee218df56e 100644 --- a/modules/ticket/front/index/index.html +++ b/modules/ticket/front/index/index.html @@ -8,17 +8,6 @@ - - - - - - - + +
+ + + + + + + + + +
+ diff --git a/modules/ticket/front/index/index.js b/modules/ticket/front/index/index.js index 05dc23c085..563265ab31 100644 --- a/modules/ticket/front/index/index.js +++ b/modules/ticket/front/index/index.js @@ -1,4 +1,5 @@ import ngModule from '../module'; +import UserError from 'core/lib/user-error'; import './style.scss'; export default class Controller { @@ -9,33 +10,45 @@ export default class Controller { this.$stateParams = $stateParams; this.$state = $state; this.selectedTicket = null; - this.moreOptions = [ - { - name: 'Payment on account...', - always: true, - callback: () => { - this.setBalanceCreateDialog(); - this.$.balanceCreateDialog.show(); - } - } - ]; } - setBalanceCreateDialog() { - let data = this.$.tickets; - let description = []; + openBalanceDialog() { + const checkedTickets = this.checked; + const description = []; this.$.balanceCreateDialog.amountPaid = 0; - if (data) { - for (let i = 0; i < data.length; i++) { - if (data[i].checked) { - this.$.balanceCreateDialog.amountPaid += data[i].total; - this.$.balanceCreateDialog.clientFk = data[i].clientFk; - description.push(`${data[i].id}`); - } - } + + const firstTicketClientId = checkedTickets[0].clientFk; + const isSameClient = checkedTickets.every(ticket => { + return ticket.clientFk == firstTicketClientId; + }); + + if (!isSameClient) + throw new UserError('You cannot make a payment on account from multiple clients'); + + for (let ticket of checkedTickets) { + this.$.balanceCreateDialog.amountPaid += ticket.total; + this.$.balanceCreateDialog.clientFk = ticket.clientFk; + description.push(`${ticket.id}`); } + this.$.balanceCreateDialog.description = 'Albaran: '; this.$.balanceCreateDialog.description += description.join(', '); + this.$.balanceCreateDialog.show(); + } + + get checked() { + const tickets = this.$.tickets || []; + const checkedLines = []; + for (let ticket of tickets) { + if (ticket.checked) + checkedLines.push(ticket); + } + + return checkedLines; + } + + get totalChecked() { + return this.checked.length; } getScopeDates(days) { @@ -51,7 +64,7 @@ export default class Controller { onSearch(params) { if (params) { - if (typeof(params.scopeDays) === 'number') + if (typeof (params.scopeDays) === 'number') Object.assign(params, this.getScopeDates(params.scopeDays)); // Set default params to 1 scope days else if (Object.entries(params).length == 0) diff --git a/modules/ticket/front/index/index.spec.js b/modules/ticket/front/index/index.spec.js index 987accd026..6b0b42ffde 100644 --- a/modules/ticket/front/index/index.spec.js +++ b/modules/ticket/front/index/index.spec.js @@ -82,12 +82,14 @@ describe('Component vnTicketIndex', () => { }); }); - describe('setBalanceCreateDialog()', () => { + describe('openBalanceDialog()', () => { it('should fill the object for the component balanceCreateDialog', () => { + controller.$.balanceCreateDialog = {show: () => {}}; + jest.spyOn(controller.$.balanceCreateDialog, 'show').mockReturnThis(); + controller.$.tickets = tickets; - controller.$.balanceCreateDialog = {}; controller.$.balanceCreateDialog.amountPaid = 0; - controller.setBalanceCreateDialog(); + controller.openBalanceDialog(); let description = controller.$.balanceCreateDialog.description; let amountPaid = controller.$.balanceCreateDialog.amountPaid; @@ -96,4 +98,26 @@ describe('Component vnTicketIndex', () => { expect(amountPaid).toEqual(50.5); }); }); + + describe('checked()', () => { + it('should return an array of checked tickets', () => { + controller.$.tickets = tickets; + const result = controller.checked; + const firstRow = result[0]; + const secondRow = result[1]; + + expect(result.length).toEqual(2); + expect(firstRow.id).toEqual(2); + expect(secondRow.id).toEqual(3); + }); + }); + + describe('totalChecked()', () => { + it('should return the total number of checked tickets', () => { + controller.$.tickets = tickets; + const result = controller.checked; + + expect(result.length).toEqual(2); + }); + }); }); From bbeca87295bb0d36f553218b6e44679e680ee2b9 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Mon, 9 Mar 2020 12:22:55 +0100 Subject: [PATCH 43/93] 2172 - Added unit test --- front/core/directives/specs/http-click.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/front/core/directives/specs/http-click.spec.js b/front/core/directives/specs/http-click.spec.js index d6b3d9e3b2..ac8e770757 100644 --- a/front/core/directives/specs/http-click.spec.js +++ b/front/core/directives/specs/http-click.spec.js @@ -14,7 +14,7 @@ fdescribe('Directive http-click', () => { }); }; - xit('should call click function on the element, disable it and then enable it again', () => { + it('should call click function on the element, disable it and then enable it again', () => { let html = ``; compile(html); @@ -56,7 +56,7 @@ fdescribe('Directive http-click', () => { myPromise.then(() => { finalValue = 'called!'; - expect(element[0].$ctrl.disabled).toEqual(false); + expect(element[0].$ctrl.disabled).toEqual(true); }).finally(() => { expect(finalValue).toEqual('called!'); }).catch(err => { From 41d25078b8ad856b91c20141e5238626bb70c835 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Mon, 9 Mar 2020 12:23:32 +0100 Subject: [PATCH 44/93] Removed focus --- front/core/directives/specs/http-click.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/core/directives/specs/http-click.spec.js b/front/core/directives/specs/http-click.spec.js index ac8e770757..70a79bcffc 100644 --- a/front/core/directives/specs/http-click.spec.js +++ b/front/core/directives/specs/http-click.spec.js @@ -1,4 +1,4 @@ -fdescribe('Directive http-click', () => { +describe('Directive http-click', () => { let $scope; let element; let compile; From 209251bf8bd79b1ac3c1184430006d1d0585f58a Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Mon, 9 Mar 2020 14:11:43 +0100 Subject: [PATCH 45/93] 2173 - descriptor_quicklink --- front/salix/components/descriptor/index.html | 24 ++++--------------- .../front/basic-data/step-two/locale/es.yml | 3 ++- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/front/salix/components/descriptor/index.html b/front/salix/components/descriptor/index.html index 3804be627f..4a50be4307 100644 --- a/front/salix/components/descriptor/index.html +++ b/front/salix/components/descriptor/index.html @@ -1,24 +1,8 @@ - + ui-sref="{{::button.state}}"> - - - - - - - - + icon="{{::button.icon}}"> \ No newline at end of file diff --git a/modules/ticket/front/basic-data/step-two/locale/es.yml b/modules/ticket/front/basic-data/step-two/locale/es.yml index 47fc87b0c0..49dd7fd808 100644 --- a/modules/ticket/front/basic-data/step-two/locale/es.yml +++ b/modules/ticket/front/basic-data/step-two/locale/es.yml @@ -1,4 +1,5 @@ Price (PPU): Precio (Ud.) New (PPU): Nuevo (Ud.) Difference: Diferencia -Charge difference to: Cargar diferencia a \ No newline at end of file +Charge difference to: Cargar diferencia a +The ticket has been unrouted: El ticket ha sido desenrutado \ No newline at end of file From ec97ab3e21a831eb97c0b1c638c1c997882bb43b Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Mon, 9 Mar 2020 16:47:02 +0100 Subject: [PATCH 46/93] log with narrow and wide widths --- e2e/helpers/selectors.js | 1 + e2e/paths/02-client/14_balance.spec.js | 3 +- e2e/paths/05-ticket/17_log.spec.js | 65 ++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 e2e/paths/05-ticket/17_log.spec.js diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 2849452415..2131704ab3 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -525,6 +525,7 @@ export default { }, ticketLog: { + firstTD: 'vn-ticket-log vn-table vn-td:nth-child(1)', logButton: 'vn-left-menu a[ui-sref="ticket.card.log"]', changedBy: 'vn-ticket-log > vn-log vn-tr:nth-child(1) > vn-td:nth-child(2) > span', actionTaken: 'vn-ticket-log > vn-log vn-td:nth-child(1) > div > div:nth-child(3) > span.value', diff --git a/e2e/paths/02-client/14_balance.spec.js b/e2e/paths/02-client/14_balance.spec.js index f45937debf..0d020831eb 100644 --- a/e2e/paths/02-client/14_balance.spec.js +++ b/e2e/paths/02-client/14_balance.spec.js @@ -35,7 +35,7 @@ describe('Client balance path', () => { await page.clearInput(selectors.globalItems.userConfigThirdAutocomplete); let result = await page.waitForLastSnackbar(); - expect(result).toEqual('Data saved!'); + expect(result).toContain('Data saved!'); }); it('should click the new payment button', async() => { @@ -63,7 +63,6 @@ describe('Client balance path', () => { let firstBalanceLine = await page .waitToGetProperty(selectors.clientBalance.firstBalanceLine, 'innerText'); - expect(company).toEqual('VNL'); expect(firstBalanceLine).toContain('0.00'); }); diff --git a/e2e/paths/05-ticket/17_log.spec.js b/e2e/paths/05-ticket/17_log.spec.js new file mode 100644 index 0000000000..2008d022e3 --- /dev/null +++ b/e2e/paths/05-ticket/17_log.spec.js @@ -0,0 +1,65 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Ticket log path', () => { + let browser; + let page; + const ticketId = '5'; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should navigate to the target ticket notes section', async() => { + await page.loginAndModule('employee', 'ticket'); + await page.accessToSearchResult(ticketId); + await page.accessToSection('ticket.card.observation'); + let url = await page.expectURL('/observation'); + + expect(url).toBe(true); + }); + + it('should create a new note for the test', async() => { + await page.waitToClick(selectors.ticketNotes.addNoteButton); + await page.autocompleteSearch(selectors.ticketNotes.firstNoteType, 'observation one'); + await page.write(selectors.ticketNotes.firstDescription, 'description'); + await page.waitToClick(selectors.ticketNotes.submitNotesButton); + const result = await page.waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); + }); + + it('should navigate to the log section', async() => { + await page.accessToSection('ticket.card.log'); + let url = await page.expectURL('/log'); + + expect(url).toBe(true); + }); + + it('should set the viewport width to 1920 to see the table full width', async() => { + await page.setViewport({ + width: 1920, + height: 0, + }); + + const result = await page.waitToGetProperty(selectors.ticketLog.firstTD, 'innerText'); + + expect(result.length).not.toBeGreaterThan('20'); + }); + + it('should set the viewport width to 800 to see the table shrink and move data to the 1st column', async() => { + await page.setViewport({ + width: 800, + height: 0, + }); + + const result = await page.waitToGetProperty(selectors.ticketLog.firstTD, 'innerText'); + + expect(result.length).toBeGreaterThan('20'); + }); +}); From 8688ecc81003e7cd199b8cd00b239d179a8b08ac Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Tue, 10 Mar 2020 07:38:21 +0100 Subject: [PATCH 47/93] eliminado el campo id en advanced search --- e2e/helpers/selectors.js | 2 +- modules/claim/front/search-panel/index.html | 17 +++++------------ modules/client/front/search-panel/index.html | 17 +++++------------ modules/order/front/search-panel/index.html | 5 ----- modules/order/front/search-panel/locale/es.yml | 2 +- modules/ticket/front/search-panel/index.html | 5 ----- modules/ticket/front/search-panel/locale/es.yml | 2 +- 7 files changed, 13 insertions(+), 37 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 2849452415..93dd6c65d9 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -366,7 +366,7 @@ export default { ticketsIndex: { openAdvancedSearchButton: 'vn-searchbar .append vn-icon[icon="arrow_drop_down"]', advancedSearchInvoiceOut: 'vn-ticket-search-panel vn-textfield[ng-model="filter.refFk"]', - newTicketButton: 'vn-ticket-index > a', + newTicketButton: 'vn-ticket-index a', searchResult: 'vn-ticket-index vn-card > vn-table > div > vn-tbody > a.vn-tr', searchWeeklyResult: 'vn-ticket-weekly-index vn-table vn-tbody > vn-tr', searchResultDate: 'vn-ticket-index vn-table vn-tbody > a:nth-child(1) > vn-td:nth-child(5)', diff --git a/modules/claim/front/search-panel/index.html b/modules/claim/front/search-panel/index.html index 93d3db4559..f50af1e5ad 100644 --- a/modules/claim/front/search-panel/index.html +++ b/modules/claim/front/search-panel/index.html @@ -10,24 +10,17 @@ + + - - - - - - - - - - - - + + - - - - Date: Tue, 10 Mar 2020 11:36:49 +0100 Subject: [PATCH 48/93] Removed autocomplete completion for chrome --- front/core/components/autocomplete/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/front/core/components/autocomplete/index.js b/front/core/components/autocomplete/index.js index 38c85db574..1d3c6e2431 100755 --- a/front/core/components/autocomplete/index.js +++ b/front/core/components/autocomplete/index.js @@ -23,6 +23,7 @@ export default class Autocomplete extends Field { this._selection = null; this.input = this.element.querySelector('input'); + this.input.setAttribute('autocomplete', 'off'); } $postLink() { From 6d437d0e2ef56e958815bc022309130abeee4f18 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Tue, 10 Mar 2020 11:46:58 +0100 Subject: [PATCH 49/93] Allow empty agency on ticket creation --- modules/ticket/back/methods/ticket/new.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/ticket/back/methods/ticket/new.js b/modules/ticket/back/methods/ticket/new.js index db5310f7c2..7c4b3adb45 100644 --- a/modules/ticket/back/methods/ticket/new.js +++ b/modules/ticket/back/methods/ticket/new.js @@ -6,7 +6,7 @@ module.exports = Self => { accessType: 'WRITE', accepts: [{ arg: 'clientId', - type: 'Number', + type: 'number', description: `The client id filter`, required: true }, @@ -22,29 +22,29 @@ module.exports = Self => { }, { arg: 'warehouseId', - type: 'Number', + type: 'number', description: `The warehouse id filter`, required: true }, { arg: 'companyId', - type: 'Number', + type: 'number', description: `The company id filter` }, { arg: 'addressId', - type: 'Number', + type: 'number', description: `The address id filter`, required: true }, { arg: 'agencyModeId', - type: 'Number', + type: 'any', description: `The agencyMode id filter` }, { arg: 'routeId', - type: 'Number', + type: 'number', description: `The route id filter` }], returns: { From 4a5d97996e023db54d703aeb0fd89caf0e58c475 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Tue, 10 Mar 2020 14:09:26 +0100 Subject: [PATCH 50/93] travel.index clonar --- front/core/components/watcher/watcher.js | 22 +++++++++-- loopback/locale/es.json | 3 +- modules/travel/back/models/travel.js | 8 ++++ modules/travel/front/create/index.js | 22 +++++++++++ modules/travel/front/create/index.spec.js | 17 ++++++++ modules/travel/front/index/index.html | 25 +++++++++--- modules/travel/front/index/index.js | 48 ++++++++++++++++++----- modules/travel/front/index/index.spec.js | 44 +++++++++++++++++++++ modules/travel/front/index/locale/es.yml | 2 + modules/travel/front/routes.json | 2 +- 10 files changed, 172 insertions(+), 21 deletions(-) create mode 100644 modules/travel/front/index/locale/es.yml diff --git a/front/core/components/watcher/watcher.js b/front/core/components/watcher/watcher.js index ddef745fda..04ccba45e6 100644 --- a/front/core/components/watcher/watcher.js +++ b/front/core/components/watcher/watcher.js @@ -100,7 +100,9 @@ export default class Watcher extends Component { */ submit() { try { - this.check(); + if (this.requestMethod() !== 'post') + this.check(); + else this.isInvalid(); } catch (err) { return this.$q.reject(err); } @@ -120,12 +122,12 @@ export default class Watcher extends Component { if (this.form) this.form.$setSubmitted(); - if (!this.dataChanged()) { + const isPost = (this.requestMethod() === 'post'); + if (!this.dataChanged() && !isPost) { this.updateOriginalData(); return this.$q.resolve(); } - let isPost = (this.$attrs.save && this.$attrs.save.toLowerCase() === 'post'); let changedData = isPost ? this.data : getModifiedData(this.data, this.orgData); @@ -158,7 +160,6 @@ export default class Watcher extends Component { }); } - return this.$q((resolve, reject) => { this.$http.post(this.url, changedData).then( json => this.writeData(json, resolve), @@ -167,6 +168,10 @@ export default class Watcher extends Component { }); } + requestMethod() { + return this.$attrs.save && this.$attrs.save.toLowerCase(); + } + /** * Checks if data is ready to send. */ @@ -177,6 +182,15 @@ export default class Watcher extends Component { throw new UserError('No changes to save'); } + /** + * Checks if data is ready to send. + */ + isInvalid() { + console.log(this.form.$invalid); + if (this.form && this.form.$invalid) + throw new UserError('Some fields are invalid'); + } + /** * Notifies the user that the data has been saved. */ diff --git a/loopback/locale/es.json b/loopback/locale/es.json index fe95bc0650..e975185041 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -128,5 +128,6 @@ "Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}", "ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto", "Distance must be lesser than 1000": "La distancia debe ser inferior a 1000", - "This ticket is deleted": "Este ticket está eliminado" + "This ticket is deleted": "Este ticket está eliminado", + "The introduced data already exists": "La información introducida ya existe" } \ No newline at end of file diff --git a/modules/travel/back/models/travel.js b/modules/travel/back/models/travel.js index 4643f79fd5..a7c045b314 100644 --- a/modules/travel/back/models/travel.js +++ b/modules/travel/back/models/travel.js @@ -1,3 +1,5 @@ +const UserError = require('vn-loopback/util/user-error'); + module.exports = Self => { require('../methods/travel/getTravel')(Self); require('../methods/travel/getEntries')(Self); @@ -5,4 +7,10 @@ module.exports = Self => { require('../methods/travel/createThermograph')(Self); require('../methods/travel/deleteThermograph')(Self); require('../methods/travel/updateThermograph')(Self); + + Self.rewriteDbError(function(err) { + if (err.code === 'ER_DUP_ENTRY') + return new UserError('The introduced data already exists'); + return err; + }); }; diff --git a/modules/travel/front/create/index.js b/modules/travel/front/create/index.js index 02be34ca78..513e1e0b13 100644 --- a/modules/travel/front/create/index.js +++ b/modules/travel/front/create/index.js @@ -2,6 +2,26 @@ import ngModule from '../module'; import Section from 'salix/components/section'; class Controller extends Section { + constructor($element, $, $stateParams) { + super($element, $); + this.$stateParams = $stateParams; + this.travel = {}; + } + + $onChanges() { + if (this.$stateParams && this.$stateParams.q) + this._travel = JSON.parse(this.$stateParams.q); + } + + get travel() { + return this._travel; + } + + set travel(value) { + this._travel = value; + if (!value) return; + } + onSubmit() { return this.$.watcher.submit().then( res => this.$state.go('travel.card.summary', {id: res.data.id}) @@ -9,6 +29,8 @@ class Controller extends Section { } } +Controller.$inject = ['$element', '$scope', '$stateParams']; + ngModule.component('vnTravelCreate', { template: require('./index.html'), controller: Controller diff --git a/modules/travel/front/create/index.spec.js b/modules/travel/front/create/index.spec.js index 63f0eda42f..ef83d98ff1 100644 --- a/modules/travel/front/create/index.spec.js +++ b/modules/travel/front/create/index.spec.js @@ -26,5 +26,22 @@ describe('Travel Component vnTravelCreate', () => { expect(controller.$state.go).toHaveBeenCalledWith('travel.card.summary', {id: 1234}); }); }); + + describe('$onChanges()', () => { + it('should update the travel data when stateParams.q is defined', () => { + controller.$stateParams = {q: { + ref: 1, + agencyModeFk: 1 + }}; + + const result = {q: { + ref: 1, + agencyModeFk: 1 + }}; + controller.$onChanges(); + + expect(controller._travel).toBe(result); + }); + }); }); diff --git a/modules/travel/front/index/index.html b/modules/travel/front/index/index.html index 3af99eb6bd..ee7f88507a 100644 --- a/modules/travel/front/index/index.html +++ b/modules/travel/front/index/index.html @@ -41,12 +41,19 @@ {{::travel.warehouseInName}} {{::travel.landed | date:'dd/MM/yyyy'}} - - - + + + + + + + @@ -65,4 +72,10 @@ fixed-bottom-right> + + \ No newline at end of file diff --git a/modules/travel/front/index/index.js b/modules/travel/front/index/index.js index a1e22d2e77..8402d00a26 100644 --- a/modules/travel/front/index/index.js +++ b/modules/travel/front/index/index.js @@ -1,16 +1,10 @@ import ngModule from '../module'; export default class Controller { - constructor($scope) { + constructor($scope, $state) { this.$ = $scope; this.ticketSelected = null; - } - - preview(event, travel) { - this.travelSelected = travel; - this.$.summary.show(); - event.preventDefault(); - event.stopImmediatePropagation(); + this.$state = $state; } getScopeDates(days) { @@ -35,9 +29,45 @@ export default class Controller { } else this.$.model.clear(); } + + stopEvent(event) { + event.preventDefault(); + event.stopImmediatePropagation(); + } + + cloneTravel(event, travel) { + this.stopEvent(event); + this.travelSelected = travel; + this.$.clone.show(); + } + + onCloneAccept(response) { + if (!(response == 'accept' && this.travelSelected)) + return; + if (this.travelSelected) { + console.log('this.travelSelected', this.travelSelected); + const travel = { + ref: this.travelSelected.ref, + agencyModeFk: this.travelSelected.agencyFk, + shipped: this.travelSelected.shipped, + landed: this.travelSelected.landed, + warehouseInFk: this.travelSelected.warehouseInFk, + warehouseOutFk: this.travelSelected.warehouseOutFk + }; + const queryParams = JSON.stringify(travel); + this.$state.go('travel.create', {q: queryParams}); + } + + this.travelSelected = null; + } + preview(event, travel) { + this.stopEvent(event); + this.travelSelected = travel; + this.$.summary.show(); + } } -Controller.$inject = ['$scope']; +Controller.$inject = ['$scope', '$state']; ngModule.component('vnTravelIndex', { template: require('./index.html'), diff --git a/modules/travel/front/index/index.spec.js b/modules/travel/front/index/index.spec.js index 5affc7c1a1..8e180e1685 100644 --- a/modules/travel/front/index/index.spec.js +++ b/modules/travel/front/index/index.spec.js @@ -61,4 +61,48 @@ describe('Travel Component vnTravelIndex', () => { expect(range - dayInMilliseconds).toEqual(dayInMilliseconds + millisecondsPerAddedDay); }); }); + + describe('onCloneAccept()', () => { + it('should do nothing if response is not accept', () => { + jest.spyOn(controller.$state, 'go'); + + let response = 'ERROR!'; + controller.travelSelected = 'check me'; + + controller.onCloneAccept(response); + + expect(controller.$state.go).not.toHaveBeenCalledWith(); + expect(controller.travelSelected).toEqual('check me'); + }); + + it('should do nothing if response is accept but travelSelected is not defined in the controller', () => { + jest.spyOn(controller.$state, 'go'); + + let response = 'accept'; + controller.travelSelected = undefined; + + controller.onCloneAccept(response); + + expect(controller.$state.go).not.toHaveBeenCalledWith(); + expect(controller.travelSelected).toBeUndefined(); + }); + + it('should call go() then update travelSelected in the controller', () => { + jest.spyOn(controller.$state, 'go'); + + let response = 'accept'; + controller.travelSelected = { + ref: 1, + agencyFk: 1}; + const travel = { + ref: controller.travelSelected.ref, + agencyModeFk: controller.travelSelected.agencyFk + }; + const queryParams = JSON.stringify(travel); + controller.onCloneAccept(response); + + expect(controller.$state.go).toHaveBeenCalledWith('travel.create', {q: queryParams}); + expect(controller.travelSelected).toBeNull(); + }); + }); }); diff --git a/modules/travel/front/index/locale/es.yml b/modules/travel/front/index/locale/es.yml new file mode 100644 index 0000000000..63d23affdd --- /dev/null +++ b/modules/travel/front/index/locale/es.yml @@ -0,0 +1,2 @@ +Do you want to clone this travel?: ¿Desea clonar este envio? +All it's properties will be copied: Todas sus propiedades serán copiadas \ No newline at end of file diff --git a/modules/travel/front/routes.json b/modules/travel/front/routes.json index 50e2368891..b802aaa4a3 100644 --- a/modules/travel/front/routes.json +++ b/modules/travel/front/routes.json @@ -54,7 +54,7 @@ "component": "vn-travel-log", "description": "Log" }, { - "url": "/create", + "url": "/create?q", "state": "travel.create", "component": "vn-travel-create", "description": "New travel" From 0cd4e2ad9ed2c82071942b2b1c6c748f4c62476e Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Tue, 10 Mar 2020 14:28:50 +0100 Subject: [PATCH 51/93] Added autocomplete property --- front/core/components/autocomplete/index.js | 1 - front/core/components/drop-down/index.html | 3 ++- front/core/components/field/index.js | 12 ++++++++++++ modules/ticket/front/index/index.html | 2 +- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/front/core/components/autocomplete/index.js b/front/core/components/autocomplete/index.js index 1d3c6e2431..38c85db574 100755 --- a/front/core/components/autocomplete/index.js +++ b/front/core/components/autocomplete/index.js @@ -23,7 +23,6 @@ export default class Autocomplete extends Field { this._selection = null; this.input = this.element.querySelector('input'); - this.input.setAttribute('autocomplete', 'off'); } $postLink() { diff --git a/front/core/components/drop-down/index.html b/front/core/components/drop-down/index.html index 5366d9d90e..52ceeeaae6 100644 --- a/front/core/components/drop-down/index.html +++ b/front/core/components/drop-down/index.html @@ -3,7 +3,8 @@ ng-model="$ctrl.search" class="dense search" ng-blur="$ctrl.onFocusOut()" - placeholder="{{::'Search' | translate}}"> + placeholder="{{::'Search' | translate}}" + autocomplete="off">
diff --git a/front/core/components/field/index.js b/front/core/components/field/index.js index 481ccce91c..18286175b4 100644 --- a/front/core/components/field/index.js +++ b/front/core/components/field/index.js @@ -132,6 +132,17 @@ export default class Field extends FormInput { return this.error || this.inputError || null; } + get autocomplete() { + return this._autocomplete; + } + + set autocomplete(value) { + this._autocomplete = value; + console.log(value); + if (value === 'off') + this.input.setAttribute('autocomplete', 'off'); + } + refreshHint() { let error = this.shownError; let hint = error || this.hint; @@ -206,6 +217,7 @@ ngModule.vnComponent('vnField', { controller: Field, bindings: { type: '@?', + autocomplete: '@?', placeholder: '@?', value: '=?', info: '@?', diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html index ee218df56e..6a0b051ece 100644 --- a/modules/ticket/front/index/index.html +++ b/modules/ticket/front/index/index.html @@ -129,7 +129,7 @@
- Date: Tue, 10 Mar 2020 11:46:58 +0100 Subject: [PATCH 52/93] Allow empty agency on ticket creation --- modules/ticket/back/methods/ticket/new.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/ticket/back/methods/ticket/new.js b/modules/ticket/back/methods/ticket/new.js index db5310f7c2..7c4b3adb45 100644 --- a/modules/ticket/back/methods/ticket/new.js +++ b/modules/ticket/back/methods/ticket/new.js @@ -6,7 +6,7 @@ module.exports = Self => { accessType: 'WRITE', accepts: [{ arg: 'clientId', - type: 'Number', + type: 'number', description: `The client id filter`, required: true }, @@ -22,29 +22,29 @@ module.exports = Self => { }, { arg: 'warehouseId', - type: 'Number', + type: 'number', description: `The warehouse id filter`, required: true }, { arg: 'companyId', - type: 'Number', + type: 'number', description: `The company id filter` }, { arg: 'addressId', - type: 'Number', + type: 'number', description: `The address id filter`, required: true }, { arg: 'agencyModeId', - type: 'Number', + type: 'any', description: `The agencyMode id filter` }, { arg: 'routeId', - type: 'Number', + type: 'number', description: `The route id filter` }], returns: { From b214de25ce5a2813882879d1781d54882d886a3b Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Tue, 10 Mar 2020 11:36:49 +0100 Subject: [PATCH 53/93] Removed autocomplete completion for chrome --- front/core/components/autocomplete/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/front/core/components/autocomplete/index.js b/front/core/components/autocomplete/index.js index 38c85db574..1d3c6e2431 100755 --- a/front/core/components/autocomplete/index.js +++ b/front/core/components/autocomplete/index.js @@ -23,6 +23,7 @@ export default class Autocomplete extends Field { this._selection = null; this.input = this.element.querySelector('input'); + this.input.setAttribute('autocomplete', 'off'); } $postLink() { From 3c88a25c2a1a2f05ca8886b582dc0d46146a857d Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Tue, 10 Mar 2020 14:28:50 +0100 Subject: [PATCH 54/93] Added autocomplete property --- front/core/components/autocomplete/index.js | 1 - front/core/components/drop-down/index.html | 3 ++- front/core/components/field/index.js | 12 ++++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/front/core/components/autocomplete/index.js b/front/core/components/autocomplete/index.js index 1d3c6e2431..38c85db574 100755 --- a/front/core/components/autocomplete/index.js +++ b/front/core/components/autocomplete/index.js @@ -23,7 +23,6 @@ export default class Autocomplete extends Field { this._selection = null; this.input = this.element.querySelector('input'); - this.input.setAttribute('autocomplete', 'off'); } $postLink() { diff --git a/front/core/components/drop-down/index.html b/front/core/components/drop-down/index.html index 5366d9d90e..52ceeeaae6 100644 --- a/front/core/components/drop-down/index.html +++ b/front/core/components/drop-down/index.html @@ -3,7 +3,8 @@ ng-model="$ctrl.search" class="dense search" ng-blur="$ctrl.onFocusOut()" - placeholder="{{::'Search' | translate}}"> + placeholder="{{::'Search' | translate}}" + autocomplete="off">
diff --git a/front/core/components/field/index.js b/front/core/components/field/index.js index 481ccce91c..18286175b4 100644 --- a/front/core/components/field/index.js +++ b/front/core/components/field/index.js @@ -132,6 +132,17 @@ export default class Field extends FormInput { return this.error || this.inputError || null; } + get autocomplete() { + return this._autocomplete; + } + + set autocomplete(value) { + this._autocomplete = value; + console.log(value); + if (value === 'off') + this.input.setAttribute('autocomplete', 'off'); + } + refreshHint() { let error = this.shownError; let hint = error || this.hint; @@ -206,6 +217,7 @@ ngModule.vnComponent('vnField', { controller: Field, bindings: { type: '@?', + autocomplete: '@?', placeholder: '@?', value: '=?', info: '@?', From 509f2233fca9ea353baefd52f44aafaf400dbed0 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Tue, 10 Mar 2020 14:28:50 +0100 Subject: [PATCH 55/93] Added autocomplete property --- front/core/components/field/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/core/components/field/index.js b/front/core/components/field/index.js index 18286175b4..62adf3233a 100644 --- a/front/core/components/field/index.js +++ b/front/core/components/field/index.js @@ -138,7 +138,7 @@ export default class Field extends FormInput { set autocomplete(value) { this._autocomplete = value; - console.log(value); + if (value === 'off') this.input.setAttribute('autocomplete', 'off'); } From 3736dcf792df3983175a4d1223c3bc5c81603466 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Tue, 10 Mar 2020 15:01:33 +0100 Subject: [PATCH 56/93] Added ticket sms options --- front/core/components/popover/index.js | 5 +++- modules/ticket/front/descriptor/index.js | 28 ++++++++++++++----- modules/ticket/front/descriptor/locale/en.yml | 5 ++-- modules/ticket/front/descriptor/locale/es.yml | 7 +++-- modules/ticket/front/index/locale/es.yml | 3 +- 5 files changed, 34 insertions(+), 14 deletions(-) diff --git a/front/core/components/popover/index.js b/front/core/components/popover/index.js index 7c54ce4949..96f1914f57 100644 --- a/front/core/components/popover/index.js +++ b/front/core/components/popover/index.js @@ -85,7 +85,10 @@ export default class Popover extends Popup { let maxWith = maxRight - margin; let maxHeight = maxBottom - margin - arrowHeight; - let width = clamp(popoverRect.width, parentRect.width, maxWith); + const scrollbarWidth = (popoverRect.width); + const innerEl = this.windowEl.querySelector('.content > *'); + console.log(innerEl); + let width = clamp(popoverRect.width, parentRect.width, maxWith) + 20; let height = popoverRect.height; let left = parentRect.left + parentRect.width / 2 - width / 2; diff --git a/modules/ticket/front/descriptor/index.js b/modules/ticket/front/descriptor/index.js index c633dd3c1e..478c1bd22d 100644 --- a/modules/ticket/front/descriptor/index.js +++ b/modules/ticket/front/descriptor/index.js @@ -16,7 +16,8 @@ class Controller extends Component { {name: 'Send Delivery Note', callback: this.confirmDeliveryNote}, {name: 'Delete ticket', callback: this.showDeleteTicketDialog}, {name: 'Change shipped hour', callback: this.showChangeShipped}, - {name: 'Send SMS', callback: this.showSMSDialog}, + {name: 'SMS: Pending payment', callback: this.sendPaymentSms}, + {name: 'SMS: Minimum import', callback: this.sendImportSms}, { name: 'Add stowaway', callback: this.showAddStowaway, @@ -240,17 +241,30 @@ class Controller extends Component { ); } + sendImportSms() { + const params = { + ticketId: this.ticket.id, + created: this.ticket.created + }; + const message = this.$params.message || this.$translate.instant('Minimum is needed', params); + this.newSMS = {message}; + this.showSMSDialog(); + } + + sendPaymentSms() { + const message = this.$params.message || this.$translate.instant('Make a payment'); + this.newSMS = {message}; + this.showSMSDialog(); + } + showSMSDialog() { const address = this.ticket.address; const client = this.ticket.client; const phone = this.$params.phone || address.mobile || address.phone || client.mobile || client.phone; - const message = this.$params.message || this.$translate.instant('SMSPayment'); - this.newSMS = { - destinationFk: this.ticket.clientFk, - destination: phone, - message: message - }; + + this.newSMS.destinationFk = this.ticket.clientFk; + this.newSMS.destination = phone; this.$.sms.open(); } diff --git a/modules/ticket/front/descriptor/locale/en.yml b/modules/ticket/front/descriptor/locale/en.yml index 4dca75a510..64075c7ef5 100644 --- a/modules/ticket/front/descriptor/locale/en.yml +++ b/modules/ticket/front/descriptor/locale/en.yml @@ -1,3 +1,2 @@ -SMSPayment: >- - Verdnatura communicates: Your order is pending of payment. - Please, enter the web page and make the payment with card. Thank you. \ No newline at end of file +Make a payment: "Verdnatura communicates:\rYour order is pending of payment.\rPlease, enter the web page and make the payment with card.\rThank you." +Minimum is needed: "Verdnatura communicates:\rA minimum import of 50€ (Without BAT) is needed for your order {{ticketId}} from date {{created | date: 'dd/MM/yyyy'}} to receive it with no extra fees." diff --git a/modules/ticket/front/descriptor/locale/es.yml b/modules/ticket/front/descriptor/locale/es.yml index 3df39fe28c..e2ea2f9aff 100644 --- a/modules/ticket/front/descriptor/locale/es.yml +++ b/modules/ticket/front/descriptor/locale/es.yml @@ -13,7 +13,8 @@ Send Delivery Note: Enviar albarán Show pallet report: Ver hoja de pallet Change shipped hour: Cambiar hora de envío Shipped hour: Hora de envío -SMSPayment: "Verdnatura le comunica:\rSu pedido está pendiente de pago.\rPor favor, entre en la página web y efectue el pago con tarjeta.\rMuchas gracias." +Make a payment: "Verdnatura le comunica:\rSu pedido está pendiente de pago.\rPor favor, entre en la página web y efectue el pago con tarjeta.\rMuchas gracias." +Minimum is needed: "Verdnatura le recuerda:\rEs necesario llegar a un importe mínimo de 50€ (Sin IVA) en su pedido {{ticketId}} del día {{created | date: 'dd/MM/yyyy'}} para recibirlo sin portes adicionales." Ticket invoiced: Ticket facturado Make invoice: Crear factura Regenerate invoice: Regenerar factura @@ -25,4 +26,6 @@ Invoice sent for a regeneration, will be available in a few minutes: La factura Shipped hour updated: Hora de envio modificada Deleted ticket: Ticket eliminado Recalculate components: Recalcular componentes -Are you sure you want to recalculate the components?: ¿Seguro que quieres recalcular los componentes? \ No newline at end of file +Are you sure you want to recalculate the components?: ¿Seguro que quieres recalcular los componentes? +SMS: Minimum import: 'SMS: Importe minimo' +SMS: Pending payment: 'SMS: Pago pendiente' \ No newline at end of file diff --git a/modules/ticket/front/index/locale/es.yml b/modules/ticket/front/index/locale/es.yml index b29c7399d3..dea55b199e 100644 --- a/modules/ticket/front/index/locale/es.yml +++ b/modules/ticket/front/index/locale/es.yml @@ -2,4 +2,5 @@ Weekly tickets: Tickets programados Go to lines: Ir a lineas Not available: No disponible Payment on account...: Pago a cuenta... -Closure: Cierre \ No newline at end of file +Closure: Cierre +You cannot make a payment on account from multiple clients: No puedes realizar un pago a cuenta de clientes diferentes \ No newline at end of file From 7496bc923eb124319837d74d54a2f1cddd0746ba Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 11 Mar 2020 08:02:58 +0100 Subject: [PATCH 57/93] Updated fonts & changed icons --- front/core/components/input-file/index.html | 2 +- front/core/styles/icons/salixfont.css | 17 +++++++++++- front/core/styles/icons/salixfont.svg | 5 ++++ front/core/styles/icons/salixfont.ttf | Bin 29868 -> 32980 bytes front/core/styles/icons/salixfont.woff | Bin 29944 -> 33056 bytes modules/entry/back/methods/entry/filter.js | 1 - modules/entry/back/models/entry.json | 27 ++++++++++--------- modules/entry/front/descriptor/index.html | 12 +++++++++ modules/entry/front/descriptor/locale/es.yml | 4 ++- modules/entry/front/index/index.html | 2 +- modules/zone/front/routes.json | 2 +- 11 files changed, 54 insertions(+), 18 deletions(-) diff --git a/front/core/components/input-file/index.html b/front/core/components/input-file/index.html index be4c15248a..ad71b744db 100644 --- a/front/core/components/input-file/index.html +++ b/front/core/components/input-file/index.html @@ -30,7 +30,7 @@ ng-click="$ctrl.onClear($event)"> diff --git a/front/core/styles/icons/salixfont.css b/front/core/styles/icons/salixfont.css index 505fb8520e..8805815e85 100644 --- a/front/core/styles/icons/salixfont.css +++ b/front/core/styles/icons/salixfont.css @@ -23,6 +23,21 @@ -moz-osx-font-smoothing: grayscale; } +.icon-zone:before { + content: "\e95d"; +} +.icon-inventory:before { + content: "\e95e"; +} +.icon-wiki:before { + content: "\e968"; +} +.icon-attach:before { + content: "\e96c"; +} +.icon-zone2:before { + content: "\e96d"; +} .icon-net:before { content: "\e95b"; } @@ -301,4 +316,4 @@ } .icon-worker:before { content: "\e943"; -} +} \ No newline at end of file diff --git a/front/core/styles/icons/salixfont.svg b/front/core/styles/icons/salixfont.svg index 7cd1af528d..9ca57000d5 100644 --- a/front/core/styles/icons/salixfont.svg +++ b/front/core/styles/icons/salixfont.svg @@ -100,4 +100,9 @@ + + + + + \ No newline at end of file diff --git a/front/core/styles/icons/salixfont.ttf b/front/core/styles/icons/salixfont.ttf index 08a36a48ba00ae23f523cc473aff246dd4a0c945..ab5de35ff5704093f92f0a42ab96502a9010e385 100644 GIT binary patch delta 3467 zcma)9U2Ggj9iQ2mow?n+wQs$5d%jKXvc7e8lk-RJZtc6+aoPqYG>PIihBi#EaPk@Nvj|=h1}&+xFk{?&zz8JU&!2V1PmBod_N3c=+j-F9;!q~q~p1YGCdWmk?vJ;pdk|7!qIFx^B_R_&ihgOzW zRun&A0{GDsrYnCbarYzlpU|a_Pu`fLZ$6gfR<06*6ZQyMLpG4zWFI*|7Rhtu+vI!X zH2DenB_YlzjndY+gLc|(sY+!}+G;{NHBl_MajQK(76wk#i5g)LH56UQwvq}X*$~Bb zR7Osx#B^Ywq~(@+XsH$kV@Z3w<;H7iv9n64(jsJU0AO1mbxNsL=vk*prDgqfUXX9{ zUK0$aC{!x_w{X306b!GCw@e|2f|0K8^$Jim^>`Lxk*FpXISlWFr-zsb##IR$xz(2aui029n`OeUFhw4thH z1)6y84;fZlD~)Nwk#Ux_vGQn8p>J~LOO zwON*BBFBUjR*4Hs>cSEknUM--hy=4Sz(BGr`sd58aW>O8E5&P;z5MpPOFa$+X0M^t z^qJEvCuB~_EL4dqqfkgOod6^=BJBw=iMMi|{f)gwELhb>vYC9E+(#ZDv!qMr2wC51 zZ>4cD7>|pE#EoG*H^7fURT?v}DC@e$5PS^$I3x#(1LG{PW4kjxP%L3WZ6>-Gx+c4F zW7H2^=;GoZ=?ca$=kF)!tb6{-wK2nTSI@Zhy36+5Rj6Gb!Z9r&4rZx=jlJLx4J86@N6Gh~4rCqE*;CVx$+q-!Vw2W_;P zonk@AMy)Bw$J!E3QlYXIZlw{N4pR}1ms*YBCKDVf0(S^ElOm{v(OA3FXqRC8sTT#s z+Y)QyIuYythv-e}eED9-m(8=zG@qk&zG0{IlDg{vA$f z6JuM77T?VKtc&_^voW*A)8KiU+*}VIiJ1ofx`|G1ga3cfC*k{y^LW0#u?=%FnCHzj zo0||KZcCsi3^u=O@9~Mr<9nwMFsqz+^exMG9N(g6-TZRcQ?2f8Y-)u&D*4Y(?mpVK z=~@5ourWG%Po>gh$493p_Bq-`Yseeoxw^OE>$+{Z+_sAI88%RkRJW5?ovJXZ?m9W; zXS15FBP>alskW6M%9oDF-0(V<{)sQckvtd%@4$kj}DHT7Q8uum@$s z#DSqCoAnuc0S6X5=+6KtbRcs+=k)SjyxM9sT2(&9`mCjw&1}}x=BysJ^t#Aqi!zfl zwEIO;7#Uf9+5VMfWioEo)UVidc4XKQOQ%(eLY`W=$o|e=MN%R(H5o|}*$c|VmBr9I zC=w6sMVS;$a}g*C4Z~D!-~!zPs^WoH-9mw@fs!D;l-yQ_DtktGg7j zm0fRp7;GgBZxAeNVGxR6iO0ur(X*H)^_L`1U=!beKLa>qm=@8va zx6>K=Mfw%`1R*NHrY%9xh!IE{t++~6Iz_`ZVqS35UU_PyuCnBoz=t+T6)OZ*b)?rH zwZn0Mr~%;JN?lvU25_b#iXYE`P=N^=RD%utwJ=c+hcz2D1=neSIpWEBB=K9-Lk;Bc zgsY1v(Nqk!u&NS00?Fzeb^-pdy}E3ys)e*E?5*X?m}uI`_4=iw>X%fDI`AD-j$N-z zU|hG>BT{WQWx5xkq&&BXwjiXu+5+TN*qQ}&PRkh%dI?t6&C>ra=@I%5THvM1| zkAp7PP}dk~|13v^gX-xlOHc)&wn+QSI2Q0QexsmKps}V}PUCNZ0jEL1;w=9eb7AA- zvgdcJ5?0Z6Tkh^}?GE;YT+gqwRC!~o3P)%Dwm}t;GbnGcYZgY)y%BPiA)GLeV0)avCz)l$-7zP0D07n$SFOkRM^;%$l;TPlTlqd8 z4(_)r{*(%(v!j8!M!&f{gxBIG$N5-x7`x=cG^G}=z9H5!ExaWj5~Y|SguDzEV6ktR zV?~8Zi$0Otqc&<|cd!@xiBypx__dI$!tOKHhkyK1@6 z8M!4Dm2KRaKz<8QPfJdIvSZ@BlwC;-3`HD31xIodD+(CunaY6tGeEvVUSe))T=-3Q zApZ?e!@Pq0;u4@kfuN)ZB+tOi{Bz;~d&ZbajMmx~KoKqm4hAM5WMoiy8T0?||NkJh zKsE!I&G`SZI15le<#w~9sggBT!sa!8FiW8&tX Wnij^%Ds@NLK|K-O>!J;wfZ%Az~y;ZytQwrzXB z>BICjBCz`4{M`9N=MS$et*j^|&;;~-8BJIIQs&;r-baK1iQlU~rf=MzS}T``!3n#U ztRvTvz2pvZkQ^b$$al#1$xGxXHg5?)9|W@yazS`?9Alq+1uIqL;Kg6XQ|n z#@)CXg>h5Kh3qJ;D3(o8+CXLOcFRl$2S(anxsR6XQ8=DQhqRF%cd(h-&*_?*H zV(3QEzLN=NxF(ZKy4rBfwnI(4|N9)Pc~1Atg=G0*Cb-#$#*6_u1DNTWsSr>(VHR!M zx0rSpSX?Lp7xZKpA~FiPVfYk1y}87(X?*>u!(Z z>!|B?gP@vd;=83%ZuzzO60Og%JQEfZQrKlKY^e)dj-7d+~77%=+{WoE#fVV01VlzEsEHAZ2OqB{vn=0x@;#3cU88TL2!GO^)R zo5@ykBe{*-N#;n8Ai6fSJKJee3MZ0MG4&ES&lU0$RE;JK5anHKfbbLKCn-5p8k%6C zlQ`Xpp;8$g>M+qe+cVk4D_{NK*&a6j-kx9#ef~k3^?GM6u6=XNy7ZdYXn1Vj&PL;X zo!@@$+^mqF{%XUsOb9j$;itYI#PQP4*t?gG=Hhsky^A=r(QZbB?IQieN4A(CpC^mt z8S*3YEArQrO1h3V5%JA-t6M4x*{rwZ#CS&{NUBuUqwO?C(4i}$iE_IcUIihLVxS|0 znG|6?ipM+MW~U72&!Q+SeWtK3E(&-_jz&@vsw3@T)d<~JO$*qm(-h^q0udD3zGx+}x z`y^tYah@zRHh17o2J`*dR%;7V#AgcV34<-%y#JZWsb}`j9AtJS_34{-;JSfLPkV*s zsIOMr-`vuUc2^5uoZ5T5sBm|G41x+iqU_PAr0 z7IJK;606r9UUO^0sCgUYbdb+$x{kCYnZ*Y~tenxOgSr_s%s<&HAqtAm$KLH zQsvLMtk~N z^u9Y*t+a|Re%g$`BMf)=72mHcFLGVyq9p0bA;+PGLcn?feoL?Td!k^{tEL+&zE*cT z6~E=W#X*>tLge5-uy5M~1zZg7W*g@5E4CC$yIC1t9b$P=W#t@F5ItGn+_N>@PZA8E5Wp5R! zvD(VAR|XEx6je|ttlG%7Kkh^mAW;J#x|O+($_+qfDhiL|K&n6o4@?6Fd_79l!C}m1 zUC|91qK|yC377b_=3xeUIKtIIlxn61UsyGXHxkKeAASLR)L9)iQPo2BDDJi8%eZJc z>E-&RtLm4`idyjXRE}S+OyFGC)+16)H-lhGo381jSXdKG)aY8FlNs!SkM(ACNe>5x zYaL|(Wx>vXrX0~(2nv>OtIJfV+ZpbKQY`njB1YHnlj3*zX?dBAC--xV9z6 zZ`$mJL2i#SStv(@FeVU4Rwu?y&vPKa8Ny+W+|#5)E3$M0+t0noZl#F6l{#C zhST_)0AMvJSls15qAwgYF8khE)v!yB*Y@^)dvCZe;(B3&t;!omRX92eZrG?2at`GU zX3e5FzBR^OWe7JaU|A_PKA9iKiq)zLGMbGz3L0qY<(8)g5lEJ-d3ST>d;3-Olx+}$ z3?}@f!u8+4s^9g)&xI0+6xE;PYK{FyxF^DqPq&MzHE@fUi z>Z$P<|Jbf5jdD_r61y-EAi#r8HJDbZbZ#tE+ZeQ#hjCimE0=)q6-u>J`@jC{fvv|U#ncPirncV(j{2`L K|7z{%S^95b%=v== delta 359 zcmZ3`#Ps7Oqe!{Gn;Qco0}zz_VBiMRYbJ_l*ViZKCKfO-FlGRSLO@tN?9$`(#A1-x z9w46siUrbhD${^sM;I9LHh}Q?zpA%0QWH}c7z#>&YRo`bf;InR22cY=1hN!pD8rF?DZ7$#6Dxog7fS&73SeB%RF;>R zn+g=O0BW2E!g1j@-3#)IftHrsfU9E$vY45FPUc~>XN;Nb!)UDyRL{T#bUqUhGBPN< zjQRif|9_wu(Bzj4U^e6b$Kosu%nXd14>2CjQw9YN5Uco9-jC^g>iC0-4QmBdWOW!ZuPeq0e%@=f&c&j diff --git a/modules/entry/back/methods/entry/filter.js b/modules/entry/back/methods/entry/filter.js index ba9b021f50..c915569dec 100644 --- a/modules/entry/back/methods/entry/filter.js +++ b/modules/entry/back/methods/entry/filter.js @@ -150,7 +150,6 @@ module.exports = Self => { JOIN vn.currency cu ON cu.id = e.currencyFk` ); - stmt.merge(conn.makeSuffix(filter)); let itemsIndex = stmts.push(stmt) - 1; diff --git a/modules/entry/back/models/entry.json b/modules/entry/back/models/entry.json index 6d38dbba10..d3f149680f 100644 --- a/modules/entry/back/models/entry.json +++ b/modules/entry/back/models/entry.json @@ -11,7 +11,7 @@ }, "properties": { "id": { - "type": "Number", + "type": "number", "id": true, "description": "Identifier" }, @@ -19,46 +19,49 @@ "type": "date" }, "ref": { - "type": "String" + "type": "string" }, "isBooked": { - "type": "Boolean" + "type": "boolean" }, "isInventory": { - "type": "Boolean" + "type": "boolean" }, "notes": { - "type": "Number" + "type": "number" }, "isConfirmed": { - "type": "Boolean" + "type": "boolean" }, "isVirtual": { - "type": "Boolean", + "type": "boolean", "mysql": { "columnName": "isRaid" } }, + "isRaid": { + "type": "boolean" + }, "commission": { - "type": "Number" + "type": "number" }, "isOrdered": { - "type": "Boolean" + "type": "boolean" }, "created": { "type": "date" }, "observation": { - "type": "String", + "type": "string", "mysql": { "columnName": "evaNotes" } }, "isBlocked": { - "type": "Boolean" + "type": "boolean" }, "loadPriority": { - "type": "Number" + "type": "number" } }, "relations": { diff --git a/modules/entry/front/descriptor/index.html b/modules/entry/front/descriptor/index.html index cd4057c43a..917c5d7213 100644 --- a/modules/entry/front/descriptor/index.html +++ b/modules/entry/front/descriptor/index.html @@ -35,6 +35,18 @@ value="{{$ctrl.entry.travel.warehouseOut.name}}">
+
+ + + + +
diff --git a/modules/entry/front/descriptor/locale/es.yml b/modules/entry/front/descriptor/locale/es.yml index 5e1eb25c2d..47fabb8f09 100644 --- a/modules/entry/front/descriptor/locale/es.yml +++ b/modules/entry/front/descriptor/locale/es.yml @@ -1,4 +1,6 @@ Reference: Referencia All travels with current agency: Todos los envios con la agencia actual All entries with current supplier: Todas las entradas con el proveedor actual -Show entry report: Ver informe del pedido \ No newline at end of file +Show entry report: Ver informe del pedido +Is inventory entry: Es una entrada de inventario +Is virtual entry: Es una redada \ No newline at end of file diff --git a/modules/entry/front/index/index.html b/modules/entry/front/index/index.html index 60bbe46d54..cb44aa630e 100644 --- a/modules/entry/front/index/index.html +++ b/modules/entry/front/index/index.html @@ -38,7 +38,7 @@ ng-show="entry.isInventory" class="bright" vn-tooltip="Inventory entry" - icon="icon-anonymous"> + icon="icon-inventory"> Date: Wed, 11 Mar 2020 08:05:38 +0100 Subject: [PATCH 58/93] Changed icon --- modules/zone/front/routes.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/zone/front/routes.json b/modules/zone/front/routes.json index be96d3d6b6..b5f0e76ab4 100644 --- a/modules/zone/front/routes.json +++ b/modules/zone/front/routes.json @@ -6,7 +6,7 @@ "dependencies": ["worker"], "menus": { "main": [ - {"state": "zone.index", "icon": "location_on"}, + {"state": "zone.index", "icon": "icon-zone"}, {"state": "zone.deliveryDays", "icon": "today"} ], "card": [ From 581e2fcd1f2a2b78b8fbdbb8d358354c48d4a93c Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 11 Mar 2020 08:45:54 +0100 Subject: [PATCH 59/93] Updated unit test --- modules/ticket/front/descriptor/index.js | 4 +-- modules/ticket/front/descriptor/index.spec.js | 25 +++++++++++++++++-- modules/ticket/front/descriptor/locale/es.yml | 4 +-- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/modules/ticket/front/descriptor/index.js b/modules/ticket/front/descriptor/index.js index 478c1bd22d..6ea2d18927 100644 --- a/modules/ticket/front/descriptor/index.js +++ b/modules/ticket/front/descriptor/index.js @@ -16,8 +16,8 @@ class Controller extends Component { {name: 'Send Delivery Note', callback: this.confirmDeliveryNote}, {name: 'Delete ticket', callback: this.showDeleteTicketDialog}, {name: 'Change shipped hour', callback: this.showChangeShipped}, - {name: 'SMS: Pending payment', callback: this.sendPaymentSms}, - {name: 'SMS: Minimum import', callback: this.sendImportSms}, + {name: 'SMS Pending payment', callback: this.sendPaymentSms}, + {name: 'SMS Minimum import', callback: this.sendImportSms}, { name: 'Add stowaway', callback: this.showAddStowaway, diff --git a/modules/ticket/front/descriptor/index.spec.js b/modules/ticket/front/descriptor/index.spec.js index a435618333..3f4b876828 100644 --- a/modules/ticket/front/descriptor/index.spec.js +++ b/modules/ticket/front/descriptor/index.spec.js @@ -20,7 +20,13 @@ describe('Ticket Component vnTicketDescriptor', () => { $httpBackend = _$httpBackend_; $httpParamSerializer = _$httpParamSerializer_; controller = $componentController('vnTicketDescriptor', {$element}); - controller._ticket = {id: 2, invoiceOut: {id: 1}, client: {id: 101, email: 'client@email'}}; + controller._ticket = { + id: 2, + clientFk: 101, + invoiceOut: {id: 1}, + client: {id: 101, email: 'client@email'}, + address: {id: 101, mobile: 111111111, phone: 2222222222} + }; controller.cardReload = ()=> { return true; }; @@ -161,7 +167,6 @@ describe('Ticket Component vnTicketDescriptor', () => { }); }); - describe('showAddStowaway()', () => { it('should show a dialog with a list of tickets available for an stowaway', () => { controller.$.addStowaway = {}; @@ -223,4 +228,20 @@ describe('Ticket Component vnTicketDescriptor', () => { expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); }); }); + + describe('showSMSDialog()', () => { + it('should set the destionationFk and destination properties and then call the sms open() method', () => { + controller.$.sms = {open: () => {}}; + jest.spyOn(controller.$.sms, 'open'); + + const clientId = 101; + const expectedPhone = 111111111; + controller.newSMS = {}; + controller.showSMSDialog(); + + expect(controller.newSMS.destinationFk).toEqual(clientId); + expect(controller.newSMS.destination).toEqual(expectedPhone); + expect(controller.$.sms.open).toHaveBeenCalledWith(); + }); + }); }); diff --git a/modules/ticket/front/descriptor/locale/es.yml b/modules/ticket/front/descriptor/locale/es.yml index e2ea2f9aff..d0e8b7bf57 100644 --- a/modules/ticket/front/descriptor/locale/es.yml +++ b/modules/ticket/front/descriptor/locale/es.yml @@ -27,5 +27,5 @@ Shipped hour updated: Hora de envio modificada Deleted ticket: Ticket eliminado Recalculate components: Recalcular componentes Are you sure you want to recalculate the components?: ¿Seguro que quieres recalcular los componentes? -SMS: Minimum import: 'SMS: Importe minimo' -SMS: Pending payment: 'SMS: Pago pendiente' \ No newline at end of file +SMS Minimum import: 'SMS Importe minimo' +SMS Pending payment: 'SMS Pago pendiente' \ No newline at end of file From 43ad139681ecd6596058a59830e51a5460cb37a1 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 11 Mar 2020 09:14:19 +0100 Subject: [PATCH 60/93] Updated selector --- e2e/helpers/selectors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 2f1c5d893c..4eebe0d666 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -824,7 +824,7 @@ export default { travelThermograph: { add: 'vn-travel-thermograph-index vn-float-button[icon="add"]', thermographID: 'vn-travel-thermograph-create vn-autocomplete[ng-model="$ctrl.dms.thermographId"]', - uploadIcon: 'vn-travel-thermograph-create vn-icon[icon="attach_file"]', + uploadIcon: 'vn-travel-thermograph-create vn-icon[icon="icon-attach"]', createdThermograph: 'vn-travel-thermograph-index vn-tbody > vn-tr', upload: 'vn-travel-thermograph-create button[type=submit]' }, From 278839b2b39febf63e242f388f8569975b2ff5ec Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 11 Mar 2020 09:15:23 +0100 Subject: [PATCH 61/93] Updated selector --- e2e/helpers/selectors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 2f1c5d893c..4eebe0d666 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -824,7 +824,7 @@ export default { travelThermograph: { add: 'vn-travel-thermograph-index vn-float-button[icon="add"]', thermographID: 'vn-travel-thermograph-create vn-autocomplete[ng-model="$ctrl.dms.thermographId"]', - uploadIcon: 'vn-travel-thermograph-create vn-icon[icon="attach_file"]', + uploadIcon: 'vn-travel-thermograph-create vn-icon[icon="icon-attach"]', createdThermograph: 'vn-travel-thermograph-index vn-tbody > vn-tr', upload: 'vn-travel-thermograph-create button[type=submit]' }, From e92030ec6eea033e50895e632da7ab7dce7628e9 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Wed, 11 Mar 2020 09:17:14 +0100 Subject: [PATCH 62/93] test --- front/core/components/watcher/watcher.js | 1 - modules/travel/front/create/index.spec.js | 14 +++++--------- modules/travel/front/index/index.js | 1 - 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/front/core/components/watcher/watcher.js b/front/core/components/watcher/watcher.js index 04ccba45e6..0ab41edf95 100644 --- a/front/core/components/watcher/watcher.js +++ b/front/core/components/watcher/watcher.js @@ -186,7 +186,6 @@ export default class Watcher extends Component { * Checks if data is ready to send. */ isInvalid() { - console.log(this.form.$invalid); if (this.form && this.form.$invalid) throw new UserError('Some fields are invalid'); } diff --git a/modules/travel/front/create/index.spec.js b/modules/travel/front/create/index.spec.js index ef83d98ff1..e1095d35bc 100644 --- a/modules/travel/front/create/index.spec.js +++ b/modules/travel/front/create/index.spec.js @@ -29,18 +29,14 @@ describe('Travel Component vnTravelCreate', () => { describe('$onChanges()', () => { it('should update the travel data when stateParams.q is defined', () => { - controller.$stateParams = {q: { - ref: 1, - agencyModeFk: 1 - }}; + controller.$stateParams = {q: '{"ref": 1,"agencyModeFk": 1}'}; + + const params = {q: '{"ref": 1, "agencyModeFk": 1}'}; + const json = JSON.parse(params.q); - const result = {q: { - ref: 1, - agencyModeFk: 1 - }}; controller.$onChanges(); - expect(controller._travel).toBe(result); + expect(controller._travel).toEqual(json); }); }); }); diff --git a/modules/travel/front/index/index.js b/modules/travel/front/index/index.js index 8402d00a26..b3e24e0e61 100644 --- a/modules/travel/front/index/index.js +++ b/modules/travel/front/index/index.js @@ -45,7 +45,6 @@ export default class Controller { if (!(response == 'accept' && this.travelSelected)) return; if (this.travelSelected) { - console.log('this.travelSelected', this.travelSelected); const travel = { ref: this.travelSelected.ref, agencyModeFk: this.travelSelected.agencyFk, From 17c8336b232284be8de616ee2e592b40d0c99f2e Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 11 Mar 2020 09:39:05 +0100 Subject: [PATCH 63/93] Removed popover changes --- front/core/components/popover/index.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/front/core/components/popover/index.js b/front/core/components/popover/index.js index 96f1914f57..7c54ce4949 100644 --- a/front/core/components/popover/index.js +++ b/front/core/components/popover/index.js @@ -85,10 +85,7 @@ export default class Popover extends Popup { let maxWith = maxRight - margin; let maxHeight = maxBottom - margin - arrowHeight; - const scrollbarWidth = (popoverRect.width); - const innerEl = this.windowEl.querySelector('.content > *'); - console.log(innerEl); - let width = clamp(popoverRect.width, parentRect.width, maxWith) + 20; + let width = clamp(popoverRect.width, parentRect.width, maxWith); let height = popoverRect.height; let left = parentRect.left + parentRect.width / 2 - width / 2; From 8fe6c651e3669a291fc4977a1830c694e7b32906 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 11 Mar 2020 12:02:12 +0100 Subject: [PATCH 64/93] Updated translations --- modules/ticket/front/sale/index.js | 7 +++---- modules/ticket/front/sale/locale/en.yml | 2 +- modules/ticket/front/sale/locale/es.yml | 3 ++- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index e7bf61cfe0..6ccc05e9d3 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -12,7 +12,7 @@ class Controller { this.edit = {}; this.moreOptions = [ { - name: 'Send SMS', + name: 'Send shortage SMS', callback: this.showSMSDialog }, { name: 'Mark as reserved', @@ -179,10 +179,9 @@ class Controller { totalCheckedLines() { const checkedLines = this.checkedLines(); if (checkedLines) - return checkedLines.length; + return checkedLines.lengt; } - removeCheckedLines() { const sales = this.checkedLines(); @@ -448,7 +447,7 @@ class Controller { this.newSMS = { destinationFk: this.ticket.clientFk, destination: phone, - message: this.$translate.instant('SMSAvailability', params) + message: this.$translate.instant('Product not available', params) }; this.$scope.sms.open(); } diff --git a/modules/ticket/front/sale/locale/en.yml b/modules/ticket/front/sale/locale/en.yml index 469e2a04ed..ec7f541609 100644 --- a/modules/ticket/front/sale/locale/en.yml +++ b/modules/ticket/front/sale/locale/en.yml @@ -1,3 +1,3 @@ -SMSAvailability: >- +Product not available: >- Verdnatura communicates: Your order {{ticketFk}} created on {{created | date: "dd/MM/yyyy"}}. {{notAvailables}} not available. Sorry for the inconvenience. \ No newline at end of file diff --git a/modules/ticket/front/sale/locale/es.yml b/modules/ticket/front/sale/locale/es.yml index 74f888f569..8de8427b9a 100644 --- a/modules/ticket/front/sale/locale/es.yml +++ b/modules/ticket/front/sale/locale/es.yml @@ -24,7 +24,8 @@ Sales to transfer: Líneas a transferir Destination ticket: Ticket destinatario Change ticket state to 'Ok': Cambiar estado del ticket a 'Ok' Reserved: Reservado -SMSAvailability: "Verdnatura le comunica:\rPedido {{ticketFk}} día {{created | date: 'dd/MM/yyyy'}}.\r{{notAvailables}} no disponible/s.\rDisculpe las molestias." +Send shortage SMS: Enviar SMS faltas +Product not available: "Verdnatura le comunica:\rPedido {{ticketFk}} día {{created | date: 'dd/MM/yyyy'}}.\r{{notAvailables}} no disponible/s.\rDisculpe las molestias." Continue anyway?: ¿Continuar de todas formas? This ticket is now empty: El ticket ha quedado vacio Do you want to delete it?: ¿Quieres eliminarlo? From d0b0c9d0606d90d75356a8a01a6ae7dbc014079c Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Wed, 11 Mar 2020 12:03:55 +0100 Subject: [PATCH 65/93] pull request changes --- front/core/components/watcher/watcher.js | 5 ++++- loopback/locale/es.json | 2 +- modules/travel/back/models/travel.js | 2 +- modules/travel/front/create/index.js | 12 +----------- modules/travel/front/create/index.spec.js | 2 +- modules/travel/front/index/locale/es.yml | 3 ++- 6 files changed, 10 insertions(+), 16 deletions(-) diff --git a/front/core/components/watcher/watcher.js b/front/core/components/watcher/watcher.js index 0ab41edf95..1a1abffa55 100644 --- a/front/core/components/watcher/watcher.js +++ b/front/core/components/watcher/watcher.js @@ -167,6 +167,9 @@ export default class Watcher extends Component { ); }); } + /** + * return the request method. + */ requestMethod() { return this.$attrs.save && this.$attrs.save.toLowerCase(); @@ -183,7 +186,7 @@ export default class Watcher extends Component { } /** - * Checks if data is ready to send. + * Checks if the form is valid. */ isInvalid() { if (this.form && this.form.$invalid) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index e975185041..5f41c9931c 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -129,5 +129,5 @@ "ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto", "Distance must be lesser than 1000": "La distancia debe ser inferior a 1000", "This ticket is deleted": "Este ticket está eliminado", - "The introduced data already exists": "La información introducida ya existe" + "A travel with this data already exists": "Ya existe un travel con estos datos" } \ No newline at end of file diff --git a/modules/travel/back/models/travel.js b/modules/travel/back/models/travel.js index a7c045b314..b47742c263 100644 --- a/modules/travel/back/models/travel.js +++ b/modules/travel/back/models/travel.js @@ -10,7 +10,7 @@ module.exports = Self => { Self.rewriteDbError(function(err) { if (err.code === 'ER_DUP_ENTRY') - return new UserError('The introduced data already exists'); + return new UserError('A travel with this data already exists'); return err; }); }; diff --git a/modules/travel/front/create/index.js b/modules/travel/front/create/index.js index 513e1e0b13..0d5a2cc018 100644 --- a/modules/travel/front/create/index.js +++ b/modules/travel/front/create/index.js @@ -5,21 +5,11 @@ class Controller extends Section { constructor($element, $, $stateParams) { super($element, $); this.$stateParams = $stateParams; - this.travel = {}; } $onChanges() { if (this.$stateParams && this.$stateParams.q) - this._travel = JSON.parse(this.$stateParams.q); - } - - get travel() { - return this._travel; - } - - set travel(value) { - this._travel = value; - if (!value) return; + this.travel = JSON.parse(this.$stateParams.q); } onSubmit() { diff --git a/modules/travel/front/create/index.spec.js b/modules/travel/front/create/index.spec.js index e1095d35bc..a6fa5a9b18 100644 --- a/modules/travel/front/create/index.spec.js +++ b/modules/travel/front/create/index.spec.js @@ -36,7 +36,7 @@ describe('Travel Component vnTravelCreate', () => { controller.$onChanges(); - expect(controller._travel).toEqual(json); + expect(controller.travel).toEqual(json); }); }); }); diff --git a/modules/travel/front/index/locale/es.yml b/modules/travel/front/index/locale/es.yml index 63d23affdd..5ce4c502f4 100644 --- a/modules/travel/front/index/locale/es.yml +++ b/modules/travel/front/index/locale/es.yml @@ -1,2 +1,3 @@ Do you want to clone this travel?: ¿Desea clonar este envio? -All it's properties will be copied: Todas sus propiedades serán copiadas \ No newline at end of file +All it's properties will be copied: Todas sus propiedades serán copiadas +Clone: Clonar \ No newline at end of file From 14d471fc3225466e498dc0ee5c1ce9876e9e6574 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 11 Mar 2020 12:20:15 +0100 Subject: [PATCH 66/93] 2187 - Sort by translated module name --- front/core/services/modules.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/front/core/services/modules.js b/front/core/services/modules.js index 1021bc4fab..6b4e9dfe1f 100644 --- a/front/core/services/modules.js +++ b/front/core/services/modules.js @@ -2,10 +2,11 @@ import ngModule from '../module'; import getMainRoute from '../lib/get-main-route'; export default class Modules { - constructor(aclService, $window) { + constructor(aclService, $window, $translate) { Object.assign(this, { aclService, - $window + $window, + $translate }); } @@ -17,7 +18,7 @@ export default class Modules { if (this.modules) return this.modules; - this.modules = []; + const modules = []; for (let mod of this.$window.routes) { if (!mod || !mod.routes) continue; @@ -31,7 +32,7 @@ export default class Modules { if (res) keyBind = res.key.toUpperCase(); } - this.modules.push({ + modules.push({ name: mod.name || mod.module, icon: mod.icon || null, route, @@ -39,9 +40,15 @@ export default class Modules { }); } - return this.modules; + const sortedModules = modules.sort((a, b) => { + const translatedNameA = this.$translate.instant(a.name); + const translatedNameB = this.$translate.instant(b.name); + return translatedNameA.localeCompare(translatedNameB); + }); + + return sortedModules; } } -Modules.$inject = ['aclService', '$window']; +Modules.$inject = ['aclService', '$window', '$translate']; ngModule.service('vnModules', Modules); From 1086e13b2e904f7821c7b8efad7c42333f67e77d Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 11 Mar 2020 12:20:15 +0100 Subject: [PATCH 67/93] 2187 - Sort by translated module name --- front/core/services/modules.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/front/core/services/modules.js b/front/core/services/modules.js index 1021bc4fab..6b4e9dfe1f 100644 --- a/front/core/services/modules.js +++ b/front/core/services/modules.js @@ -2,10 +2,11 @@ import ngModule from '../module'; import getMainRoute from '../lib/get-main-route'; export default class Modules { - constructor(aclService, $window) { + constructor(aclService, $window, $translate) { Object.assign(this, { aclService, - $window + $window, + $translate }); } @@ -17,7 +18,7 @@ export default class Modules { if (this.modules) return this.modules; - this.modules = []; + const modules = []; for (let mod of this.$window.routes) { if (!mod || !mod.routes) continue; @@ -31,7 +32,7 @@ export default class Modules { if (res) keyBind = res.key.toUpperCase(); } - this.modules.push({ + modules.push({ name: mod.name || mod.module, icon: mod.icon || null, route, @@ -39,9 +40,15 @@ export default class Modules { }); } - return this.modules; + const sortedModules = modules.sort((a, b) => { + const translatedNameA = this.$translate.instant(a.name); + const translatedNameB = this.$translate.instant(b.name); + return translatedNameA.localeCompare(translatedNameB); + }); + + return sortedModules; } } -Modules.$inject = ['aclService', '$window']; +Modules.$inject = ['aclService', '$window', '$translate']; ngModule.service('vnModules', Modules); From 1c8541376b513b34d41f195285bc3aa4f8fc9e62 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 11 Mar 2020 12:54:28 +0100 Subject: [PATCH 68/93] Fixed removed letter --- 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 6ccc05e9d3..42ff5f116a 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -179,7 +179,7 @@ class Controller { totalCheckedLines() { const checkedLines = this.checkedLines(); if (checkedLines) - return checkedLines.lengt; + return checkedLines.length; } removeCheckedLines() { From 91c354e3947f5df8ef01990cc09dd550c36d98dd Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 11 Mar 2020 12:57:49 +0100 Subject: [PATCH 69/93] Removed console.log --- front/core/directives/specs/http-click.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/core/directives/specs/http-click.spec.js b/front/core/directives/specs/http-click.spec.js index 70a79bcffc..1b0979f13b 100644 --- a/front/core/directives/specs/http-click.spec.js +++ b/front/core/directives/specs/http-click.spec.js @@ -60,7 +60,7 @@ describe('Directive http-click', () => { }).finally(() => { expect(finalValue).toEqual('called!'); }).catch(err => { - console.log(err); + throw err; }); }); }); From aba24292cf1057fc70a80a464132b5d16c70f511 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 11 Mar 2020 13:36:56 +0100 Subject: [PATCH 70/93] Module translations --- front/core/services/modules.js | 3 ++- front/salix/components/home/home.html | 2 +- modules/ticket/front/sale/index.js | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/front/core/services/modules.js b/front/core/services/modules.js index 6b4e9dfe1f..874a4a97b0 100644 --- a/front/core/services/modules.js +++ b/front/core/services/modules.js @@ -45,8 +45,9 @@ export default class Modules { const translatedNameB = this.$translate.instant(b.name); return translatedNameA.localeCompare(translatedNameB); }); + this.modules = sortedModules; - return sortedModules; + return this.modules; } } Modules.$inject = ['aclService', '$window', '$translate']; diff --git a/front/salix/components/home/home.html b/front/salix/components/home/home.html index b3fc02d0db..ada51d76fb 100644 --- a/front/salix/components/home/home.html +++ b/front/salix/components/home/home.html @@ -8,7 +8,7 @@
-

+

diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index e7bf61cfe0..ff7daba03b 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -182,7 +182,6 @@ class Controller { return checkedLines.length; } - removeCheckedLines() { const sales = this.checkedLines(); From b9a482fc37b7ed8d818aa104204e1a3707d977ef Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 11 Mar 2020 15:56:02 +0100 Subject: [PATCH 71/93] 2181 - Ticket sale fix item search --- modules/item/back/models/item.json | 7 +++++++ modules/ticket/front/sale/index.html | 20 ++++++++++++-------- modules/ticket/front/sale/index.js | 6 ++++++ 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/modules/item/back/models/item.json b/modules/item/back/models/item.json index dbaa3a4090..5d2e47d2a3 100644 --- a/modules/item/back/models/item.json +++ b/modules/item/back/models/item.json @@ -175,5 +175,12 @@ "model": "ItemNiche", "foreignKey": "itemFk" } + }, + "scope": { + "where": { + "name": { + "neq": "" + } + } } } \ No newline at end of file diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 41ef74c38d..9fb0337f23 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -105,20 +105,22 @@ on-error-src/> - - {{sale.itemFk | zeroFill:6}} + {{sale.itemFk}} + search-function="$ctrl.itemSearchFunc($search)" + on-change="sale.quantity && $ctrl.onChangeQuantity(sale)" + order="id DESC" + tabindex="1"> {{id}} - {{name}} @@ -137,7 +139,8 @@ + on-change="$ctrl.onChangeQuantity(sale)" + tabindex="2"> @@ -150,7 +153,7 @@ - @@ -167,7 +170,8 @@ + ng-click="$ctrl.showEditDiscountPopover($event, sale)" + ng-if="sale.id"> {{(sale.discount / 100) | percentage}} diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index 42ff5f116a..09b5c7deaf 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -560,6 +560,12 @@ class Controller { this.$scope.model.refresh(); }); } + + itemSearchFunc($search) { + return /^\d+$/.test($search) + ? {id: $search} + : {name: {like: '%' + $search + '%'}}; + } } Controller.$inject = ['$scope', '$state', '$http', 'vnApp', '$translate']; From 6798f9709c1baa5e147323659948644f498f2963 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Thu, 12 Mar 2020 10:59:41 +0100 Subject: [PATCH 72/93] update view holiday --- .../worker/back/methods/holiday/getByWarehouse.js | 12 ++++++------ modules/worker/back/model-config.json | 2 +- .../back/models/{holiday.js => calendar-holiday.js} | 0 .../models/{holiday.json => calendar-holiday.json} | 8 ++++---- modules/worker/back/models/work-center.json | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) rename modules/worker/back/models/{holiday.js => calendar-holiday.js} (100%) rename modules/worker/back/models/{holiday.json => calendar-holiday.json} (85%) diff --git a/modules/worker/back/methods/holiday/getByWarehouse.js b/modules/worker/back/methods/holiday/getByWarehouse.js index 8a7fd8be37..093885d137 100644 --- a/modules/worker/back/methods/holiday/getByWarehouse.js +++ b/modules/worker/back/methods/holiday/getByWarehouse.js @@ -23,12 +23,12 @@ module.exports = Self => { beginningYear.setHours(0, 0, 0, 0); let holidays = await Self.rawSql( - `SELECT lh.dated, chn.name, cht.name, w.id - FROM vn.holiday lh - JOIN vn.workCenter w ON w.id = lh.workcenterFk - LEFT JOIN vn.calendarHolidaysName chn ON chn.id = lh.holidayDetailFk - LEFT JOIN vn.calendarHolidaysType cht ON cht.id = lh.holidayTypeFk - WHERE w.warehouseFk = ? AND lh.dated >= ?`, [warehouseFk, beginningYear]); + `SELECT clh.dated, chn.name, cht.name, w.id + FROM vn.calendarHolidays clh + JOIN vn.workCenter w ON w.id = clh.workcenterFk + LEFT JOIN vn.calendarHolidaysName chn ON chn.id = clh.calendarHolidaysNameFk + LEFT JOIN vn.calendarHolidaysType cht ON cht.id = clh.calendarHolidaysTypeFk + WHERE w.warehouseFk = ? AND clh.dated >= ?`, [warehouseFk, beginningYear]); return holidays.map(holiday => { holiday.dated = new Date(holiday.dated); diff --git a/modules/worker/back/model-config.json b/modules/worker/back/model-config.json index 5b9136f68c..884759bc95 100644 --- a/modules/worker/back/model-config.json +++ b/modules/worker/back/model-config.json @@ -5,7 +5,7 @@ "Department": { "dataSource": "vn" }, - "Holiday": { + "CalendarHoliday": { "dataSource": "vn" }, "CalendarHolidaysName": { diff --git a/modules/worker/back/models/holiday.js b/modules/worker/back/models/calendar-holiday.js similarity index 100% rename from modules/worker/back/models/holiday.js rename to modules/worker/back/models/calendar-holiday.js diff --git a/modules/worker/back/models/holiday.json b/modules/worker/back/models/calendar-holiday.json similarity index 85% rename from modules/worker/back/models/holiday.json rename to modules/worker/back/models/calendar-holiday.json index a820c0d518..0956893aec 100644 --- a/modules/worker/back/models/holiday.json +++ b/modules/worker/back/models/calendar-holiday.json @@ -1,17 +1,17 @@ { - "name": "Holiday", + "name": "CalendarHoliday", "base": "VnModel", "options": { "mysql": { - "table": "holiday" + "table": "calendarHolidays" } }, "properties": { - "holidayDetailFk": { + "calendarHolidaysNameFk": { "id": true, "type": "Number" }, - "holidayTypeFk": { + "calendarHolidaysTypeFk": { "id": true, "type": "Number" }, diff --git a/modules/worker/back/models/work-center.json b/modules/worker/back/models/work-center.json index 03a3350223..a0e651bba5 100644 --- a/modules/worker/back/models/work-center.json +++ b/modules/worker/back/models/work-center.json @@ -23,7 +23,7 @@ }, "holidays": { "type": "hasMany", - "model": "Holiday", + "model": "CalendarHoliday", "foreignKey": "workCenterFk" } }, From d51356f11b91b060fd7241e721d879e0e2af4898 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 13 Mar 2020 08:20:30 +0100 Subject: [PATCH 73/93] Add line on change item --- modules/ticket/front/sale/index.html | 2 +- modules/ticket/front/sale/index.js | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 9fb0337f23..b050d3579f 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -118,7 +118,7 @@ show-field="name" value-field="id" search-function="$ctrl.itemSearchFunc($search)" - on-change="sale.quantity && $ctrl.onChangeQuantity(sale)" + on-change="$ctrl.onChangeQuantity(sale)" order="id DESC" tabindex="1"> diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index 09b5c7deaf..c5e947d237 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -464,10 +464,12 @@ class Controller { * Updates the sale quantity for existing instance */ onChangeQuantity(sale) { + if (!sale.quantity) return; + if (!sale.id) - this.addSale(sale); - else - this.updateQuantity(sale); + return this.addSale(sale); + + this.updateQuantity(sale); } /* From f8c69306f4672e1105bbcd1a806a0bb36ad322ec Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 13 Mar 2020 08:44:01 +0100 Subject: [PATCH 74/93] Updated unit test --- modules/ticket/front/sale/specs/index.spec.js | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/modules/ticket/front/sale/specs/index.spec.js b/modules/ticket/front/sale/specs/index.spec.js index 2e7979faa0..14000e01af 100644 --- a/modules/ticket/front/sale/specs/index.spec.js +++ b/modules/ticket/front/sale/specs/index.spec.js @@ -2,7 +2,7 @@ import '../index.js'; import watcher from 'core/mocks/watcher'; import crudModel from 'core/mocks/crud-model'; -describe('Ticket', () => { +fdescribe('Ticket', () => { describe('Component vnTicketSale', () => { let controller; let $scope; @@ -207,6 +207,39 @@ describe('Ticket', () => { }); }); + describe('onChangeQuantity()', () => { + it('should not call addSale() or updateQuantity() methods', () => { + jest.spyOn(controller, 'addSale'); + jest.spyOn(controller, 'updateQuantity'); + + const sale = {itemFk: 4}; + controller.onChangeQuantity(sale); + + expect(controller.addSale).not.toHaveBeenCalled(); + expect(controller.updateQuantity).not.toHaveBeenCalled(); + }); + + it('should call addSale() method', () => { + jest.spyOn(controller, 'addSale'); + + const sale = {itemFk: 4, quantity: 5}; + controller.onChangeQuantity(sale); + + expect(controller.addSale).toHaveBeenCalledWith(sale); + }); + + it('should call updateQuantity() method', () => { + jest.spyOn(controller, 'updateQuantity'); + jest.spyOn(controller, 'addSale'); + + const sale = {id: 1, itemFk: 4, quantity: 5}; + controller.onChangeQuantity(sale); + + expect(controller.addSale).not.toHaveBeenCalled(); + expect(controller.updateQuantity).toHaveBeenCalledWith(sale); + }); + }); + describe('updateQuantity()', () => { it('should make a POST query saving sale quantity', () => { jest.spyOn(controller.$scope.watcher, 'updateOriginalData'); From 2d755c90944feadc86e1df691a8002a24016e7d2 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 13 Mar 2020 08:47:41 +0100 Subject: [PATCH 75/93] Updated unit test --- modules/ticket/front/sale/specs/index.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/front/sale/specs/index.spec.js b/modules/ticket/front/sale/specs/index.spec.js index 14000e01af..3b0f04a82c 100644 --- a/modules/ticket/front/sale/specs/index.spec.js +++ b/modules/ticket/front/sale/specs/index.spec.js @@ -2,7 +2,7 @@ import '../index.js'; import watcher from 'core/mocks/watcher'; import crudModel from 'core/mocks/crud-model'; -fdescribe('Ticket', () => { +describe('Ticket', () => { describe('Component vnTicketSale', () => { let controller; let $scope; From 298e52e055e61f0649a9e231fb05c2c2806d3534 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 13 Mar 2020 10:49:44 +0100 Subject: [PATCH 76/93] 2193 - Chrome datalist hotfix --- front/core/components/datalist/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/front/core/components/datalist/index.js b/front/core/components/datalist/index.js index d52e6ca230..d74de46438 100644 --- a/front/core/components/datalist/index.js +++ b/front/core/components/datalist/index.js @@ -14,6 +14,9 @@ export default class Datalist extends Textfield { this.buildInput('text'); this.input.setAttribute('autocomplete', 'off'); + this.input.addEventListener('blur', () => { + console.log('focus out'); + }); } get field() { @@ -258,7 +261,8 @@ export default class Datalist extends Textfield { fragment.appendChild(option); } - list.appendChild(fragment); + this.$.$applyAsync(() => + list.appendChild(fragment)); } } From ba19c9069a178b3b158216d140972197b9c2ff51 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 13 Mar 2020 10:52:56 +0100 Subject: [PATCH 77/93] Removed event --- front/core/components/datalist/index.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/front/core/components/datalist/index.js b/front/core/components/datalist/index.js index d74de46438..3ac787d462 100644 --- a/front/core/components/datalist/index.js +++ b/front/core/components/datalist/index.js @@ -13,10 +13,7 @@ export default class Datalist extends Textfield { this._selection = null; this.buildInput('text'); - this.input.setAttribute('autocomplete', 'off'); - this.input.addEventListener('blur', () => { - console.log('focus out'); - }); + this.autocomplete = 'off'; } get field() { From 269bd8e69a64212192c7f6c49a2fd0c436439073 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 11 Mar 2020 15:56:02 +0100 Subject: [PATCH 78/93] 2181 - Ticket sale fix item search --- modules/item/back/models/item.json | 7 +++++++ modules/ticket/front/sale/index.html | 20 ++++++++++++-------- modules/ticket/front/sale/index.js | 6 ++++++ 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/modules/item/back/models/item.json b/modules/item/back/models/item.json index dbaa3a4090..5d2e47d2a3 100644 --- a/modules/item/back/models/item.json +++ b/modules/item/back/models/item.json @@ -175,5 +175,12 @@ "model": "ItemNiche", "foreignKey": "itemFk" } + }, + "scope": { + "where": { + "name": { + "neq": "" + } + } } } \ No newline at end of file diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 41ef74c38d..9fb0337f23 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -105,20 +105,22 @@ on-error-src/> - - {{sale.itemFk | zeroFill:6}} + {{sale.itemFk}} + search-function="$ctrl.itemSearchFunc($search)" + on-change="sale.quantity && $ctrl.onChangeQuantity(sale)" + order="id DESC" + tabindex="1"> {{id}} - {{name}} @@ -137,7 +139,8 @@ + on-change="$ctrl.onChangeQuantity(sale)" + tabindex="2"> @@ -150,7 +153,7 @@ - @@ -167,7 +170,8 @@ + ng-click="$ctrl.showEditDiscountPopover($event, sale)" + ng-if="sale.id"> {{(sale.discount / 100) | percentage}} diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index ff7daba03b..fd52bd970d 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -560,6 +560,12 @@ class Controller { this.$scope.model.refresh(); }); } + + itemSearchFunc($search) { + return /^\d+$/.test($search) + ? {id: $search} + : {name: {like: '%' + $search + '%'}}; + } } Controller.$inject = ['$scope', '$state', '$http', 'vnApp', '$translate']; From d9176728b07469c170c7f36cff2a137ec3120902 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 13 Mar 2020 08:20:30 +0100 Subject: [PATCH 79/93] Add line on change item --- modules/ticket/front/sale/index.html | 2 +- modules/ticket/front/sale/index.js | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 9fb0337f23..b050d3579f 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -118,7 +118,7 @@ show-field="name" value-field="id" search-function="$ctrl.itemSearchFunc($search)" - on-change="sale.quantity && $ctrl.onChangeQuantity(sale)" + on-change="$ctrl.onChangeQuantity(sale)" order="id DESC" tabindex="1"> diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index fd52bd970d..0b4b8f176d 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -464,10 +464,12 @@ class Controller { * Updates the sale quantity for existing instance */ onChangeQuantity(sale) { + if (!sale.quantity) return; + if (!sale.id) - this.addSale(sale); - else - this.updateQuantity(sale); + return this.addSale(sale); + + this.updateQuantity(sale); } /* From db89e3f5d428ad80ea0ce6fcadcfa6fac04e026f Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 13 Mar 2020 08:44:01 +0100 Subject: [PATCH 80/93] Updated unit test --- modules/ticket/front/sale/specs/index.spec.js | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/modules/ticket/front/sale/specs/index.spec.js b/modules/ticket/front/sale/specs/index.spec.js index 2e7979faa0..14000e01af 100644 --- a/modules/ticket/front/sale/specs/index.spec.js +++ b/modules/ticket/front/sale/specs/index.spec.js @@ -2,7 +2,7 @@ import '../index.js'; import watcher from 'core/mocks/watcher'; import crudModel from 'core/mocks/crud-model'; -describe('Ticket', () => { +fdescribe('Ticket', () => { describe('Component vnTicketSale', () => { let controller; let $scope; @@ -207,6 +207,39 @@ describe('Ticket', () => { }); }); + describe('onChangeQuantity()', () => { + it('should not call addSale() or updateQuantity() methods', () => { + jest.spyOn(controller, 'addSale'); + jest.spyOn(controller, 'updateQuantity'); + + const sale = {itemFk: 4}; + controller.onChangeQuantity(sale); + + expect(controller.addSale).not.toHaveBeenCalled(); + expect(controller.updateQuantity).not.toHaveBeenCalled(); + }); + + it('should call addSale() method', () => { + jest.spyOn(controller, 'addSale'); + + const sale = {itemFk: 4, quantity: 5}; + controller.onChangeQuantity(sale); + + expect(controller.addSale).toHaveBeenCalledWith(sale); + }); + + it('should call updateQuantity() method', () => { + jest.spyOn(controller, 'updateQuantity'); + jest.spyOn(controller, 'addSale'); + + const sale = {id: 1, itemFk: 4, quantity: 5}; + controller.onChangeQuantity(sale); + + expect(controller.addSale).not.toHaveBeenCalled(); + expect(controller.updateQuantity).toHaveBeenCalledWith(sale); + }); + }); + describe('updateQuantity()', () => { it('should make a POST query saving sale quantity', () => { jest.spyOn(controller.$scope.watcher, 'updateOriginalData'); From d2346471129c16dd37bd092904dff1061e2afb5b Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 13 Mar 2020 08:47:41 +0100 Subject: [PATCH 81/93] Updated unit test --- modules/ticket/front/sale/specs/index.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/front/sale/specs/index.spec.js b/modules/ticket/front/sale/specs/index.spec.js index 14000e01af..3b0f04a82c 100644 --- a/modules/ticket/front/sale/specs/index.spec.js +++ b/modules/ticket/front/sale/specs/index.spec.js @@ -2,7 +2,7 @@ import '../index.js'; import watcher from 'core/mocks/watcher'; import crudModel from 'core/mocks/crud-model'; -fdescribe('Ticket', () => { +describe('Ticket', () => { describe('Component vnTicketSale', () => { let controller; let $scope; From fdd1c7348543f0c51d8df6c5293e9a041fd7291c Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Fri, 13 Mar 2020 12:26:15 +0100 Subject: [PATCH 82/93] refactor componentUpdate --- .../back/methods/ticket/componentUpdate.js | 42 ++++++++++--------- .../ticket/specs/componentUpdate.spec.js | 7 +++- .../ticket/front/basic-data/step-two/index.js | 12 +++--- 3 files changed, 33 insertions(+), 28 deletions(-) diff --git a/modules/ticket/back/methods/ticket/componentUpdate.js b/modules/ticket/back/methods/ticket/componentUpdate.js index 3447f52bfe..00a6aae4bb 100644 --- a/modules/ticket/back/methods/ticket/componentUpdate.js +++ b/modules/ticket/back/methods/ticket/componentUpdate.js @@ -12,32 +12,32 @@ module.exports = Self => { description: 'The ticket id', http: {source: 'path'} }, { - arg: 'clientId', + arg: 'clientFk', type: 'Number', description: 'The client id', required: true }, { - arg: 'agencyModeId', + arg: 'agencyModeFk', type: 'Number', description: 'The agencyMode id', required: true }, { - arg: 'addressId', + arg: 'addressFk', type: 'Number', description: 'The address id', required: true }, { - arg: 'zoneId', + arg: 'zoneFk', type: 'Number', description: 'The zone id', required: true }, { - arg: 'warehouseId', + arg: 'warehouseFk', type: 'Number', description: 'The warehouse id', required: true }, { - arg: 'companyId', + arg: 'companyFk', type: 'Number', description: 'The company id', required: true @@ -72,8 +72,8 @@ module.exports = Self => { } }); - Self.componentUpdate = async(ctx, id, clientId, agencyModeId, addressId, zoneId, warehouseId, - companyId, shipped, landed, isDeleted, option) => { + Self.componentUpdate = async(ctx, id, clientFk, agencyModeFk, addressFk, zoneFk, warehouseFk, + companyFk, shipped, landed, isDeleted, option) => { const userId = ctx.req.accessToken.userId; const models = Self.app.models; const isEditable = await models.Ticket.isEditable(ctx, id); @@ -83,31 +83,33 @@ module.exports = Self => { const isProductionBoss = await models.Account.hasRole(userId, 'productionBoss'); if (!isProductionBoss) { - const zoneShipped = await models.Agency.getShipped(landed, addressId, agencyModeId, warehouseId); + const zoneShipped = await models.Agency.getShipped(landed, addressFk, agencyModeFk, warehouseFk); - if (!zoneShipped || zoneShipped.zoneFk != zoneId) + if (!zoneShipped || zoneShipped.zoneFk != zoneFk) throw new UserError(`You don't have privileges to change the zone`); } const originalTicket = await models.Ticket.findById(id, {fields: ['id', 'clientFk', 'agencyModeFk', 'addressFk', 'zoneFk', 'warehouseFk', 'companyFk', 'shipped', 'landed', 'isDeleted'] }); - const properties = Object.assign({}, ctx.args); - delete properties.ctx; - delete properties.option; + const updatedTicket = Object.assign({}, ctx.args); + delete updatedTicket.ctx; + delete updatedTicket.option; // Force unroute const hasToBeUnrouted = true; + console.log('updatedTicket', updatedTicket); console.log('originalTicket', originalTicket); - console.log('properties', properties); + const propertiesChange = diff(originalTicket, updatedTicket); + console.log('propertiesChange', propertiesChange); let query = 'CALL vn.ticket_componentMakeUpdate(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; let res = await Self.rawSql(query, [ id, - clientId, - agencyModeId, - addressId, - zoneId, - warehouseId, - companyId, + clientFk, + agencyModeFk, + addressFk, + zoneFk, + warehouseFk, + companyFk, shipped, landed, isDeleted, diff --git a/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js b/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js index 04570390d5..cb36a3b2d1 100644 --- a/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js +++ b/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js @@ -1,6 +1,6 @@ const app = require('vn-loopback/server/server'); -describe('ticket componentUpdate()', () => { +fdescribe('ticket componentUpdate()', () => { const ticketId = 11; const today = new Date(); const tomorrow = new Date(); @@ -39,7 +39,10 @@ describe('ticket componentUpdate()', () => { const landed = tomorrow; const option = 1; - let ctx = {req: {accessToken: {userId: 101}}}; + let ctx = { + args: {ticketId: '', + } + req: {accessToken: {userId: 101}}}; await app.models.Ticket.componentUpdate(ctx, ticketId, clientId, agencyModeId, addressId, zoneId, warehouseId, companyId, shipped, landed, isDeleted, option); diff --git a/modules/ticket/front/basic-data/step-two/index.js b/modules/ticket/front/basic-data/step-two/index.js index ec8d94f9a7..f766f57269 100644 --- a/modules/ticket/front/basic-data/step-two/index.js +++ b/modules/ticket/front/basic-data/step-two/index.js @@ -75,12 +75,12 @@ class Controller { let query = `tickets/${this.ticket.id}/componentUpdate`; let params = { - clientId: this.ticket.clientFk, - agencyModeId: this.ticket.agencyModeFk, - addressId: this.ticket.addressFk, - zoneId: this.ticket.zoneFk, - warehouseId: this.ticket.warehouseFk, - companyId: this.ticket.companyFk, + clientFk: this.ticket.clientFk, + agencyModeFk: this.ticket.agencyModeFk, + addressFk: this.ticket.addressFk, + zoneFk: this.ticket.zoneFk, + warehouseFk: this.ticket.warehouseFk, + companyFk: this.ticket.companyFk, shipped: this.ticket.shipped, landed: this.ticket.landed, isDeleted: this.ticket.isDeleted, From f9abaa409aa03f7921299d57c0ba454fa0ee8bdd Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Fri, 13 Mar 2020 13:10:04 +0100 Subject: [PATCH 83/93] fix calendar-holiday model --- modules/worker/back/models/calendar-holiday.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/worker/back/models/calendar-holiday.json b/modules/worker/back/models/calendar-holiday.json index 0956893aec..5444525530 100644 --- a/modules/worker/back/models/calendar-holiday.json +++ b/modules/worker/back/models/calendar-holiday.json @@ -23,12 +23,12 @@ "detail": { "type": "belongsTo", "model": "CalendarHolidaysName", - "foreignKey": "holidayDetailFk" + "foreignKey": "calendarHolidaysNameFk" }, "type": { "type": "belongsTo", "model": "CalendarHolidaysType", - "foreignKey": "holidayTypeFk" + "foreignKey": "calendarHolidaysTypeFk" }, "workCenter": { "type": "belongsTo", From 227760d71287893d881772e887112c4464c41e52 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 13 Mar 2020 14:09:22 +0100 Subject: [PATCH 84/93] 2191 - Added showEmpty filter --- modules/order/back/methods/order/filter.js | 20 ++++++++-- .../back/methods/order/specs/filter.spec.js | 38 +++++++++++++++---- modules/order/front/main/index.html | 3 +- modules/order/front/main/index.js | 6 ++- modules/order/front/search-panel/index.html | 6 +++ 5 files changed, 60 insertions(+), 13 deletions(-) diff --git a/modules/order/back/methods/order/filter.js b/modules/order/back/methods/order/filter.js index 1eaa167a70..3b891ebad8 100644 --- a/modules/order/back/methods/order/filter.js +++ b/modules/order/back/methods/order/filter.js @@ -55,6 +55,10 @@ module.exports = Self => { arg: 'isConfirmed', type: 'Boolean', description: `Order is confirmed` + }, { + arg: 'showEmpty', + type: 'boolean', + description: `Show empty orders` } ], returns: { @@ -75,6 +79,7 @@ module.exports = Self => { {relation: 'collegues'} ] }); + const args = ctx.args; let teamIds = []; if (worker.collegues().length && ctx.args.myTeam) { @@ -164,6 +169,7 @@ module.exports = Self => { sql: `LEFT JOIN orderTicket ort ON ort.orderFk = o.id` }); } + stmt.merge(conn.makeSuffix(filter)); stmts.push(stmt); @@ -176,10 +182,18 @@ module.exports = Self => { stmts.push('CALL hedera.order_getTotal()'); - let orderIndex = stmts.push(` - SELECT f.*, ot.* + stmt = new ParameterizedSQL( + `SELECT f.*, ot.* FROM tmp.filter f - LEFT JOIN tmp.orderTotal ot ON ot.orderFk = f.id`) - 1; + LEFT JOIN tmp.orderTotal ot ON ot.orderFk = f.id`); + const filterWhere = {}; + + if (args && args.showEmpty === false) + filterWhere.total = {neq: 0}; + + stmt.merge(conn.makeWhere(filterWhere)); + + const orderIndex = stmts.push(stmt) - 1; stmts.push(` DROP TEMPORARY TABLE diff --git a/modules/order/back/methods/order/specs/filter.spec.js b/modules/order/back/methods/order/specs/filter.spec.js index fc987613ad..13cb8fdeba 100644 --- a/modules/order/back/methods/order/specs/filter.spec.js +++ b/modules/order/back/methods/order/specs/filter.spec.js @@ -1,32 +1,54 @@ const app = require('vn-loopback/server/server'); describe('order filter()', () => { - let ctx = { + const ctx = { req: {accessToken: {userId: 9}}, args: {}, params: {} }; it('should call the filter method with a basic search', async() => { - let filter = {where: {'o.id': 2}}; - let result = await app.models.Order.filter(ctx, filter); - let orderId = result[0].id; + const filter = {where: {'o.id': 2}}; + const result = await app.models.Order.filter(ctx, filter); + const orderId = result[0].id; expect(orderId).toEqual(2); }); it('should call the filter method with a single advanced search', async() => { - let filter = {where: {'o.confirmed': false}}; - let result = await app.models.Order.filter(ctx, filter); + const filter = {where: {'o.confirmed': false}}; + const result = await app.models.Order.filter(ctx, filter); expect(result.length).toEqual(16); }); it('should call the filter method with a complex advanced search', async() => { - let filter = {where: {'o.confirmed': false, 'c.salesPersonFk': 19}}; - let result = await app.models.Order.filter(ctx, filter); + const filter = {where: {'o.confirmed': false, 'c.salesPersonFk': 19}}; + const result = await app.models.Order.filter(ctx, filter); expect(result.length).toEqual(7); expect(result[0].id).toEqual(16); }); + + it('should return the orders matching the showEmpty on false', async() => { + const filter = {}; + ctx.args = {showEmpty: false}; + const result = await app.models.Order.filter(ctx, filter); + const hasEmptyLines = result.some(order => { + return order.total === 0; + }); + + expect(hasEmptyLines).toBeFalsy(); + }); + + it('should return the orders matching the showEmpty on true', async() => { + const filter = {}; + ctx.args = {showEmpty: true}; + const result = await app.models.Order.filter(ctx, filter); + const hasEmptyLines = result.some(order => { + return order.total === 0; + }); + + expect(hasEmptyLines).toBeTruthy(); + }); }); diff --git a/modules/order/front/main/index.html b/modules/order/front/main/index.html index 09d4985996..7948e591af 100644 --- a/modules/order/front/main/index.html +++ b/modules/order/front/main/index.html @@ -2,7 +2,8 @@ + info="Search orders by id" + filter="$ctrl.filter"> diff --git a/modules/order/front/main/index.js b/modules/order/front/main/index.js index 7513d21447..caf819c9d9 100644 --- a/modules/order/front/main/index.js +++ b/modules/order/front/main/index.js @@ -1,7 +1,11 @@ import ngModule from '../module'; import ModuleMain from 'salix/components/module-main'; -export default class Order extends ModuleMain {} +export default class Order extends ModuleMain { + $postLink() { + this.filter = {showEmpty: false}; + } +} ngModule.vnComponent('vnOrder', { controller: Order, diff --git a/modules/order/front/search-panel/index.html b/modules/order/front/search-panel/index.html index 383df455f7..e73e0d1dcb 100644 --- a/modules/order/front/search-panel/index.html +++ b/modules/order/front/search-panel/index.html @@ -76,6 +76,12 @@ triple-state="true" ng-model="filter.isConfirmed"> + + From 920d2c66b0fe3122500eac702c855ec2a3245572 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 13 Mar 2020 14:25:34 +0100 Subject: [PATCH 85/93] Added translation --- modules/order/front/search-panel/index.html | 3 +-- modules/order/front/search-panel/locale/es.yml | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/order/front/search-panel/index.html b/modules/order/front/search-panel/index.html index e73e0d1dcb..f9b214578d 100644 --- a/modules/order/front/search-panel/index.html +++ b/modules/order/front/search-panel/index.html @@ -79,8 +79,7 @@ + ng-model="filter.showEmpty"> diff --git a/modules/order/front/search-panel/locale/es.yml b/modules/order/front/search-panel/locale/es.yml index 8f8620ac8d..949f9b2024 100644 --- a/modules/order/front/search-panel/locale/es.yml +++ b/modules/order/front/search-panel/locale/es.yml @@ -6,4 +6,5 @@ To: Hasta Agency: Agencia Application: Aplicación SalesPerson: Comercial -Order confirmed: Pedido confirmado \ No newline at end of file +Order confirmed: Pedido confirmado +Show empty: Mostrar vacías \ No newline at end of file From 55ff624394f05a65d6c375fa91525aab37617eac Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 13 Mar 2020 14:09:22 +0100 Subject: [PATCH 86/93] 2191 - Added showEmpty filter --- modules/order/back/methods/order/filter.js | 20 ++++++++-- .../back/methods/order/specs/filter.spec.js | 38 +++++++++++++++---- modules/order/front/main/index.html | 3 +- modules/order/front/main/index.js | 6 ++- modules/order/front/search-panel/index.html | 6 +++ 5 files changed, 60 insertions(+), 13 deletions(-) diff --git a/modules/order/back/methods/order/filter.js b/modules/order/back/methods/order/filter.js index 1eaa167a70..3b891ebad8 100644 --- a/modules/order/back/methods/order/filter.js +++ b/modules/order/back/methods/order/filter.js @@ -55,6 +55,10 @@ module.exports = Self => { arg: 'isConfirmed', type: 'Boolean', description: `Order is confirmed` + }, { + arg: 'showEmpty', + type: 'boolean', + description: `Show empty orders` } ], returns: { @@ -75,6 +79,7 @@ module.exports = Self => { {relation: 'collegues'} ] }); + const args = ctx.args; let teamIds = []; if (worker.collegues().length && ctx.args.myTeam) { @@ -164,6 +169,7 @@ module.exports = Self => { sql: `LEFT JOIN orderTicket ort ON ort.orderFk = o.id` }); } + stmt.merge(conn.makeSuffix(filter)); stmts.push(stmt); @@ -176,10 +182,18 @@ module.exports = Self => { stmts.push('CALL hedera.order_getTotal()'); - let orderIndex = stmts.push(` - SELECT f.*, ot.* + stmt = new ParameterizedSQL( + `SELECT f.*, ot.* FROM tmp.filter f - LEFT JOIN tmp.orderTotal ot ON ot.orderFk = f.id`) - 1; + LEFT JOIN tmp.orderTotal ot ON ot.orderFk = f.id`); + const filterWhere = {}; + + if (args && args.showEmpty === false) + filterWhere.total = {neq: 0}; + + stmt.merge(conn.makeWhere(filterWhere)); + + const orderIndex = stmts.push(stmt) - 1; stmts.push(` DROP TEMPORARY TABLE diff --git a/modules/order/back/methods/order/specs/filter.spec.js b/modules/order/back/methods/order/specs/filter.spec.js index fc987613ad..13cb8fdeba 100644 --- a/modules/order/back/methods/order/specs/filter.spec.js +++ b/modules/order/back/methods/order/specs/filter.spec.js @@ -1,32 +1,54 @@ const app = require('vn-loopback/server/server'); describe('order filter()', () => { - let ctx = { + const ctx = { req: {accessToken: {userId: 9}}, args: {}, params: {} }; it('should call the filter method with a basic search', async() => { - let filter = {where: {'o.id': 2}}; - let result = await app.models.Order.filter(ctx, filter); - let orderId = result[0].id; + const filter = {where: {'o.id': 2}}; + const result = await app.models.Order.filter(ctx, filter); + const orderId = result[0].id; expect(orderId).toEqual(2); }); it('should call the filter method with a single advanced search', async() => { - let filter = {where: {'o.confirmed': false}}; - let result = await app.models.Order.filter(ctx, filter); + const filter = {where: {'o.confirmed': false}}; + const result = await app.models.Order.filter(ctx, filter); expect(result.length).toEqual(16); }); it('should call the filter method with a complex advanced search', async() => { - let filter = {where: {'o.confirmed': false, 'c.salesPersonFk': 19}}; - let result = await app.models.Order.filter(ctx, filter); + const filter = {where: {'o.confirmed': false, 'c.salesPersonFk': 19}}; + const result = await app.models.Order.filter(ctx, filter); expect(result.length).toEqual(7); expect(result[0].id).toEqual(16); }); + + it('should return the orders matching the showEmpty on false', async() => { + const filter = {}; + ctx.args = {showEmpty: false}; + const result = await app.models.Order.filter(ctx, filter); + const hasEmptyLines = result.some(order => { + return order.total === 0; + }); + + expect(hasEmptyLines).toBeFalsy(); + }); + + it('should return the orders matching the showEmpty on true', async() => { + const filter = {}; + ctx.args = {showEmpty: true}; + const result = await app.models.Order.filter(ctx, filter); + const hasEmptyLines = result.some(order => { + return order.total === 0; + }); + + expect(hasEmptyLines).toBeTruthy(); + }); }); diff --git a/modules/order/front/main/index.html b/modules/order/front/main/index.html index 09d4985996..7948e591af 100644 --- a/modules/order/front/main/index.html +++ b/modules/order/front/main/index.html @@ -2,7 +2,8 @@ + info="Search orders by id" + filter="$ctrl.filter"> diff --git a/modules/order/front/main/index.js b/modules/order/front/main/index.js index 7513d21447..caf819c9d9 100644 --- a/modules/order/front/main/index.js +++ b/modules/order/front/main/index.js @@ -1,7 +1,11 @@ import ngModule from '../module'; import ModuleMain from 'salix/components/module-main'; -export default class Order extends ModuleMain {} +export default class Order extends ModuleMain { + $postLink() { + this.filter = {showEmpty: false}; + } +} ngModule.vnComponent('vnOrder', { controller: Order, diff --git a/modules/order/front/search-panel/index.html b/modules/order/front/search-panel/index.html index 383df455f7..e73e0d1dcb 100644 --- a/modules/order/front/search-panel/index.html +++ b/modules/order/front/search-panel/index.html @@ -76,6 +76,12 @@ triple-state="true" ng-model="filter.isConfirmed"> + + From 2d2441707896a38935fc14accf1fa0b46650bfad Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 13 Mar 2020 14:25:34 +0100 Subject: [PATCH 87/93] Added translation --- modules/order/front/search-panel/index.html | 3 +-- modules/order/front/search-panel/locale/es.yml | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/order/front/search-panel/index.html b/modules/order/front/search-panel/index.html index e73e0d1dcb..f9b214578d 100644 --- a/modules/order/front/search-panel/index.html +++ b/modules/order/front/search-panel/index.html @@ -79,8 +79,7 @@ + ng-model="filter.showEmpty"> diff --git a/modules/order/front/search-panel/locale/es.yml b/modules/order/front/search-panel/locale/es.yml index 8f8620ac8d..949f9b2024 100644 --- a/modules/order/front/search-panel/locale/es.yml +++ b/modules/order/front/search-panel/locale/es.yml @@ -6,4 +6,5 @@ To: Hasta Agency: Agencia Application: Aplicación SalesPerson: Comercial -Order confirmed: Pedido confirmado \ No newline at end of file +Order confirmed: Pedido confirmado +Show empty: Mostrar vacías \ No newline at end of file From 36ad778a590b4d432c2dea54a2d53b5f57d6d758 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 13 Mar 2020 15:02:51 +0100 Subject: [PATCH 88/93] Removed default filter --- modules/order/front/main/index.js | 2 +- modules/order/front/search-panel/index.html | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/order/front/main/index.js b/modules/order/front/main/index.js index caf819c9d9..afab4fc6e4 100644 --- a/modules/order/front/main/index.js +++ b/modules/order/front/main/index.js @@ -3,7 +3,7 @@ import ModuleMain from 'salix/components/module-main'; export default class Order extends ModuleMain { $postLink() { - this.filter = {showEmpty: false}; + // this.filter = {showEmpty: false}; } } diff --git a/modules/order/front/search-panel/index.html b/modules/order/front/search-panel/index.html index f9b214578d..991daa2e6e 100644 --- a/modules/order/front/search-panel/index.html +++ b/modules/order/front/search-panel/index.html @@ -76,11 +76,11 @@ triple-state="true" ng-model="filter.isConfirmed"> - - + --> From 7987603d7b64df95df991f7f3a5a53ec2edf826f Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 13 Mar 2020 17:22:59 +0100 Subject: [PATCH 89/93] Updated filter --- modules/order/back/methods/order/filter.js | 22 ++++++++------------- modules/order/front/main/index.js | 2 +- modules/order/front/search-panel/index.html | 4 ++-- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/modules/order/back/methods/order/filter.js b/modules/order/back/methods/order/filter.js index 3b891ebad8..5b6af92b19 100644 --- a/modules/order/back/methods/order/filter.js +++ b/modules/order/back/methods/order/filter.js @@ -82,13 +82,13 @@ module.exports = Self => { const args = ctx.args; let teamIds = []; - if (worker.collegues().length && ctx.args.myTeam) { + if (worker.collegues().length && args.myTeam) { worker.collegues().forEach(collegue => { teamIds.push(collegue.collegueFk); }); } - if (worker.collegues().length === 0 && ctx.args.myTeam) { + if (worker.collegues().length === 0 && args.myTeam) { worker = await Self.app.models.Worker.findOne({ fields: ['id'], where: {userFk: ctx.req.accessToken.userId} @@ -96,9 +96,9 @@ module.exports = Self => { teamIds = [worker && worker.id]; } - if (ctx.args && ctx.args.myTeam) - ctx.args.teamIds = teamIds; - let where = buildFilter(ctx.args, (param, value) => { + if (args && args.myTeam) + args.teamIds = teamIds; + let where = buildFilter(args, (param, value) => { switch (param) { case 'search': return /^\d+$/.test(value) @@ -106,7 +106,6 @@ module.exports = Self => { : {or: [ {'c.name': {like: `%${value}%`}} ]}; - // return {'o.id': value}; case 'from': return {'o.date_send': {gte: value}}; case 'to': @@ -125,6 +124,8 @@ module.exports = Self => { return {'o.confirmed': value ? 1 : 0}; case 'myTeam': return {'c.salesPersonFk': {inq: teamIds}}; + case 'showEmpty': + return {'o.total': {neq: value}}; case 'id': param = `o.${param}`; return {[param]: value}; @@ -164,7 +165,7 @@ module.exports = Self => { LEFT JOIN account.user u ON u.id = wk.userFk LEFT JOIN company co ON co.id = o.company_id`); - if (ctx.args && ctx.args.ticketFk) { + if (args && args.ticketFk) { stmt.merge({ sql: `LEFT JOIN orderTicket ort ON ort.orderFk = o.id` }); @@ -186,13 +187,6 @@ module.exports = Self => { `SELECT f.*, ot.* FROM tmp.filter f LEFT JOIN tmp.orderTotal ot ON ot.orderFk = f.id`); - const filterWhere = {}; - - if (args && args.showEmpty === false) - filterWhere.total = {neq: 0}; - - stmt.merge(conn.makeWhere(filterWhere)); - const orderIndex = stmts.push(stmt) - 1; stmts.push(` diff --git a/modules/order/front/main/index.js b/modules/order/front/main/index.js index afab4fc6e4..caf819c9d9 100644 --- a/modules/order/front/main/index.js +++ b/modules/order/front/main/index.js @@ -3,7 +3,7 @@ import ModuleMain from 'salix/components/module-main'; export default class Order extends ModuleMain { $postLink() { - // this.filter = {showEmpty: false}; + this.filter = {showEmpty: false}; } } diff --git a/modules/order/front/search-panel/index.html b/modules/order/front/search-panel/index.html index 991daa2e6e..f9b214578d 100644 --- a/modules/order/front/search-panel/index.html +++ b/modules/order/front/search-panel/index.html @@ -76,11 +76,11 @@ triple-state="true" ng-model="filter.isConfirmed"> - + From f6ca9eee0181a01a8b57ce4f6ed4fb0f4a4dac03 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Mon, 16 Mar 2020 09:13:44 +0100 Subject: [PATCH 90/93] ticketlog in componentUpdate --- .../back/methods/ticket/componentUpdate.js | 16 +++++++++++++--- .../methods/ticket/specs/componentUpdate.spec.js | 12 ++++++++---- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/modules/ticket/back/methods/ticket/componentUpdate.js b/modules/ticket/back/methods/ticket/componentUpdate.js index 00a6aae4bb..15cfa05975 100644 --- a/modules/ticket/back/methods/ticket/componentUpdate.js +++ b/modules/ticket/back/methods/ticket/componentUpdate.js @@ -97,10 +97,18 @@ module.exports = Self => { delete updatedTicket.option; // Force unroute const hasToBeUnrouted = true; - console.log('updatedTicket', updatedTicket); - console.log('originalTicket', originalTicket); const propertiesChange = diff(originalTicket, updatedTicket); - console.log('propertiesChange', propertiesChange); + + let logRecord = { + originFk: id, + userFk: userId, + action: 'update', + changedModel: 'Ticket', + changedModelId: id, + oldInstance: originalTicket, + newInstance: propertiesChange + }; + let query = 'CALL vn.ticket_componentMakeUpdate(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; let res = await Self.rawSql(query, [ id, @@ -116,6 +124,8 @@ module.exports = Self => { hasToBeUnrouted, option ]); + + await models.TicketLog.create(logRecord); return res; }; }; diff --git a/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js b/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js index cb36a3b2d1..8954e6d479 100644 --- a/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js +++ b/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js @@ -1,6 +1,6 @@ const app = require('vn-loopback/server/server'); -fdescribe('ticket componentUpdate()', () => { +describe('ticket componentUpdate()', () => { const ticketId = 11; const today = new Date(); const tomorrow = new Date(); @@ -40,8 +40,8 @@ fdescribe('ticket componentUpdate()', () => { const option = 1; let ctx = { - args: {ticketId: '', - } + args: {clientFk: 102, + agencyModeFk: 8}, req: {accessToken: {userId: 101}}}; await app.models.Ticket.componentUpdate(ctx, ticketId, clientId, agencyModeId, addressId, @@ -69,7 +69,11 @@ fdescribe('ticket componentUpdate()', () => { const landed = tomorrow; const option = 1; - let ctx = {req: {accessToken: {userId: 101}}}; + let ctx = { + args: {clientFk: 102, + agencyModeFk: 7}, + req: {accessToken: {userId: 101}}}; + await app.models.Ticket.componentUpdate(ctx, ticketId, clientId, agencyModeId, addressId, zoneId, warehouseId, companyId, shipped, landed, isDeleted, option); From 676033060dfffa38b3372e2bd95ac6feffacfbba Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Mon, 16 Mar 2020 09:51:29 +0100 Subject: [PATCH 91/93] 2152 - Show identifier at file name on downloads --- print/methods/report.js | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/print/methods/report.js b/print/methods/report.js index 626830c39a..117462d9ee 100644 --- a/print/methods/report.js +++ b/print/methods/report.js @@ -13,12 +13,49 @@ module.exports = app => { if (!hasRequiredArgs) throw new Error(`Required properties not found [${argList}]`); - const report = new Report(req.params.name, args); + const reportName = req.params.name; + const fileName = getFileName(reportName, args); + const report = new Report(reportName, args); const stream = await report.toPdfStream(); + res.setHeader('Content-type', 'application/pdf'); + res.setHeader('Content-Disposition', `inline; filename="${fileName}"`); + stream.pipe(res); } catch (error) { next(error); } }); + + /** + * Returns all the params that ends with id + * @param {object} args - Params object + * + * @return {array} List of identifiers + */ + function getIdentifiers(args) { + const identifiers = []; + const keys = Object.keys(args); + + for (let arg of keys) { + // FIXME: #2197 - Remove clientId as a required param + if (arg != 'clientId' && arg.endsWith('Id')) + identifiers.push(arg); + } + + return identifiers; + } + + function getFileName(name, args) { + const identifiers = getIdentifiers(args); + const params = []; + params.push(name); + + for (let id of identifiers) + params.push(args[id]); + + const fileName = params.join('_'); + + return `${fileName}.pdf`; + } }; From a19a0578e9b4cc086612210d2c321fdbeb5ce03c Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Mon, 16 Mar 2020 10:25:49 +0100 Subject: [PATCH 92/93] structure DB --- db/dump/dumpedFixtures.sql | 30 +- db/dump/structure.sql | 3450 +++++++++++++++++++++++++++++------- 2 files changed, 2828 insertions(+), 652 deletions(-) diff --git a/db/dump/dumpedFixtures.sql b/db/dump/dumpedFixtures.sql index acdd3ea14b..2f2f826a1d 100644 --- a/db/dump/dumpedFixtures.sql +++ b/db/dump/dumpedFixtures.sql @@ -23,7 +23,7 @@ USE `util`; LOCK TABLES `config` WRITE; /*!40000 ALTER TABLE `config` DISABLE KEYS */; -INSERT INTO `config` VALUES (1,'10160',0,'production',NULL); +INSERT INTO `config` VALUES (1,'10161',0,'production',NULL); /*!40000 ALTER TABLE `config` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -36,7 +36,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-02-27 13:26:24 +-- Dump completed on 2020-03-16 9:45:09 USE `account`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -61,7 +61,7 @@ USE `account`; LOCK TABLES `role` WRITE; /*!40000 ALTER TABLE `role` DISABLE KEYS */; -INSERT INTO `role` VALUES (0,'root','Rol con todos los privilegios',0,'2018-04-23 14:33:36','2018-04-23 14:33:59'),(1,'employee','Empleado básico',1,'2017-05-19 07:04:58','2017-11-29 10:06:31'),(2,'customer','Privilegios básicos de un cliente',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(3,'agency','Consultar tablas de predicciones de bultos',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(5,'administrative','Tareas relacionadas con la contabilidad',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(6,'guest','Privilegios para usuarios sin cuenta',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(9,'developer','Desarrolladores del sistema',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(11,'account','Privilegios relacionados con el login',0,'2017-05-19 07:04:58','2017-09-20 17:06:35'),(13,'teamBoss','Jefe de departamento',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(15,'logistic','Departamento de compras, responsables de la logistica',1,'2017-05-19 07:04:58','2018-02-12 10:50:10'),(16,'logisticBoss','Jefe del departamento de logística',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(17,'adminBoss','Jefe del departamento de administración',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(18,'salesPerson','Departamento de ventas',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(19,'salesBoss','Jefe del departamento de ventas',1,'2017-05-19 07:04:58','2017-08-16 12:38:27'),(20,'manager','Departamento de gerencia',1,'2017-06-01 14:57:02','2017-06-01 14:57:51'),(21,'salesAssistant','Jefe auxiliar de ventas',1,'2017-08-16 12:40:52','2017-08-16 12:40:52'),(22,'teamManager','Jefe de departamento con privilegios de auxiliar de venta.',1,'2017-09-07 09:08:12','2017-09-07 09:08:12'),(30,'financialBoss','Director finaciero',1,'2017-09-21 11:05:36','2017-09-21 11:05:36'),(31,'freelancer','Trabajadores por cuenta ajena',1,'2017-10-10 12:57:26','2017-10-10 12:59:27'),(32,'ett','Trabajadores de empresa temporal',1,'2017-10-10 12:58:58','2017-10-10 12:59:20'),(33,'invoicing','Personal con acceso a facturación',0,'2018-01-29 16:43:34','2018-01-29 16:43:34'),(34,'agencyBoss','Jefe/a del departamento de agencias',1,'2018-01-29 16:44:39','2018-02-23 07:58:53'),(35,'buyer','Departamento de compras',1,'2018-02-12 10:35:42','2018-02-12 10:35:42'),(36,'replenisher','Trabajadores de camara',1,'2018-02-16 14:07:10','2019-04-12 05:38:08'),(37,'hr','Gestor/a de recursos humanos',1,'2018-02-22 17:34:53','2018-02-22 17:34:53'),(38,'hrBoss','Jefe/a de recursos humanos',1,'2018-02-22 17:35:09','2018-02-22 17:35:09'),(39,'adminAssistant','Jefe auxiliar administrativo',1,'2018-02-23 10:37:36','2018-02-23 10:38:41'),(40,'handmade','Departamento de confección',1,'2018-02-23 11:14:53','2018-02-23 11:39:12'),(41,'handmadeBoss','Jefe de departamento de confección',1,'2018-02-23 11:15:09','2018-02-23 11:39:26'),(42,'artificial','Departamento de artificial',1,'2018-02-23 11:39:59','2018-02-23 11:39:59'),(43,'artificialBoss','Jefe del departamento de artificial',1,'2018-02-23 11:40:16','2018-02-23 11:40:16'),(44,'accessory','Departamento de complementos',1,'2018-02-23 11:41:12','2018-02-23 11:41:12'),(45,'accessoryBoss','Jefe del departamento de complementos',1,'2018-02-23 11:41:23','2018-02-23 11:41:23'),(47,'cooler','Empleados de cámara',1,'2018-02-23 13:08:18','2018-02-23 13:08:18'),(48,'coolerBoss','Jefe del departamento de cámara',1,'2018-02-23 13:12:01','2018-02-23 13:12:01'),(49,'production','Empleado de producción',0,'2018-02-26 15:28:23','2019-01-21 12:57:21'),(50,'productionBoss','Jefe de producción',1,'2018-02-26 15:34:12','2018-02-26 15:34:12'),(51,'marketing','Departamento de marketing',1,'2018-03-01 07:28:39','2018-03-01 07:28:39'),(52,'marketingBoss','Jefe del departamento de marketing',1,'2018-03-01 07:28:57','2018-03-01 07:28:57'),(53,'insurance','Gestor de seguros de cambio',0,'2018-03-05 07:44:35','2019-02-01 13:47:57'),(54,'itemPicker','Sacador en cámara',1,'2018-03-05 12:08:17','2018-03-05 12:08:17'),(55,'itemPickerBoss','Jefe de sacadores',1,'2018-03-05 12:08:31','2018-03-05 12:08:31'),(56,'delivery','Personal de reparto',1,'2018-05-30 06:07:02','2018-05-30 06:07:02'),(57,'deliveryBoss','Jefe de personal de reparto',1,'2018-05-30 06:07:19','2018-05-30 06:07:19'),(58,'packager','Departamento encajadores',1,'2019-01-21 12:43:45','2019-01-21 12:43:45'),(59,'packagerBoss','Jefe departamento encajadores',1,'2019-01-21 12:44:10','2019-01-21 12:44:10'),(60,'productionAssi','Tareas relacionadas con producción y administración',1,'2019-01-29 13:29:01','2019-01-29 13:29:01'),(61,'replenisherBos','Jefe de Complementos/Camara',1,'2019-07-01 06:44:07','2019-07-01 06:44:07'),(62,'noLogin','Role without login access to MySQL',0,'2019-07-01 06:50:19','2019-07-02 13:42:05'),(64,'balanceSheet','Consulta de Balance',0,'2019-07-16 12:12:08','2019-07-16 12:12:08'),(65,'officeBoss','Jefe de filial',1,'2019-08-02 06:54:26','2019-08-02 06:54:26'),(66,'sysadmin','Administrador de sistema',1,'2019-08-08 06:58:56','2019-08-08 06:58:56'),(67,'adminOfficer','categoria profesional oficial de administración',1,'2020-01-03 08:09:23','2020-01-03 08:09:23'),(69,'coolerAssist','Empleado cámara con permiso compras',1,'2020-02-05 12:36:09','2020-02-05 12:36:09'); +INSERT INTO `role` VALUES (0,'root','Rol con todos los privilegios',0,'2018-04-23 14:33:36','2018-04-23 14:33:59'),(1,'employee','Empleado básico',1,'2017-05-19 07:04:58','2017-11-29 10:06:31'),(2,'customer','Privilegios básicos de un cliente',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(3,'agency','Consultar tablas de predicciones de bultos',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(5,'administrative','Tareas relacionadas con la contabilidad',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(6,'guest','Privilegios para usuarios sin cuenta',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(9,'developer','Desarrolladores del sistema',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(11,'account','Privilegios relacionados con el login',0,'2017-05-19 07:04:58','2017-09-20 17:06:35'),(13,'teamBoss','Jefe de departamento',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(15,'logistic','Departamento de compras, responsables de la logistica',1,'2017-05-19 07:04:58','2018-02-12 10:50:10'),(16,'logisticBoss','Jefe del departamento de logística',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(17,'adminBoss','Jefe del departamento de administración',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(18,'salesPerson','Departamento de ventas',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(19,'salesBoss','Jefe del departamento de ventas',1,'2017-05-19 07:04:58','2017-08-16 12:38:27'),(20,'manager','Departamento de gerencia',1,'2017-06-01 14:57:02','2017-06-01 14:57:51'),(21,'salesAssistant','Jefe auxiliar de ventas',1,'2017-08-16 12:40:52','2017-08-16 12:40:52'),(22,'teamManager','Jefe de departamento con privilegios de auxiliar de venta.',1,'2017-09-07 09:08:12','2017-09-07 09:08:12'),(30,'financialBoss','Director finaciero',1,'2017-09-21 11:05:36','2017-09-21 11:05:36'),(31,'freelancer','Trabajadores por cuenta ajena',1,'2017-10-10 12:57:26','2017-10-10 12:59:27'),(32,'ett','Trabajadores de empresa temporal',1,'2017-10-10 12:58:58','2017-10-10 12:59:20'),(33,'invoicing','Personal con acceso a facturación',0,'2018-01-29 16:43:34','2018-01-29 16:43:34'),(34,'agencyBoss','Jefe/a del departamento de agencias',1,'2018-01-29 16:44:39','2018-02-23 07:58:53'),(35,'buyer','Departamento de compras',1,'2018-02-12 10:35:42','2018-02-12 10:35:42'),(36,'replenisher','Trabajadores de camara',1,'2018-02-16 14:07:10','2019-04-12 05:38:08'),(37,'hr','Gestor/a de recursos humanos',1,'2018-02-22 17:34:53','2018-02-22 17:34:53'),(38,'hrBoss','Jefe/a de recursos humanos',1,'2018-02-22 17:35:09','2018-02-22 17:35:09'),(39,'adminAssistant','Jefe auxiliar administrativo',1,'2018-02-23 10:37:36','2018-02-23 10:38:41'),(40,'handmade','Departamento de confección',1,'2018-02-23 11:14:53','2018-02-23 11:39:12'),(41,'handmadeBoss','Jefe de departamento de confección',1,'2018-02-23 11:15:09','2018-02-23 11:39:26'),(42,'artificial','Departamento de artificial',1,'2018-02-23 11:39:59','2018-02-23 11:39:59'),(43,'artificialBoss','Jefe del departamento de artificial',1,'2018-02-23 11:40:16','2018-02-23 11:40:16'),(44,'accessory','Departamento de complementos',1,'2018-02-23 11:41:12','2018-02-23 11:41:12'),(45,'accessoryBoss','Jefe del departamento de complementos',1,'2018-02-23 11:41:23','2018-02-23 11:41:23'),(47,'cooler','Empleados de cámara',1,'2018-02-23 13:08:18','2018-02-23 13:08:18'),(48,'coolerBoss','Jefe del departamento de cámara',1,'2018-02-23 13:12:01','2018-02-23 13:12:01'),(49,'production','Empleado de producción',0,'2018-02-26 15:28:23','2019-01-21 12:57:21'),(50,'productionBoss','Jefe de producción',1,'2018-02-26 15:34:12','2018-02-26 15:34:12'),(51,'marketing','Departamento de marketing',1,'2018-03-01 07:28:39','2018-03-01 07:28:39'),(52,'marketingBoss','Jefe del departamento de marketing',1,'2018-03-01 07:28:57','2018-03-01 07:28:57'),(53,'insurance','Gestor de seguros de cambio',0,'2018-03-05 07:44:35','2019-02-01 13:47:57'),(54,'itemPicker','Sacador en cámara',1,'2018-03-05 12:08:17','2018-03-05 12:08:17'),(55,'itemPickerBoss','Jefe de sacadores',1,'2018-03-05 12:08:31','2018-03-05 12:08:31'),(56,'delivery','Personal de reparto',1,'2018-05-30 06:07:02','2018-05-30 06:07:02'),(57,'deliveryBoss','Jefe de personal de reparto',1,'2018-05-30 06:07:19','2018-05-30 06:07:19'),(58,'packager','Departamento encajadores',1,'2019-01-21 12:43:45','2019-01-21 12:43:45'),(59,'packagerBoss','Jefe departamento encajadores',1,'2019-01-21 12:44:10','2019-01-21 12:44:10'),(60,'productionAssi','Tareas relacionadas con producción y administración',1,'2019-01-29 13:29:01','2019-01-29 13:29:01'),(61,'replenisherBos','Jefe de Complementos/Camara',1,'2019-07-01 06:44:07','2019-07-01 06:44:07'),(62,'noLogin','Role without login access to MySQL',0,'2019-07-01 06:50:19','2019-07-02 13:42:05'),(64,'balanceSheet','Consulta de Balance',0,'2019-07-16 12:12:08','2019-07-16 12:12:08'),(65,'officeBoss','Jefe de filial',1,'2019-08-02 06:54:26','2019-08-02 06:54:26'),(66,'sysadmin','Administrador de sistema',1,'2019-08-08 06:58:56','2019-08-08 06:58:56'),(67,'adminOfficer','categoria profesional oficial de administración',1,'2020-01-03 08:09:23','2020-01-03 08:09:23'),(69,'coolerAssist','Empleado cámara con permiso compras',1,'2020-02-05 12:36:09','2020-02-05 12:36:09'),(70,'trainee','Alumno de prácticas',1,'2020-03-04 11:00:25','2020-03-04 11:00:25'); /*!40000 ALTER TABLE `role` ENABLE KEYS */; UNLOCK TABLES; @@ -71,7 +71,7 @@ UNLOCK TABLES; LOCK TABLES `roleInherit` WRITE; /*!40000 ALTER TABLE `roleInherit` DISABLE KEYS */; -INSERT INTO `roleInherit` VALUES (9,0),(66,0),(5,1),(13,1),(18,1),(31,1),(32,1),(34,1),(35,1),(37,1),(40,1),(42,1),(44,1),(47,1),(51,1),(53,1),(54,1),(56,1),(58,1),(1,2),(1,3),(30,5),(39,5),(60,5),(67,5),(11,6),(1,11),(2,11),(3,11),(16,13),(20,13),(21,13),(22,13),(34,13),(41,13),(43,13),(45,13),(48,13),(50,13),(52,13),(55,13),(57,13),(59,13),(61,13),(16,15),(20,16),(21,18),(52,19),(65,19),(17,20),(30,20),(5,21),(19,21),(22,21),(39,21),(50,21),(30,22),(5,33),(34,33),(15,35),(41,35),(50,35),(52,35),(65,35),(69,35),(49,36),(61,36),(17,37),(38,37),(60,37),(67,37),(17,39),(41,40),(43,42),(36,44),(45,44),(36,47),(48,47),(69,47),(50,49),(60,50),(65,50),(52,51),(21,53),(30,53),(55,54),(57,56),(15,57),(39,57),(50,57),(60,57),(49,58),(59,58),(50,59),(17,64),(30,64),(38,64),(20,65); +INSERT INTO `roleInherit` VALUES (9,0),(66,0),(5,1),(13,1),(18,1),(31,1),(32,1),(34,1),(35,1),(37,1),(40,1),(42,1),(44,1),(47,1),(51,1),(53,1),(54,1),(56,1),(58,1),(1,2),(1,3),(30,5),(39,5),(60,5),(67,5),(11,6),(2,11),(3,11),(70,11),(16,13),(20,13),(21,13),(22,13),(34,13),(41,13),(43,13),(45,13),(48,13),(50,13),(52,13),(55,13),(57,13),(59,13),(61,13),(16,15),(20,16),(21,18),(52,19),(65,19),(17,20),(30,20),(5,21),(19,21),(22,21),(39,21),(50,21),(30,22),(5,33),(34,33),(15,35),(41,35),(50,35),(52,35),(65,35),(69,35),(49,36),(61,36),(17,37),(38,37),(60,37),(67,37),(17,39),(41,40),(43,42),(36,44),(45,44),(36,47),(48,47),(69,47),(50,49),(60,50),(65,50),(52,51),(21,53),(30,53),(55,54),(57,56),(15,57),(39,57),(50,57),(60,57),(49,58),(59,58),(50,59),(17,64),(30,64),(38,64),(20,65),(1,70); /*!40000 ALTER TABLE `roleInherit` ENABLE KEYS */; UNLOCK TABLES; @@ -81,7 +81,7 @@ UNLOCK TABLES; LOCK TABLES `roleRole` WRITE; /*!40000 ALTER TABLE `roleRole` DISABLE KEYS */; -INSERT INTO `roleRole` VALUES (0,0),(0,1),(0,2),(0,3),(0,5),(0,6),(0,9),(0,11),(0,13),(0,15),(0,16),(0,17),(0,18),(0,19),(0,20),(0,21),(0,22),(0,30),(0,31),(0,32),(0,33),(0,34),(0,35),(0,36),(0,37),(0,38),(0,39),(0,40),(0,41),(0,42),(0,43),(0,44),(0,45),(0,47),(0,48),(0,49),(0,50),(0,51),(0,52),(0,53),(0,54),(0,55),(0,56),(0,57),(0,58),(0,59),(0,60),(0,61),(0,62),(0,64),(0,65),(0,66),(0,67),(0,69),(1,1),(1,2),(1,3),(1,6),(1,11),(2,2),(2,6),(2,11),(3,3),(3,6),(3,11),(5,1),(5,2),(5,3),(5,5),(5,6),(5,11),(5,13),(5,18),(5,21),(5,33),(5,53),(6,6),(9,0),(9,1),(9,2),(9,3),(9,5),(9,6),(9,9),(9,11),(9,13),(9,15),(9,16),(9,17),(9,18),(9,19),(9,20),(9,21),(9,22),(9,30),(9,31),(9,32),(9,33),(9,34),(9,35),(9,36),(9,37),(9,38),(9,39),(9,40),(9,41),(9,42),(9,43),(9,44),(9,45),(9,47),(9,48),(9,49),(9,50),(9,51),(9,52),(9,53),(9,54),(9,55),(9,56),(9,57),(9,58),(9,59),(9,60),(9,61),(9,62),(9,64),(9,65),(9,66),(9,67),(9,69),(11,6),(11,11),(13,1),(13,2),(13,3),(13,6),(13,11),(13,13),(15,1),(15,2),(15,3),(15,6),(15,11),(15,13),(15,15),(15,35),(15,56),(15,57),(16,1),(16,2),(16,3),(16,6),(16,11),(16,13),(16,15),(16,16),(16,35),(16,56),(16,57),(17,1),(17,2),(17,3),(17,5),(17,6),(17,11),(17,13),(17,15),(17,16),(17,17),(17,18),(17,19),(17,20),(17,21),(17,33),(17,35),(17,36),(17,37),(17,39),(17,44),(17,47),(17,49),(17,50),(17,53),(17,56),(17,57),(17,58),(17,59),(17,64),(17,65),(18,1),(18,2),(18,3),(18,6),(18,11),(18,18),(19,1),(19,2),(19,3),(19,6),(19,11),(19,13),(19,18),(19,19),(19,21),(19,53),(20,1),(20,2),(20,3),(20,6),(20,11),(20,13),(20,15),(20,16),(20,18),(20,19),(20,20),(20,21),(20,35),(20,36),(20,44),(20,47),(20,49),(20,50),(20,53),(20,56),(20,57),(20,58),(20,59),(20,65),(21,1),(21,2),(21,3),(21,6),(21,11),(21,13),(21,18),(21,21),(21,53),(22,1),(22,2),(22,3),(22,6),(22,11),(22,13),(22,18),(22,21),(22,22),(22,53),(30,1),(30,2),(30,3),(30,5),(30,6),(30,11),(30,13),(30,15),(30,16),(30,18),(30,19),(30,20),(30,21),(30,22),(30,30),(30,33),(30,35),(30,36),(30,44),(30,47),(30,49),(30,50),(30,53),(30,56),(30,57),(30,58),(30,59),(30,64),(30,65),(31,1),(31,2),(31,3),(31,6),(31,11),(31,31),(32,1),(32,2),(32,3),(32,6),(32,11),(32,32),(33,33),(34,1),(34,2),(34,3),(34,6),(34,11),(34,13),(34,33),(34,34),(35,1),(35,2),(35,3),(35,6),(35,11),(35,35),(36,1),(36,2),(36,3),(36,6),(36,11),(36,36),(36,44),(36,47),(37,1),(37,2),(37,3),(37,6),(37,11),(37,37),(38,1),(38,2),(38,3),(38,6),(38,11),(38,37),(38,38),(38,64),(39,1),(39,2),(39,3),(39,5),(39,6),(39,11),(39,13),(39,18),(39,21),(39,33),(39,39),(39,53),(39,56),(39,57),(40,1),(40,2),(40,3),(40,6),(40,11),(40,40),(41,1),(41,2),(41,3),(41,6),(41,11),(41,13),(41,35),(41,40),(41,41),(42,1),(42,2),(42,3),(42,6),(42,11),(42,42),(43,1),(43,2),(43,3),(43,6),(43,11),(43,13),(43,42),(43,43),(44,1),(44,2),(44,3),(44,6),(44,11),(44,44),(45,1),(45,2),(45,3),(45,6),(45,11),(45,13),(45,44),(45,45),(47,1),(47,2),(47,3),(47,6),(47,11),(47,47),(48,1),(48,2),(48,3),(48,6),(48,11),(48,13),(48,47),(48,48),(49,1),(49,2),(49,3),(49,6),(49,11),(49,36),(49,44),(49,47),(49,49),(49,58),(50,1),(50,2),(50,3),(50,6),(50,11),(50,13),(50,18),(50,21),(50,35),(50,36),(50,44),(50,47),(50,49),(50,50),(50,53),(50,56),(50,57),(50,58),(50,59),(51,1),(51,2),(51,3),(51,6),(51,11),(51,51),(52,1),(52,2),(52,3),(52,6),(52,11),(52,13),(52,18),(52,19),(52,21),(52,35),(52,51),(52,52),(52,53),(53,1),(53,2),(53,3),(53,6),(53,11),(53,53),(54,1),(54,2),(54,3),(54,6),(54,11),(54,54),(55,1),(55,2),(55,3),(55,6),(55,11),(55,13),(55,54),(55,55),(56,1),(56,2),(56,3),(56,6),(56,11),(56,56),(57,1),(57,2),(57,3),(57,6),(57,11),(57,13),(57,56),(57,57),(58,1),(58,2),(58,3),(58,6),(58,11),(58,58),(59,1),(59,2),(59,3),(59,6),(59,11),(59,13),(59,58),(59,59),(60,1),(60,2),(60,3),(60,5),(60,6),(60,11),(60,13),(60,18),(60,21),(60,33),(60,35),(60,36),(60,37),(60,44),(60,47),(60,49),(60,50),(60,53),(60,56),(60,57),(60,58),(60,59),(60,60),(61,1),(61,2),(61,3),(61,6),(61,11),(61,13),(61,36),(61,44),(61,47),(61,61),(62,62),(64,64),(65,1),(65,2),(65,3),(65,6),(65,11),(65,13),(65,18),(65,19),(65,21),(65,35),(65,36),(65,44),(65,47),(65,49),(65,50),(65,53),(65,56),(65,57),(65,58),(65,59),(65,65),(66,0),(66,1),(66,2),(66,3),(66,5),(66,6),(66,9),(66,11),(66,13),(66,15),(66,16),(66,17),(66,18),(66,19),(66,20),(66,21),(66,22),(66,30),(66,31),(66,32),(66,33),(66,34),(66,35),(66,36),(66,37),(66,38),(66,39),(66,40),(66,41),(66,42),(66,43),(66,44),(66,45),(66,47),(66,48),(66,49),(66,50),(66,51),(66,52),(66,53),(66,54),(66,55),(66,56),(66,57),(66,58),(66,59),(66,60),(66,61),(66,62),(66,64),(66,65),(66,66),(66,67),(66,69),(67,1),(67,2),(67,3),(67,5),(67,6),(67,11),(67,13),(67,18),(67,21),(67,33),(67,37),(67,53),(67,67),(69,1),(69,2),(69,3),(69,6),(69,11),(69,35),(69,47),(69,69); +INSERT INTO `roleRole` VALUES (0,0),(0,1),(0,2),(0,3),(0,5),(0,6),(0,9),(0,11),(0,13),(0,15),(0,16),(0,17),(0,18),(0,19),(0,20),(0,21),(0,22),(0,30),(0,31),(0,32),(0,33),(0,34),(0,35),(0,36),(0,37),(0,38),(0,39),(0,40),(0,41),(0,42),(0,43),(0,44),(0,45),(0,47),(0,48),(0,49),(0,50),(0,51),(0,52),(0,53),(0,54),(0,55),(0,56),(0,57),(0,58),(0,59),(0,60),(0,61),(0,62),(0,64),(0,65),(0,66),(0,67),(0,69),(0,70),(1,1),(1,2),(1,3),(1,6),(1,11),(1,70),(2,2),(2,6),(2,11),(3,3),(3,6),(3,11),(5,1),(5,2),(5,3),(5,5),(5,6),(5,11),(5,13),(5,18),(5,21),(5,33),(5,53),(5,70),(6,6),(9,0),(9,1),(9,2),(9,3),(9,5),(9,6),(9,9),(9,11),(9,13),(9,15),(9,16),(9,17),(9,18),(9,19),(9,20),(9,21),(9,22),(9,30),(9,31),(9,32),(9,33),(9,34),(9,35),(9,36),(9,37),(9,38),(9,39),(9,40),(9,41),(9,42),(9,43),(9,44),(9,45),(9,47),(9,48),(9,49),(9,50),(9,51),(9,52),(9,53),(9,54),(9,55),(9,56),(9,57),(9,58),(9,59),(9,60),(9,61),(9,62),(9,64),(9,65),(9,66),(9,67),(9,69),(9,70),(11,6),(11,11),(13,1),(13,2),(13,3),(13,6),(13,11),(13,13),(13,70),(15,1),(15,2),(15,3),(15,6),(15,11),(15,13),(15,15),(15,35),(15,56),(15,57),(15,70),(16,1),(16,2),(16,3),(16,6),(16,11),(16,13),(16,15),(16,16),(16,35),(16,56),(16,57),(16,70),(17,1),(17,2),(17,3),(17,5),(17,6),(17,11),(17,13),(17,15),(17,16),(17,17),(17,18),(17,19),(17,20),(17,21),(17,33),(17,35),(17,36),(17,37),(17,39),(17,44),(17,47),(17,49),(17,50),(17,53),(17,56),(17,57),(17,58),(17,59),(17,64),(17,65),(17,70),(18,1),(18,2),(18,3),(18,6),(18,11),(18,18),(18,70),(19,1),(19,2),(19,3),(19,6),(19,11),(19,13),(19,18),(19,19),(19,21),(19,53),(19,70),(20,1),(20,2),(20,3),(20,6),(20,11),(20,13),(20,15),(20,16),(20,18),(20,19),(20,20),(20,21),(20,35),(20,36),(20,44),(20,47),(20,49),(20,50),(20,53),(20,56),(20,57),(20,58),(20,59),(20,65),(20,70),(21,1),(21,2),(21,3),(21,6),(21,11),(21,13),(21,18),(21,21),(21,53),(21,70),(22,1),(22,2),(22,3),(22,6),(22,11),(22,13),(22,18),(22,21),(22,22),(22,53),(22,70),(30,1),(30,2),(30,3),(30,5),(30,6),(30,11),(30,13),(30,15),(30,16),(30,18),(30,19),(30,20),(30,21),(30,22),(30,30),(30,33),(30,35),(30,36),(30,44),(30,47),(30,49),(30,50),(30,53),(30,56),(30,57),(30,58),(30,59),(30,64),(30,65),(30,70),(31,1),(31,2),(31,3),(31,6),(31,11),(31,31),(31,70),(32,1),(32,2),(32,3),(32,6),(32,11),(32,32),(32,70),(33,33),(34,1),(34,2),(34,3),(34,6),(34,11),(34,13),(34,33),(34,34),(34,70),(35,1),(35,2),(35,3),(35,6),(35,11),(35,35),(35,70),(36,1),(36,2),(36,3),(36,6),(36,11),(36,36),(36,44),(36,47),(36,70),(37,1),(37,2),(37,3),(37,6),(37,11),(37,37),(37,70),(38,1),(38,2),(38,3),(38,6),(38,11),(38,37),(38,38),(38,64),(38,70),(39,1),(39,2),(39,3),(39,5),(39,6),(39,11),(39,13),(39,18),(39,21),(39,33),(39,39),(39,53),(39,56),(39,57),(39,70),(40,1),(40,2),(40,3),(40,6),(40,11),(40,40),(40,70),(41,1),(41,2),(41,3),(41,6),(41,11),(41,13),(41,35),(41,40),(41,41),(41,70),(42,1),(42,2),(42,3),(42,6),(42,11),(42,42),(42,70),(43,1),(43,2),(43,3),(43,6),(43,11),(43,13),(43,42),(43,43),(43,70),(44,1),(44,2),(44,3),(44,6),(44,11),(44,44),(44,70),(45,1),(45,2),(45,3),(45,6),(45,11),(45,13),(45,44),(45,45),(45,70),(47,1),(47,2),(47,3),(47,6),(47,11),(47,47),(47,70),(48,1),(48,2),(48,3),(48,6),(48,11),(48,13),(48,47),(48,48),(48,70),(49,1),(49,2),(49,3),(49,6),(49,11),(49,36),(49,44),(49,47),(49,49),(49,58),(49,70),(50,1),(50,2),(50,3),(50,6),(50,11),(50,13),(50,18),(50,21),(50,35),(50,36),(50,44),(50,47),(50,49),(50,50),(50,53),(50,56),(50,57),(50,58),(50,59),(50,70),(51,1),(51,2),(51,3),(51,6),(51,11),(51,51),(51,70),(52,1),(52,2),(52,3),(52,6),(52,11),(52,13),(52,18),(52,19),(52,21),(52,35),(52,51),(52,52),(52,53),(52,70),(53,1),(53,2),(53,3),(53,6),(53,11),(53,53),(53,70),(54,1),(54,2),(54,3),(54,6),(54,11),(54,54),(54,70),(55,1),(55,2),(55,3),(55,6),(55,11),(55,13),(55,54),(55,55),(55,70),(56,1),(56,2),(56,3),(56,6),(56,11),(56,56),(56,70),(57,1),(57,2),(57,3),(57,6),(57,11),(57,13),(57,56),(57,57),(57,70),(58,1),(58,2),(58,3),(58,6),(58,11),(58,58),(58,70),(59,1),(59,2),(59,3),(59,6),(59,11),(59,13),(59,58),(59,59),(59,70),(60,1),(60,2),(60,3),(60,5),(60,6),(60,11),(60,13),(60,18),(60,21),(60,33),(60,35),(60,36),(60,37),(60,44),(60,47),(60,49),(60,50),(60,53),(60,56),(60,57),(60,58),(60,59),(60,60),(60,70),(61,1),(61,2),(61,3),(61,6),(61,11),(61,13),(61,36),(61,44),(61,47),(61,61),(61,70),(62,62),(64,64),(65,1),(65,2),(65,3),(65,6),(65,11),(65,13),(65,18),(65,19),(65,21),(65,35),(65,36),(65,44),(65,47),(65,49),(65,50),(65,53),(65,56),(65,57),(65,58),(65,59),(65,65),(65,70),(66,0),(66,1),(66,2),(66,3),(66,5),(66,6),(66,9),(66,11),(66,13),(66,15),(66,16),(66,17),(66,18),(66,19),(66,20),(66,21),(66,22),(66,30),(66,31),(66,32),(66,33),(66,34),(66,35),(66,36),(66,37),(66,38),(66,39),(66,40),(66,41),(66,42),(66,43),(66,44),(66,45),(66,47),(66,48),(66,49),(66,50),(66,51),(66,52),(66,53),(66,54),(66,55),(66,56),(66,57),(66,58),(66,59),(66,60),(66,61),(66,62),(66,64),(66,65),(66,66),(66,67),(66,69),(66,70),(67,1),(67,2),(67,3),(67,5),(67,6),(67,11),(67,13),(67,18),(67,21),(67,33),(67,37),(67,53),(67,67),(67,70),(69,1),(69,2),(69,3),(69,6),(69,11),(69,35),(69,47),(69,69),(69,70),(70,6),(70,11),(70,70); /*!40000 ALTER TABLE `roleRole` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -94,7 +94,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-02-27 13:26:25 +-- Dump completed on 2020-03-16 9:45:11 USE `salix`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -119,7 +119,7 @@ USE `salix`; LOCK TABLES `ACL` WRITE; /*!40000 ALTER TABLE `ACL` DISABLE KEYS */; -INSERT INTO `ACL` VALUES (1,'Account','*','*','ALLOW','ROLE','employee'),(3,'Address','*','*','ALLOW','ROLE','employee'),(5,'AgencyService','*','READ','ALLOW','ROLE','employee'),(7,'Client','*','*','ALLOW','ROLE','employee'),(9,'ClientObservation','*','*','ALLOW','ROLE','employee'),(11,'ContactChannel','*','READ','ALLOW','ROLE','employee'),(13,'Employee','*','READ','ALLOW','ROLE','employee'),(14,'PayMethod','*','READ','ALLOW','ROLE','employee'),(16,'FakeProduction','*','READ','ALLOW','ROLE','employee'),(17,'Warehouse','* ','READ','ALLOW','ROLE','employee'),(18,'State','*','READ','ALLOW','ROLE','employee'),(20,'TicketState','*','*','ALLOW','ROLE','employee'),(24,'Delivery','*','READ','ALLOW','ROLE','employee'),(25,'Zone','*','READ','ALLOW','ROLE','employee'),(26,'ClientCredit','*','*','ALLOW','ROLE','employee'),(27,'ClientCreditLimit','*','READ','ALLOW','ROLE','employee'),(30,'GreugeType','*','READ','ALLOW','ROLE','employee'),(31,'Mandate','*','READ','ALLOW','ROLE','employee'),(32,'MandateType','*','READ','ALLOW','ROLE','employee'),(33,'Company','*','READ','ALLOW','ROLE','employee'),(34,'Greuge','*','READ','ALLOW','ROLE','employee'),(35,'AddressObservation','*','*','ALLOW','ROLE','employee'),(36,'ObservationType','*','*','ALLOW','ROLE','employee'),(37,'Greuge','*','WRITE','ALLOW','ROLE','employee'),(38,'AgencyMode','*','READ','ALLOW','ROLE','employee'),(39,'ItemTag','*','WRITE','ALLOW','ROLE','buyer'),(40,'ItemBotanical','*','WRITE','ALLOW','ROLE','buyer'),(41,'ItemBotanical','*','READ','ALLOW','ROLE','employee'),(42,'ItemPlacement','*','WRITE','ALLOW','ROLE','buyer'),(43,'ItemPlacement','*','WRITE','ALLOW','ROLE','replenisher'),(44,'ItemPlacement','*','READ','ALLOW','ROLE','employee'),(45,'ItemBarcode','*','READ','ALLOW','ROLE','employee'),(46,'ItemBarcode','*','WRITE','ALLOW','ROLE','buyer'),(47,'ItemBarcode','*','WRITE','ALLOW','ROLE','replenisher'),(48,'ItemNiche','*','READ','ALLOW','ROLE','employee'),(49,'ItemNiche','*','WRITE','ALLOW','ROLE','buyer'),(50,'ItemNiche','*','WRITE','ALLOW','ROLE','replenisher'),(51,'ItemTag','*','READ','ALLOW','ROLE','employee'),(53,'Item','*','READ','ALLOW','ROLE','employee'),(54,'Item','*','WRITE','ALLOW','ROLE','buyer'),(55,'Recovery','*','READ','ALLOW','ROLE','employee'),(56,'Recovery','*','WRITE','ALLOW','ROLE','administrative'),(58,'CreditClassification','*','*','ALLOW','ROLE','insurance'),(60,'CreditInsurance','*','*','ALLOW','ROLE','insurance'),(61,'InvoiceOut','*','READ','ALLOW','ROLE','employee'),(62,'Ticket','*','*','ALLOW','ROLE','employee'),(63,'TicketObservation','*','*','ALLOW','ROLE','employee'),(64,'Route','*','READ','ALLOW','ROLE','employee'),(65,'Sale','*','READ','ALLOW','ROLE','employee'),(66,'TicketTracking','*','READ','ALLOW','ROLE','employee'),(68,'TicketPackaging','*','*','ALLOW','ROLE','employee'),(69,'Packaging','*','READ','ALLOW','ROLE','employee'),(70,'Packaging','*','WRITE','ALLOW','ROLE','logistic'),(71,'SaleChecked','*','READ','ALLOW','ROLE','employee'),(72,'SaleComponent','*','READ','ALLOW','ROLE','employee'),(73,'Expedition','*','READ','ALLOW','ROLE','employee'),(74,'Expedition','*','WRITE','ALLOW','ROLE','deliveryBoss'),(75,'Expedition','*','WRITE','ALLOW','ROLE','production'),(76,'AnnualAverageInvoiced','*','READ','ALLOW','ROLE','employee'),(77,'WorkerMana','*','READ','ALLOW','ROLE','employee'),(78,'TicketTracking','*','WRITE','ALLOW','ROLE','production'),(79,'TicketTracking','changeState','*','ALLOW','ROLE','employee'),(80,'Sale','removes','*','ALLOW','ROLE','employee'),(81,'Sale','moveToTicket','*','ALLOW','ROLE','employee'),(82,'Sale','updateQuantity','*','ALLOW','ROLE','employee'),(83,'Sale','updatePrice','*','ALLOW','ROLE','employee'),(84,'Sale','updateDiscount','*','ALLOW','ROLE','employee'),(85,'SaleTracking','*','READ','ALLOW','ROLE','employee'),(86,'Order','*','*','ALLOW','ROLE','employee'),(87,'OrderRow','*','*','ALLOW','ROLE','employee'),(88,'ClientContact','*','*','ALLOW','ROLE','employee'),(89,'Sale','moveToNewTicket','*','ALLOW','ROLE','employee'),(90,'Sale','reserve','*','ALLOW','ROLE','employee'),(91,'TicketWeekly','*','READ','ALLOW','ROLE','employee'),(94,'Agency','landsThatDay','*','ALLOW','ROLE','employee'),(96,'ClaimEnd','*','READ','ALLOW','ROLE','employee'),(97,'ClaimEnd','*','WRITE','ALLOW','ROLE','salesAssistant'),(98,'ClaimBeginning','*','*','ALLOW','ROLE','employee'),(99,'ClaimDevelopment','*','READ','ALLOW','ROLE','employee'),(100,'ClaimDevelopment','*','WRITE','ALLOW','ROLE','salesAssistant'),(101,'Claim','*','*','ALLOW','ROLE','employee'),(102,'Claim','createFromSales','*','ALLOW','ROLE','employee'),(103,'ClaimEnd','importTicketSales','WRITE','ALLOW','ROLE','salesAssistant'),(104,'Item','*','WRITE','ALLOW','ROLE','marketingBoss'),(105,'ItemBarcode','*','WRITE','ALLOW','ROLE','marketingBoss'),(106,'ItemBotanical','*','WRITE','ALLOW','ROLE','marketingBoss'),(107,'ItemNiche','*','WRITE','ALLOW','ROLE','marketingBoss'),(108,'ItemPlacement','*','WRITE','ALLOW','ROLE','marketingBoss'),(109,'UserConfig','*','*','ALLOW','ROLE','employee'),(110,'Bank','*','READ','ALLOW','ROLE','employee'),(111,'ClientLog','*','READ','ALLOW','ROLE','employee'),(112,'Defaulter','*','READ','ALLOW','ROLE','employee'),(113,'ClientRisk','*','READ','ALLOW','ROLE','employee'),(114,'Receipt','*','READ','ALLOW','ROLE','employee'),(115,'Receipt','*','WRITE','ALLOW','ROLE','administrative'),(116,'BankEntity','*','*','ALLOW','ROLE','employee'),(117,'ClientSample','*','*','ALLOW','ROLE','employee'),(118,'WorkerTeam','*','*','ALLOW','ROLE','salesPerson'),(119,'Travel','*','READ','ALLOW','ROLE','employee'),(120,'Travel','*','WRITE','ALLOW','ROLE','buyer'),(121,'Item','regularize','*','ALLOW','ROLE','employee'),(122,'TicketRequest','*','*','ALLOW','ROLE','employee'),(123,'Worker','*','*','ALLOW','ROLE','employee'),(124,'Client','confirmTransaction','WRITE','ALLOW','ROLE','administrative'),(125,'Agency','getAgenciesWithWarehouse','*','ALLOW','ROLE','employee'),(126,'Client','activeWorkersWithRole','*','ALLOW','ROLE','employee'),(127,'TicketLog','*','READ','ALLOW','ROLE','employee'),(129,'TicketService','*','*','ALLOW','ROLE','employee'),(130,'Expedition','*','WRITE','ALLOW','ROLE','packager'),(131,'CreditInsurance','*','READ','ALLOW','ROLE','employee'),(132,'CreditClassification','*','READ','ALLOW','ROLE','employee'),(133,'ItemTag','*','WRITE','ALLOW','ROLE','marketingBoss'),(135,'ZoneGeo','*','READ','ALLOW','ROLE','employee'),(136,'ZoneCalendar','*','READ','ALLOW','ROLE','employee'),(137,'ZoneIncluded','*','READ','ALLOW','ROLE','employee'),(138,'LabourHoliday','*','READ','ALLOW','ROLE','employee'),(139,'LabourHolidayLegend','*','READ','ALLOW','ROLE','employee'),(140,'LabourHolidayType','*','READ','ALLOW','ROLE','employee'),(141,'Zone','*','*','ALLOW','ROLE','deliveryBoss'),(142,'ZoneCalendar','*','WRITE','ALLOW','ROLE','deliveryBoss'),(143,'ZoneIncluded','*','*','ALLOW','ROLE','deliveryBoss'),(144,'Stowaway','*','*','ALLOW','ROLE','employee'),(145,'Ticket','getPossibleStowaways','READ','ALLOW','ROLE','employee'),(147,'UserConfigView','*','*','ALLOW','ROLE','employee'),(148,'UserConfigView','*','*','ALLOW','ROLE','employee'),(149,'Sip','*','READ','ALLOW','ROLE','employee'),(150,'Sip','*','WRITE','ALLOW','ROLE','hr'),(151,'Department','*','READ','ALLOW','ROLE','employee'),(152,'Department','*','WRITE','ALLOW','ROLE','hr'),(153,'Route','*','READ','ALLOW','ROLE','employee'),(154,'Route','*','WRITE','ALLOW','ROLE','delivery'),(155,'WorkerCalendar','*','READ','ALLOW','ROLE','hr'),(156,'WorkerLabour','*','READ','ALLOW','ROLE','hr'),(157,'WorkerCalendar','absences','READ','ALLOW','ROLE','employee'),(158,'ItemTag','*','WRITE','ALLOW','ROLE','accessory'),(160,'TicketServiceType','*','READ','ALLOW','ROLE','employee'),(161,'TicketConfig','*','READ','ALLOW','ROLE','employee'),(162,'InvoiceOut','delete','WRITE','ALLOW','ROLE','invoicing'),(163,'InvoiceOut','book','WRITE','ALLOW','ROLE','invoicing'),(164,'InvoiceOut','regenerate','WRITE','ALLOW','ROLE','invoicing'),(165,'TicketDms','*','READ','ALLOW','ROLE','employee'),(167,'Worker','isSubordinate','READ','ALLOW','ROLE','employee'),(168,'Worker','mySubordinates','READ','ALLOW','ROLE','employee'),(169,'WorkerTimeControl','filter','READ','ALLOW','ROLE','employee'),(170,'WorkerTimeControl','addTime','WRITE','ALLOW','ROLE','employee'),(171,'TicketServiceType','*','WRITE','ALLOW','ROLE','administrative'),(172,'Sms','*','READ','ALLOW','ROLE','employee'),(173,'Sms','send','WRITE','ALLOW','ROLE','employee'),(174,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(175,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(176,'Device','*','*','ALLOW','ROLE','employee'),(177,'Device','*','*','ALLOW','ROLE','employee'),(178,'WorkerTimeControl','*','*','ALLOW','ROLE','employee'),(179,'ItemLog','*','READ','ALLOW','ROLE','employee'),(180,'RouteLog','*','READ','ALLOW','ROLE','employee'),(181,'Dms','removeFile','WRITE','ALLOW','ROLE','employee'),(182,'Dms','uploadFile','WRITE','ALLOW','ROLE','employee'),(183,'Dms','downloadFile','READ','ALLOW','ROLE','employee'),(184,'Client','uploadFile','WRITE','ALLOW','ROLE','employee'),(185,'ClientDms','removeFile','WRITE','ALLOW','ROLE','employee'),(186,'ClientDms','*','READ','ALLOW','ROLE','employee'),(187,'Ticket','uploadFile','WRITE','ALLOW','ROLE','employee'),(188,'TicketDms','removeFile','WRITE','ALLOW','ROLE','employee'),(189,'TicketDms','*','READ','ALLOW','ROLE','employee'),(190,'Route','updateVolume','WRITE','ALLOW','ROLE','deliveryBoss'),(191,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(192,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(194,'Postcode','*','WRITE','ALLOW','ROLE','employee'),(195,'Ticket','addSale','WRITE','ALLOW','ROLE','employee'),(196,'Dms','updateFile','WRITE','ALLOW','ROLE','employee'),(197,'Dms','*','READ','ALLOW','ROLE','employee'),(198,'ClaimDms','removeFile','WRITE','ALLOW','ROLE','employee'),(199,'ClaimDms','*','READ','ALLOW','ROLE','employee'),(200,'Claim','uploadFile','WRITE','ALLOW','ROLE','employee'),(201,'Sale','updateConcept','WRITE','ALLOW','ROLE','employee'),(202,'Claim','updateClaimAction','WRITE','ALLOW','ROLE','salesAssistant'),(203,'UserPhone','*','*','ALLOW','ROLE','employee'),(204,'WorkerDms','removeFile','WRITE','ALLOW','ROLE','hr'),(205,'WorkerDms','*','READ','ALLOW','ROLE','hr'),(206,'Chat','*','*','ALLOW','ROLE','employee'),(207,'Chat','sendMessage','*','ALLOW','ROLE','employee'),(208,'Sale','recalculatePrice','WRITE','ALLOW','ROLE','employee'),(209,'Ticket','recalculateComponents','WRITE','ALLOW','ROLE','employee'),(211,'TravelLog','*','READ','ALLOW','ROLE','buyer'),(212,'Thermograph','*','*','ALLOW','ROLE','buyer'),(213,'TravelThermograph','*','*','ALLOW','ROLE','buyer'),(214,'Entry','*','*','ALLOW','ROLE','buyer'),(215,'TicketWeekly','*','WRITE','ALLOW','ROLE','buyer'),(216,'TravelThermograph','*','READ','ALLOW','ROLE','employee'),(217,'CustomsAgent','*','*','ALLOW','ROLE','employee'),(218,'Intrastat','*','*','ALLOW','ROLE','buyer'); +INSERT INTO `ACL` VALUES (1,'Account','*','*','ALLOW','ROLE','employee'),(3,'Address','*','*','ALLOW','ROLE','employee'),(5,'AgencyService','*','READ','ALLOW','ROLE','employee'),(7,'Client','*','*','ALLOW','ROLE','employee'),(9,'ClientObservation','*','*','ALLOW','ROLE','employee'),(11,'ContactChannel','*','READ','ALLOW','ROLE','trainee'),(13,'Employee','*','READ','ALLOW','ROLE','employee'),(14,'PayMethod','*','READ','ALLOW','ROLE','trainee'),(16,'FakeProduction','*','READ','ALLOW','ROLE','employee'),(17,'Warehouse','* ','READ','ALLOW','ROLE','trainee'),(18,'State','*','READ','ALLOW','ROLE','employee'),(20,'TicketState','*','*','ALLOW','ROLE','employee'),(24,'Delivery','*','READ','ALLOW','ROLE','employee'),(25,'Zone','*','READ','ALLOW','ROLE','employee'),(26,'ClientCredit','*','*','ALLOW','ROLE','employee'),(27,'ClientCreditLimit','*','READ','ALLOW','ROLE','trainee'),(30,'GreugeType','*','READ','ALLOW','ROLE','trainee'),(31,'Mandate','*','READ','ALLOW','ROLE','trainee'),(32,'MandateType','*','READ','ALLOW','ROLE','trainee'),(33,'Company','*','READ','ALLOW','ROLE','trainee'),(34,'Greuge','*','READ','ALLOW','ROLE','trainee'),(35,'AddressObservation','*','*','ALLOW','ROLE','employee'),(36,'ObservationType','*','*','ALLOW','ROLE','employee'),(37,'Greuge','*','WRITE','ALLOW','ROLE','employee'),(38,'AgencyMode','*','READ','ALLOW','ROLE','employee'),(39,'ItemTag','*','WRITE','ALLOW','ROLE','buyer'),(40,'ItemBotanical','*','WRITE','ALLOW','ROLE','buyer'),(41,'ItemBotanical','*','READ','ALLOW','ROLE','employee'),(42,'ItemPlacement','*','WRITE','ALLOW','ROLE','buyer'),(43,'ItemPlacement','*','WRITE','ALLOW','ROLE','replenisher'),(44,'ItemPlacement','*','READ','ALLOW','ROLE','employee'),(45,'ItemBarcode','*','READ','ALLOW','ROLE','employee'),(46,'ItemBarcode','*','WRITE','ALLOW','ROLE','buyer'),(47,'ItemBarcode','*','WRITE','ALLOW','ROLE','replenisher'),(48,'ItemNiche','*','READ','ALLOW','ROLE','employee'),(49,'ItemNiche','*','WRITE','ALLOW','ROLE','buyer'),(50,'ItemNiche','*','WRITE','ALLOW','ROLE','replenisher'),(51,'ItemTag','*','READ','ALLOW','ROLE','employee'),(53,'Item','*','READ','ALLOW','ROLE','employee'),(54,'Item','*','WRITE','ALLOW','ROLE','buyer'),(55,'Recovery','*','READ','ALLOW','ROLE','trainee'),(56,'Recovery','*','WRITE','ALLOW','ROLE','administrative'),(58,'CreditClassification','*','*','ALLOW','ROLE','insurance'),(60,'CreditInsurance','*','*','ALLOW','ROLE','insurance'),(61,'InvoiceOut','*','READ','ALLOW','ROLE','employee'),(62,'Ticket','*','*','ALLOW','ROLE','employee'),(63,'TicketObservation','*','*','ALLOW','ROLE','employee'),(64,'Route','*','READ','ALLOW','ROLE','employee'),(65,'Sale','*','READ','ALLOW','ROLE','employee'),(66,'TicketTracking','*','READ','ALLOW','ROLE','employee'),(68,'TicketPackaging','*','*','ALLOW','ROLE','employee'),(69,'Packaging','*','READ','ALLOW','ROLE','employee'),(70,'Packaging','*','WRITE','ALLOW','ROLE','logistic'),(71,'SaleChecked','*','READ','ALLOW','ROLE','employee'),(72,'SaleComponent','*','READ','ALLOW','ROLE','employee'),(73,'Expedition','*','READ','ALLOW','ROLE','employee'),(74,'Expedition','*','WRITE','ALLOW','ROLE','deliveryBoss'),(75,'Expedition','*','WRITE','ALLOW','ROLE','production'),(76,'AnnualAverageInvoiced','*','READ','ALLOW','ROLE','employee'),(77,'WorkerMana','*','READ','ALLOW','ROLE','employee'),(78,'TicketTracking','*','WRITE','ALLOW','ROLE','production'),(79,'TicketTracking','changeState','*','ALLOW','ROLE','employee'),(80,'Sale','removes','*','ALLOW','ROLE','employee'),(81,'Sale','moveToTicket','*','ALLOW','ROLE','employee'),(82,'Sale','updateQuantity','*','ALLOW','ROLE','employee'),(83,'Sale','updatePrice','*','ALLOW','ROLE','employee'),(84,'Sale','updateDiscount','*','ALLOW','ROLE','employee'),(85,'SaleTracking','*','READ','ALLOW','ROLE','employee'),(86,'Order','*','*','ALLOW','ROLE','employee'),(87,'OrderRow','*','*','ALLOW','ROLE','employee'),(88,'ClientContact','*','*','ALLOW','ROLE','employee'),(89,'Sale','moveToNewTicket','*','ALLOW','ROLE','employee'),(90,'Sale','reserve','*','ALLOW','ROLE','employee'),(91,'TicketWeekly','*','READ','ALLOW','ROLE','employee'),(94,'Agency','landsThatDay','*','ALLOW','ROLE','employee'),(96,'ClaimEnd','*','READ','ALLOW','ROLE','employee'),(97,'ClaimEnd','*','WRITE','ALLOW','ROLE','salesAssistant'),(98,'ClaimBeginning','*','*','ALLOW','ROLE','employee'),(99,'ClaimDevelopment','*','READ','ALLOW','ROLE','employee'),(100,'ClaimDevelopment','*','WRITE','ALLOW','ROLE','salesAssistant'),(101,'Claim','*','*','ALLOW','ROLE','employee'),(102,'Claim','createFromSales','*','ALLOW','ROLE','employee'),(103,'ClaimEnd','importTicketSales','WRITE','ALLOW','ROLE','salesAssistant'),(104,'Item','*','WRITE','ALLOW','ROLE','marketingBoss'),(105,'ItemBarcode','*','WRITE','ALLOW','ROLE','marketingBoss'),(106,'ItemBotanical','*','WRITE','ALLOW','ROLE','marketingBoss'),(107,'ItemNiche','*','WRITE','ALLOW','ROLE','marketingBoss'),(108,'ItemPlacement','*','WRITE','ALLOW','ROLE','marketingBoss'),(109,'UserConfig','*','*','ALLOW','ROLE','employee'),(110,'Bank','*','READ','ALLOW','ROLE','trainee'),(111,'ClientLog','*','READ','ALLOW','ROLE','trainee'),(112,'Defaulter','*','READ','ALLOW','ROLE','employee'),(113,'ClientRisk','*','READ','ALLOW','ROLE','trainee'),(114,'Receipt','*','READ','ALLOW','ROLE','trainee'),(115,'Receipt','*','WRITE','ALLOW','ROLE','administrative'),(116,'BankEntity','*','*','ALLOW','ROLE','employee'),(117,'ClientSample','*','*','ALLOW','ROLE','employee'),(118,'WorkerTeam','*','*','ALLOW','ROLE','salesPerson'),(119,'Travel','*','READ','ALLOW','ROLE','employee'),(120,'Travel','*','WRITE','ALLOW','ROLE','buyer'),(121,'Item','regularize','*','ALLOW','ROLE','employee'),(122,'TicketRequest','*','*','ALLOW','ROLE','employee'),(123,'Worker','*','*','ALLOW','ROLE','employee'),(124,'Client','confirmTransaction','WRITE','ALLOW','ROLE','administrative'),(125,'Agency','getAgenciesWithWarehouse','*','ALLOW','ROLE','employee'),(126,'Client','activeWorkersWithRole','*','ALLOW','ROLE','employee'),(127,'TicketLog','*','READ','ALLOW','ROLE','employee'),(129,'TicketService','*','*','ALLOW','ROLE','employee'),(130,'Expedition','*','WRITE','ALLOW','ROLE','packager'),(131,'CreditInsurance','*','READ','ALLOW','ROLE','trainee'),(132,'CreditClassification','*','READ','ALLOW','ROLE','trainee'),(133,'ItemTag','*','WRITE','ALLOW','ROLE','marketingBoss'),(135,'ZoneGeo','*','READ','ALLOW','ROLE','employee'),(136,'ZoneCalendar','*','READ','ALLOW','ROLE','employee'),(137,'ZoneIncluded','*','READ','ALLOW','ROLE','employee'),(138,'LabourHoliday','*','READ','ALLOW','ROLE','employee'),(139,'LabourHolidayLegend','*','READ','ALLOW','ROLE','employee'),(140,'LabourHolidayType','*','READ','ALLOW','ROLE','employee'),(141,'Zone','*','*','ALLOW','ROLE','deliveryBoss'),(142,'ZoneCalendar','*','WRITE','ALLOW','ROLE','deliveryBoss'),(143,'ZoneIncluded','*','*','ALLOW','ROLE','deliveryBoss'),(144,'Stowaway','*','*','ALLOW','ROLE','employee'),(145,'Ticket','getPossibleStowaways','READ','ALLOW','ROLE','employee'),(147,'UserConfigView','*','*','ALLOW','ROLE','employee'),(148,'UserConfigView','*','*','ALLOW','ROLE','employee'),(149,'Sip','*','READ','ALLOW','ROLE','employee'),(150,'Sip','*','WRITE','ALLOW','ROLE','hr'),(151,'Department','*','READ','ALLOW','ROLE','employee'),(152,'Department','*','WRITE','ALLOW','ROLE','hr'),(153,'Route','*','READ','ALLOW','ROLE','employee'),(154,'Route','*','WRITE','ALLOW','ROLE','delivery'),(155,'WorkerCalendar','*','READ','ALLOW','ROLE','hr'),(156,'WorkerLabour','*','READ','ALLOW','ROLE','hr'),(157,'WorkerCalendar','absences','READ','ALLOW','ROLE','employee'),(158,'ItemTag','*','WRITE','ALLOW','ROLE','accessory'),(160,'TicketServiceType','*','READ','ALLOW','ROLE','employee'),(161,'TicketConfig','*','READ','ALLOW','ROLE','employee'),(162,'InvoiceOut','delete','WRITE','ALLOW','ROLE','invoicing'),(163,'InvoiceOut','book','WRITE','ALLOW','ROLE','invoicing'),(164,'InvoiceOut','regenerate','WRITE','ALLOW','ROLE','invoicing'),(165,'TicketDms','*','READ','ALLOW','ROLE','employee'),(167,'Worker','isSubordinate','READ','ALLOW','ROLE','employee'),(168,'Worker','mySubordinates','READ','ALLOW','ROLE','employee'),(169,'WorkerTimeControl','filter','READ','ALLOW','ROLE','employee'),(170,'WorkerTimeControl','addTime','WRITE','ALLOW','ROLE','employee'),(171,'TicketServiceType','*','WRITE','ALLOW','ROLE','administrative'),(172,'Sms','*','READ','ALLOW','ROLE','employee'),(173,'Sms','send','WRITE','ALLOW','ROLE','employee'),(174,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(175,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(176,'Device','*','*','ALLOW','ROLE','employee'),(177,'Device','*','*','ALLOW','ROLE','employee'),(178,'WorkerTimeControl','*','*','ALLOW','ROLE','employee'),(179,'ItemLog','*','READ','ALLOW','ROLE','employee'),(180,'RouteLog','*','READ','ALLOW','ROLE','employee'),(181,'Dms','removeFile','WRITE','ALLOW','ROLE','employee'),(182,'Dms','uploadFile','WRITE','ALLOW','ROLE','employee'),(183,'Dms','downloadFile','READ','ALLOW','ROLE','employee'),(184,'Client','uploadFile','WRITE','ALLOW','ROLE','employee'),(185,'ClientDms','removeFile','WRITE','ALLOW','ROLE','employee'),(186,'ClientDms','*','READ','ALLOW','ROLE','trainee'),(187,'Ticket','uploadFile','WRITE','ALLOW','ROLE','employee'),(188,'TicketDms','removeFile','WRITE','ALLOW','ROLE','employee'),(189,'TicketDms','*','READ','ALLOW','ROLE','employee'),(190,'Route','updateVolume','WRITE','ALLOW','ROLE','deliveryBoss'),(191,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(192,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(194,'Postcode','*','WRITE','ALLOW','ROLE','employee'),(195,'Ticket','addSale','WRITE','ALLOW','ROLE','employee'),(196,'Dms','updateFile','WRITE','ALLOW','ROLE','employee'),(197,'Dms','*','READ','ALLOW','ROLE','trainee'),(198,'ClaimDms','removeFile','WRITE','ALLOW','ROLE','employee'),(199,'ClaimDms','*','READ','ALLOW','ROLE','employee'),(200,'Claim','uploadFile','WRITE','ALLOW','ROLE','employee'),(201,'Sale','updateConcept','WRITE','ALLOW','ROLE','employee'),(202,'Claim','updateClaimAction','WRITE','ALLOW','ROLE','salesAssistant'),(203,'UserPhone','*','*','ALLOW','ROLE','employee'),(204,'WorkerDms','removeFile','WRITE','ALLOW','ROLE','hr'),(205,'WorkerDms','*','READ','ALLOW','ROLE','hr'),(206,'Chat','*','*','ALLOW','ROLE','employee'),(207,'Chat','sendMessage','*','ALLOW','ROLE','employee'),(208,'Sale','recalculatePrice','WRITE','ALLOW','ROLE','employee'),(209,'Ticket','recalculateComponents','WRITE','ALLOW','ROLE','employee'),(211,'TravelLog','*','READ','ALLOW','ROLE','buyer'),(212,'Thermograph','*','*','ALLOW','ROLE','buyer'),(213,'TravelThermograph','*','*','ALLOW','ROLE','buyer'),(214,'Entry','*','*','ALLOW','ROLE','buyer'),(215,'TicketWeekly','*','WRITE','ALLOW','ROLE','buyer'),(216,'TravelThermograph','*','READ','ALLOW','ROLE','employee'),(218,'Intrastat','*','*','ALLOW','ROLE','buyer'),(219,'Account','acl','READ','ALLOW','ROLE','account'),(220,'Account','getCurrentUserData','READ','ALLOW','ROLE','account'),(221,'UserConfig','getUserConfig','READ','ALLOW','ROLE','account'),(222,'Client','*','READ','ALLOW','ROLE','trainee'),(226,'ClientObservation','*','READ','ALLOW','ROLE','trainee'),(227,'Address','*','READ','ALLOW','ROLE','trainee'),(228,'AddressObservation','*','READ','ALLOW','ROLE','trainee'),(229,'CustomsAgent','*','READ','ALLOW','ROLE','trainee'),(230,'ClientCredit','*','READ','ALLOW','ROLE','trainee'),(231,'ClientContact','*','READ','ALLOW','ROLE','trainee'),(232,'ClientSample','*','READ','ALLOW','ROLE','trainee'),(233,'EntryLog','*','READ','ALLOW','ROLE','buyer'); /*!40000 ALTER TABLE `ACL` ENABLE KEYS */; UNLOCK TABLES; @@ -142,7 +142,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-02-27 13:26:25 +-- Dump completed on 2020-03-16 9:45:12 USE `vn`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -287,7 +287,7 @@ UNLOCK TABLES; LOCK TABLES `state` WRITE; /*!40000 ALTER TABLE `state` DISABLE KEYS */; -INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING',NULL,1,0,0,0,0,0),(2,'Libre',2,0,'FREE',NULL,2,0,0,0,0,1),(3,'OK',3,0,'OK',3,28,1,0,0,0,1),(4,'Impreso',4,1,'PRINTED',2,29,1,0,1,0,0),(5,'Preparación',5,1,'ON_PREPARATION',7,5,0,0,0,2,0),(6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0,1,0,3,0),(7,'Sin Acabar',1,0,'NOT_READY',NULL,7,0,0,0,0,1),(8,'Revisado',8,1,'CHECKED',NULL,8,0,1,0,3,0),(9,'Encajando',9,2,'PACKING',NULL,9,0,1,0,0,0),(10,'Encajado',10,2,'PACKED',NULL,10,0,1,0,0,0),(11,'Facturado',0,0,'INVOICED',NULL,11,0,1,0,0,0),(12,'Bloqueado',0,0,'BLOCKED',NULL,12,0,0,0,0,0),(13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0,1,0,0,0),(14,'Preparado',6,1,'PREPARED',NULL,14,0,1,0,2,0),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0,1,0,0,0),(16,'Entregado',13,3,'DELIVERED',NULL,16,0,1,0,0,0),(17,'Eliminado',14,3,'ERASED',NULL,17,0,0,0,0,0),(20,'Asignado',4,1,'PICKER_DESIGNED',NULL,20,1,0,0,0,0),(21,'Retornado',4,1,'PRINTED_BACK',6,21,0,0,0,0,0),(22,'¿Fecha?',2,0,'WRONG_DATE',NULL,22,0,0,0,0,0),(23,'URGENTE',2,0,'LAST_CALL',NULL,23,1,0,0,0,0),(24,'Encadenado',4,0,'CHAINED',4,24,0,0,0,0,0),(25,'Embarcando',3,0,'BOARDING',5,25,0,0,0,0,0),(26,'Prep Previa',5,1,'PREVIOUS_PREPARATION',1,26,0,0,0,1,0),(27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0,0,0,0,0),(28,'Previa OK',3,1,'OK PREVIOUS',3,28,1,0,0,1,1),(29,'Previa Impreso',4,1,'PRINTED PREVIOUS',2,29,1,0,1,1,0),(30,'Embarcado',4,0,'BOARD',5,30,0,0,0,2,0); +INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING',NULL,1,0,0,0,0,0,0),(2,'Libre',2,0,'FREE',NULL,2,0,0,0,0,1,0),(3,'OK',3,0,'OK',3,28,1,0,0,0,1,1),(4,'Impreso',4,1,'PRINTED',2,29,1,0,1,0,0,0),(5,'Preparación',5,1,'ON_PREPARATION',7,5,0,0,0,2,0,0),(6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0,1,0,3,0,0),(7,'Sin Acabar',1,0,'NOT_READY',NULL,7,0,0,0,0,1,0),(8,'Revisado',8,1,'CHECKED',NULL,8,0,1,0,3,0,0),(9,'Encajando',9,2,'PACKING',NULL,9,0,1,0,0,0,0),(10,'Encajado',10,2,'PACKED',NULL,10,0,1,0,0,0,0),(11,'Facturado',0,0,'INVOICED',NULL,11,0,1,0,0,0,0),(12,'Bloqueado',0,0,'BLOCKED',NULL,12,0,0,0,0,0,0),(13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0,1,0,0,0,0),(14,'Preparado',6,1,'PREPARED',NULL,14,0,1,0,2,0,0),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0,1,0,0,0,0),(16,'Entregado',13,3,'DELIVERED',NULL,16,0,1,0,0,0,0),(17,'Eliminado',14,3,'ERASED',NULL,17,0,0,0,0,0,0),(20,'Asignado',4,1,'PICKER_DESIGNED',NULL,20,1,0,0,0,0,0),(21,'Retornado',4,1,'PRINTED_BACK',6,21,0,0,0,0,0,0),(22,'¿Fecha?',2,0,'WRONG_DATE',NULL,22,0,0,0,0,0,0),(23,'URGENTE',2,0,'LAST_CALL',NULL,23,1,0,0,0,0,0),(24,'Encadenado',4,0,'CHAINED',4,24,0,0,0,0,0,0),(25,'Embarcando',3,0,'BOARDING',5,25,0,0,0,0,0,0),(26,'Prep Previa',5,1,'PREVIOUS_PREPARATION',1,26,0,0,0,1,0,0),(27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0,0,0,0,0,0),(28,'Previa OK',3,1,'OK PREVIOUS',3,28,1,0,0,1,1,1),(29,'Previa Impreso',4,1,'PRINTED PREVIOUS',2,29,1,0,1,1,0,0),(30,'Embarcado',4,0,'BOARD',5,30,0,0,0,2,0,0); /*!40000 ALTER TABLE `state` ENABLE KEYS */; UNLOCK TABLES; @@ -307,7 +307,7 @@ UNLOCK TABLES; LOCK TABLES `department` WRITE; /*!40000 ALTER TABLE `department` DISABLE KEYS */; -INSERT INTO `department` VALUES (1,'VERDNATURA',1,2,763,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(22,'COMPRAS',3,4,NULL,72,596,2,5,0,0,0,0,NULL,'/',NULL),(23,'CAMARA',5,6,NULL,72,604,2,6,1,0,0,0,NULL,'/',NULL),(31,'INFORMATICA',7,8,NULL,72,127,3,9,0,0,0,0,NULL,'/','informatica'),(34,'CONTABILIDAD',9,10,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(35,'FINANZAS',11,12,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(36,'LABORAL',13,14,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(37,'PRODUCCION',15,42,NULL,72,230,3,11,0,0,0,13,NULL,'/',NULL),(38,'SACADO',16,17,NULL,72,230,4,14,1,0,1,0,37,'/37/',NULL),(39,'ENCAJADO',18,19,NULL,72,230,4,12,1,0,1,0,37,'/37/',NULL),(41,'ADMINISTRACION',43,44,NULL,72,599,3,8,0,0,0,0,NULL,'/',NULL),(43,'VENTAS',45,66,NULL,0,NULL,NULL,NULL,0,0,0,10,NULL,'/',NULL),(44,'GERENCIA',67,68,NULL,72,300,2,7,0,0,0,0,NULL,'/',NULL),(45,'LOGISTICA',69,70,NULL,72,596,3,19,0,0,0,0,NULL,'/',NULL),(46,'REPARTO',20,21,NULL,72,659,3,10,0,0,1,0,37,'/37/',NULL),(48,'ALMACENAJE',71,72,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(49,'PROPIEDAD',73,74,NULL,72,1008,1,1,0,0,0,0,NULL,'/',NULL),(52,'CARGA AEREA',75,76,NULL,72,163,4,28,0,0,0,0,NULL,'/',NULL),(53,'MARKETING Y COMUNICACIÓN',77,78,NULL,72,1238,0,0,0,0,0,0,NULL,'/',NULL),(54,'ORNAMENTALES',79,80,NULL,72,433,3,21,0,0,0,0,NULL,'/',NULL),(55,'TALLER NATURAL',81,82,NULL,72,695,2,23,0,0,0,0,NULL,'/',NULL),(56,'TALLER ARTIFICIAL',83,84,NULL,72,1780,2,24,0,0,0,0,NULL,'/',NULL),(58,'CAMPOS',85,86,NULL,72,225,2,2,0,0,0,0,NULL,'/',NULL),(59,'MANTENIMIENTO',87,88,NULL,72,1907,4,16,0,0,0,0,NULL,'/',NULL),(60,'RECLAMACIONES',89,90,NULL,72,563,3,20,0,0,0,0,NULL,'/',NULL),(61,'VNH',91,92,NULL,73,1297,3,17,0,0,0,0,NULL,'/',NULL),(63,'VENTAS FRANCIA',46,47,NULL,72,277,2,27,0,0,1,0,43,'/43/',NULL),(66,'VERDNAMADRID',93,94,NULL,72,163,3,18,0,0,0,0,NULL,'/',NULL),(68,'COMPLEMENTOS',95,96,NULL,72,617,3,26,1,0,0,0,NULL,'/',NULL),(69,'VERDNABARNA',97,98,NULL,74,432,3,22,0,0,0,0,NULL,'/',NULL),(77,'PALETIZADO',22,23,NULL,72,230,4,15,1,0,1,0,37,'/37/',NULL),(80,'EQUIPO J VALLES',48,49,NULL,72,693,3,4,0,0,1,0,43,'/43/','jvp_equipo'),(86,'LIMPIEZA',99,100,NULL,72,599,0,0,0,0,0,0,NULL,'/',NULL),(89,'COORDINACION',101,102,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL),(90,'TRAILER',103,104,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(91,'ARTIFICIAL',105,106,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL),(92,'EQUIPO SILVERIO',50,51,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','sdc_equipo'),(93,'CONFECCION',107,108,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(94,'EQUIPO J BROCAL',52,53,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jes_equipo'),(95,'EQUIPO C ZAMBRANO',54,55,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','czg_equipo'),(96,'EQUIPO C LOPEZ',56,57,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','cla_equipo'),(97,'EQUIPO D SARRION',58,59,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','dsr_equipo'),(98,'EQUIPO RODRIGO',60,61,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','rhr_equipo'),(99,'EQUIPO MANOLI',62,63,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','man_equipo'),(101,'EQUIPO J IBAÑEZ',64,65,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jmi_equipo'),(102,'EQ ROJO FV RUBEN C',24,25,NULL,0,NULL,NULL,NULL,0,0,1,0,37,'/37/',NULL),(103,'EQ AZUL FV A FOLQUES',26,27,NULL,0,NULL,NULL,NULL,0,0,1,0,37,'/37/',NULL),(104,'EQ AMARILLO FV NORMAN G',28,29,NULL,0,NULL,NULL,NULL,0,0,1,0,37,'/37/',NULL),(105,'EQ MORADO FV MATOU',30,31,NULL,0,NULL,NULL,NULL,0,0,1,0,37,'/37/',NULL),(106,'EQ VERDE PCA KEVIN GIMENEZ',32,33,NULL,0,NULL,NULL,NULL,0,0,1,0,37,'/37/',NULL),(107,'EQ NARANJA PCA RUBEN ZANON',34,35,NULL,0,NULL,NULL,NULL,0,0,1,0,37,'/37/',NULL),(109,'EQ MARRON PCA JC ESTELLES',36,37,NULL,0,NULL,NULL,NULL,0,0,1,0,37,'/37/',NULL),(110,'EQ ROSA PCA J BONDIA',38,39,NULL,0,NULL,NULL,NULL,0,0,1,0,37,'/37/',NULL),(111,'EQ REPONEDOR CAJAS',40,41,NULL,0,NULL,NULL,NULL,0,0,1,0,37,'/37/',NULL); +INSERT INTO `department` VALUES (1,'VERDNATURA',1,2,763,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(22,'COMPRAS',3,4,NULL,72,596,2,5,0,0,0,0,NULL,'/',NULL),(23,'CAMARA',14,19,NULL,72,604,2,6,1,0,1,2,37,'/37/',NULL),(31,'INFORMATICA',5,6,NULL,72,127,3,9,0,0,0,0,NULL,'/','informatica'),(34,'CONTABILIDAD',7,8,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(35,'FINANZAS',9,10,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(36,'LABORAL',11,12,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(37,'PRODUCCION',13,46,NULL,72,230,3,11,1,0,0,14,NULL,'/',NULL),(38,'SACADO',20,21,NULL,72,230,4,14,1,0,1,0,37,'/37/',NULL),(39,'ENCAJADO',22,23,NULL,72,230,4,12,1,0,1,0,37,'/37/',NULL),(41,'ADMINISTRACION',47,48,NULL,72,599,3,8,0,0,0,0,NULL,'/',NULL),(43,'VENTAS',49,70,NULL,0,NULL,NULL,NULL,0,0,0,10,NULL,'/',NULL),(44,'GERENCIA',71,72,NULL,72,300,2,7,0,0,0,0,NULL,'/',NULL),(45,'LOGISTICA',73,74,NULL,72,596,3,19,0,0,0,0,NULL,'/',NULL),(46,'REPARTO',75,78,NULL,72,659,3,10,0,0,0,1,NULL,'/',NULL),(48,'ALMACENAJE',79,80,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(49,'PROPIEDAD',81,82,NULL,72,1008,1,1,0,0,0,0,NULL,'/',NULL),(52,'CARGA AEREA',83,84,NULL,72,163,4,28,0,0,0,0,NULL,'/',NULL),(53,'MARKETING Y COMUNICACIÓN',85,86,NULL,72,1238,0,0,0,0,0,0,NULL,'/',NULL),(54,'ORNAMENTALES',87,88,NULL,72,433,3,21,0,0,0,0,NULL,'/',NULL),(55,'TALLER NATURAL',89,90,NULL,72,695,2,23,0,0,0,0,NULL,'/',NULL),(56,'TALLER ARTIFICIAL',91,92,NULL,72,1780,2,24,0,0,0,0,NULL,'/',NULL),(58,'CAMPOS',93,94,NULL,72,225,2,2,0,0,0,0,NULL,'/',NULL),(59,'MANTENIMIENTO',95,96,NULL,72,1907,4,16,0,0,0,0,NULL,'/',NULL),(60,'RECLAMACIONES',97,98,NULL,72,563,3,20,0,0,0,0,NULL,'/',NULL),(61,'VNH',99,100,NULL,73,1297,3,17,0,0,0,0,NULL,'/',NULL),(63,'VENTAS FRANCIA',50,51,NULL,72,277,2,27,0,0,1,0,43,'/43/',NULL),(66,'VERDNAMADRID',101,102,NULL,72,163,3,18,0,0,0,0,NULL,'/',NULL),(68,'COMPLEMENTOS',24,25,NULL,72,617,3,26,1,0,1,0,37,'/37/',NULL),(69,'VERDNABARNA',103,104,NULL,74,432,3,22,0,0,0,0,NULL,'/',NULL),(77,'PALETIZADO',76,77,NULL,72,230,4,15,0,0,1,0,46,'/46/',NULL),(80,'EQUIPO J VALLES',52,53,NULL,72,693,3,4,0,0,1,0,43,'/43/','jvp_equipo'),(86,'LIMPIEZA',105,106,NULL,72,599,0,0,0,0,0,0,NULL,'/',NULL),(89,'COORDINACION',107,108,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(90,'TRAILER',109,110,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(91,'ARTIFICIAL',26,27,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(92,'EQUIPO SILVERIO',54,55,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','sdc_equipo'),(93,'CONFECCION',111,112,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(94,'EQUIPO J BROCAL',56,57,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jes_equipo'),(95,'EQUIPO C ZAMBRANO',58,59,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','czg_equipo'),(96,'EQUIPO C LOPEZ',60,61,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','cla_equipo'),(97,'EQUIPO D SARRION',62,63,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','dsr_equipo'),(98,'EQUIPO RODRIGO',64,65,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','rhr_equipo'),(99,'EQUIPO MANOLI',66,67,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','man_equipo'),(101,'EQUIPO J IBAÑEZ',68,69,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jmi_equipo'),(102,'EQ ROJO FV RUBEN C',28,29,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(103,'EQ AZUL FV A FOLQUES',30,31,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(104,'EQ AMARILLO FV NORMAN G',32,33,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(105,'EQ MORADO FV MATOU',34,35,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(106,'EQ VERDE PCA KEVIN GIMENEZ',36,37,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(107,'EQ NARANJA PCA RUBEN ZANON',38,39,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(110,'EQ ROSA PCA J BONDIA',40,41,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(111,'EQ REPONEDOR CAJAS',42,43,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(112,'CAMARA EQ EDGAR LLEO',15,16,NULL,0,NULL,NULL,NULL,0,0,2,0,23,'/37/23/',NULL),(113,'CAMARA EQ MARC ROCA',17,18,NULL,0,NULL,NULL,NULL,0,0,2,0,23,'/37/23/',NULL),(114,'EQ MARRON PCA JL NUEVO',44,45,NULL,0,NULL,NULL,NULL,0,0,1,0,37,'/37/',NULL); /*!40000 ALTER TABLE `department` ENABLE KEYS */; UNLOCK TABLES; @@ -340,7 +340,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-02-27 13:26:25 +-- Dump completed on 2020-03-16 9:45:18 USE `cache`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -378,7 +378,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-02-27 13:26:26 +-- Dump completed on 2020-03-16 9:45:19 USE `hedera`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -436,7 +436,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-02-27 13:26:26 +-- Dump completed on 2020-03-16 9:45:21 USE `postgresql`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -511,7 +511,7 @@ UNLOCK TABLES; LOCK TABLES `workcenter` WRITE; /*!40000 ALTER TABLE `workcenter` DISABLE KEYS */; -INSERT INTO `workcenter` VALUES (1,'Silla',20,1030,1),(2,'Mercaflor',19,NULL,NULL),(3,'Marjales',26,20008,NULL),(4,'VNH',NULL,NULL,3),(5,'Madrid',28,2852,5),(6,'Vilassar',88,88031,2),(7,'Tenerife',NULL,NULL,10); +INSERT INTO `workcenter` VALUES (1,'Silla',20,1033,1),(2,'Mercaflor',19,NULL,NULL),(3,'Marjales',26,20008,NULL),(4,'VNH',NULL,NULL,3),(5,'Madrid',28,2852,5),(6,'Vilassar',88,88031,2),(7,'Tenerife',NULL,NULL,10); /*!40000 ALTER TABLE `workcenter` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -524,4 +524,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-02-27 13:26:27 +-- Dump completed on 2020-03-16 9:45:23 diff --git a/db/dump/structure.sql b/db/dump/structure.sql index c008cb055f..8e783c8337 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -2378,13 +2378,49 @@ CREATE TABLE `payMethodClientEvolution` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `productivity` +-- Table structure for table `produccion` -- -DROP TABLE IF EXISTS `productivity`; +DROP TABLE IF EXISTS `produccion`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `productivity` ( +CREATE TABLE `produccion` ( + `dated` date NOT NULL, + `m3` int(11) NOT NULL DEFAULT '0', + `cost` int(11) NOT NULL DEFAULT '0', + `eurosM3` decimal(10,2) NOT NULL DEFAULT '0.00', + PRIMARY KEY (`dated`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `productivityDepartment__` +-- + +DROP TABLE IF EXISTS `productivityDepartment__`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `productivityDepartment__` ( + `dated` date NOT NULL, + `amountCoordinacion` decimal(10,2) NOT NULL DEFAULT '0.00', + `amountSacado` decimal(10,2) NOT NULL DEFAULT '0.00', + `amountEncajado` decimal(10,2) NOT NULL DEFAULT '0.00', + `amountPaletizado` decimal(10,2) NOT NULL DEFAULT '0.00', + `amountCamara` decimal(10,2) NOT NULL DEFAULT '0.00', + `amountComplementos` decimal(10,2) NOT NULL DEFAULT '0.00', + `amountArtificial` decimal(10,2) NOT NULL DEFAULT '0.00', + PRIMARY KEY (`dated`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `productivity__` +-- + +DROP TABLE IF EXISTS `productivity__`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `productivity__` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `dated` date NOT NULL, `hh` int(10) unsigned NOT NULL, @@ -2414,33 +2450,13 @@ CREATE TABLE `productivity` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `productivityDepartment` +-- Table structure for table `productivity_evolution__` -- -DROP TABLE IF EXISTS `productivityDepartment`; +DROP TABLE IF EXISTS `productivity_evolution__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `productivityDepartment` ( - `dated` date NOT NULL, - `amountCoordinacion` decimal(10,2) NOT NULL DEFAULT '0.00', - `amountSacado` decimal(10,2) NOT NULL DEFAULT '0.00', - `amountEncajado` decimal(10,2) NOT NULL DEFAULT '0.00', - `amountPaletizado` decimal(10,2) NOT NULL DEFAULT '0.00', - `amountCamara` decimal(10,2) NOT NULL DEFAULT '0.00', - `amountComplementos` decimal(10,2) NOT NULL DEFAULT '0.00', - `amountArtificial` decimal(10,2) NOT NULL DEFAULT '0.00', - PRIMARY KEY (`dated`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `productivity_evolution` --- - -DROP TABLE IF EXISTS `productivity_evolution`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `productivity_evolution` ( +CREATE TABLE `productivity_evolution__` ( `dated` date NOT NULL, `m3productionCost` decimal(10,2) NOT NULL DEFAULT '0.00', PRIMARY KEY (`dated`) @@ -3104,116 +3120,142 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `comercialesCompleto`(IN vWorker INT, vDate DATE) BEGIN - -CALL vn.worker_GetHierarchy(vWorker); - -SELECT - c.Id_Cliente id_cliente, - c.calidad, - c.Cliente cliente, - cr.recobro * 100 tarifa, - c.Telefono telefono, - c.movil, - c.POBLACION poblacion, - p.`name` provincia, - vn2008.red(f.futur) futur, - c.Credito credito, - pm.`name` forma_pago, - vn2008.red(c365 / 12) consumo_medio365, - vn2008.red(c365) consumo365, - vn2008.red(CmLy.peso) peso_mes_año_pasado, - vn2008.red(CmLy.peso * 1.19) objetivo, - tr.CodigoTrabajador, - vn2008.red(mes_actual.consumo) consumoMes, - vn2008.red(IFNULL(mes_actual.consumo, 0) - IFNULL(CmLy.peso * 1.19, 0)) como_lo_llevo, - DATE(LastTicket) ultimo_ticket, - dead.muerto, - g.Greuge, - cr.recobro -FROM - vn2008.Clientes c - LEFT JOIN - (SELECT Id_Cliente, CAST( SUM(Importe) as DECIMAL(12,2)) AS Greuge - FROM vn2008.Greuges - GROUP BY Id_Cliente - ) g ON g.Id_Cliente = c.Id_Cliente - LEFT JOIN - vn2008.province p ON p.province_id = c.province_id - JOIN - vn2008.pay_met pm ON pm.id = c.pay_met_id - LEFT JOIN - vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador - LEFT JOIN - bi.claims_ratio cr on cr.Id_Cliente = c.Id_Cliente - LEFT JOIN - (SELECT v.Id_Cliente, SUM(importe) c365 -- optimizat de 6s /5.3s/ 4.7s a 0.3/0.4/0.3 - FROM bs.ventas v - JOIN vn2008.Clientes c USING (Id_Cliente) + CALL vn.worker_GetHierarchy(vWorker); + + INSERT IGNORE INTO tmp.workerHierarchyList (workerFk) + SELECT wd2.workerFk + FROM vn.departmentItemType dit + JOIN vn.workerDepartment wd2 ON wd2.departmentFk = dit.departmentFk + WHERE dit.workerFk = vWorker; + + DROP TABLE IF EXISTS tmp.itemTypeExcluded; + CREATE TABLE tmp.itemTypeExcluded + (itemTypeFk INT PRIMARY KEY) + ENGINE = MEMORY; + + IF (SELECT COUNT(*) FROM vn.departmentItemType WHERE workerFk = vWorker LIMIT 1) = 0 THEN + INSERT INTO tmp.itemTypeExcluded (itemTypeFk) + SELECT dit2.itemTypeFk + FROM vn.workerDepartment wd + JOIN vn.departmentItemType dit1 ON wd.departmentFk = dit1.departmentFk AND wd.workerFk = vWorker + JOIN vn.itemType it ON TRUE + LEFT JOIN vn.departmentItemType dit2 ON dit2.departmentFk = dit1.departmentFk AND dit2.itemTypeFk = it.id + WHERE dit2.itemTypeFk IS NOT NULL + GROUP BY it.id; + ELSE -- comercial especialista + INSERT INTO tmp.itemTypeExcluded (itemTypeFk) + SELECT it.id itemTypeFk + FROM vn.itemType it + JOIN vn.workerDepartment wd ON wd.workerFk = vWorker + LEFT JOIN vn.departmentItemType dit ON dit.itemTypeFk = it.id + WHERE NOT (dit.workerFk <=> vWorker); + END IF; + + -- Falta que en algunos casos solo tenga en cuenta los tipos afectados. + SELECT + c.Id_Cliente id_cliente, + c.calidad, + c.Cliente cliente, + cr.recobro * 100 tarifa, + c.Telefono telefono, + c.movil, + c.POBLACION poblacion, + p.`name` provincia, + vn2008.red(f.futur) futur, + c.Credito credito, + pm.`name` forma_pago, + vn2008.red(c365 / 12) consumo_medio365, + vn2008.red(c365) consumo365, + vn2008.red(CmLy.peso) peso_mes_año_pasado, + vn2008.red(CmLy.peso * 1.19) objetivo, + tr.CodigoTrabajador, + vn2008.red(mes_actual.consumo) consumoMes, + vn2008.red(IFNULL(mes_actual.consumo, 0) - IFNULL(CmLy.peso * 1.19, 0)) como_lo_llevo, + DATE(LastTicket) ultimo_ticket, + dead.muerto, + g.Greuge, + cr.recobro + FROM + vn2008.Clientes c + LEFT JOIN + (SELECT Id_Cliente, CAST( SUM(Importe) as DECIMAL(12,2)) AS Greuge + FROM vn2008.Greuges + GROUP BY Id_Cliente + ) g ON g.Id_Cliente = c.Id_Cliente + LEFT JOIN + vn2008.province p ON p.province_id = c.province_id + JOIN + vn2008.pay_met pm ON pm.id = c.pay_met_id + LEFT JOIN + vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador + LEFT JOIN + bi.claims_ratio cr on cr.Id_Cliente = c.Id_Cliente + LEFT JOIN + (SELECT v.Id_Cliente, SUM(importe) c365 -- optimizat de 6s /5.3s/ 4.7s a 0.3/0.4/0.3 + FROM bs.ventas v + JOIN vn2008.Clientes c ON c.Id_Cliente = v.Id_Cliente + LEFT JOIN tmp.itemTypeExcluded ite ON ite.itemTypeFk = v.tipo_id + WHERE v.fecha BETWEEN TIMESTAMPADD(YEAR, - 1, vDate) AND vDate + AND ite.itemTypeFk IS NULL + GROUP BY v.Id_Cliente) c365 ON c365.Id_Cliente = c.Id_Cliente + LEFT JOIN + (SELECT + Id_Cliente, SUM(importe) consumo + FROM + bs.ventas v + INNER JOIN vn2008.Clientes c USING (Id_Cliente) + LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador + LEFT JOIN tmp.itemTypeExcluded ite ON ite.itemTypeFk = v.tipo_id + WHERE + (c.Id_Trabajador = vWorker OR tr.boss = vWorker) AND ite.itemTypeFk IS NULL + AND (v.fecha BETWEEN TIMESTAMPADD(DAY, - DAY(vDate) + 1, vDate) AND TIMESTAMPADD(DAY, - 1, vDate)) + GROUP BY Id_Cliente) mes_actual ON mes_actual.Id_Cliente = c.Id_Cliente + LEFT JOIN + (SELECT + t.Id_Cliente, + SUM(m.preu * m.Cantidad * (1 - m.Descuento / 100)) futur + FROM vn2008.Tickets t + JOIN vn2008.Clientes c ON c.Id_Cliente = t.Id_Cliente + JOIN vn2008.Movimientos m ON m.Id_Ticket = t.Id_Ticket + LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador + WHERE + (c.Id_Trabajador = vWorker OR tr.boss = vWorker) + AND DATE(Fecha) BETWEEN vDate AND LAST_DAY(vDate) + GROUP BY Id_Cliente) f ON c.Id_Cliente = f.Id_Cliente + LEFT JOIN + (SELECT + MAX(t.Fecha) LastTicket, c.Id_Cliente + FROM + vn2008.Tickets t + JOIN vn2008.Clientes c ON c.Id_cliente = t.Id_Cliente + LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador - WHERE v.fecha BETWEEN TIMESTAMPADD(YEAR, - 1, vDate) AND vDate - GROUP BY v.Id_Cliente) c365 ON c365.Id_Cliente = c.Id_Cliente - LEFT JOIN - (SELECT - Id_Cliente, SUM(importe) consumo - FROM - bs.ventas v - INNER JOIN vn2008.Clientes c USING (Id_Cliente) - LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador - WHERE - (c.Id_Trabajador = vWorker OR tr.boss = vWorker) - AND (v.fecha BETWEEN TIMESTAMPADD(DAY, - DAY(vDate) + 1, vDate) AND TIMESTAMPADD(DAY, - 1, vDate)) - GROUP BY Id_Cliente) mes_actual ON mes_actual.Id_Cliente = c.Id_Cliente - LEFT JOIN - (SELECT - t.Id_Cliente, - SUM(m.preu * m.Cantidad * (1 - m.Descuento / 100)) futur - FROM - vn2008.Tickets t - JOIN vn2008.Clientes c ON c.Id_Cliente = t.Id_Cliente - JOIN vn2008.Movimientos m ON m.Id_Ticket = t.Id_Ticket - LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador - WHERE - (c.Id_Trabajador = vWorker OR tr.boss = vWorker) - AND DATE(Fecha) BETWEEN vDate AND LAST_DAY(vDate) - GROUP BY Id_Cliente) f ON c.Id_Cliente = f.Id_Cliente - LEFT JOIN - (SELECT - MAX(t.Fecha) LastTicket, c.Id_Cliente - FROM - vn2008.Tickets t - JOIN vn2008.Clientes c ON c.Id_cliente = t.Id_Cliente - LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador - - WHERE - (c.Id_Trabajador = vWorker OR tr.boss = vWorker) - GROUP BY t.Id_Cliente) LastTicket ON LastTicket.Id_Cliente = c.Id_Cliente - LEFT JOIN - (SELECT - SUM(importe) peso, c.Id_Cliente - FROM - bs.ventas v - JOIN vn2008.Clientes c ON c.Id_Cliente = v.Id_Cliente - LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador - WHERE - MONTH(fecha) = MONTH(vDate) - AND YEAR(fecha) = YEAR(vDate) - 1 - AND (c.Id_Trabajador = vWorker OR tr.boss = vWorker) - GROUP BY c.Id_Cliente) CmLy ON CmLy.Id_Cliente = c.Id_Cliente - LEFT JOIN - (SELECT - c.Id_Cliente, - IF(MAX(Fecha) < DATE_FORMAT(TIMESTAMPADD(MONTH, - 1, vDate), '%Y- %m-01'), TRUE, FALSE) muerto - FROM - vn2008.Facturas f - JOIN vn2008.Clientes c ON c.Id_cliente = f.Id_Cliente - - LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador - WHERE - (c.Id_Trabajador = vWorker OR tr.boss = vWorker) - GROUP BY Id_Cliente) dead ON dead.Id_Cliente = c.Id_Cliente - JOIN tmp.workerHierarchyList s ON s.workerFk = c.Id_Trabajador; + WHERE + (c.Id_Trabajador = vWorker OR tr.boss = vWorker) + GROUP BY t.Id_Cliente) LastTicket ON LastTicket.Id_Cliente = c.Id_Cliente + LEFT JOIN + ( + SELECT SUM(importe) peso, c.Id_Cliente + FROM bs.ventas v + JOIN vn2008.Clientes c ON c.Id_Cliente = v.Id_Cliente + LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador + LEFT JOIN tmp.itemTypeExcluded ite ON ite.itemTypeFk = v.tipo_id + WHERE MONTH(fecha) = MONTH(vDate) + AND YEAR(fecha) = YEAR(vDate) - 1 + AND (c.Id_Trabajador = vWorker OR tr.boss = vWorker) + GROUP BY c.Id_Cliente) CmLy ON CmLy.Id_Cliente = c.Id_Cliente + LEFT JOIN + (SELECT c.Id_Cliente, + IF(MAX(Fecha) < DATE_FORMAT(TIMESTAMPADD(MONTH, - 1, vDate), '%Y- %m-01'), TRUE, FALSE) muerto + FROM vn2008.Facturas f + JOIN vn2008.Clientes c ON c.Id_cliente = f.Id_Cliente + LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador + WHERE (c.Id_Trabajador = vWorker OR tr.boss = vWorker) + GROUP BY Id_Cliente) dead ON dead.Id_Cliente = c.Id_Cliente + JOIN tmp.workerHierarchyList s ON s.workerFk = c.Id_Trabajador; -DROP TEMPORARY TABLE tmp.workerHierarchyList; + DROP TEMPORARY TABLE tmp.workerHierarchyList; + DROP TABLE IF EXISTS tmp.itemTypeExcluded; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -4234,7 +4276,7 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `productivityAdd` */; +/*!50003 DROP PROCEDURE IF EXISTS `produccionAdd` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -4244,7 +4286,127 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `productivityAdd`(vDate DATE) +CREATE DEFINER=`root`@`%` PROCEDURE `produccionAdd`(vDate DATE) +BEGIN + + DECLARE vDateStart DATETIME DEFAULT vDate; + DECLARE vDateEnd DATETIME DEFAULT util.dayEnd(vDate); + DECLARE myDepLft INT; + DECLARE myDepRgt INT; + + + -- Trabajadores + CALL vn.dayMinuteWorker(vDateStart,vDateEnd); -- Genera la tabla tmp.dayMinuteWorker + CALL vn.workerDepartmentByDate(vDate); + + -- General + REPLACE bs.produccion(dated, cost) + SELECT vDate,sum(wdd.costeHora) / 60 as Bruto + FROM tmp.dayMinuteWorker dmw + JOIN tmp.workerDepartmentByDate wdd ON wdd.userFk = dmw.userFk + WHERE Almacen IN (1,44) + AND wdd.isProduction; + + UPDATE bs.produccion p + JOIN (SELECT sum(volume) as m3 + FROM vn.saleVolume sv + JOIN vn.ticket t ON sv.ticketFk = t.id + JOIN vn.warehouse w ON w.id = t.warehouseFk + JOIN vn.warehouseAlias wa ON wa.id = w.aliasFk + WHERE t.shipped BETWEEN vDateStart AND vDateEnd + AND wa.name = 'Silla' + ) sub + SET p.m3 = sub.m3, + p.eurosM3 = p.cost / sub.m3 + WHERE p.dated = vDate; + + DROP TEMPORARY TABLE tmp.dayMinuteWorker; + DROP TEMPORARY TABLE tmp.workerDepartmentByDate; + + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `produccion_launcher` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `produccion_launcher`(vDateFrom DATE, vDateTo DATE) +BEGIN + + WHILE vDateFrom <= vDateTo DO + + CALL bs.produccionAdd(vDateFrom); + + SET vDateFrom = TIMESTAMPADD(DAY,1,vDateFrom); + + END WHILE; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `produccion_launcher_auto` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `produccion_launcher_auto`() +BEGIN + + DECLARE vDate DATE DEFAULT TIMESTAMPADD(WEEK, -1, CURDATE()); + + WHILE vDate <= CURDATE() DO + + CALL bs.produccionAdd(vDate); + + SET vDate = TIMESTAMPADD(DAY,1,vDate); + + END WHILE; + + SET vDate = TIMESTAMPADD(DAY,-372, CURDATE()); + + WHILE vDate <= TIMESTAMPADD(YEAR,-1, CURDATE()) DO + + CALL bs.produccionAdd(vDate); + + SET vDate = TIMESTAMPADD(DAY,1,vDate); + + END WHILE; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `productivityAdd__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `productivityAdd__`(vDate DATE) BEGIN DECLARE vDateStart DATETIME DEFAULT vDate; @@ -4509,7 +4671,7 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `productivityDepartmentAdd` */; +/*!50003 DROP PROCEDURE IF EXISTS `productivityDepartmentAdd__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -4519,7 +4681,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `productivityDepartmentAdd`(IN vDateStartPeriod DATETIME, IN vDateEndPeriod DATETIME, IN vDateStart DATETIME) +CREATE DEFINER=`root`@`%` PROCEDURE `productivityDepartmentAdd__`(IN vDateStartPeriod DATETIME, IN vDateEndPeriod DATETIME, IN vDateStart DATETIME) BEGIN DECLARE vEndingDate DATETIME; @@ -4572,17 +4734,17 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `productivityDepartmentLauncher` */; +/*!50003 DROP PROCEDURE IF EXISTS `productivityDepartmentLauncher__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `productivityDepartmentLauncher`() +CREATE DEFINER=`root`@`%` PROCEDURE `productivityDepartmentLauncher__`() BEGIN CALL bs.productivityDepartmentAdd('2019-05-06', CURDATE(),DATE_SUB(CURDATE(), INTERVAL 2 WEEK)); END ;; @@ -4591,17 +4753,51 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `productivityLauncher` */; +/*!50003 DROP PROCEDURE IF EXISTS `productivityLauncher_manual__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `productivityLauncher`() +CREATE DEFINER=`root`@`%` PROCEDURE `productivityLauncher_manual__`(vDateFrom DATE, vToDate DATE) +BEGIN + + TRUNCATE tmp.log; + + WHILE vToDate >= vDateFrom DO + + INSERT INTO tmp.log(text) VALUES (vDateFrom); + CALL bs.productivityAdd(vDateFrom); + + CALL bs.productivityAdd(TIMESTAMPADD(YEAR, -1,vDateFrom)); + INSERT INTO tmp.log(text) VALUES (TIMESTAMPADD(YEAR, -1,vDateFrom)); + + SET vDateFrom = TIMESTAMPADD(DAY,1,vDateFrom); + + END WHILE; + + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `productivityLauncher__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `productivityLauncher__`() BEGIN DECLARE vDateFrom DATE; @@ -4622,40 +4818,6 @@ BEGIN SET vDateFrom = TIMESTAMPADD(DAY,1,vDateFrom); END WHILE; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `productivityLauncher_manual` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `productivityLauncher_manual`(vDateFrom DATE, vToDate DATE) -BEGIN - - TRUNCATE tmp.log; - - WHILE vToDate >= vDateFrom DO - - INSERT INTO tmp.log(text) VALUES (vDateFrom); - CALL bs.productivityAdd(vDateFrom); - - CALL bs.productivityAdd(TIMESTAMPADD(YEAR, -1,vDateFrom)); - INSERT INTO tmp.log(text) VALUES (TIMESTAMPADD(YEAR, -1,vDateFrom)); - - SET vDateFrom = TIMESTAMPADD(DAY,1,vDateFrom); - - END WHILE; - - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -12009,13 +12171,13 @@ BEGIN SELECT COUNT(*) > 0 INTO vOk FROM order_row WHERE order_id = vOrder AND amount > 0; - IF !vOk THEN + IF NOT vOk THEN CALL util.throw ('ORDER_EMPTY'); END IF; -- Carga las fechas de salida de cada almacén - CALL vn.zone_getShippedWarehouse (vDelivery, vAddress, vAgencyModeId); + CALL vn.zone_getShipped (vDelivery, vAddress, vAgencyModeId, FALSE); -- Trabajador que realiza la acción @@ -12209,7 +12371,6 @@ BEGIN DECLARE vAgencyModeId INT; DECLARE TICKET_FREE INT DEFAULT 2; - DECLARE SYSTEM_WORKER INT DEFAULT 20; DECLARE cDates CURSOR FOR SELECT zgs.shipped, r.warehouse_id @@ -12220,9 +12381,9 @@ BEGIN GROUP BY r.warehouse_id; DECLARE cRows CURSOR FOR - SELECT r.id, r.item_id, a.Article, r.amount, r.price, r.rate + SELECT r.id, r.item_id, i.name, r.amount, r.price, r.rate FROM order_row r - JOIN vn2008.Articles a ON a.Id_Article = r.item_id + JOIN vn.item i ON i.id = r.item_id WHERE r.amount != 0 AND r.warehouse_id = vWarehouse AND r.order_id = vOrder @@ -12240,12 +12401,12 @@ BEGIN -- Carga los datos del pedido SELECT o.date_send, o.address_id, o.note, - o.confirmed, cs.Id_Cliente, o.company_id, o.agency_id + o.confirmed, a.clientFk, o.company_id, o.agency_id INTO vDelivery, vAddress, vNotes, vIsConfirmed, vClientId, vCompanyId, vAgencyModeId FROM hedera.`order` o - JOIN vn2008.Consignatarios cs ON cs.Id_Consigna = o.address_id - WHERE id = vOrder; + JOIN vn.address a ON a.id = o.address_id + WHERE o.id = vOrder; -- Comprueba que el pedido no está confirmado @@ -12264,7 +12425,7 @@ BEGIN -- Carga las fechas de salida de cada almacén - CALL vn.zoneGetShippedWarehouse (vDelivery, vAddress, vAgencyModeId); + CALL vn.zone_getShippedWarehouse (vDelivery, vAddress, vAgencyModeId); -- Trabajador que realiza la acción @@ -12290,19 +12451,19 @@ BEGIN -- Busca un ticket existente que coincida con los parametros - SELECT Id_Ticket INTO vTicket - FROM vn2008.Tickets t - LEFT JOIN vn.ticketState tls on tls.ticket = t.Id_Ticket + SELECT t.id INTO vTicket + FROM vn.ticket t + LEFT JOIN vn.ticketState tls on tls.ticket = t.id JOIN `order` o - ON o.address_id = t.Id_Consigna - AND vWarehouse = t.warehouse_id - AND o.agency_id = t.Id_Agencia - AND t.landing = o.date_send - AND vShipment = DATE(t.Fecha) + ON o.address_id = t.addressFk + AND vWarehouse = t.warehouseFk + AND o.agency_id = t.agencyModeFk + AND o.date_send = t.landed + AND vShipment = DATE(t.shipped) WHERE o.id = vOrder - AND t.Factura IS NULL + AND t.invoiceOutFk IS NULL AND IFNULL(tls.alertLevel,0) = 0 - AND t.Id_Cliente <> 1118 + AND t.clientFk <> 1118 LIMIT 1; -- Crea el ticket en el caso de no existir uno adecuado @@ -12324,24 +12485,24 @@ BEGIN ELSE INSERT INTO vncontrol.inter SET Id_Ticket = vTicket, - Id_Trabajador = SYSTEM_WORKER, + Id_Trabajador = vUserId, state_id = TICKET_FREE; END IF; - INSERT IGNORE INTO vn2008.order_Tickets - SET order_id = vOrder, - Id_Ticket = vTicket; + INSERT IGNORE INTO vn.orderTicket + SET orderFk = vOrder, + ticketFk = vTicket; -- Añade las notas IF vNotes IS NOT NULL AND vNotes != '' THEN - INSERT INTO vn2008.ticket_observation SET - Id_Ticket = vTicket, - observation_type_id = 4 /* salesperson */ , - `text` = vNotes + INSERT INTO vn.ticketObservation SET + ticketFk = vTicket, + observationTypeFk = 4 /* salesperson */ , + `description` = vNotes ON DUPLICATE KEY UPDATE - `text` = CONCAT(VALUES(`text`),'. ', `text`); + `description` = CONCAT(VALUES(`description`),'. ', `description`); END IF; -- Añade los movimientos y sus componentes @@ -12357,24 +12518,23 @@ BEGIN LEAVE lRows; END IF; - INSERT INTO vn2008.Movimientos + INSERT INTO vn.sale SET - Id_Article = vItem, - Id_Ticket = vTicket, - Concepte = vConcept, - Cantidad = vAmount, - Preu = vPrice, - CostFixat = 0, - PrecioFijado = TRUE; + itemFk = vItem, + ticketFk = vTicket, + concept = vConcept, + quantity = vAmount, + price = vPrice, + priceFixed = 0, + isPriceFixed = TRUE; SET vSale = LAST_INSERT_ID(); - INSERT INTO vn2008.Movimientos_componentes - (Id_Movimiento, Id_Componente, Valor) + INSERT INTO vn.saleComponent + (saleFk, componentFk, `value`) SELECT vSale, cm.component_id, cm.price FROM order_component cm - JOIN bi.tarifa_componentes tc - ON tc.Id_Componente = cm.component_id + JOIN vn.component c ON c.id = cm.component_id WHERE cm.order_row_id = vRowId GROUP BY vSale, cm.component_id; @@ -12391,20 +12551,17 @@ BEGIN CREATE TEMPORARY TABLE tComponents (INDEX (saleFk)) ENGINE = MEMORY - SELECT SUM(mc.Valor) valueSum, mc.Id_Movimiento saleFk - FROM vn2008.Movimientos_componentes mc - JOIN bi.tarifa_componentes tc USING(Id_Componente) - JOIN bi.tarifa_componentes_series tcs - ON tcs.tarifa_componentes_series_id = tc.tarifa_componentes_series_id - AND tcs.base - JOIN vn2008.Movimientos m - ON m.Id_Movimiento = mc.Id_Movimiento - WHERE m.Id_Ticket = vTicket - GROUP BY mc.Id_Movimiento; + SELECT SUM(sc.`value`) valueSum, sc.saleFk + FROM vn.saleComponent sc + JOIN vn.component c ON c.id = sc.componentFk + JOIN vn.componentType ct ON ct.id = c.typeFk AND ct.isBase + JOIN vn.sale s ON s.id = sc.saleFk + WHERE s.ticketFk = vTicket + GROUP BY sc.saleFk; - UPDATE vn2008.Movimientos m - JOIN tComponents mc ON mc.saleFk = m.Id_Movimiento - SET m.CostFixat = valueSum; + UPDATE vn.sale s + JOIN tComponents mc ON mc.saleFk = s.id + SET s.priceFixed = valueSum; DROP TEMPORARY TABLE tComponents; END LOOP; @@ -14871,6 +15028,21 @@ CREATE TABLE `currency` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `erte_COVID19` +-- + +DROP TABLE IF EXISTS `erte_COVID19`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `erte_COVID19` ( + `personFk` int(11) NOT NULL, + `description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + PRIMARY KEY (`personFk`), + CONSTRAINT `erte_COVID19_fk1` FOREIGN KEY (`personFk`) REFERENCES `person` (`person_id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `income_employee` -- @@ -14924,7 +15096,7 @@ CREATE TABLE `journey` ( `business_id` int(11) NOT NULL, PRIMARY KEY (`journey_id`), KEY `fki_business_journey` (`business_id`), - CONSTRAINT `business_journey` FOREIGN KEY (`business_id`) REFERENCES `business_labour` (`business_id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `business_journey` FOREIGN KEY (`business_id`) REFERENCES `business` (`business_id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -17899,6 +18071,8 @@ CREATE TABLE `XDiario` ( `FECREGCON` date DEFAULT NULL, PRIMARY KEY (`id`), KEY `empresa_id` (`empresa_id`), + KEY `ASIENidx` (`id`,`ASIEN`), + KEY `SERIEidx` (`ASIEN`,`SERIE`), CONSTRAINT `XDiario_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -18390,7 +18564,6 @@ CREATE TABLE `bank` ( `bank` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `account` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, `cash` smallint(6) NOT NULL DEFAULT '0', - `warehouseFk__` smallint(5) unsigned NOT NULL DEFAULT '1', `entityFk` int(10) unsigned NOT NULL, `isActive` tinyint(4) NOT NULL DEFAULT '1', `currencyFk` tinyint(3) unsigned DEFAULT '1', @@ -18685,10 +18858,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `buy_afterUpdate` - AFTER UPDATE ON `buy` - FOR EACH ROW -trig: BEGIN +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `buy_afterUpdate` AFTER UPDATE ON `buy` FOR EACH ROW trig: BEGIN IF !(NEW.id <=> OLD.id) OR !(NEW.entryFk <=> OLD.entryFk) OR !(NEW.itemFk <=> OLD.itemFk) @@ -18703,7 +18873,7 @@ trig: BEGIN CALL buy_afterUpsert(NEW.id); - IF (!(NEW.weight <=> OLD.weight) OR !(NEW.packing <=> OLD.packing) OR !(NEW.packageFk <=> OLD.packageFk)) AND NEW.weight THEN + IF !(NEW.weight <=> OLD.weight) AND NEW.weight THEN UPDATE item SET density = NEW.weight / (item_getVolume(NEW.itemFk, NEW.packageFk) / 1000000) WHERE id = NEW.itemFk; @@ -19309,9 +19479,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -19361,6 +19531,18 @@ BEGIN LEFT JOIN account.account ac ON ac.id = u.id WHERE w.id = NEW.salesPersonFk; END IF; + + IF NEW.salespersonFk IS NULL AND OLD.salespersonFk IS NOT NULL THEN + IF (SELECT COUNT(clientFk) + FROM clientProtected + WHERE clientFk = NEW.id + ) > 0 THEN + CALL util.throw("HAS_CLIENT_PROTECTED"); + END IF; + UPDATE vn2008.Clientes_cedidos + SET datEND = CURDATE() + WHERE Id_Cliente = NEW.id; + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -19526,48 +19708,6 @@ CREATE TABLE `clientManaCache` ( CONSTRAINT `cliente_fk` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`clientManaCache_AFTER_INSERT` AFTER INSERT ON `clientManaCache` FOR EACH ROW -BEGIN - IF NEW.clientFk = 7157 THEN - INSERT INTO mail(sender, replyTo, `subject`, body) - SELECT 'carlosap@verdnatura.es','carlosap@verdnatura.es','Mana cliente 7157 ', CONCAT(current_user(), USER()); - END IF; -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`clientManaCache_AFTER_UPDATE` AFTER UPDATE ON `clientManaCache` FOR EACH ROW -BEGIN - IF NEW.clientFk = 7157 THEN - INSERT INTO mail(sender, replyTo, `subject`, body) - SELECT 'carlosap@verdnatura.es','carlosap@verdnatura.es','Mana cliente 7157 ', CONCAT(current_user(), USER()); - END IF; -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -- -- Temporary table structure for view `clientManaCache__` @@ -20170,6 +20310,7 @@ CREATE TABLE `conveyor` ( `height` int(11) DEFAULT NULL, `x` int(11) DEFAULT NULL, `y` int(11) DEFAULT NULL, + `color` int(11) DEFAULT '14548991', PRIMARY KEY (`id`), KEY `conveyor_fk1_idx` (`typeFk`), CONSTRAINT `conveyor_fk1` FOREIGN KEY (`typeFk`) REFERENCES `conveyorType` (`id`) ON UPDATE CASCADE @@ -20247,10 +20388,27 @@ CREATE TABLE `conveyorMode` ( `code` varchar(20) COLLATE utf8_unicode_ci NOT NULL, `saturacion` int(11) NOT NULL, `gap` int(11) NOT NULL, + `isActive` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `conveyorMove` +-- + +DROP TABLE IF EXISTS `conveyorMove`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `conveyorMove` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `fromConveyorFk` int(11) NOT NULL, + `toConveyorFk` int(11) NOT NULL, + `created` datetime NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `conveyorType` -- @@ -20611,7 +20769,7 @@ CREATE TABLE `customsAgent` ( `email` varchar(150) COLLATE utf8mb4_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `nif_UNIQUE` (`nif`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -20720,9 +20878,9 @@ CREATE TABLE `department` ( `rgt` int(11) DEFAULT NULL, `workerFk` int(11) DEFAULT NULL COMMENT 'Id_Trabajador es el jefe del departamento', `companyFk` int(11) NOT NULL, - `bossFk` int(11) DEFAULT NULL, - `x` int(11) DEFAULT NULL, - `y` int(11) DEFAULT NULL, + `bossFk__` int(11) DEFAULT NULL, + `x__` int(11) DEFAULT NULL, + `y__` int(11) DEFAULT NULL, `isProduction` tinyint(4) NOT NULL DEFAULT '0', `isSelected` tinyint(1) NOT NULL DEFAULT '0', `depth` int(11) NOT NULL DEFAULT '0', @@ -21809,6 +21967,23 @@ CREATE TABLE `expeditionBoxVol` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Establece el volumen de cada servicio para poder comparar el teorico y el real en el control de portes'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Temporary table structure for view `expeditionTimeExpended` +-- + +DROP TABLE IF EXISTS `expeditionTimeExpended`; +/*!50001 DROP VIEW IF EXISTS `expeditionTimeExpended`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `expeditionTimeExpended` AS SELECT + 1 AS `ticketFk`, + 1 AS `started`, + 1 AS `finished`, + 1 AS `cajas`, + 1 AS `code`, + 1 AS `warehouseFk`*/; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `expence` -- @@ -22090,7 +22265,7 @@ DROP TABLE IF EXISTS `intrastat`; CREATE TABLE `intrastat` ( `id` int(8) unsigned zerofill NOT NULL, `description` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `import` tinyint(4) NOT NULL DEFAULT '0', + `import__` tinyint(4) NOT NULL DEFAULT '0', `taxClassFk` tinyint(3) unsigned NOT NULL DEFAULT '2', `taxCodeFk` tinyint(2) unsigned NOT NULL DEFAULT '64', PRIMARY KEY (`id`), @@ -22442,6 +22617,7 @@ CREATE TABLE `invoiceOutSerial` ( `taxAreaFk` varchar(15) CHARACTER SET utf8 NOT NULL DEFAULT 'NATIONAL', `isCEE` tinyint(1) NOT NULL DEFAULT '0', `cplusInvoiceType477Fk` int(10) unsigned DEFAULT '1', + `footNotes` longtext COLLATE utf8_unicode_ci, PRIMARY KEY (`code`), KEY `taxAreaFk_idx` (`taxAreaFk`), CONSTRAINT `invoiceOutSeriaTaxArea` FOREIGN KEY (`taxAreaFk`) REFERENCES `taxArea` (`code`) ON UPDATE CASCADE @@ -24067,6 +24243,23 @@ CREATE TABLE `mobileAppVersionControl` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Tabla para llevar el control de las Versions de las aplicaciones móvil '; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `mrw` +-- + +DROP TABLE IF EXISTS `mrw`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `mrw` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `ticketFk` int(11) NOT NULL, + `counter` smallint(5) unsigned DEFAULT NULL, + `shipped` date DEFAULT NULL, + `price` decimal(10,2) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `noticeCategory` -- @@ -25033,7 +25226,8 @@ DROP TABLE IF EXISTS `punchState`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `punchState` ( `workerFk` int(11) NOT NULL, - `state` tinyint(4) DEFAULT '0', + `state` tinyint(4) DEFAULT '1', + `created` datetime DEFAULT NULL, PRIMARY KEY (`workerFk`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Table for storing punches that have cars with errors'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -25495,18 +25689,19 @@ DROP TABLE IF EXISTS `routeParams`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `routeParams` ( - `ID` int(10) unsigned NOT NULL AUTO_INCREMENT, + `id` int(10) unsigned NOT NULL, `kmRate` decimal(10,4) DEFAULT NULL, - `m3Distributed` decimal(10,4) DEFAULT NULL, + `m3Distribution` decimal(10,4) DEFAULT NULL, `m3Management` decimal(10,2) DEFAULT NULL, + `m3Palletization` decimal(10,2) DEFAULT NULL, `load1m3` decimal(10,4) DEFAULT NULL, `load2m3` decimal(10,4) DEFAULT NULL, `load3m3` decimal(10,4) DEFAULT NULL, `load4m3` decimal(10,4) DEFAULT NULL, `load5m3` decimal(10,4) DEFAULT NULL, `load6m3` decimal(10,4) DEFAULT NULL, - PRIMARY KEY (`ID`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25845,27 +26040,6 @@ SET character_set_client = utf8; 1 AS `clientFk`*/; SET character_set_client = @saved_cs_client; --- --- Temporary table structure for view `saleVolume__` --- - -DROP TABLE IF EXISTS `saleVolume__`; -/*!50001 DROP VIEW IF EXISTS `saleVolume__`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `saleVolume__` AS SELECT - 1 AS `ticketFk`, - 1 AS `saleFk`, - 1 AS `litros`, - 1 AS `routeFk`, - 1 AS `shipped`, - 1 AS `volume`, - 1 AS `physicalWeight`, - 1 AS `weight`, - 1 AS `physicalVolume`, - 1 AS `freight`*/; -SET character_set_client = @saved_cs_client; - -- -- Temporary table structure for view `sale_freightComponent` -- @@ -25880,6 +26054,42 @@ SET character_set_client = utf8; 1 AS `shipped`*/; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `salesPreparedLastHour` +-- + +DROP TABLE IF EXISTS `salesPreparedLastHour`; +/*!50001 DROP VIEW IF EXISTS `salesPreparedLastHour`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `salesPreparedLastHour` AS SELECT + 1 AS `warehouseFk`, + 1 AS `saleFk`, + 1 AS `isChecked`, + 1 AS `originalQuantity`, + 1 AS `accion`, + 1 AS `created`, + 1 AS `code`, + 1 AS `firstname`, + 1 AS `lastName`, + 1 AS `workerCode`, + 1 AS `litros`, + 1 AS `concept`, + 1 AS `departmentName`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `salesPreviousPreparated` +-- + +DROP TABLE IF EXISTS `salesPreviousPreparated`; +/*!50001 DROP VIEW IF EXISTS `salesPreviousPreparated`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `salesPreviousPreparated` AS SELECT + 1 AS `saleFk`*/; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `sample` -- @@ -26292,6 +26502,7 @@ CREATE TABLE `state` ( `isPreparable` tinyint(1) NOT NULL DEFAULT '0', `semaphore` int(11) NOT NULL DEFAULT '0', `isPrintable` tinyint(4) NOT NULL DEFAULT '0', + `isOK` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `code_UNIQUE` (`code`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -26343,29 +26554,29 @@ DROP TABLE IF EXISTS `supplier`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `supplier` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `account` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `street` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `postCode__` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'deprecada', - `city` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, + `account` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, + `street` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, + `postCode__` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'deprecada', + `city` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, `provinceFk` smallint(5) unsigned DEFAULT NULL, `countryFk` mediumint(8) unsigned DEFAULT NULL, - `nif` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `nif` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, `isOfficial` tinyint(1) NOT NULL DEFAULT '1', `isFarmer` tinyint(1) NOT NULL DEFAULT '0', - `retAccount` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `phone` varchar(16) COLLATE utf8_unicode_ci DEFAULT NULL, - `Fax` varchar(16) COLLATE utf8_unicode_ci DEFAULT NULL, + `retAccount` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, + `phone` varchar(16) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, + `Fax` varchar(16) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, `commission` float NOT NULL DEFAULT '0', - `nickname` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `nickname` varchar(45) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, `payMethodFk` tinyint(3) unsigned NOT NULL, `payDay` tinyint(4) unsigned DEFAULT NULL, `payDemFk` tinyint(3) unsigned NOT NULL DEFAULT '7', `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `isSerious` tinyint(1) unsigned zerofill DEFAULT '1', - `note` text COLLATE utf8_unicode_ci, + `note` text CHARACTER SET utf8 COLLATE utf8_unicode_ci, `postcodeFk` int(11) unsigned DEFAULT NULL, - `postCode` char(5) COLLATE utf8_unicode_ci DEFAULT NULL, + `postCode` char(5) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, `isActive` tinyint(4) DEFAULT '1', PRIMARY KEY (`id`), UNIQUE KEY `cuenta` (`account`), @@ -26379,7 +26590,7 @@ CREATE TABLE `supplier` ( CONSTRAINT `pay_dem_id` FOREIGN KEY (`payDemFk`) REFERENCES `payDem` (`id`) ON UPDATE CASCADE, CONSTRAINT `pay_met_id` FOREIGN KEY (`payMethodFk`) REFERENCES `payMethod` (`id`) ON UPDATE CASCADE, CONSTRAINT `province_id` FOREIGN KEY (`provinceFk`) REFERENCES `province` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26807,7 +27018,7 @@ BEGIN SET NEW.landed = DATE_FORMAT(NEW.landed, '2000-%m-%d %T'); SET NEW.routeFk = NULL; END IF; - + IF NEW.routeFk AND NEW.isDeleted THEN CALL util.throw ('This ticket is deleted'); END IF; @@ -27129,16 +27340,16 @@ CREATE TABLE `ticketPackaging` ( /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`ticketPackaging_BEFORE_INSERT` BEFORE INSERT ON `ticketPackaging` FOR EACH ROW BEGIN - SET NEW.workerFk = vn.getWorker(); + SET NEW.workerFk = vn.myWorker_getId(); END */;; DELIMITER ; @@ -28325,6 +28536,21 @@ SET character_set_client = utf8; 1 AS `departmentFk`*/; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `workerDisableExcluded` +-- + +DROP TABLE IF EXISTS `workerDisableExcluded`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `workerDisableExcluded` ( + `workerFk` int(11) NOT NULL, + `dated` date DEFAULT NULL, + PRIMARY KEY (`workerFk`), + CONSTRAINT `workerDisableExcludedFk1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='No se deshabilitan hasta la fecha especificada'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `workerDocument` -- @@ -28515,6 +28741,44 @@ SET character_set_client = utf8; 1 AS `mediaValue`*/; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `workerSpeedExpedition` +-- + +DROP TABLE IF EXISTS `workerSpeedExpedition`; +/*!50001 DROP VIEW IF EXISTS `workerSpeedExpedition`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `workerSpeedExpedition` AS SELECT + 1 AS `ticketFk`, + 1 AS `litros`, + 1 AS `literLastHour`, + 1 AS `litersByMinute`, + 1 AS `workerCode`, + 1 AS `cajas`, + 1 AS `warehouseFk`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `workerSpeedSaleTracking` +-- + +DROP TABLE IF EXISTS `workerSpeedSaleTracking`; +/*!50001 DROP VIEW IF EXISTS `workerSpeedSaleTracking`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `workerSpeedSaleTracking` AS SELECT + 1 AS `warehouseFk`, + 1 AS `accion`, + 1 AS `workerCode`, + 1 AS `sumaLitros`, + 1 AS `started`, + 1 AS `finished`, + 1 AS `sumaLitrosLastHour`, + 1 AS `litersByMinute`, + 1 AS `departmentName`*/; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `workerTeam` -- @@ -28930,13 +29194,13 @@ CREATE TABLE `zone` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `zoneCalendar` +-- Table structure for table `zoneCalendar__` -- -DROP TABLE IF EXISTS `zoneCalendar`; +DROP TABLE IF EXISTS `zoneCalendar__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `zoneCalendar` ( +CREATE TABLE `zoneCalendar__` ( `zoneFk` int(11) NOT NULL, `delivered` date NOT NULL, `price` double NOT NULL, @@ -31952,10 +32216,10 @@ BEGIN */ DECLARE vWorker INT; - SELECT IFNULL(w.id, c.defaultWorkerFk) INTO vWorker + SELECT w.id INTO vWorker FROM worker w, workerConfig c WHERE w.userFk = account.userGetId(); - + RETURN vWorker; END ;; DELIMITER ; @@ -32574,13 +32838,14 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` FUNCTION `workerIsBoss`(vUserId INT) RETURNS int(11) + DETERMINISTIC BEGIN /** * Comprueba por jerarquía si el trabajador actual es jefe @@ -32613,7 +32878,7 @@ BEGIN END IF; IF vBossId = vWorkerId THEN RETURN FALSE; - ELSEIF vBossId = vn.getWorker() THEN + ELSEIF vBossId = vn.myWorker_getId() THEN RETURN TRUE; ELSE INSERT INTO tCheckedWorker VALUES (vWorkerId); @@ -33227,6 +33492,76 @@ BEGIN -- Establecemos los almacenes y las fechas que van a entrar al disponible + CALL vn.zone_getShipped (vDate, vAddress, vAgencyMode, FALSE); + + DROP TEMPORARY TABLE IF EXISTS tmp.availableCalc; + CREATE TEMPORARY TABLE tmp.availableCalc( + calcFk INT UNSIGNED, + PRIMARY KEY (calcFk) + ) + ENGINE = MEMORY; + + OPEN cWarehouses; + + l: LOOP + SET vDone = FALSE; + FETCH cWarehouses INTO vWarehouse, vShipment; + + IF vDone THEN + LEAVE l; + END IF; + + CALL `cache`.available_refresh(vCalcFk, FALSE, vWarehouse, vShipment); + + INSERT IGNORE INTO tmp.availableCalc + SET calcFk = vCalcFk; + END LOOP; + + CLOSE cWarehouses; + DROP TEMPORARY TABLE tmp.zoneGetShipped; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `available_calc__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `available_calc__`( + vDate DATE, + vAddress INT, + vAgencyMode INT) +BEGIN +/** + * Calculates the available for all available stores + * according to the given parameters. + * + * @param vDate The delivery date + * @param vAddress The delivery address id + * @param vAgencyMode The shipping agency + * @return tmp.availableCalc(calcFk) The available cache ids + */ + DECLARE vCalcFk INT; + DECLARE vShipment DATE; + DECLARE vWarehouse INT; + DECLARE vDone BOOL; + + DECLARE cWarehouses CURSOR FOR + SELECT warehouseFk, shipped FROM tmp.zoneGetShipped; + + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET vDone = TRUE; + + -- Establecemos los almacenes y las fechas que van a entrar al disponible + CALL vn.zone_getShippedWarehouse(vDate, vAddress, vAgencyMode); DROP TEMPORARY TABLE IF EXISTS tmp.availableCalc; @@ -33925,6 +34260,132 @@ proc: BEGIN * @return tmp.ticketComponentPrice * @return tmp.zoneGetShipped + **/ + + DECLARE vAvailableCalc INT; + DECLARE vShipped DATE; + DECLARE vClient INT; + DECLARE vWarehouseFk SMALLINT; + DECLARE vZoneFk INT; + DECLARE vDone BOOL; + DECLARE cTravelTree CURSOR FOR + SELECT zoneFk, warehouseFk, shipped FROM tmp.zoneGetShipped; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + -- Establece los almacenes y las fechas que van a entrar al disponible + + SELECT clientFk INTO vClient + FROM address WHERE id = vAddressFk; + + CALL vn.zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, FALSE); + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; + CREATE TEMPORARY TABLE tmp.ticketLot( + `warehouseFk` smallint(5) unsigned NOT NULL, + `itemFk` int(11) NOT NULL, + `available` double DEFAULT NULL, + `buyFk` int(11) DEFAULT NULL, + `fix` tinyint(3) unsigned DEFAULT '0', + KEY `itemFk` (`itemFk`), + KEY `item_warehouse` (`itemFk`,`warehouseFk`) USING HASH + ) ENGINE=MEMORY DEFAULT CHARSET=utf8; + + OPEN cTravelTree; + + l: LOOP + SET vDone = FALSE; + FETCH cTravelTree INTO vZoneFk, vWarehouseFk, vShipped; + + IF vDone THEN + LEAVE l; + END IF; + + CALL `cache`.available_refresh (vAvailableCalc, FALSE, vWarehouseFk, vShipped); + CALL buyUltimate (vWarehouseFk, vShipped); + + INSERT INTO tmp.ticketLot (warehouseFk, itemFk, available, buyFk) + SELECT vWarehouseFk, + i.item_id, + IFNULL(i.available, 0), + bu.buyFk + FROM `cache`.available i + JOIN tmp.item br ON br.itemFk = i.item_id + LEFT JOIN item it ON it.id = i.item_id + LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = i.item_id + WHERE i.calc_id = vAvailableCalc + AND it.id != 100 + AND i.available > 0; + + DROP TEMPORARY TABLE tmp.buyUltimate; + END LOOP; + + CLOSE cTravelTree; + + CALL vn.catalog_componentCalculate(vZoneFk, vAddressFk, vShipped); + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketCalculateItem; + CREATE TEMPORARY TABLE tmp.ticketCalculateItem + ENGINE = MEMORY + SELECT + b.itemFk, + SUM(b.available) available, + p.name producer, + i.name item, + i.size size, + i.stems, + i.category, + i.inkFk, + i.image, + o.code origin, + bl.price, + bl.priceKg + FROM tmp.ticketLot b + JOIN item i ON b.itemFk = i.id + LEFT JOIN producer p ON p.id = i.producerFk AND p.isVisible + JOIN origin o ON o.id = i.originFk + JOIN ( + SELECT MIN(price) price, itemFk, priceKg + FROM tmp.ticketComponentPrice + GROUP BY itemFk + ) bl ON bl.itemFk = b.itemFk + GROUP BY b.itemFk; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `catalog_calculate__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `catalog_calculate__`( + vLanded DATE, + vAddressFk INT, + vAgencyModeFk INT) +proc: BEGIN +/** + * Calcula los articulos disponibles y sus precios + * + * @table tmp.item(itemFk) Listado de artículos a calcular + * @param vLanded Fecha de recepcion de mercancia + * @param vAddressFk Id del consignatario + * @param vAgencyModeFk Id de la agencia + * @return tmp.ticketCalculateItem(itemFk, available, producer, + * item, size, stems, category, inkFk, image, origin, price) + * @return tmp.ticketLot(warehouseFk, itemFk, available, buyFk) + * @return tmp.ticketComponent + * @return tmp.ticketComponentPrice + * @return tmp.zoneGetShipped + **/ DECLARE vAvailableCalc INT; @@ -34026,13 +34487,289 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `catalog_componentCalculate`( + vZoneFk INT, + vAddressFk INT, + vShipped DATE) +proc: BEGIN +/** + * Calcula los componentes de los articulos de tmp.ticketLot + * + * @param vZoneFk para calcular el transporte + * @param vAddressFk Consignatario + * @param vShipped dia de salida del pedido + * @param tmp.ticketLot (warehouseFk,available,itemFk,buyFk) + * + * @return tmp.ticketComponent(itemFk, warehouseFk, available, rate2, rate3, minPrice, + * packing, grouping, groupingMode, buyFk, typeFk) + * @return tmp.ticketComponentPrice (warehouseFk, itemFk, rate, grouping, price) + */ + DECLARE vClientFk INT; + DECLARE vGeneralInflationCoefficient INT DEFAULT 1; + DECLARE vMinimumDensityWeight INT DEFAULT 167; + DECLARE vBoxFreightItem INT DEFAULT 71; + DECLARE vBoxVolume BIGINT; -- DEFAULT 138000; + DECLARE vSpecialPriceComponent INT DEFAULT 10; + DECLARE vDeliveryComponent INT DEFAULT 15; + DECLARE vRecoveryComponent INT DEFAULT 17; + DECLARE vSellByPacketComponent INT DEFAULT 22; + DECLARE vBuyValueComponent INT DEFAULT 28; + DECLARE vMarginComponent INT DEFAULT 29; + DECLARE vDiscountLastItemComponent INT DEFAULT 32; + DECLARE vExtraBaggedComponent INT DEFAULT 38; + DECLARE vManaAutoComponent INT DEFAULT 39; + + SELECT volume INTO vBoxVolume + FROM vn.packaging + WHERE id = '94'; + + SELECT clientFk INTO vClientFK + FROM address + WHERE id = vAddressFk; + + SET @rate2 := 0; + SET @rate3 := 0; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentCalculate; + CREATE TEMPORARY TABLE tmp.ticketComponentCalculate + (PRIMARY KEY (itemFk, warehouseFk)) + ENGINE = MEMORY + SELECT + tl.itemFk, tl.warehouseFk, tl.available, + IF((@rate2 := IFNULL(pf.rate2, b.price2)) < i.minPrice AND i.hasMinPrice, i.minPrice, @rate2) * 1.0 rate2, + IF((@rate3 := IFNULL(pf.rate3, b.price3)) < i.minPrice AND i.hasMinPrice, i.minPrice, @rate3) * 1.0 rate3, + IFNULL(pf.rate3, 0) AS minPrice, + IFNULL(pf.packing, b.packing) packing, + IFNULL(pf.`grouping`, b.`grouping`) `grouping`, + ABS(IFNULL(pf.box, b.groupingMode)) groupingMode, + tl.buyFk, + i.typeFk, + IF(i.hasKgPrice, b.weight / b.packing, NULL) weightGrouping + FROM tmp.ticketLot tl + JOIN buy b ON b.id = tl.buyFk + JOIN item i ON i.id = tl.itemFk + JOIN itemType it ON it.id = i.typeFk + LEFT JOIN itemCategory ic ON ic.id = it.categoryFk + LEFT JOIN specialPrice sp ON sp.itemFk = i.id AND sp.clientFk = vClientFk + LEFT JOIN ( + SELECT * FROM ( + SELECT pf.itemFk, pf.`grouping`, pf.packing, pf.box, pf.rate2, pf.rate3, zw.warehouseFk + FROM priceFixed pf + JOIN zoneWarehouse zw ON zw.zoneFk = vZoneFk AND (zw.warehouseFk = pf.warehouseFk OR pf.warehouseFk = 0) + WHERE vShipped BETWEEN pf.started AND pf.ended ORDER BY pf.itemFk, pf.warehouseFk DESC + ) tpf + GROUP BY tpf.itemFk, tpf.warehouseFk + ) pf ON pf.itemFk = tl.itemFk AND pf.warehouseFk = tl.warehouseFk + WHERE b.buyingValue + b.freightValue + b.packageValue + b.comissionValue > 0.01 AND ic.display <> 0; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent; + CREATE TEMPORARY TABLE tmp.ticketComponent ( + `warehouseFk` INT UNSIGNED NOT NULL, + `itemFk` INT NOT NULL, + `componentFk` INT UNSIGNED NOT NULL, + `cost` DECIMAL(10,4) NOT NULL, + INDEX `itemWarehouse` USING BTREE (`itemFk` ASC, `warehouseFk` ASC), + UNIQUE INDEX `itemWarehouseComponent` (`itemFk` ASC, `warehouseFk` ASC, `componentFk` ASC)); + + INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) + SELECT + tcc.warehouseFk, + tcc.itemFk, + vBuyValueComponent, + b.buyingValue + b.freightValue + b.packageValue + b.comissionValue + FROM tmp.ticketComponentCalculate tcc + JOIN buy b ON b.id = tcc.buyFk; + + INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) + SELECT + tcc.warehouseFk, + tcc.itemFk, + vMarginComponent, + tcc.rate3 - b.buyingValue - b.freightValue - b.packageValue - b.comissionValue + FROM tmp.ticketComponentCalculate tcc + JOIN buy b ON b.id = tcc.buyFk; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentBase; + CREATE TEMPORARY TABLE tmp.ticketComponentBase ENGINE = MEMORY + SELECT tc.itemFk, ROUND(SUM(tc.cost), 4) AS base, tc.warehouseFk + FROM tmp.ticketComponent tc + GROUP BY tc.itemFk, warehouseFk; + + INSERT INTO tmp.ticketComponent + SELECT tcb.warehouseFk, tcb.itemFk, vRecoveryComponent, ROUND(tcb.base * LEAST(cr.priceIncreasing, 0.25), 3) + FROM tmp.ticketComponentBase tcb + JOIN claimRatio cr ON cr.clientFk = vClientFk + WHERE cr.priceIncreasing > 0.009; + + INSERT INTO tmp.ticketComponent + SELECT tcb.warehouseFk, tcb.itemFk, vManaAutoComponent, ROUND(base * (0.01 + wm.pricesModifierRate), 3) as manaAuto + FROM tmp.ticketComponentBase tcb + JOIN `client` c on c.id = vClientFk + JOIN workerMana wm ON c.salesPersonFk = wm.workerFk + WHERE wm.isPricesModifierActivated + HAVING manaAuto <> 0; + + INSERT INTO tmp.ticketComponent + SELECT tcb.warehouseFk, + tcb.itemFk, + c.id, + GREATEST(IFNULL(ROUND(tcb.base * c.tax, 4), 0), tcc.minPrice - tcc.rate3) + FROM tmp.ticketComponentBase tcb + JOIN component c + JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tcb.itemFk AND tcc.warehouseFk = tcb.warehouseFk + LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk + WHERE c.id = vDiscountLastItemComponent AND c.tax <> 0 AND tcc.minPrice < tcc.rate3 AND sp.value IS NULL; + + INSERT INTO tmp.ticketComponent + SELECT tcc.warehouseFk, tcc.itemFk, vSellByPacketComponent, tcc.rate2 - tcc.rate3 + FROM tmp.ticketComponentCalculate tcc + JOIN buy b ON b.id = tcc.buyFk + LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk + WHERE sp.value IS NULL; + + DROP TEMPORARY TABLE IF EXISTS tmp.zone; + CREATE TEMPORARY TABLE IF NOT EXISTS tmp.zone (INDEX (id)) + ENGINE = MEMORY + SELECT vZoneFk id; + + CALL zone_getOptionsForShipment(vShipped, TRUE); + + INSERT INTO tmp.ticketComponent + SELECT tcc.warehouseFK, + tcc.itemFk, + vDeliveryComponent, + vGeneralInflationCoefficient + * ROUND(( + i.compression + * ic.cm3 + * IF(am.deliveryMethodFk = 1, (GREATEST(i.density, vMinimumDensityWeight) / vMinimumDensityWeight), 1) + * IFNULL((zo.price - zo.bonus) + * 1/*amz.inflation*/ , 50)) / vBoxVolume, 4 + ) cost + FROM tmp.ticketComponentCalculate tcc + JOIN item i ON i.id = tcc.itemFk + JOIN tmp.zoneOption zo ON zo.zoneFk = vZoneFk + JOIN zone z ON z.id = vZoneFk + JOIN agencyMode am ON am.id = z.agencyModeFk + LEFT JOIN itemCost ic ON ic.warehouseFk = tcc.warehouseFk + AND ic.itemFk = tcc.itemFk + HAVING cost <> 0; + + DROP TEMPORARY TABLE tmp.zoneOption; + + IF (SELECT COUNT(*) FROM vn.addressForPackaging WHERE addressFk = vAddressFk) THEN + INSERT INTO tmp.ticketComponent + SELECT tcc.warehouseFk, b.itemFk, vExtraBaggedComponent, ap.packagingValue cost + FROM tmp.ticketComponentCalculate tcc + JOIN vn.addressForPackaging ap + WHERE ap.addressFk = vAddressFk; + END IF; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentCopy; + CREATE TEMPORARY TABLE tmp.ticketComponentCopy ENGINE = MEMORY + SELECT * FROM tmp.ticketComponent; + + INSERT INTO tmp.ticketComponent + SELECT tcc.warehouseFk, + tcc.itemFk, + vSpecialPriceComponent, + sp.value - SUM(tcc.cost) sumCost + FROM tmp.ticketComponentCopy tcc + JOIN component c ON c.id = tcc.componentFk + JOIN specialPrice sp ON sp.clientFk = vClientFK AND sp.itemFk = tcc.itemFk + WHERE c.classRate IS NULL + GROUP BY tcc.itemFk, tcc.warehouseFk + HAVING ABS(sumCost) > 0.001; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentSum; + CREATE TEMPORARY TABLE tmp.ticketComponentSum + (INDEX (itemFk, warehouseFk)) + ENGINE = MEMORY + SELECT SUM(cost) sumCost, tc.itemFk, tc.warehouseFk, c.classRate + FROM tmp.ticketComponent tc + JOIN component c ON c.id = tc.componentFk + GROUP BY tc.itemFk, tc.warehouseFk, c.classRate; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentRate; + CREATE TEMPORARY TABLE tmp.ticketComponentRate ENGINE = MEMORY + SELECT tcc.warehouseFk, + tcc.itemFk, + 1 rate, + IF(tcc.groupingMode = 1, tcc.`grouping`, 1) `grouping`, + CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) price, + CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) / weightGrouping priceKg + FROM tmp.ticketComponentCalculate tcc + JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk + AND tcs.warehouseFk = tcc.warehouseFk + WHERE IFNULL(tcs.classRate, 1) = 1 + AND tcc.groupingMode < 2 AND (tcc.packing > tcc.`grouping` or tcc.groupingMode = 0) + GROUP BY tcs.warehouseFk, tcs.itemFk; + + INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg) + SELECT + tcc.warehouseFk, + tcc.itemFk, + 2 rate, + tcc.packing `grouping`, + SUM(tcs.sumCost) price, + SUM(tcs.sumCost) / weightGrouping priceKg + FROM tmp.ticketComponentCalculate tcc + JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk + AND tcs.warehouseFk = tcc.warehouseFk + WHERE tcc.available IS NULL OR (IFNULL(tcs.classRate, 2) = 2 + AND tcc.packing > 0 AND tcc.available >= tcc.packing) + GROUP BY tcs.warehouseFk, tcs.itemFk; + + INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg) + SELECT + tcc.warehouseFk, + tcc.itemFk, + 3 rate, + tcc.available `grouping`, + SUM(tcs.sumCost) price, + SUM(tcs.sumCost) / weightGrouping priceKg + FROM tmp.ticketComponentCalculate tcc + JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk + AND tcs.warehouseFk = tcc.warehouseFk + WHERE IFNULL(tcs.classRate, 3) = 3 + GROUP BY tcs.warehouseFk, tcs.itemFk; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentPrice; + CREATE TEMPORARY TABLE tmp.ticketComponentPrice ENGINE = MEMORY + SELECT * FROM ( + SELECT * FROM tmp.ticketComponentRate ORDER BY price + ) t + GROUP BY itemFk, warehouseFk, `grouping`; + + DROP TEMPORARY TABLE + tmp.ticketComponentCalculate, + tmp.ticketComponentSum, + tmp.ticketComponentBase, + tmp.ticketComponentRate, + tmp.ticketComponentCopy; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `catalog_componentCalculate__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8 */ ; /*!50003 SET character_set_results = utf8 */ ; /*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `catalog_componentCalculate`( +CREATE DEFINER=`root`@`%` PROCEDURE `catalog_componentCalculate__`( vZoneFk INT, vAddressFk INT, vShipped DATE) @@ -35177,13 +35914,72 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `clientRemoveWorker`() +BEGIN + DECLARE done BOOL DEFAULT FALSE; + DECLARE vClientFk INT; + + DECLARE rs CURSOR FOR + SELECT c.clientFk + FROM tmp.clientGetDebt c + LEFT JOIN clientRisk r ON r.clientFk = c.clientFk + WHERE IFNULL(r.amount,0) = 0; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; + + DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt; + CREATE TEMPORARY TABLE tmp.clientGetDebt + SELECT cd.id as clientFk + FROM bs.clientDied cd + LEFT JOIN vn.clientProtected cp ON cp.clientFk = cd.id + JOIN vn.client c ON c.id = cd.id + JOIN vn.province p ON p.id = c.provinceFk + JOIN vn.country co ON co.id = p.countryFk + WHERE cd.Aviso = 'TERCER AVISO' + AND cp.clientFk IS NULL + AND co.country NOT IN ('Portugal','Francia','España exento') + AND c.salesPersonFk IS NOT NULL; + + OPEN rs; + FETCH rs INTO vClientFk; + + WHILE NOT done DO + + CALL vn.clientGreugeSpray(vClientFk, TRUE, '',TRUE); + UPDATE vn.client SET salesPersonFk = NULL WHERE id = vClientFk; + + INSERT INTO vn.clientLog (originFk, userFk, `action`, description) + VALUES (vClientFk, account.userGetId(), 'update', CONCAT('Se ha desasignado el cliente por que no ha comprado en 3 meses')); + + REPLACE bs.clientNewBorn(clientFk, shipped) + VALUES(vClientFk, CURDATE()); + FETCH rs INTO vClientFk; + END WHILE; + + CLOSE rs; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `clientRemoveWorker__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `clientRemoveWorker__`() BEGIN DECLARE done BOOL DEFAULT FALSE; DECLARE vClientFk INT; @@ -35696,6 +36492,30 @@ BEGIN LEFT JOIN vn.worker w ON w.id = c.salesPersonFk WHERE tc.collectionFk = vCollectionFk; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `collection_get` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `collection_get`(vWorkerFk INT) +BEGIN + + SELECT c.id AS collectionFk, date(c.created) AS created + FROM vn.collection c + JOIN vn.state s ON c.stateFk = s.id + WHERE c.workerFk = vWorkerFk AND s.code = 'ON_PREPARATION'; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -35792,7 +36612,7 @@ proc:BEGIN AND a.name != 'REC_SILLA' AND (pb.ubicacion IS NOT NULL OR a.isOwn = FALSE) AND s.isPrintable - AND (pb.m3 > 0.05 OR s.code = 'OK') + AND (pb.m3 > 0.05 OR s.isOK) ORDER BY (Hora - 1) * 60 + minuto > hour(now()) * 60 + minute(now()) , s.order DESC, Hora, @@ -35880,7 +36700,7 @@ proc:BEGIN -- Vamos a generar una tabla con todas las posibilidades de asignacion de pedido DROP TEMPORARY TABLE IF EXISTS tmp.ticketShelve; CREATE TEMPORARY TABLE tmp.ticketShelve - SELECT ticketFk, shelve + SELECT ticketFk, shelve, linesDif, LitersDif, heightDif FROM ( SELECT t.ticketFk, cv.`level` shelve, @@ -35900,6 +36720,7 @@ proc:BEGIN SELECT IFNULL(shelve,0) INTO vShelve FROM tmp.ticketShelve WHERE ticketFk = vFirstTicketFk + ORDER BY heightDif, litersDif, linesDif LIMIT 1; IF vShelve THEN @@ -35980,6 +36801,693 @@ proc:BEGIN SELECT vCollectionFk; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `collection_newBeta` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `collection_newBeta`(vSectorFk INT,vWorkerFk INT) +proc:BEGIN + + DECLARE vIsPreviousPrepared BOOLEAN; + DECLARE vCollectionFk INT; + DECLARE vWarehouseFk INT; + DECLARE vMaxTickets INT DEFAULT 4; + DECLARE vStateFk INT; + DECLARE vFirstTicketFk INT; + DECLARE vWorkerCode VARCHAR(3); + DECLARE vShelve INT; + DECLARE vTicket INT; + DECLARE myUserIsSalesPersonRole BOOLEAN; + DECLARE vPrintedTickets INT; + DECLARE vMaxTicketPrinted INT DEFAULT 10; + + -- Establecemos el almacén y si es un sector de preparación previa, así como el estado para los tickets que se vayan preparando + SELECT isPreviousPrepared, warehouseFk + INTO vIsPreviousPrepared, vWarehouseFk + FROM vn.sector + WHERE id = vSectorFk; + + IF vIsPreviousPrepared THEN + + SELECT id INTO vStateFk + FROM vn.state + WHERE `code` = 'PREVIOUS_PREPARATION'; + ELSE + + SELECT id INTO vStateFk + FROM vn.state + WHERE `code` = 'ON_PREPARATION'; + + END IF; + + -- Averiguamos si es comercial el usuario + SELECT (r.name = 'salesPerson') + INTO myUserIsSalesPersonRole + FROM account.user u + JOIN account.role r ON r.id = u.role + WHERE u.id = vWorkerFk; + + -- Obtenemos el código del usuario + SELECT w.code + INTO vWorkerCode + FROM vn.worker w + WHERE w.id = vWorkerFk; + + -- Se obtiene nº de colección y el buffer con los pedidos preparables + INSERT INTO vn.collection + SET workerFk = vWorkerFk; + + SELECT LAST_INSERT_ID() INTO vCollectionFk; + + CALL vn2008.production_control_source(vWarehouseFk, 0); + + SELECT COUNT(*) INTO vPrintedTickets + FROM tmp.production_buffer pb + JOIN vn.state s ON s.id = pb.state + WHERE pb.Fecha = CURDATE() + AND s.isPreparable; + + SET vMaxTicketPrinted = vMaxTicketPrinted - vPrintedTickets; + + -- AutoPRINT + + IF vMaxTicketPrinted > 0 THEN + + INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) + SELECT s2.id, pb.Id_Ticket, vWorkerFk + FROM tmp.production_buffer pb + JOIN vn.agency a ON a.id = pb.agency_id + JOIN vn.state s ON s.id = pb.state + JOIN vn.state s2 ON s2.code = 'PRINTED' + LEFT JOIN vn.route r ON r.id = pb.Id_Ruta + WHERE pb.Fecha = CURDATE() + AND NOT pb.problems + AND a.name != 'REC_SILLA' + AND (pb.ubicacion IS NOT NULL OR a.isOwn = FALSE) + AND s.isPrintable + AND (pb.m3 > 0.05 OR s.isOK) + ORDER BY (Hora - 1) * 60 + minuto > hour(now()) * 60 + minute(now()) , + s.order DESC, + Hora, + minuto, + IFNULL(r.priority,99999), + pb.m3 DESC + LIMIT vMaxTicketPrinted; + + END IF; + + -- SELECT vMaxTicketPrinted; + -- Se seleccionan los primeros tickets, asignando colección para dejarlos bloqueados a otros sacadores. + + INSERT IGNORE INTO vn.ticketCollection(ticketFk, collectionFk) + SELECT pb.Id_Ticket, + vCollectionFk + FROM tmp.production_buffer pb + JOIN vn.state s ON s.id = pb.state + WHERE pb.collectionFk IS NULL + AND ( + (s.isPreparable AND NOT myUserIsSalesPersonRole AND pb.Agencia != 'REC_SILLA') + OR + (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) + ) + ORDER BY (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) DESC, pb.Hora, pb.Minuto + LIMIT vMaxTickets; + + + -- Creamos una tabla temporal con los datos que necesitamos para depurar la colección + DROP TEMPORARY TABLE IF EXISTS tmp.ticket; + CREATE TEMPORARY TABLE tmp.ticket + SELECT pb.Id_Ticket ticketFk, + pb.lines, + pb.m3 * 1000 liters, + 0 as height, + 0 as shelve + FROM tmp.production_buffer pb + JOIN vn.ticketCollection tc ON tc.ticketFk = pb.Id_Ticket + WHERE tc.collectionFk = vCollectionFk; + + /* El criterio para formar la colección es el siguiente: + * + * 1º.- Los tickets asignados son prioritarios, y por ello ya vienen ordenados en las primeras posiciones. + * 2º.- Las recogidas en Silla tienen que ir en carros independientes. + * + * Por tanto, si el primer pedido es recogida, nos olvidamos del resto. + * Si el primer pedido no es recogida, eliminamos las recogidas posteriores. + */ + + SELECT ticketFk + INTO vFirstTicketFk + FROM tmp.ticket + LIMIT 1; + + IF (SELECT pb.Agencia FROM tmp.production_buffer pb WHERE Id_Ticket = vFirstTicketFk) = 'REC_SILLA' THEN + + DELETE FROM tmp.ticket WHERE ticketFk != vFirstTicketFk; + + UPDATE tmp.ticket SET shelve = 1; + -- Como sólo hay un ticket, se le asigna el nivel 1 y acabamos + + ELSE + + -- Eliminamos los de recogida, puesto que el primero sabemos que no es de rec_silla + DELETE t.* + FROM tmp.ticket t + JOIN tmp.production_buffer pb ON pb.Id_Ticket = t.ticketFk + WHERE pb.Agencia = 'REC_SILLA'; + + -- Establece altura máxima por pedido, porque las plantas no se pueden recostar. + UPDATE tmp.ticket t + JOIN + ( SELECT MAX(i.size) maxHeigth, + tc.ticketFk + FROM vn.ticketCollection tc + JOIN vn.sale s ON s.ticketFk = tc.ticketFk + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk + WHERE ic.isReclining = FALSE + AND tc.collectionFk = vCollectionFk + GROUP BY tc.ticketFk) sub ON sub.ticketFk = t.ticketFk + SET t.height = sub.maxHeigth; + + -- Vamos a generar una tabla con todas las posibilidades de asignacion de pedido + DROP TEMPORARY TABLE IF EXISTS tmp.ticketShelve; + CREATE TEMPORARY TABLE tmp.ticketShelve + SELECT ticketFk, shelve, linesDif, LitersDif, heightDif + FROM ( + SELECT t.ticketFk, + cv.`level` shelve, + CAST(cv.lines AS SIGNED) - t.lines as linesDif, + CAST(cv.liters AS SIGNED) - t.liters as litersDif, + CAST(cv.height AS SIGNED) - t.height as heightDif + FROM vn.collectionVolumetry cv + JOIN tmp.ticket t + ORDER BY (t.ticketFk = vFirstTicketFk) DESC, linesDif + ) sub + WHERE linesDif >= 0 + AND litersDif >= 0 + AND heightDif >= 0 + ORDER BY linesDif; + + -- Asignamos la primera balda util al primer pedido + SELECT IFNULL(shelve,0) INTO vShelve + FROM tmp.ticketShelve + WHERE ticketFk = vFirstTicketFk + ORDER BY heightDif, litersDif, linesDif + LIMIT 1; + + IF vShelve THEN + + UPDATE tmp.ticket + SET shelve = vShelve + WHERE ticketFk = vFirstTicketFk; + + DELETE FROM tmp.ticketShelve + WHERE ticketFk = vFirstTicketFk + OR shelve = vShelve; + + WHILE (SELECT COUNT(*) FROM tmp.ticketShelve) DO + + SELECT ticketFk, shelve + INTO vTicket, vShelve + FROM tmp.ticketShelve + LIMIT 1; + + UPDATE tmp.ticket + SET shelve = vShelve + WHERE ticketFk = vTicket; + + DELETE FROM tmp.ticketShelve + WHERE ticketFk = vTicket + OR shelve = vShelve; + + END WHILE; + + ELSE + + UPDATE tmp.ticket + SET shelve = 1 + WHERE ticketFk = vFirstTicketFk; + + END IF; + + END IF; + + -- Eliminamos los que se han quedado sin balda + DELETE FROM tmp.ticket WHERE shelve = 0 ; + + -- Elimina los tickets bloqueados que no se van a preparar + DELETE tc.* + FROM vn.ticketCollection tc + LEFT JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk + WHERE tc.collectionFk = vCollectionFk + AND t.ticketFk IS NULL; + + -- Actualiza el estado de la colección + UPDATE vn.collection c + JOIN vn.state st ON st.code = 'ON_PREPARATION' + SET c.stateFk = st.id + WHERE c.id = vCollectionFk; + + -- Asigna las bandejas + UPDATE vn.ticketCollection tc + JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk + SET tc.level = t.shelve; + + -- Actualiza el estado de los tickets + INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) + SELECT vStateFk, ticketFk, vWorkerFk + FROM vn.ticketCollection tc + WHERE tc.collectionFk = vCollectionFk; + + -- Avisa los preparados previos que hay que bajar del altillo imprimiendo etiqueta + INSERT IGNORE INTO vn.ticketDown(ticketFk) + SELECT DISTINCT tc.ticketFk + FROM vn.ticketCollection tc + JOIN vncontrol.inter vi ON vi.Id_Ticket = tc.ticketFk + JOIN vn.state st ON st.id = vi.state_id + JOIN vn.ticket t ON t.id = tc.ticketFk + JOIN vn.warehouse w ON w.id = t.warehouseFk + WHERE tc.collectionFk = vCollectionFk + AND w.name = 'Silla FV' + AND st.code = 'PREVIOUS_PREPARATION'; + + SELECT vCollectionFk; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `collection_new_test` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `collection_new_test`(vSectorFk INT) +proc:BEGIN + + DECLARE vIsPreviousPrepared BOOLEAN; + DECLARE vCollectionFk INT; + DECLARE vWarehouseFk INT; + DECLARE vMaxTickets INT DEFAULT 4; + DECLARE vStateFk INT; + DECLARE vFirstTicketFk INT; + DECLARE vWorkerCode VARCHAR(3); + DECLARE vShelve INT; + DECLARE vTicket INT; + DECLARE myUserIsSalesPersonRole BOOLEAN; + DECLARE vPrintedTickets INT; + DECLARE vMaxTicketPrinted INT DEFAULT 10; + + DROP TEMPORARY TABLE IF EXISTS tmp.log; + CREATE TEMPORARY TABLE tmp.log + SELECT CURTIME() as hora, + 'Comienza el proc ' as accion, + ' -- ' as valor; + + -- Establecemos el almacén y si es un sector de preparación previa, así como el estado para los tickets que se vayan preparando + SELECT isPreviousPrepared, warehouseFk + INTO vIsPreviousPrepared, vWarehouseFk + FROM vn.sector + WHERE id = vSectorFk; + + IF vIsPreviousPrepared THEN + + SELECT id INTO vStateFk + FROM vn.state + WHERE `code` = 'PREVIOUS_PREPARATION'; + ELSE + + SELECT id INTO vStateFk + FROM vn.state + WHERE `code` = 'ON_PREPARATION'; + + END IF; + + -- Averiguamos si es comercial el usuario + SELECT (r.name = 'salesPerson') + INTO myUserIsSalesPersonRole + FROM account.user u + JOIN account.role r ON r.id = u.role + WHERE u.id = vn.getUser(); + + INSERT INTO tmp.log(hora, + accion, + valor) + VALUES( CURTIME(), + 'Determina si es comercial el usuario', + myUserIsSalesPersonRole); + + -- Obtenemos el código del usuario + SELECT w.code + INTO vWorkerCode + FROM vn.worker w + WHERE w.id = account.myUserGetId(); + + -- Se obtiene nº de colección y el buffer con los pedidos preparables + INSERT INTO vn.collection + SET workerFk = account.myUserGetId(); + + SELECT LAST_INSERT_ID() INTO vCollectionFk; + + INSERT INTO tmp.log(hora, + accion, + valor) + VALUES( CURTIME(), + 'Obtiene numero de coleccion', + vCollectionFk); + + + + CALL vn2008.production_control_source(vWarehouseFk, 0); + + SELECT COUNT(*) INTO vPrintedTickets + FROM tmp.production_buffer pb + JOIN vn.state s ON s.id = pb.state + WHERE pb.Fecha = CURDATE() + AND s.isPreparable; + + + INSERT INTO tmp.log(hora, + accion, + valor) + VALUES( CURTIME(), + 'Calcula tickets impresos', + vPrintedTickets); + + + + SET vMaxTicketPrinted = vMaxTicketPrinted - vPrintedTickets; + + -- AutoPRINT + + IF vMaxTicketPrinted > 0 THEN + + + INSERT INTO tmp.log(hora, + accion, + valor) + SELECT CURTIME(), + CONCAT('T', pb.Id_Ticket), +'PRINTED' + FROM tmp.production_buffer pb + JOIN vn.agency a ON a.id = pb.agency_id + JOIN vn.state s ON s.id = pb.state + JOIN vn.state s2 ON s2.code = 'PRINTED' + LEFT JOIN vn.route r ON r.id = pb.Id_Ruta + WHERE pb.Fecha = CURDATE() + AND NOT pb.problems + AND a.name != 'REC_SILLA' + AND (pb.ubicacion IS NOT NULL OR a.isOwn = FALSE) + AND s.isPrintable + AND (pb.m3 > 0.05 OR s.isOK) + ORDER BY (Hora - 1) * 60 + minuto > hour(now()) * 60 + minute(now()) , + s.order DESC, + Hora, + minuto, + IFNULL(r.priority,99999), + pb.m3 DESC + LIMIT vMaxTicketPrinted; + + INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) + SELECT s2.id, pb.Id_Ticket, vn.getUser() + FROM tmp.production_buffer pb + JOIN vn.agency a ON a.id = pb.agency_id + JOIN vn.state s ON s.id = pb.state + JOIN vn.state s2 ON s2.code = 'PRINTED' + LEFT JOIN vn.route r ON r.id = pb.Id_Ruta + WHERE pb.Fecha = CURDATE() + AND NOT pb.problems + AND a.name != 'REC_SILLA' + AND (pb.ubicacion IS NOT NULL OR a.isOwn = FALSE) + AND s.isPrintable + AND (pb.m3 > 0.05 OR s.isOK) + ORDER BY (Hora - 1) * 60 + minuto > hour(now()) * 60 + minute(now()) , + s.order DESC, + Hora, + minuto, + IFNULL(r.priority,99999), + pb.m3 DESC + LIMIT vMaxTicketPrinted; + + END IF; + + -- SELECT vMaxTicketPrinted; + -- Se seleccionan los primeros tickets, asignando colección para dejarlos bloqueados a otros sacadores. + + INSERT IGNORE INTO vn.ticketCollection(ticketFk, collectionFk) + SELECT pb.Id_Ticket, + vCollectionFk + FROM tmp.production_buffer pb + JOIN vn.state s ON s.id = pb.state + WHERE pb.collectionFk IS NULL + AND ( + (s.isPreparable AND NOT myUserIsSalesPersonRole AND pb.Agencia != 'REC_SILLA') + OR + (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) + ) + ORDER BY (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) DESC, pb.Hora, pb.Minuto + LIMIT vMaxTickets; + + + INSERT INTO tmp.log(hora, accion, valor) + SELECT CURTIME(),ticketFk,vCollectionFk + FROM vn.ticketCollection + WHERE collectionFk = vCollectionFk; + + + -- Creamos una tabla temporal con los datos que necesitamos para depurar la colección + DROP TEMPORARY TABLE IF EXISTS tmp.ticket; + CREATE TEMPORARY TABLE tmp.ticket + SELECT pb.Id_Ticket ticketFk, + pb.lines, + pb.m3 * 1000 liters, + 0 as height, + 0 as shelve + FROM tmp.production_buffer pb + JOIN vn.ticketCollection tc ON tc.ticketFk = pb.Id_Ticket + WHERE tc.collectionFk = vCollectionFk; + + + INSERT INTO tmp.log(hora, accion, valor) + SELECT CURTIME(),ticketFk,CONCAT('Ln:',`lines`,' Lt:',liters,' h:',height,' sh:',shelve) + FROM tmp.ticket; + + /* El criterio para formar la colección es el siguiente: + * + * 1º.- Los tickets asignados son prioritarios, y por ello ya vienen ordenados en las primeras posiciones. + * 2º.- Las recogidas en Silla tienen que ir en carros independientes. + * + * Por tanto, si el primer pedido es recogida, nos olvidamos del resto. + * Si el primer pedido no es recogida, eliminamos las recogidas posteriores. + */ + + SELECT ticketFk + INTO vFirstTicketFk + FROM tmp.ticket + LIMIT 1; + + + INSERT INTO tmp.log(hora, accion, valor) + VALUES( CURTIME(),'Primer ticket',vFirstTicketFk) + ; + + IF (SELECT pb.Agencia FROM tmp.production_buffer pb WHERE Id_Ticket = vFirstTicketFk) = 'REC_SILLA' THEN + + DELETE FROM tmp.ticket WHERE ticketFk != vFirstTicketFk; + + UPDATE tmp.ticket SET shelve = 1; + -- Como sólo hay un ticket, se le asigna el nivel 1 y acabamos + + ELSE + + -- Eliminamos los de recogida, puesto que el primero sabemos que no es de rec_silla + DELETE t.* + FROM tmp.ticket t + JOIN tmp.production_buffer pb ON pb.Id_Ticket = t.ticketFk + WHERE pb.Agencia = 'REC_SILLA'; + + -- Establece altura máxima por pedido, porque las plantas no se pueden recostar. + UPDATE tmp.ticket t + JOIN + ( SELECT MAX(i.size) maxHeigth, + tc.ticketFk + FROM vn.ticketCollection tc + JOIN vn.sale s ON s.ticketFk = tc.ticketFk + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk + WHERE ic.isReclining = FALSE + AND tc.collectionFk = vCollectionFk + GROUP BY tc.ticketFk) sub ON sub.ticketFk = t.ticketFk + SET t.height = sub.maxHeigth; + + INSERT INTO tmp.log(hora, accion, valor) + SELECT CURTIME(),ticketFk,CONCAT('Ln:',`lines`,' Lt:',liters,' h:',height,' sh:',shelve) + FROM tmp.ticket; + + + -- Vamos a generar una tabla con todas las posibilidades de asignacion de pedido + DROP TEMPORARY TABLE IF EXISTS tmp.ticketShelve; + CREATE TEMPORARY TABLE tmp.ticketShelve + SELECT ticketFk, shelve, linesDif, litersDif, heightDif + FROM ( + SELECT t.ticketFk, + cv.`level` shelve, + CAST(cv.lines AS SIGNED) - t.lines as linesDif, + CAST(cv.liters AS SIGNED) - t.liters as litersDif, + CAST(cv.height AS SIGNED) - t.height as heightDif + FROM vn.collectionVolumetry cv + JOIN tmp.ticket t + ORDER BY (t.ticketFk = vFirstTicketFk) DESC, linesDif + ) sub + WHERE linesDif >= 0 + AND litersDif >= 0 + AND heightDif >= 0 + ORDER BY linesDif; + INSERT INTO tmp.log(hora, accion, valor) + SELECT CURTIME(),'Todas las posibilidades',COUNT(*) + FROM tmp.ticketShelve; + + INSERT INTO tmp.log(hora, accion, valor) + SELECT CURTIME(),ticketFk,CONCAT('Lnd:',`linesDif`,' Ltd',litersDif,' hd:',heightDif,' sh:',shelve) + FROM tmp.ticketShelve; + + -- Asignamos la primera balda util al primer pedido + SELECT IFNULL(shelve,0) INTO vShelve + FROM tmp.ticketShelve + WHERE ticketFk = vFirstTicketFk + ORDER BY heightDif, litersDif, linesDif + LIMIT 1; + INSERT INTO tmp.log(hora, accion, valor) + SELECT CURTIME(),'vShelve',vShelve; + IF vShelve THEN + + UPDATE tmp.ticket + SET shelve = vShelve + WHERE ticketFk = vFirstTicketFk; + + DELETE FROM tmp.ticketShelve + WHERE ticketFk = vFirstTicketFk + OR shelve = vShelve; + + WHILE (SELECT COUNT(*) FROM tmp.ticketShelve) DO + + SELECT ticketFk, shelve + INTO vTicket, vShelve + FROM tmp.ticketShelve + LIMIT 1; + + UPDATE tmp.ticket + SET shelve = vShelve + WHERE ticketFk = vTicket; + + INSERT INTO tmp.log(hora, accion, valor) + SELECT CURTIME(),'Quedan', COUNT(*) + FROM tmp.ticketShelve; + INSERT INTO tmp.log(hora, accion, valor) + SELECT CURTIME(),ticketFk,CONCAT(' sh:',shelve) + FROM tmp.ticket; + + DELETE FROM tmp.ticketShelve + WHERE ticketFk = vTicket + OR shelve = vShelve; + INSERT INTO tmp.log(hora, accion, valor) + SELECT CURTIME(),'Borrar los asignados', COUNT(*) + FROM tmp.ticketShelve + WHERE ticketFk = vTicket + OR shelve = vShelve; + + INSERT INTO tmp.log(hora, accion, valor) + SELECT CURTIME(),ticketFk,CONCAT(' sh:',shelve) + FROM tmp.ticket; + + END WHILE; + + + ELSE + + UPDATE tmp.ticket + SET shelve = 1 + WHERE ticketFk = vFirstTicketFk; + + END IF; + + END IF; + + -- Eliminamos los que se han quedado sin balda + DELETE FROM tmp.ticket WHERE shelve = 0 ; + + INSERT INTO tmp.log(hora, accion, valor) + SELECT CURTIME(),ticketFk,CONCAT('Borrar sh:',shelve) + FROM tmp.ticket + WHERE shelve = 0; + + -- Elimina los tickets bloqueados que no se van a preparar + DELETE tc.* + FROM vn.ticketCollection tc + LEFT JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk + WHERE tc.collectionFk = vCollectionFk + AND t.ticketFk IS NULL; + + INSERT INTO tmp.log(hora, accion, valor) + SELECT CURTIME(),'Elimina tickets bloqueados', tc.ticketFk + FROM vn.ticketCollection tc + LEFT JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk + WHERE tc.collectionFk = vCollectionFk + AND t.ticketFk IS NULL; + + + -- Actualiza el estado de la colección + UPDATE vn.collection c + JOIN vn.state st ON st.code = 'ON_PREPARATION' + SET c.stateFk = st.id + WHERE c.id = vCollectionFk; + + -- Asigna las bandejas + UPDATE vn.ticketCollection tc + JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk + SET tc.level = t.shelve; + + -- Actualiza el estado de los tickets + INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) + SELECT vStateFk, ticketFk, account.myUserGetId() + FROM vn.ticketCollection tc + WHERE tc.collectionFk = vCollectionFk; + + -- Avisa los preparados previos que hay que bajar del altillo imprimiendo etiqueta + INSERT IGNORE INTO vn.ticketDown(ticketFk) + SELECT DISTINCT tc.ticketFk + FROM vn.ticketCollection tc + JOIN vncontrol.inter vi ON vi.Id_Ticket = tc.ticketFk + JOIN vn.state st ON st.id = vi.state_id + JOIN vn.ticket t ON t.id = tc.ticketFk + JOIN vn.warehouse w ON w.id = t.warehouseFk + WHERE tc.collectionFk = vCollectionFk + AND w.name = 'Silla FV' + AND st.code = 'PREVIOUS_PREPARATION'; + + SELECT * FROM tmp.log; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -36038,8 +37546,7 @@ DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `conveyorExpedition_Add`(vDate DATE) BEGIN - DELETE FROM vn.conveyorExpedition - WHERE date(created) = vDate; + TRUNCATE vn.conveyorExpedition; INSERT INTO vn.conveyorExpedition( expeditionFk, created, @@ -36085,8 +37592,6 @@ BEGIN AND t.warehouseFk = 44 AND e.isBox = 71; - - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -37835,7 +39340,74 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `entryWithItem`(IN `vShipmentWarehouse` INT, IN `vLandingWarehouse` INT, IN `vSale` INT, IN `vVolume` INT, IN netCost DECIMAL(10,2), IN `vInOutDate` DATE) +CREATE DEFINER=`root`@`%` PROCEDURE `entryWithItem`(vShipmentWarehouse INT, vLandingWarehouse INT,vSale INT, vVolume INT, netCost DECIMAL(10,2), vInOutDate DATE) +BEGIN + + DECLARE vTravel INT; + DECLARE vEntry INT; + DECLARE vBucket VARCHAR(10); + DECLARE vSupplierFk INT; + + SET vSupplierFk = IF (vLandingWarehouse = 1, 850, 963); + -- seleccionamos travel + SELECT t.id, e.id INTO vTravel, vEntry + FROM travel t LEFT JOIN entry e ON t.id = e.travelFk + WHERE t.landed = vInOutDate AND t.shipped = vInOutDate AND t.warehouseOutFk = vShipmentWarehouse + AND t.warehouseInFk = vLandingWarehouse AND t.agencyFk IS NULL AND e.supplierFk = vSupplierFk + LIMIT 1; + + -- creamos el travel si es necesario + IF IFNULL(vTravel, FALSE) = FALSE THEN + INSERT INTO travel (shipped, landed, warehouseInFk, warehouseOutFk) + VALUES (vInOutDate, vInOutDate, vLandingWarehouse, vShipmentWarehouse); + SELECT LAST_INSERT_ID() INTO vTravel; + END IF; + + -- creamos la Entrada si es necesario + IF IFNULL(vEntry, FALSE) = FALSE THEN + INSERT INTO entry (supplierFk, travelFk) + VALUES (vSupplierFk, vTravel); -- proveedor 'CONFECCION ARTIFICIAL' + SELECT LAST_INSERT_ID() INTO vEntry; + END IF; + + -- creamos el cubo si es necesario + SELECT id INTO vBucket FROM packaging WHERE volume = vVolume LIMIT 1; + IF vBucket IS NULL THEN + INSERT INTO packaging (id, volume) + VALUES (CONCAT('dm',vVolume/1000), vVolume); + -- SELECT LAST_INSERT_ID() INTO vBucket; + SELECT id INTO vBucket FROM packaging WHERE volume = vVolume LIMIT 1; + END IF; + + INSERT INTO buy(itemFk,quantity, entryFk, packageFk, packing, stickers, buyingValue, price2, price3) + SELECT itemFk, + quantity, + vEntry, + vBucket, + 1 packing, + quantity, + netCost, + s.price, + s.price + FROM sale s + WHERE s.id = vSale; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `entryWithItem__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `entryWithItem__`(IN `vShipmentWarehouse` INT, IN `vLandingWarehouse` INT, IN `vSale` INT, IN `vVolume` INT, IN netCost DECIMAL(10,2), IN `vInOutDate` DATE) BEGIN DECLARE vTravel INT; @@ -37871,7 +39443,8 @@ BEGIN IF vBucket IS NULL THEN INSERT INTO packaging (id, volume) VALUES (CONCAT('dm',vVolume/1000), vVolume); - SELECT LAST_INSERT_ID() INTO vBucket; + -- SELECT LAST_INSERT_ID() INTO vBucket; + SELECT id INTO vBucket FROM packaging WHERE volume = vVolume LIMIT 1; END IF; INSERT INTO buy(itemFk,quantity, entryFk, packageFk, packing, `grouping`, stickers, buyingValue, price2, price3) @@ -40640,9 +42213,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -40664,7 +42237,7 @@ BEGIN DECLARE vSpainCountryCode INT DEFAULT 1; DECLARE vIsAnySaleToInvoice BOOL; DECLARE vNewRef VARCHAR(255); - DECLARE vWorker INT DEFAULT vn.getWorker(); + DECLARE vWorker INT DEFAULT vn.myWorker_getId(); DECLARE vCompany INT; DECLARE vClient INT; DECLARE vCplusStandardInvoiceTypeFk INT DEFAULT 1; @@ -40696,7 +42269,9 @@ BEGIN JOIN ticket t ON t.id = ti.id JOIN client c ON c.id = t.clientFk WHERE YEAR(t.shipped) < 2001 - OR c.isTaxDataChecked = FALSE; + OR c.isTaxDataChecked = FALSE + OR t.isDeleted + OR c.hasToInvoice = FALSE; SELECT SUM(quantity * price * (100 - discount)/100) INTO vIsAnySaleToInvoice @@ -41769,16 +43344,24 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `itemPlacementSupplyStockGetTargetList`(vItemFk INT,vSectorFk INT) BEGIN - SELECT shelving, parking, sum(stock) as stockTotal,created + DECLARE vWarehouseFk INT; + DECLARE vWarehouseAliasFk INT; + + SELECT s.warehouseFk , w.aliasFk INTO vWarehouseFk, vWarehouseAliasFk + FROM vn.sector s + JOIN vn.warehouse w ON w.id = s.warehouseFk + WHERE s.id = vSectorFk; + + SELECT shelving, parking, sum(stock) as stockTotal,created,`order` FROM ( SELECT `ispss`.`itemShelvingFk` AS `itemShelvingFk`, @@ -41794,12 +43377,20 @@ BEGIN `ispss`.`created` AS `created`, `ispss`.`priority` AS `priority`, `ispss`.`parkingFk` AS `parkingFk`, - `ispss`.`sectorFk` AS `sectorFk` + `ispss`.`sectorFk` AS `sectorFk`, + IFNULL(cpd.id,0) as `order` FROM vn.itemShelvingPlacementSupplyStock ispss - LEFT JOIN vn.parking p ON p.code = parking - WHERE itemFk = vItemFk - -- AND p.sectorFk = vSectorFk + JOIN vn.itemShelving ish ON ish.itemFk = vItemFk + JOIN vn.shelving sh ON sh.code = ish.shelvingFk + JOIN vn.parking p ON p.id = sh.parkingFk + LEFT JOIN vn.coolerPathDetail cpd ON CAST(cpd.hallway AS DECIMAL(3,0)) = p.column + JOIN vn.sector sc ON sc.id = p.sectorFk + JOIN vn.warehouse w ON w.id = sc.warehouseFk + WHERE ispss.itemFk = vItemFk + AND w.aliasFk = vWarehouseAliasFk + -- AND p.sectorFk = vSectorFk AND stock > 0 + AND ispss.sectorFk IN (SELECT id FROM vn.sector WHERE warehouseFk = vWarehouseFk) ORDER BY priority DESC ) sub GROUP BY shelving @@ -43353,7 +44944,7 @@ BEGIN CALL cache.available_refresh(vAvailableCalc, FALSE /*vRefresh*/ , vWarehouse, vDate); CALL cache.visible_refresh(vVisibleCalc, FALSE,vWarehouse); - SELECT visible INTO vVisibleAltillo + SELECT SUM(visible) INTO vVisibleAltillo FROM vn.itemShelvingStock WHERE itemFk = vItem AND warehouseFk = vWarehouse; @@ -44897,7 +46488,7 @@ BEGIN SET valueFk = (IFNULL(valueFk,0) + 1) MOD 3; REPLACE vn2008.Movimientos_mark(Id_Movimiento, valor, Id_Trabajador, stateFk) - VALUES(saleFk,valueFk,getWorker(),encajando); + VALUES(saleFk,valueFk,myWorker_getId(),encajando); END ;; @@ -45039,9 +46630,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -45060,7 +46651,7 @@ BEGIN DECLARE vShipmentHour VARCHAR(10); SELECT getTicketTrolleyLabelCount(vTicket) INTO vLabelCount; - SELECT getWorker() INTO vWorker; + SELECT myWorker_getId() INTO vWorker; SELECT CONCAT(getShipmentHour(vTicket),':00') INTO vShipmentHour; INSERT INTO printingQueue(printer @@ -45728,9 +47319,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -45749,7 +47340,7 @@ BEGIN WHERE s.ticketFk = vTicketFk; REPLACE vn2008.Movimientos_mark(Id_Movimiento, Valor, original_quantity, Id_Trabajador, stateFk) - SELECT s.id, s.isPicked, s.quantity, getWorker(), vStateFk + SELECT s.id, s.isPicked, s.quantity, myWorker_getId(), vStateFk FROM sale s JOIN vn.saleItemShelving sis ON sis.saleFk = s.id WHERE s.ticketFk = vTicketFk; @@ -45852,9 +47443,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -45903,7 +47494,7 @@ BEGIN END IF; INSERT INTO ticketTracking(ticketFk, workerFk, stateFk) - SELECT vNewTicket, getWorker(), s.id + SELECT vNewTicket, myWorker_getId(), s.id FROM state s WHERE s.code = 'FIXING'; @@ -46367,6 +47958,28 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `sector_get` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `sector_get`() +BEGIN + + SELECT s.id,s.description,s.warehouseFk + FROM vn.sector s; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `setPlacementReserve` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -47050,24 +48663,24 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `stowawayBoarding` */; +/*!50003 DROP PROCEDURE IF EXISTS `stowawayBoarding__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `stowawayBoarding`(IN vShipFk INT, IN vStowawayFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `stowawayBoarding__`(IN vShipFk INT, IN vStowawayFk INT) BEGIN REPLACE stowaway(shipFk, id) VALUES (vShipFk, vStowawayFk); INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) - SELECT id, vShipFk, getWorker() + SELECT id, vShipFk, myWorker_getId() FROM state WHERE code = 'BOARDING'; @@ -48096,18 +49709,18 @@ BEGIN CALL ticketClosure(); - INSERT INTO mail (sender, replyTo, subject, body) - SELECT 'jgallego@verdnatura.es', 'jgallego@verdnatura.es', 'Tickets enrutados y NO preparados', - GROUP_CONCAT(ticketFk) tickets - FROM ticket t + -- cau 15033 + UPDATE ticket t JOIN ticketState ts ON t.id = ts.ticketFk JOIN alertLevel al ON al.alertLevel = ts.alertLevel JOIN agencyMode am ON am.id = t.agencyModeFk JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk + JOIN zone z ON z.id = t.zoneFk + SET t.routeFk = NULL WHERE shipped BETWEEN vDateTo AND vDateToEndDay AND al.code NOT IN('DELIVERED','PACKED') AND t.routeFk - HAVING tickets IS NOT NULL; + AND z.`name` LIKE '%MADRID%'; DROP TEMPORARY TABLE tmp.ticketClosure; END ;; @@ -48134,7 +49747,8 @@ BEGIN * * @param vDate Fecha del cierre */ - + DECLARE vDateToEndDay DATETIME DEFAULT util.dayEnd(vDateTo); + DROP TEMPORARY TABLE IF EXISTS tmp.ticketClosure; CREATE TEMPORARY TABLE tmp.ticketClosure ENGINE = MEMORY ( @@ -48160,7 +49774,7 @@ BEGIN JOIN alertLevel al ON al.alertLevel = ts.alertLevel JOIN agencyMode am ON am.id = t.agencyModeFk JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk - WHERE shipped = TIMESTAMPADD(DAY, -1, CURDATE()) + WHERE shipped BETWEEN vDateTo AND vDateToEndDay AND al.code NOT IN('DELIVERED','PACKED') AND t.routeFk HAVING tickets IS NOT NULL; @@ -48598,13 +50212,110 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `ticketCreateWithoutZone`( + vClientId INT + ,vShipped DATE + ,vWarehouseFk INT + ,vCompanyFk INT + ,vAddressFk INT + ,vAgencyModeFk INT + ,vRouteFk INT + ,vlanded DATE + ,vUserId INT + ,OUT vNewTicket INT) +BEGIN + + DECLARE vZoneFk INT; + + IF vClientId IS NULL THEN + CALL util.throw ('CLIENT_NOT_ESPECIFIED'); + END IF; + + IF NOT vAddressFk OR vAddressFk IS NULL THEN + SELECT id INTO vAddressFk + FROM address + WHERE clientFk = vClientId AND isDefaultAddress; + END IF; + + IF NOT vAgencyModeFk OR vAgencyModeFk IS NULL THEN + SELECT agencyModeFk INTO vAgencyModeFk + FROM address + WHERE clientFk = vClientId AND isDefaultAddress; + END IF; + + CALL vn.zone_getShippedWarehouse(vlanded, vAddressFk, vAgencyModeFk); + + SELECT zoneFk INTO vZoneFk FROM tmp.zoneGetShipped + WHERE shipped = vShipped AND warehouseFk = vWarehouseFk LIMIT 1; + + INSERT INTO vn2008.Tickets ( + Id_Cliente, + Fecha, + Id_Consigna, + Id_Agencia, + Alias, + warehouse_id, + Id_Ruta, + empresa_id, + landing, + zoneFk + ) + SELECT + vClientId, + vShipped, + a.id, + IF(vAgencyModeFk, vAgencyModeFk, a.agencyModeFk), + a.nickname, + vWarehouseFk, + IF(vRouteFk,vRouteFk,NULL), + vCompanyFk, + vlanded, + vZoneFk + FROM address a + JOIN agencyMode am ON am.id = a.agencyModeFk + WHERE a.id = vAddressFk; + + SET vNewTicket = LAST_INSERT_ID(); + + INSERT INTO ticketObservation(ticketFk, observationTypeFk, description) + SELECT vNewTicket, ao.observationTypeFk, ao.description + FROM addressObservation ao + JOIN address a ON a.id = ao.addressFk + WHERE a.id = vAddressFk; + + -- CALL logAddWithUser(vNewTicket, vUserId, 'insert', 'ticket', CONCAT('Ha creado el ticket', ' ', vNewTicket)); + INSERT INTO vn.ticketLog + SET originFk = vNewTicket, userFk = vUserId, `action` = 'insert', description = CONCAT('Ha creado el ticket:', ' ', vNewTicket); + + IF (SELECT ct.isCreatedAsServed FROM vn.clientType ct JOIN vn.client c ON c.typeFk = ct.code WHERE c.id = vClientId ) <> FALSE THEN + INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) + SELECT id, vNewTicket, vUserId + FROM state + WHERE `code` = 'DELIVERED'; + END IF; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticketCreateWithoutZone__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8 */ ; /*!50003 SET character_set_results = utf8 */ ; /*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ticketCreateWithoutZone`( +CREATE DEFINER=`root`@`%` PROCEDURE `ticketCreateWithoutZone__`( vClientId INT ,vShipped DATE ,vWarehouseFk INT @@ -48695,13 +50406,116 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `ticketCreateWithUser`( + vClientId INT + ,vShipped DATE + ,vWarehouseFk INT + ,vCompanyFk INT + ,vAddressFk INT + ,vAgencyModeFk INT + ,vRouteFk INT + ,vlanded DATE + ,vUserId INT + ,OUT vNewTicket INT) +BEGIN + + DECLARE vZoneFk INT; + DECLARE vPrice DECIMAL(10,2); + DECLARE vBonus DECIMAL(10,2); + + IF vClientId IS NULL THEN + CALL util.throw ('CLIENT_NOT_ESPECIFIED'); + END IF; + + IF NOT vAddressFk OR vAddressFk IS NULL THEN + SELECT id INTO vAddressFk + FROM address + WHERE clientFk = vClientId AND isDefaultAddress; + END IF; + + IF vAgencyModeFk IS NOT NULL THEN + + CALL vn.zone_getShipped (vlanded, vAddressFk, vAgencyModeFk, TRUE); + + SELECT zoneFk, price, bonus INTO vZoneFk, vPrice, vBonus + FROM tmp.zoneGetShipped + WHERE shipped = vShipped AND warehouseFk = vWarehouseFk LIMIT 1; + + IF vZoneFk IS NULL OR vZoneFk = 0 THEN + CALL util.throw ('NOT_ZONE_WITH_THIS_PARAMETERS'); + END IF; + END IF; + INSERT INTO ticket ( + clientFk, + shipped, + addressFk, + agencyModeFk, + nickname, + warehouseFk, + routeFk, + companyFk, + landed, + zoneFk, + zonePrice, + zoneBonus + ) + SELECT + vClientId, + vShipped, + a.id, + vAgencyModeFk, + a.nickname, + vWarehouseFk, + IF(vRouteFk,vRouteFk,NULL), + vCompanyFk, + vlanded, + vZoneFk, + vPrice, + vBonus + FROM address a + JOIN agencyMode am ON am.id = a.agencyModeFk + WHERE a.id = vAddressFk; + + SET vNewTicket = LAST_INSERT_ID(); + + INSERT INTO ticketObservation(ticketFk, observationTypeFk, description) + SELECT vNewTicket, ao.observationTypeFk, ao.description + FROM addressObservation ao + JOIN address a ON a.id = ao.addressFk + WHERE a.id = vAddressFk; + + INSERT INTO vn.ticketLog + SET originFk = vNewTicket, userFk = vUserId, `action` = 'insert', description = CONCAT('Ha creado el ticket:', ' ', vNewTicket); + + IF (SELECT ct.isCreatedAsServed FROM vn.clientType ct JOIN vn.client c ON c.typeFk = ct.code WHERE c.id = vClientId ) <> FALSE THEN + INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) + SELECT id, vNewTicket, myWorker_getId() + FROM state + WHERE `code` = 'DELIVERED'; + END IF; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticketCreateWithUser__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8 */ ; /*!50003 SET character_set_results = utf8 */ ; /*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ticketCreateWithUser`( +CREATE DEFINER=`root`@`%` PROCEDURE `ticketCreateWithUser__`( vClientId INT ,vShipped DATE ,vWarehouseFk INT @@ -49424,7 +51238,7 @@ BEGIN FROM vn.ticketParking WHERE ticketFk = vTicketFk; - SELECT tp.ticketFk, CONCAT(vCollectionFk, ' - ', tc.level) coleccion, tp.created, p.code, am.name as Agencia + SELECT tp.ticketFk, CONCAT(tc.collectionFk, ' - ', tc.level) coleccion, tp.created, p.code, am.name as Agencia FROM vn.ticketParking tp JOIN vn.parking p ON p.id = tp.parkingFk JOIN vn.sector sc ON sc.id = p.sectorFk @@ -49590,9 +51404,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -49629,7 +51443,7 @@ BEGIN WHERE inter_id = vControlFk; */ INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador, Id_Supervisor) - SELECT s.nextStateFk, i.Id_Ticket, vLastWorkerFk, vn.getWorker() + SELECT s.nextStateFk, i.Id_Ticket, vLastWorkerFk, vn.myWorker_getId() FROM vncontrol.inter i JOIN vn.state s ON i.state_id = s.id WHERE inter_id = vControlFk; @@ -49657,9 +51471,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -49667,7 +51481,7 @@ CREATE DEFINER=`root`@`%` PROCEDURE `ticketStateUpdate`(vTicketFk INT, vStateCod BEGIN INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) - SELECT id, vTicketFk, getWorker() + SELECT id, vTicketFk, myWorker_getId() FROM vn.state WHERE `code` = vStateCode collate utf8_unicode_ci; @@ -50470,7 +52284,8 @@ BEGIN OPEN vCursor; REPEAT FETCH vCursor INTO vFechedTicket, vLanded, vAddressFk, vAgencyModeFk, vWarehouseFk; - CALL zone_getShippedWarehouse(vLanded, vAddressFk, vAgencyModeFk); + CALL vn.zone_getShipped (vlanded, vAddressFk, vAgencyModeFk, TRUE); + UPDATE vn.ticket t JOIN tmp.zoneGetShipped zgs ON zgs.warehouseFk = vWarehouseFk SET t.zoneFk = zgs.zoneFk @@ -50585,7 +52400,7 @@ proc: BEGIN FROM ticket WHERE id = vTicketFk; - CALL zone_getShippedWarehouse(vLanded, vAddressFk , vAgencyModeFk); + CALL vn.zone_getShipped (vlanded, vAddressFk, vAgencyModeFk, TRUE); CALL vn.buyUltimate (vWarehouseFk, vShipped); -- rellena la tabla buyUltimate con la ultima compra @@ -50668,6 +52483,174 @@ proc: BEGIN INTO vWarehouseFk, vShipped, vAddressFk, vAgencyModeFk, vLanded FROM ticket WHERE id = vTicketFk; + + CALL vn.zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, TRUE); + + CALL vn.buyUltimate (vWarehouseFk, vShipped); -- rellena la tabla buyUltimate con la ultima compra + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; + CREATE TEMPORARY TABLE tmp.ticketLot + SELECT vWarehouseFk warehouseFk, NULL available, + s.itemFk, bu.buyFk + FROM sale s + LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk + WHERE s.ticketFk = vTicketFk + GROUP BY s.itemFk; + + CALL vn.catalog_componentCalculate(vZoneFk, vAddressFk, vShipped); + + DROP TEMPORARY TABLE IF EXISTS tmp.sale; + CREATE TEMPORARY TABLE tmp.sale + (PRIMARY KEY (saleFk)) ENGINE = MEMORY + SELECT id saleFk, vWarehouseFk warehouseFk + FROM sale s + WHERE s.ticketFk = vTicketFk; + + CALL vn.ticketComponentUpdateSale(IF(vIsTicketEditable,1,6)); -- si el ticket esta facturado, respeta los precios + + IF vLanded IS NULL THEN + + CALL zone_getLanded(vShipped, vAddressFk, vAgencyModeFk, vWarehouseFk); + + UPDATE vn2008.Tickets t + SET t.landing = (SELECT landed FROM tmp.zoneGetLanded) + WHERE Id_Ticket = vTicketFk; + + DROP TEMPORARY TABLE tmp.zoneGetLanded; + + END IF; + + DROP TEMPORARY TABLE tmp.buyUltimate; + DROP TEMPORARY TABLE tmp.ticketComponentPrice; + DROP TEMPORARY TABLE tmp.ticketComponent; + DROP TEMPORARY TABLE tmp.sale; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_recalcComponentsForcePrice__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `ticket_recalcComponentsForcePrice__`(IN vTicketFk BIGINT, vIsTicketEditable BOOLEAN ) +proc: BEGIN + +/** + * Este procedimiento trata de "rebionizar" un ticket, + * eliminando los componentes existentes e insertandolos de nuevo + * + * @param vTicketFk Id del ticket + * @return tmp.buyUltimate + */ + DECLARE vShipped DATE; + DECLARE vWarehouseFk SMALLINT; + DECLARE vAgencyModeFk INT; + DECLARE vAddressFk INT; + DECLARE vLanded DATE; + DECLARE vZoneFk INTEGER; + + IF vIsTicketEditable IS NULL THEN + SELECT (IFNULL(ts.alertLevel,0) >0 or IFNULL(t.refFk,"") != "") = FALSE, t.zoneFk + INTO vIsTicketEditable, vZoneFk + FROM ticket t LEFT JOIN ticketState ts ON t.id = ts.ticket + WHERE id = vTicketFk; + END IF; + SELECT warehouseFk, date(shipped), addressFk, agencyModeFk, landed + INTO vWarehouseFk, vShipped, vAddressFk, vAgencyModeFk, vLanded + FROM ticket + WHERE id = vTicketFk; + + CALL zone_getShippedWarehouse(vLanded, vAddressFk , vAgencyModeFk); + + CALL vn.buyUltimate (vWarehouseFk, vShipped); -- rellena la tabla buyUltimate con la ultima compra + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; + CREATE TEMPORARY TABLE tmp.ticketLot + SELECT vWarehouseFk warehouseFk, NULL available, + s.itemFk, bu.buyFk + FROM sale s + LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk + WHERE s.ticketFk = vTicketFk + GROUP BY s.itemFk; + + CALL vn.catalog_componentCalculate(vZoneFk, vAddressFk, vShipped); + + DROP TEMPORARY TABLE IF EXISTS tmp.sale; + CREATE TEMPORARY TABLE tmp.sale + (PRIMARY KEY (saleFk)) ENGINE = MEMORY + SELECT id saleFk, vWarehouseFk warehouseFk + FROM sale s + WHERE s.ticketFk = vTicketFk; + + CALL vn.ticketComponentUpdateSale(IF(vIsTicketEditable,1,6)); -- si el ticket esta facturado, respeta los precios + + IF vLanded IS NULL THEN + + CALL zone_getLanded(vShipped, vAddressFk, vAgencyModeFk, vWarehouseFk); + + UPDATE vn2008.Tickets t + SET t.landing = (SELECT landed FROM tmp.zoneGetLanded) + WHERE Id_Ticket = vTicketFk; + + DROP TEMPORARY TABLE tmp.zoneGetLanded; + + END IF; + + DROP TEMPORARY TABLE tmp.buyUltimate; + DROP TEMPORARY TABLE tmp.ticketComponentPrice; + DROP TEMPORARY TABLE tmp.ticketComponent; + DROP TEMPORARY TABLE tmp.sale; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_recalcComponents__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `ticket_recalcComponents__`(IN vTicketFk BIGINT ) +proc: BEGIN + +/** + * Este procedimiento trata de "rebionizar" un ticket, + * eliminando los componentes existentes e insertandolos de nuevo + * + * @param vTicketFk Id del ticket + * @return tmp.buyUltimate + */ + DECLARE vShipped DATE; + DECLARE vWarehouseFk SMALLINT; + DECLARE vAgencyModeFk INT; + DECLARE vAddressFk INT; + DECLARE vLanded DATE; + DECLARE vIsTicketEditable BOOLEAN; + DECLARE vZoneFk INTEGER; + + SELECT (IFNULL(ts.alertLevel,0) >0 or IFNULL(t.refFk,"") != "") = FALSE, t.zoneFk + INTO vIsTicketEditable, vZoneFk + FROM ticket t LEFT JOIN ticketState ts ON t.id = ts.ticket + WHERE id = vTicketFk; + + SELECT warehouseFk, date(shipped), addressFk, agencyModeFk, landed + INTO vWarehouseFk, vShipped, vAddressFk, vAgencyModeFk, vLanded + FROM ticket + WHERE id = vTicketFk; CALL zone_getShippedWarehouse(vLanded, vAddressFk , vAgencyModeFk); @@ -50874,13 +52857,13 @@ BEGIN t.timeWorkDecimal = t.timeWorkDecimal - (t.timeWorkDecimal * permissionRate) WHERE permissionRate <> 0; - UPDATE tmp.timeBusinessCalculate t - JOIN postgresql.calendar_labour cl ON cl.day = t.dated - JOIN postgresql.business_labour bl ON bl.business_id = t.businessFk AND bl.workcenter_id = cl.workcenter_id +UPDATE tmp.timeBusinessCalculate t + JOIN vn.calendarHolidays ch ON ch.dated = t.dated + JOIN postgresql.business_labour bl ON bl.business_id = t.businessFk AND bl.workcenter_id = ch.workcenterFk SET t.timeWorkSeconds = 0, t.timeWorkSexagesimal = 0, t.timeWorkDecimal = 0, - t.permissionRate = 1, + t.permissionrate = 1, t.type = 'Festivo' WHERE t.type IS NULL; @@ -50895,9 +52878,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -50915,7 +52898,7 @@ BEGIN SELECT userFk FROM vn.worker w JOIN vn.`user` u ON u.id = w.userFk - WHERE userFk IS NOT NULL AND u.active = TRUE; + WHERE userFk IS NOT NULL; CALL vn.timeBusiness_calculate(vDatedFrom, vDatedTo); @@ -51787,9 +53770,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -51804,9 +53787,9 @@ BEGIN p.name, p.firstname, d.name AS department, - d.department_id as departmentFk, + d.id as departmentFk, b.date_start, - d.production, + d.isProduction, CAST(12 * blp.importepactado / clt.hours_week / 52 AS DECIMAL(10,2)) as costeHora FROM postgresql.person p @@ -51815,7 +53798,7 @@ BEGIN JOIN postgresql.business_labour bl ON bl.business_id = b.business_id JOIN postgresql.calendar_labour_type clt ON clt.calendar_labour_type_id = bl.calendar_labour_type_id JOIN postgresql.business_labour_payroll blp ON blp.business_id = b.business_id - JOIN vn2008.department d ON d.department_id = bl.department_id + JOIN vn.department d ON d.id = bl.department_id JOIN vn.worker w ON w.id = p.id_trabajador WHERE b.date_start <= vDate AND IFNULL(b.date_end,'3000-01-01') > vDate ; @@ -51832,16 +53815,16 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerDisable`(vUserId int) mainLabel:BEGIN - IF vUserId = 14255 THEN + IF (SELECT COUNT(*) FROM workerDisableExcluded WHERE workerFk = vUserId AND (dated > CURDATE() OR dated IS NULL)) > 0 THEN LEAVE mainLabel; END IF; DELETE FROM account.account @@ -51915,6 +53898,42 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `workerDisable__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `workerDisable__`(vUserId int) +mainLabel:BEGIN + + IF vUserId = 14255 THEN + LEAVE mainLabel; + END IF; + DELETE FROM account.account + WHERE id = vUserId; + + UPDATE account.user + SET role = 2 + WHERE id = vUserId; + + DELETE FROM pbx.sip + WHERE user_id = vUserId; + + UPDATE `client` c + JOIN payMethod p ON p.name = 'CONTADO' + SET c.credit = 0, c.payMethodFk = p.id, hasCoreVnl = FALSE + WHERE c.id = vUserId; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerForAllCalculateBoss` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -51965,9 +53984,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -52169,9 +54188,9 @@ BEGIN -- Festivos por centro de trabajo - UPDATE vn.workerJourney wj - JOIN postgresql.calendar_labour pcl ON pcl.day = wj.dated - JOIN postgresql.business_labour pbl ON wj.businessFk = pbl.business_id AND pbl.workcenter_id = pcl.workcenter_id +UPDATE vn.workerJourney wj + JOIN vn.calendarHolidays ch ON ch.dated = wj.dated + JOIN postgresql.business_labour pbl ON wj.businessFk = pbl.business_id AND pbl.workcenter_id = ch.workcenterFk SET wj.hollyday = wj.total, wj.permission = wj.contractJourney, wj.contractJourney = 0 @@ -52697,190 +54716,6 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControl_check`(vUserFk INT, vDated DATE,vTabletFk VARCHAR(100)) proc: BEGIN -/** - * Verifica si el empleado puede fichar en el momento actual, si puede fichar llama a vn.workerTimeControlAdd - * - * @param vUserFk Identificador del trabajador - * @return Retorna si encuentra un problema 'odd','maxTimeWork','breakDay','breakWeek' ; - * En caso de tener algun problema retorna el primero que encuentra - */ - DECLARE vLastIn DATETIME ; - DECLARE vLastOut DATETIME ; - DECLARE vDayWorkMax INT; - DECLARE vDayBreak INT; - DECLARE vWeekBreak INT ; - DECLARE vWeekScope INT; - DECLARE vDayStayMax INT; - DECLARE vProblem VARCHAR(20) DEFAULT NULL; - DECLARE vTimedWorked INT; - DECLARE vCalendarStateType VARCHAR(20) DEFAULT NULL; - DECLARE vTo VARCHAR(50) DEFAULT NULL; - DECLARE vUserName VARCHAR(50) DEFAULT NULL; - DECLARE vBody VARCHAR(255) DEFAULT NULL; - - SELECT dayBreak, weekBreak, weekScope, dayWorkMax, dayStayMax - INTO vDayBreak, vWeekBreak, vWeekScope, vDayWorkMax, vDayStayMax - FROM vn.workerTimeControlParams; - - SELECT MAX(timed) INTO vLastIn - FROM vn.workerTimeControl - WHERE userFk = vUserFk - AND direction = 'in'; - - SELECT MAX(timed) INTO vLastOut - FROM vn.workerTimeControl - WHERE userFk = vUserFk - AND direction = 'out'; - - SELECT email INTO vTo - FROM vn.worker w - WHERE w.id = (SELECT bossFk FROM vn.worker WHERE id = vUserFk); - - SELECT CONCAT(firstName,' ',lastName) INTO vUserName - FROM vn.worker w - WHERE w.id = vUserFk; - - - IF UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(vLastIn) > vDayStayMax THEN -- NUEVA JORNADA - - -- VERIFICAR DESCANSO DIARIO - IF UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(vLastOut) < vDayBreak THEN - SELECT "Descansos 12 h" AS problem; - -- ENVIAMOS CORREO AL BOSSFK - SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"Descansos 12 h") INTO vBody; - CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); - LEAVE proc; - END IF; - - -- VERIFICAR FICHADAS IMPARES DEL ÚLTIMO DÍA QUE SE FICHÓ - IF (SELECT MOD(COUNT(*),2) -- <>0 - FROM vn.workerTimeControl - WHERE userFk = vUserFk - AND timed >= vLastIn - ) THEN - SELECT "Dias con fichadas impares" AS problem; - -- ENVIAMOS CORREO AL BOSSFK - SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"Dias con fichadas impares") INTO vBody; - CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); - LEAVE proc; - END IF; - - -- VERIFICAR VACACIONES - SELECT cs.type INTO vCalendarStateType - FROM postgresql.calendar_employee ce - JOIN postgresql.business b USING(business_id) - JOIN postgresql.profile pr ON pr.profile_id = b.client_id - JOIN postgresql.person p ON p.person_id = pr.person_id - JOIN postgresql.calendar_state cs USING(calendar_state_id) - JOIN vn.worker w ON w.id = p.id_trabajador - WHERE ce.date = CURDATE() - AND cs.isAllowedToWork = FALSE - AND w.userFk = vUserFk - LIMIT 1; - - IF(LENGTH(vCalendarStateType)) THEN - SELECT vCalendarStateType AS problem; - -- ENVIAMOS CORREO AL BOSSFK - SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"Vacaciones") INTO vBody; - CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); - LEAVE proc; - - END IF; - - - -- VERIFICAR CONTRATO EN VIGOR - IF (SELECT COUNT(*) - FROM postgresql.business b - JOIN postgresql.profile pr ON pr.profile_id = b.client_id - JOIN postgresql.person p ON p.person_id = pr.person_id - JOIN vn.worker w ON w.id = p.id_trabajador - WHERE w.userFk = vUserFk - AND b.date_start <= vDated - AND IFNULL(b.date_end,vDated) >= vDated - ) = 0 THEN - SELECT "No hay un contrato en vigor" AS problem; - -- ENVIAMOS CORREO AL BOSSFK - SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"No hay un contrato en vigor") INTO vBody; - CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); - LEAVE proc; - - END IF; - - -- VERIFICAR DESCANSO SEMANAL - SET @vHasBreakWeek:= FALSE; - SET @vLastTimed:= UNIX_TIMESTAMP((NOW() - INTERVAL vWeekScope SECOND)); - - DROP TEMPORARY TABLE IF EXISTS tmp.trash; - CREATE TEMPORARY TABLE tmp.trash - SELECT IF(vWeekBreak-(UNIX_TIMESTAMP(timed)-@vLastTimed) <= 0, @vHasBreakWeek:=TRUE, TRUE) alias, - @vLastTimed:= UNIX_TIMESTAMP(timed) - FROM workerTimeControl - WHERE timed>= (NOW() - INTERVAL vWeekScope SECOND) - AND userFk= vUserFk - AND direction IN ('in','out') - ORDER BY timed ASC; - - IF UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(vLastOut) < vWeekBreak AND @vHasBreakWeek = FALSE THEN -- REVISA SI EL DESCANSO SE HA REALIZADO DESPUÉS DE LA ÚLTIMA FICHADA - SELECT "Descansos 36 h" AS problem; - -- ENVIAMOS CORREO AL BOSSFK - SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"Descansos 36 h") INTO vBody; - CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); - LEAVE proc; - END IF; - - DROP TEMPORARY TABLE tmp.trash; - - ELSE -- DIA ACTUAL - - -- VERIFICA QUE EL TIEMPO EFECTIVO NO SUPERE EL MÁXIMO - SELECT IFNULL(SUM(if( mod(wtc.order,2)=1, -UNIX_TIMESTAMP(timed), UNIX_TIMESTAMP(timed))),0) - IF( MOD(COUNT(*),2), UNIX_TIMESTAMP(NOW()), 0) INTO vTimedWorked - FROM vn.workerTimeControl wtc - WHERE userFk = vUserFk - AND timed >= vLastIn - ORDER BY timed; - - IF vTimedWorked > vDayWorkMax THEN - SELECT "Jornadas" AS problem; - -- ENVIAMOS CORREO AL BOSSFK - SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"Jornadas") INTO vBody; - CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); - LEAVE proc; - END IF; - - END IF; - - -- VERIFICAR DEPARTAMENTO - IF vTabletFk IS NOT NULL THEN - IF ( SELECT COUNT(*) - FROM vn.tabletDepartment td - JOIN vn.workerTimeControlUserInfo wtcu ON wtcu.departmentFk = td.departmentFk - WHERE td.tabletFk = vTabletFk AND wtcu.userFk = vUserFk - ) = 0 THEN - SELECT "No perteneces a este departamento." AS problem; - -- ENVIAMOS CORREO AL BOSSFK - SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"No perteneces a este departamento.") INTO vBody; - CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); - LEAVE proc; - END IF; - END IF; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_check_` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControl_check_`(vUserFk INT, vDated DATE,vTabletFk VARCHAR(100)) -proc: BEGIN /** * Verifica si el empleado puede fichar en el momento actual, si puede fichar llama a vn.workerTimeControlAdd * @@ -53057,6 +54892,197 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_checkTest` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControl_checkTest`(vUserFk INT, vTabletFk VARCHAR(100), vTimed DATETIME) +BEGIN + +/** + * Verifica si el empleado puede fichar en el momento actual, si puede fichar llama a vn.workerTimeControlAdd + * @param vUserFk Identificador del trabajador + * @return Retorna si encuentra un problema 'odd','maxTimeWork','breakDay','breakWeek' ; + * En caso de tener algun problema retorna el primero que encuentra + */ + DECLARE vLastIn DATETIME ; + DECLARE vLastOut DATETIME ; + DECLARE vDayWorkMax INT; + DECLARE vDayBreak INT; + DECLARE vWeekBreak INT ; + DECLARE vWeekMaxBreak INT; + DECLARE vWeekScope INT; + DECLARE vWeekMaxScope INT; + DECLARE vDayStayMax INT; + DECLARE vAskInOut INT; + DECLARE vTimedWorked INT; + DECLARE vCalendarStateType VARCHAR(20) DEFAULT NULL; + DECLARE vDepartmentFk INT; + DECLARE vTo VARCHAR(50) DEFAULT NULL; + DECLARE vUserName VARCHAR(50) DEFAULT NULL; + DECLARE vBody VARCHAR(255) DEFAULT NULL; + + IF (vTimed IS NULL) THEN + SET vTimed = NOW(); + END IF; + + SELECT dayBreak, weekBreak, weekScope, dayWorkMax, dayStayMax, weekMaxBreak, weekMaxScope, askInOut + INTO vDayBreak, vWeekBreak, vWeekScope, vDayWorkMax, vDayStayMax, vWeekMaxBreak, vWeekMaxScope, vAskInOut + FROM vn.workerTimeControlParams; + + SELECT MAX(timed) INTO vLastIn + FROM vn.workerTimeControl + WHERE userFk = vUserFk AND + direction = 'in'; + + SELECT MAX(timed) INTO vLastOut + FROM vn.workerTimeControl + WHERE userFk = vUserFk AND + direction = 'out'; + + SELECT email INTO vTo + FROM vn.worker w + WHERE w.id = (SELECT bossFk FROM vn.worker WHERE id = vUserFk); + + SELECT CONCAT(firstName,' ',lastName) INTO vUserName + FROM vn.worker w + WHERE w.id = vUserFk; + + -- VERIFICAR CONTRATO EN VIGOR + IF (SELECT COUNT(*) + FROM postgresql.business b + JOIN postgresql.profile pr ON pr.profile_id = b.client_id + JOIN postgresql.person p ON p.person_id = pr.person_id + JOIN vn.worker w ON w.id = p.id_trabajador + WHERE w.userFk = vUserFk AND + b.date_start <= CURDATE() AND + IFNULL(b.date_end,CURDATE()) >= CURDATE() + ) = 0 THEN + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"No hay un contrato en vigor") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + CALL util.throw("No hay un contrato en vigor"); + END IF; + + -- VERIFICAR DEPARTAMENTO + IF vTabletFk IS NOT NULL THEN + IF ( SELECT COUNT(*) + FROM vn.tabletDepartment td + JOIN vn.workerTimeControlUserInfo wtcu ON wtcu.departmentFk = td.departmentFk + WHERE td.tabletFk = vTabletFk AND wtcu.userFk = vUserFk + ) = 0 THEN + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"No perteneces a este departamento.") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + CALL util.throw("No perteneces a este departamento."); + END IF; + END IF; + + SELECT IFNULL(dayBreak, vDayBreak) INTO vDayBreak + FROM postgresql.business b + JOIN postgresql.profile pr ON pr.profile_id = b.client_id + JOIN postgresql.person p ON p.person_id = pr.person_id + JOIN postgresql. business_labour bl ON b.business_id = bl.business_id + JOIN postgresql.professional_category pc ON bl.professional_category_id = pc.professional_category_id + WHERE p.id_trabajador = vUserFk AND + b.date_start <= DATE(vTimed) AND + IFNULL(b.date_end, DATE(vTimed)) >= DATE(vTimed); + -- VERIFICAR DESCANSO DIARIO + -- 12 / 9 horas dependiendo del valor de vDayBreak + IF UNIX_TIMESTAMP(vTimed) - UNIX_TIMESTAMP(vLastOut) < vDayBreak THEN + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos ", FORMAT(vDayBreak/3600,0) ," h") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + CALL util.throw(CONCAT("Descansos ", FORMAT(vDayBreak/3600,0) ," h")); + END IF; + + -- VERIFICAR FICHADAS IMPARES DEL ÚLTIMO DÍA QUE SE FICHÓ + IF (SELECT MOD(COUNT(*),2) -- <>0 + FROM vn.workerTimeControl + WHERE userFk = vUserFk AND + timed >= vLastIn + ) THEN + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Dias con fichadas impares") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + CALL util.throw("Dias con fichadas impares"); + END IF; + -- VERIFICAR VACACIONES + SELECT cs.type INTO vCalendarStateType + FROM postgresql.calendar_employee ce + JOIN postgresql.business b USING(business_id) + JOIN postgresql.profile pr ON pr.profile_id = b.client_id + JOIN postgresql.person p ON p.person_id = pr.person_id + JOIN postgresql.calendar_state cs USING(calendar_state_id) + JOIN vn.worker w ON w.id = p.id_trabajador + WHERE ce.date = CURDATE() AND + cs.isAllowedToWork = FALSE AND + w.userFk = vUserFk + LIMIT 1; + + IF(LENGTH(vCalendarStateType)) THEN + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Vacaciones") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + CALL util.throw(vCalendarStateType); + END IF; + + -- VERIFICAR DESCANSO SEMANAL + SET @vHasBreakWeek:= FALSE; + SET @vLastTimed:= UNIX_TIMESTAMP((vTimed - INTERVAL vWeekScope SECOND)); + + DROP TEMPORARY TABLE IF EXISTS tmp.trash; + CREATE TEMPORARY TABLE tmp.trash + SELECT IF(vWeekBreak-(UNIX_TIMESTAMP(timed)-@vLastTimed) <= 0, @vHasBreakWeek:=TRUE, TRUE) alias, + @vLastTimed:= UNIX_TIMESTAMP(timed) + FROM workerTimeControl + WHERE timed>= (vTimed - INTERVAL vWeekScope SECOND) AND + userFk= vUserFk AND + direction IN ('in','out') + ORDER BY timed ASC; + + IF UNIX_TIMESTAMP(vTimed) - UNIX_TIMESTAMP(vLastOut) < vWeekBreak AND @vHasBreakWeek = FALSE THEN -- REVISA SI EL DESCANSO SE HA REALIZADO DESPUÉS DE LA ÚLTIMA FICHADA + SET @vHasBreakWeek:= FALSE; + SET @vLastTimed:= UNIX_TIMESTAMP((vTimed - INTERVAL vWeekMaxScope SECOND)); + DROP TEMPORARY TABLE tmp.trash; + CREATE TEMPORARY TABLE tmp.trash + SELECT IF(vWeekMaxBreak-(UNIX_TIMESTAMP(timed)-@vLastTimed) <= 0, @vHasBreakWeek:=TRUE, TRUE) alias, + @vLastTimed:= UNIX_TIMESTAMP(timed) + FROM workerTimeControl + WHERE timed>= (vTimed - INTERVAL vWeekMaxScope SECOND) AND + userFk= vUserFk AND + direction IN ('in','out') + ORDER BY timed ASC; + IF UNIX_TIMESTAMP(vTimed) - UNIX_TIMESTAMP(vLastOut) < vWeekMaxBreak AND @vHasBreakWeek = FALSE THEN -- REVISA SI EL DESCANSO SE HA REALIZADO DESPUÉS DE LA ÚLTIMA FICHADA + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos ", FORMAT(vWeekMaxBreak/3600,0) ," h") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + CALL util.throw(CONCAT( "Descansos ", FORMAT(vWeekMaxBreak/3600,0) ," h")); + END IF; + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos ", FORMAT(vWeekBreak/3600,0) ," h") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + CALL util.warn(CONCAT( "Descansos ", FORMAT(vWeekBreak/3600,0) ," h")); + END IF; + DROP TEMPORARY TABLE tmp.trash; + + -- Preguntar dirección de la fichada + IF UNIX_TIMESTAMP(vTimed) - UNIX_TIMESTAMP(vLastIn) >= vAskInOut AND (SELECT MOD(COUNT(*),2) + FROM vn.workerTimeControl WHERE userFk = vUserFk AND timed >= vLastIn) THEN + CALL util.warn("AskInOut"); + END IF ; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_remove` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -55028,6 +57054,56 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `zone_getShipped` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `zone_getShipped`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT, vShowExpiredZones BOOLEAN) +BEGIN +/** + * Devuelve la mínima fecha de envío para cada warehouse + * + * @param vLanded La fecha de recepcion + * @param vAddressFk Id del consignatario + * @param vAgencyModeFk Id de la agencia + * @return tmp.zoneGetShipped + */ + CALL zone_getFromGeo(address_getGeo(vAddressFk)); + CALL zone_getOptionsForLanding(vLanded, vShowExpiredZones); + + DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetShipped; + CREATE TEMPORARY TABLE tmp.zoneGetShipped + ENGINE = MEMORY + SELECT * FROM ( + SELECT zo.zoneFk, + TIMESTAMPADD(DAY,-zo.travelingDays, vLanded) shipped, + zo.`hour`, + zw.warehouseFk, + z.agencyModeFk, + zo.price, + zo.bonus + FROM tmp.zoneOption zo + JOIN zoneWarehouse zw ON zw.zoneFk = zo.zoneFk + JOIN zone z ON z.id = zo.zoneFk + WHERE z.agencyModeFk = vAgencyModeFk + ORDER BY shipped) t + GROUP BY warehouseFk; + + DROP TEMPORARY TABLE + tmp.zone, + tmp.zoneOption; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `zone_getShippedWarehouse` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -55040,6 +57116,34 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `zone_getShippedWarehouse`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT) BEGIN +/** + * Devuelve la mínima fecha de envío para cada warehouse + * + * @param vLanded La fecha de recepcion + * @param vAddressFk Id del consignatario + * @param vAgencyModeFk Id de la agencia + * @return tmp.zoneGetShipped + */ + + CALL zone_getShipped(vLanded, vAddressFk, vAgencyModeFk, TRUE); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `zone_getShippedWarehouse__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `zone_getShippedWarehouse__`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT) +BEGIN /** * Devuelve la mínima fecha de envío para cada warehouse * @@ -56547,6 +58651,24 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `expeditionTimeExpended` +-- + +/*!50001 DROP VIEW IF EXISTS `expeditionTimeExpended`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `expeditionTimeExpended` AS select `e`.`ticketFk` AS `ticketFk`,min(`e`.`created`) AS `started`,max(`e`.`created`) AS `finished`,max(`e`.`counter`) AS `cajas`,`w`.`code` AS `code`,`t`.`warehouseFk` AS `warehouseFk` from ((`expedition` `e` join `worker` `w` on((`w`.`id` = `e`.`workerFk`))) join `ticket` `t` on((`t`.`id` = `e`.`ticketFk`))) where (`e`.`created` > curdate()) group by `e`.`ticketFk` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `firstTicketShipped` -- @@ -57177,24 +59299,6 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `saleVolume__` --- - -/*!50001 DROP VIEW IF EXISTS `saleVolume__`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8 */; -/*!50001 SET character_set_results = utf8 */; -/*!50001 SET collation_connection = utf8_general_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleVolume__` AS select `s`.`ticketFk` AS `ticketFk`,`s`.`id` AS `saleFk`,ifnull(round(((((`i`.`compression` * (greatest(`i`.`density`,167) / 167)) * `ic`.`cm3`) * `s`.`quantity`) / 1000),2),0) AS `litros`,`t`.`routeFk` AS `routeFk`,`t`.`shipped` AS `shipped`,(((`s`.`quantity` * `ic`.`cm3`) * `i`.`compression`) / 1000000) AS `volume`,((((`s`.`quantity` * `ic`.`cm3`) * `i`.`compression`) * (greatest(`i`.`density`,167) / 167)) / 1000000) AS `physicalWeight`,(((`s`.`quantity` * `ic`.`cm3`) * `i`.`density`) / 1000000) AS `weight`,(((`s`.`quantity` * `ic`.`cm3`) * `i`.`compression`) / 1000000) AS `physicalVolume`,((((`s`.`quantity` * `ic`.`cm3`) * `t`.`zonePrice`) * `i`.`compression`) / `cb`.`volume`) AS `freight` from ((((`sale` `s` join `item` `i` on((`i`.`id` = `s`.`itemFk`))) join `ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `packaging` `cb` on((`cb`.`id` = '94'))) join `itemCost` `ic` on(((`ic`.`itemFk` = `s`.`itemFk`) and (`ic`.`warehouseFk` = `t`.`warehouseFk`)))) */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - -- -- Final view structure for view `sale_freightComponent` -- @@ -57213,6 +59317,42 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `salesPreparedLastHour` +-- + +/*!50001 DROP VIEW IF EXISTS `salesPreparedLastHour`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `salesPreparedLastHour` AS select `t`.`warehouseFk` AS `warehouseFk`,`st`.`saleFk` AS `saleFk`,`st`.`isChecked` AS `isChecked`,`st`.`originalQuantity` AS `originalQuantity`,`a`.`accion` AS `accion`,`st`.`created` AS `created`,`e`.`code` AS `code`,`w`.`firstName` AS `firstname`,`w`.`lastName` AS `lastName`,`w`.`code` AS `workerCode`,((`r`.`cm3` * `s`.`quantity`) / 1000) AS `litros`,`s`.`concept` AS `concept`,`d`.`name` AS `departmentName` from (((((((((`vn`.`saleTracking` `st` left join `vn`.`salesPreviousPreparated` `prevPrepSales` on((`prevPrepSales`.`saleFk` = `st`.`saleFk`))) join `vn`.`sale` `s` on((`s`.`id` = `st`.`saleFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `bi`.`rotacion` `r` on(((`r`.`warehouse_id` = `t`.`warehouseFk`) and (`r`.`Id_Article` = `s`.`itemFk`)))) join `vn`.`worker` `w` on((`w`.`id` = `st`.`workerFk`))) join `vn`.`state` `e` on((`e`.`id` = `st`.`stateFk`))) join `vncontrol`.`accion` `a` on((`a`.`accion_id` = `st`.`actionFk`))) join `vn`.`workerDepartment` `wd` on((`wd`.`workerFk` = `st`.`workerFk`))) join `vn`.`department` `d` on((`d`.`id` = `wd`.`departmentFk`))) where ((`st`.`created` > (now() + interval -(1) hour)) and isnull(`prevPrepSales`.`saleFk`) and (not((`d`.`name` like 'EQUIPO%')))) */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `salesPreviousPreparated` +-- + +/*!50001 DROP VIEW IF EXISTS `salesPreviousPreparated`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `salesPreviousPreparated` AS select `st`.`saleFk` AS `saleFk` from (`saleTracking` `st` join `state` `e` on((`e`.`id` = `st`.`stateFk`))) where ((`st`.`created` > curdate()) and (`e`.`code` like 'PREVIOUS_PREPARATION')) */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `supplierPackaging` -- @@ -57465,6 +59605,42 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `workerSpeedExpedition` +-- + +/*!50001 DROP VIEW IF EXISTS `workerSpeedExpedition`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `workerSpeedExpedition` AS select `sv`.`ticketFk` AS `ticketFk`,sum(`sv`.`litros`) AS `litros`,sum(if((`sub`.`started` > (now() + interval -(1) hour)),`sv`.`litros`,0)) AS `literLastHour`,cast(((60 * sum(`sv`.`litros`)) / time_to_sec(timediff(max(`sub`.`finished`),min(`sub`.`started`)))) as decimal(10,1)) AS `litersByMinute`,`sub`.`code` AS `workerCode`,`sub`.`cajas` AS `cajas`,`sub`.`warehouseFk` AS `warehouseFk` from (`saleVolume` `sv` join `expeditionTimeExpended` `sub` on((`sub`.`ticketFk` = `sv`.`ticketFk`))) group by `workerCode` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `workerSpeedSaleTracking` +-- + +/*!50001 DROP VIEW IF EXISTS `workerSpeedSaleTracking`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `workerSpeedSaleTracking` AS select `salesPreparedLastHour`.`warehouseFk` AS `warehouseFk`,`salesPreparedLastHour`.`accion` AS `accion`,`salesPreparedLastHour`.`workerCode` AS `workerCode`,sum(`salesPreparedLastHour`.`litros`) AS `sumaLitros`,min(`salesPreparedLastHour`.`created`) AS `started`,max(`salesPreparedLastHour`.`created`) AS `finished`,sum(if((`salesPreparedLastHour`.`created` >= (now() + interval -(1) hour)),`salesPreparedLastHour`.`litros`,0)) AS `sumaLitrosLastHour`,cast(((60 * sum(`salesPreparedLastHour`.`litros`)) / time_to_sec(timediff(max(`salesPreparedLastHour`.`created`),min(`salesPreparedLastHour`.`created`)))) as decimal(10,1)) AS `litersByMinute`,`salesPreparedLastHour`.`departmentName` AS `departmentName` from `vn`.`salesPreparedLastHour` group by `salesPreparedLastHour`.`warehouseFk`,`salesPreparedLastHour`.`accion`,`salesPreparedLastHour`.`workerCode` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `workerTeamCollegues` -- @@ -57588,4 +59764,4 @@ USE `vncontrol`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-02-27 13:42:11 +-- Dump completed on 2020-03-16 9:43:30 From 285d930b8e6586d5656c41d8411521e5e218da49 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Mon, 16 Mar 2020 12:32:26 +0100 Subject: [PATCH 93/93] showReport fix --- modules/route/front/descriptor/index.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/route/front/descriptor/index.js b/modules/route/front/descriptor/index.js index e28654b99a..51ca23a92c 100644 --- a/modules/route/front/descriptor/index.js +++ b/modules/route/front/descriptor/index.js @@ -35,10 +35,9 @@ class Controller extends Component { } showRouteReport() { - const user = this.route.worker.user; const params = { authorization: this.vnToken.token, - clientId: user.id, + clientId: this.vnConfig.storage.currentUserWorkerId, routeId: this.route.id }; const serializedParams = this.$httpParamSerializer(params); @@ -47,10 +46,9 @@ class Controller extends Component { } sendRouteReport() { - const user = this.route.worker.user; const params = { recipient: user.emailUser.email, - clientId: user.id, + clientId: this.vnConfig.storage.currentUserWorkerId, routeId: this.route.id }; this.$http.get(`email/driver-route`, {params}).then(() => {