diff --git a/.eslintrc.yml b/.eslintrc.yml index d8b869d91..13fc2b140 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -9,7 +9,7 @@ env: rules: require-jsdoc: 0 no-undef: 0 - max-len: 0 + max-len: ["error", {code: 120}] eqeqeq: 0 operator-linebreak: 0 radix: 0 @@ -17,7 +17,7 @@ rules: camelcase: 0 default-case: 0 no-eq-null: 0 - no-console: 0 + no-console: ["error"] no-warning-comments: 0 no-empty: [error, allowEmptyCatch: true] complexity: 0 diff --git a/Jenkinsfile b/Jenkinsfile index d411ddb22..03ac84de3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -40,7 +40,7 @@ pipeline { NODE_ENV = "" } steps { - nodejs('node-v12') { + nodejs('node-v14') { sh 'npm install --no-audit --prefer-offline' sh 'gulp install --ci' } @@ -57,14 +57,14 @@ pipeline { parallel { stage('Frontend') { steps { - nodejs('node-v12') { + nodejs('node-v14') { sh 'jest --ci --reporters=default --reporters=jest-junit --maxWorkers=2' } } } // stage('Backend') { // steps { - // nodejs('node-v12') { + // nodejs('node-v14') { // sh 'gulp launchBackTest --ci' // } // } @@ -80,7 +80,7 @@ pipeline { CREDENTIALS = credentials('docker-registry') } steps { - nodejs('node-v12') { + nodejs('node-v14') { sh 'gulp build' } diff --git a/README.md b/README.md index 32377c115..1e3ad5e9e 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,6 @@ Required applications. * Node.js = 14.x LTS * Docker * Git -* Docker You will need to install globally the following items. ``` diff --git a/back/methods/dms/updateFile.js b/back/methods/dms/updateFile.js index 314761932..161f4728c 100644 --- a/back/methods/dms/updateFile.js +++ b/back/methods/dms/updateFile.js @@ -89,6 +89,7 @@ module.exports = Self => { await uploadNewFile(ctx, dms, myOptions); if (tx) await tx.commit(); + return dms; } catch (e) { if (tx) await tx.rollback(); diff --git a/back/methods/dms/uploadFile.js b/back/methods/dms/uploadFile.js index d6540cbc5..6bda1e6db 100644 --- a/back/methods/dms/uploadFile.js +++ b/back/methods/dms/uploadFile.js @@ -96,6 +96,7 @@ module.exports = Self => { } if (tx) await tx.commit(); + return addedDms; } catch (e) { if (tx) await tx.rollback(); diff --git a/back/methods/user-config-view/save.js b/back/methods/user-config-view/save.js index da8a27083..b2144c01e 100644 --- a/back/methods/user-config-view/save.js +++ b/back/methods/user-config-view/save.js @@ -7,8 +7,7 @@ module.exports = function(Self) { required: true, description: `Code of the table you ask its configuration`, http: {source: 'body'} - } - ], + }], returns: { type: 'object', root: true @@ -29,6 +28,6 @@ module.exports = function(Self) { config.userFk = ctx.req.accessToken.userId; - return await Self.app.models.UserConfigView.create(config); + return Self.app.models.UserConfigView.create(config); }; }; diff --git a/back/model-config.json b/back/model-config.json index 18bf4cf98..8ad15a16a 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -29,6 +29,9 @@ "ChatConfig": { "dataSource": "vn" }, + "DefaultViewConfig": { + "dataSource": "vn" + }, "Delivery": { "dataSource": "vn" }, diff --git a/back/models/accounting-type.json b/back/models/accounting-type.json index c2bf977b2..be08ac533 100644 --- a/back/models/accounting-type.json +++ b/back/models/accounting-type.json @@ -25,6 +25,9 @@ }, "isAutoConciliated": { "type": "boolean" + }, + "maxAmount": { + "type": "number" } }, "acls": [{ diff --git a/back/models/default-view-config.json b/back/models/default-view-config.json new file mode 100644 index 000000000..88164692d --- /dev/null +++ b/back/models/default-view-config.json @@ -0,0 +1,25 @@ +{ + "name": "DefaultViewConfig", + "base": "VnModel", + "options": { + "mysql": { + "table": "salix.defaultViewConfig" + } + }, + "properties": { + "tableCode": { + "id": true, + "type": "string", + "required": true + }, + "columns": { + "type": "object" + } + }, + "acls": [{ + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + }] +} diff --git a/back/models/emailUser.json b/back/models/email-user.json similarity index 72% rename from back/models/emailUser.json rename to back/models/email-user.json index d612d5d29..e983635ce 100644 --- a/back/models/emailUser.json +++ b/back/models/email-user.json @@ -23,5 +23,13 @@ "model": "Account", "foreignKey": "userFk" } - } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + } + ] } diff --git a/back/models/image.js b/back/models/image.js index a35018814..d736e924f 100644 --- a/back/models/image.js +++ b/back/models/image.js @@ -151,6 +151,7 @@ module.exports = Self => { await fs.unlink(srcFilePath); await tx.commit(); + return newImage; } catch (e) { await tx.rollback(); diff --git a/db/changes/10330-jun2021/00-invoiceLog.sql b/db/changes/10330-jun2021/00-invoiceLog.sql deleted file mode 100644 index 899c6c63f..000000000 --- a/db/changes/10330-jun2021/00-invoiceLog.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE `vn`.`invoiceInLog` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `originFk` MEDIUMINT UNSIGNED NOT NULL, - `userFk` int(10) unsigned DEFAULT NULL, - `action` set('insert','update','delete') COLLATE utf8_unicode_ci NOT NULL, - `creationDate` timestamp NULL DEFAULT current_timestamp(), - `description` text CHARACTER SET utf8 DEFAULT NULL, - `changedModel` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `oldInstance` text COLLATE utf8_unicode_ci DEFAULT NULL, - `newInstance` text COLLATE utf8_unicode_ci DEFAULT NULL, - `changedModelId` int(11) DEFAULT NULL, - `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `originFk` (`originFk`), - KEY `userFk` (`userFk`), - CONSTRAINT `invoiceInLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `vn`.`invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `invoiceInLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; \ No newline at end of file diff --git a/db/changes/10330-jun2021/00-sale_getProblems.sql b/db/changes/10330-jun2021/00-sale_getProblems.sql deleted file mode 100644 index 6685378b3..000000000 --- a/db/changes/10330-jun2021/00-sale_getProblems.sql +++ /dev/null @@ -1,192 +0,0 @@ -DROP PROCEDURE IF EXISTS `vn`.`sale_getProblems`; - -DELIMITER $$ -$$ -CREATE - DEFINER = root@`%` PROCEDURE `vn`.`sale_getProblems`(IN vIsTodayRelative TINYINT(1)) -BEGIN -/** - * Calcula los problemas de cada venta - * para un conjunto de tickets. - * - * @table tmp.sale_getProblems(ticketFk, clientFk, warehouseFk, shipped) Identificadores de los tickets a calcular - * @return tmp.sale_problems - */ - DECLARE vWarehouse INT; - DECLARE vDate DATE; - DECLARE vAvailableCache INT; - DECLARE vDone INT DEFAULT 0; - DECLARE vComponentCount INT; - - DECLARE vCursor CURSOR FOR - SELECT DISTINCT tt.warehouseFk, IF(vIsTodayRelative, CURDATE(), date(tt.shipped)) - FROM tmp.sale_getProblems tt - WHERE DATE(tt.shipped) BETWEEN CURDATE() - AND TIMESTAMPADD(DAY, IF(vIsTodayRelative, 9.9, 1.9), CURDATE()); - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = 1; - - DROP TEMPORARY TABLE IF EXISTS tmp.sale_problems; - CREATE TEMPORARY TABLE tmp.sale_problems ( - ticketFk INT(11), - saleFk INT(11), - isFreezed INTEGER(1) DEFAULT 0, - risk DECIMAL(10,2) DEFAULT 0, - hasTicketRequest INTEGER(1) DEFAULT 0, - isAvailable INTEGER(1) DEFAULT 1, - itemShortage VARCHAR(250), - isTaxDataChecked INTEGER(1) DEFAULT 1, - itemDelay VARCHAR(250), - hasComponentLack INTEGER(1), - PRIMARY KEY (ticketFk, saleFk) - ) ENGINE = MEMORY; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; - CREATE TEMPORARY TABLE tmp.ticket_list - (PRIMARY KEY (ticketFk)) - ENGINE = MEMORY - SELECT tp.ticketFk, c.id clientFk - FROM tmp.sale_getProblems tp - JOIN vn.client c ON c.id = tp.clientFk; - - SELECT COUNT(*) INTO vComponentCount - FROM vn.component c - WHERE c.isRequired; - - INSERT INTO tmp.sale_problems(ticketFk, hasComponentLack, saleFk) - SELECT tl.ticketFk, (COUNT(DISTINCT s.id) * vComponentCount > COUNT(c.id)), s.id - FROM tmp.ticket_list tl - JOIN vn.sale s ON s.ticketFk = tl.ticketFk - LEFT JOIN vn.saleComponent sc ON sc.saleFk = s.id - LEFT JOIN vn.component c ON c.id = sc.componentFk AND c.isRequired - GROUP BY tl.ticketFk, s.id; - - INSERT INTO tmp.sale_problems(ticketFk, isFreezed) - SELECT DISTINCT tl.ticketFk, TRUE - FROM tmp.ticket_list tl - JOIN vn.client c ON c.id = tl.clientFk - WHERE c.isFreezed - ON DUPLICATE KEY UPDATE - isFreezed = c.isFreezed; - - DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt; - CREATE TEMPORARY TABLE tmp.clientGetDebt - (PRIMARY KEY (clientFk)) - ENGINE = MEMORY - SELECT DISTINCT clientFk - FROM tmp.ticket_list; - - CALL clientGetDebt(CURDATE()); - - INSERT INTO tmp.sale_problems(ticketFk, risk) - SELECT DISTINCT tl.ticketFk, r.risk - FROM tmp.ticket_list tl - JOIN vn.ticket t ON t.id = tl.ticketFk - JOIN vn.agencyMode a ON t.agencyModeFk = a.id - JOIN tmp.risk r ON r.clientFk = t.clientFk - JOIN vn.client c ON c.id = t.clientFk - JOIN vn.clientConfig cc - WHERE r.risk > c.credit + 10 - AND a.isRiskFree = FALSE - ON DUPLICATE KEY UPDATE - risk = r.risk; - - INSERT INTO tmp.sale_problems(ticketFk, hasTicketRequest) - SELECT DISTINCT tl.ticketFk, TRUE - FROM tmp.ticket_list tl - JOIN vn.ticketRequest tr ON tr.ticketFk = tl.ticketFk - WHERE tr.isOK IS NULL - ON DUPLICATE KEY UPDATE - hasTicketRequest = TRUE; - - OPEN vCursor; - - WHILE NOT vDone - DO - FETCH vCursor INTO vWarehouse, vDate; - - CALL cache.available_refresh(vAvailableCache, FALSE, vWarehouse, vDate); - - INSERT INTO tmp.sale_problems(ticketFk, isAvailable, saleFk) - SELECT tl.ticketFk, FALSE, s.id - FROM tmp.ticket_list tl - JOIN vn.ticket t ON t.id = tl.ticketFk - JOIN vn.sale s ON s.ticketFk = t.id - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it on it.id = i.typeFk - LEFT JOIN cache.available av ON av.item_id = i.id - AND av.calc_id = vAvailableCache - WHERE date(t.shipped) = vDate - AND it.categoryFk != 6 - AND IFNULL(av.available, 0) < 0 - AND s.isPicked = FALSE - AND NOT i.generic - AND vWarehouse = t.warehouseFk - GROUP BY tl.ticketFk - ON DUPLICATE KEY UPDATE - isAvailable = FALSE, saleFk = VALUE(saleFk); - - INSERT INTO tmp.sale_problems(ticketFk, itemShortage, saleFk) - SELECT ticketFk, problem, saleFk - FROM ( - SELECT tl.ticketFk, CONCAT('F: ',GROUP_CONCAT(i.id, ' ', i.longName, ' ')) problem, s.id AS saleFk - FROM tmp.ticket_list tl - JOIN vn.ticket t ON t.id = tl.ticketFk - JOIN vn.sale s ON s.ticketFk = t.id - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it on it.id = i.typeFk - LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk - LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache - WHERE IFNULL(av.available, 0) < 0 - AND s.quantity > IFNULL(issw.visible, 0) - AND s.quantity > 0 - AND s.isPicked = FALSE - AND s.reserved = FALSE - AND it.categoryFk != 6 - AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate) - AND NOT i.generic - AND CURDATE() = vDate - AND t.warehouseFk = vWarehouse - GROUP BY tl.ticketFk LIMIT 1) sub - ON DUPLICATE KEY UPDATE - itemShortage = sub.problem, saleFk = sub.saleFk; - - INSERT INTO tmp.sale_problems(ticketFk, itemDelay, saleFk) - SELECT ticketFk, problem, saleFk - FROM ( - SELECT tl.ticketFk, GROUP_CONCAT('I: ',i.id, ' ', i.longName, ' ') problem, s.id AS saleFk - FROM tmp.ticket_list tl - JOIN vn.ticket t ON t.id = tl.ticketFk - JOIN vn.sale s ON s.ticketFk = t.id - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it on it.id = i.typeFk - LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk - WHERE s.quantity > IFNULL(issw.visible, 0) - AND s.quantity > 0 - AND s.isPicked = FALSE - AND s.reserved = FALSE - AND it.categoryFk != 6 - AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate) - AND NOT i.generic - AND CURDATE() = vDate - AND t.warehouseFk = vWarehouse - GROUP BY tl.ticketFk LIMIT 1) sub - ON DUPLICATE KEY UPDATE - itemDelay = sub.problem, saleFk = sub.saleFk; - END WHILE; - - CLOSE vCursor; - - INSERT INTO tmp.sale_problems(ticketFk, isTaxDataChecked) - SELECT DISTINCT tl.ticketFk, FALSE - FROM tmp.ticket_list tl - JOIN vn.client c ON c.id = tl.clientFk - WHERE c.isTaxDataChecked = FALSE - ON DUPLICATE KEY UPDATE - isTaxDataChecked = FALSE; - - DROP TEMPORARY TABLE - tmp.clientGetDebt, - tmp.ticket_list; -END;;$$ -DELIMITER ; diff --git a/db/changes/10330-jun2021/01-ticket_componentMakeUpdate.sql b/db/changes/10330-jun2021/01-ticket_componentMakeUpdate.sql deleted file mode 100644 index 058d6eb99..000000000 --- a/db/changes/10330-jun2021/01-ticket_componentMakeUpdate.sql +++ /dev/null @@ -1,95 +0,0 @@ -DROP PROCEDURE IF EXISTS `vn`.`ticket_componentMakeUpdate`; - -DELIMITER $$ -$$ - -CREATE - DEFINER = root@`%` PROCEDURE `vn`.`ticket_componentMakeUpdate`(IN vTicketFk INT, IN vClientFk INT, - IN vNickname VARCHAR(50), IN vAgencyModeFk INT, - IN vAddressFk INT, IN vZoneFk INT, IN vWarehouseFk TINYINT, - IN vCompanyFk SMALLINT, IN vShipped DATETIME, - IN vLanded DATE, IN vIsDeleted TINYINT(1), - IN vHasToBeUnrouted TINYINT(1), IN vOption INT) -BEGIN -/** - * Modifica en el ticket los campos que se le pasan por parámetro - * y cambia sus componentes - * - * @param vTicketFk Id del ticket a modificar - * @param vClientFk nuevo cliente - * @param vNickname nuevo alias - * @param vAgencyModeFk nueva agencia - * @param vAddressFk nuevo consignatario - * @param vZoneFk nueva zona - * @param vWarehouseFk nuevo almacen - * @param vCompanyFk nueva empresa - * @param vShipped nueva fecha del envio de mercancia - * @param vLanded nueva fecha de recepcion de mercancia - * @param vIsDeleted si se borra el ticket - * @param vHasToBeUnrouted si se le elimina la ruta al ticket - * @param vOption opcion para el case del proc ticketComponentUpdateSale - */ - DECLARE vPrice DECIMAL(10,2); - DECLARE vBonus DECIMAL(10,2); - - CALL ticket_componentPreview (vTicketFk, vLanded, vAddressFk, vZoneFk, vWarehouseFk); - - IF (SELECT addressFk FROM ticket WHERE id = vTicketFk) <> vAddressFk THEN - - UPDATE ticket t - JOIN address a ON a.id = vAddressFk - SET t.nickname = a.nickname - WHERE t.id = vTicketFk; - - END IF; - - CALL zone_getShippedWarehouse(vlanded, vAddressFk, vAgencyModeFk); - - SELECT zoneFk, price, bonus INTO vZoneFk, vPrice, vBonus - FROM tmp.zoneGetShipped - WHERE shipped BETWEEN DATE(vShipped) AND util.dayEnd(vShipped) AND warehouseFk = vWarehouseFk LIMIT 1; - - UPDATE ticket t - SET - t.clientFk = vClientFk, - t.nickname = vNickname, - t.agencyModeFk = vAgencyModeFk, - t.addressFk = vAddressFk, - t.zoneFk = vZoneFk, - t.zonePrice = vPrice, - t.zoneBonus = vBonus, - t.warehouseFk = vWarehouseFk, - t.companyFk = vCompanyFk, - t.landed = vLanded, - t.shipped = vShipped, - t.isDeleted = vIsDeleted - WHERE - t.id = vTicketFk; - - IF vHasToBeUnrouted THEN - UPDATE ticket t SET t.routeFk = NULL - WHERE t.id = vTicketFk; - END IF; - - IF vOption <> 8 THEN - DROP TEMPORARY TABLE IF EXISTS tmp.sale; - CREATE TEMPORARY TABLE tmp.sale - (PRIMARY KEY (saleFk)) - ENGINE = MEMORY - SELECT id AS saleFk, vWarehouseFk warehouseFk - FROM sale s WHERE s.ticketFk = vTicketFk; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent; - CREATE TEMPORARY TABLE tmp.ticketComponent - SELECT * FROM tmp.ticketComponentPreview; - - CALL ticketComponentUpdateSale (vOption); - - DROP TEMPORARY TABLE tmp.sale; - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent; - END IF; - - DROP TEMPORARY TABLE tmp.zoneGetShipped, tmp.ticketComponentPreview; -END$$ -DELIMITER ; - diff --git a/db/changes/10340-summer/00-ACL.sql b/db/changes/10340-summer/00-ACL.sql deleted file mode 100644 index dff946e4b..000000000 --- a/db/changes/10340-summer/00-ACL.sql +++ /dev/null @@ -1,15 +0,0 @@ -DELETE FROM `salix`.`ACL` WHERE id = 189; -DELETE FROM `salix`.`ACL` WHERE id = 188; -UPDATE `salix`.`ACL` tdms SET tdms.accessType = '*' - WHERE tdms.id = 165; - -INSERT INTO `salix`.`ACL` (model, principalId, property, accessType) - VALUES - ('InvoiceInTax','administrative', '*', '*'), - ('InvoiceInLog','administrative', '*', 'READ'); - -INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) - VALUES - ('InvoiceOut', 'createManualInvoice', 'WRITE', 'ALLOW', 'ROLE', 'invoicing'), - ('InvoiceOut', 'globalInvoicing', 'WRITE', 'ALLOW', 'ROLE', 'invoicing'); - diff --git a/db/changes/10340-summer/00-buy_importReference.sql b/db/changes/10340-summer/00-buy_importReference.sql deleted file mode 100644 index f6bdc059c..000000000 --- a/db/changes/10340-summer/00-buy_importReference.sql +++ /dev/null @@ -1,14 +0,0 @@ -create table `vn`.`itemMatchProperties` -( - itemFk int not null, - name varchar(80) not null, - producer varchar(80) not null, - size int not null, - constraint itemMatchProperties_pk - primary key (itemFk, name, producer, size), - constraint itemFk___fk - foreign key (itemFk) references item (id) - on update cascade on delete cascade -) -comment 'Propiedades para encontrar articulos equivalentes en verdnatura'; - diff --git a/db/changes/10340-summer/00-invoiceFromClient.sql b/db/changes/10340-summer/00-invoiceFromClient.sql deleted file mode 100644 index d198e873d..000000000 --- a/db/changes/10340-summer/00-invoiceFromClient.sql +++ /dev/null @@ -1,21 +0,0 @@ -drop procedure `vn`.`invoiceFromClient`; - -DELIMITER $$ -$$ -create - definer = root@`%` procedure `vn`.`invoiceFromClient`(IN vMaxTicketDate datetime, IN vClientFk INT, IN vCompanyFk INT) -BEGIN - DECLARE vMinTicketDate DATE DEFAULT TIMESTAMPADD(YEAR, -3, CURDATE()); - SET vMaxTicketDate = util.dayend(vMaxTicketDate); - - DROP TEMPORARY TABLE IF EXISTS `ticketToInvoice`; - CREATE TEMPORARY TABLE `ticketToInvoice` - (PRIMARY KEY (`id`)) - ENGINE = MEMORY - SELECT id FROM ticket t - WHERE t.clientFk = vClientFk - AND t.refFk IS NULL - AND t.companyFk = vCompanyFk - AND (t.shipped BETWEEN vMinTicketDate AND vMaxTicketDate); -END;;$$ -DELIMITER ; diff --git a/db/changes/10340-summer/00-invoiceOut_newFromClient.sql b/db/changes/10340-summer/00-invoiceOut_newFromClient.sql deleted file mode 100644 index b4d4f916b..000000000 --- a/db/changes/10340-summer/00-invoiceOut_newFromClient.sql +++ /dev/null @@ -1,45 +0,0 @@ -drop procedure `vn`.`invoiceOut_newFromClient`; - -DELIMITER $$ -$$ -create - definer = root@`%` procedure `vn`.`invoiceOut_newFromClient`(IN vClientFk int, IN vSerial char(2), IN vMaxShipped date, - IN vCompanyFk int, IN vTaxArea varchar(25), - IN vRef varchar(25), OUT vInvoiceId int) -BEGIN -/** - * Factura los tickets de un cliente hasta una fecha dada - * @param vClientFk Id del cliente a facturar - * @param vSerial Serie de factura - * @param vMaxShipped Fecha hasta la cual cogera tickets para facturar - * @param vCompanyFk Id de la empresa desde la que se factura - * @param vTaxArea Tipo de iva en relacion a la empresa y al cliente, NULL por defecto - * @param vRef Referencia de la factura en caso que se quiera forzar, NULL por defecto - * @return vInvoiceId factura - */ - - DECLARE vIsRefEditable BOOLEAN; - - IF vRef IS NOT NULL THEN - SELECT isRefEditable INTO vIsRefEditable - FROM invoiceOutSerial - WHERE code = vSerial; - - IF NOT vIsRefEditable THEN - CALL util.throw('serial non editable'); - END IF; - END IF; - - CALL invoiceFromClient(vMaxShipped, vClientFk, vCompanyFk); - CALL invoiceOut_new(vSerial, CURDATE(), vTaxArea, vInvoiceId); - - UPDATE invoiceOut - SET `ref` = vRef - WHERE id = vInvoiceId - AND vRef IS NOT NULL; - - IF vSerial <> 'R' AND NOT ISNULL(vInvoiceId) AND vInvoiceId <> 0 THEN - CALL invoiceOutBooking(vInvoiceId); - END IF; -END;;$$ -DELIMITER ; diff --git a/db/changes/10340-summer/00-invoiceOut_newFromTicket.sql b/db/changes/10340-summer/00-invoiceOut_newFromTicket.sql deleted file mode 100644 index 15be3d83c..000000000 --- a/db/changes/10340-summer/00-invoiceOut_newFromTicket.sql +++ /dev/null @@ -1,38 +0,0 @@ -drop procedure `vn`.`invoiceOut_newFromTicket`; - -DELIMITER $$ -$$ -create - definer = root@`%` procedure `vn`.`invoiceOut_newFromTicket`(IN vTicketFk int, IN vSerial char(2), IN vTaxArea varchar(25), - IN vRef varchar(25), OUT vInvoiceId int) -BEGIN -/** - * Factura un ticket - * @param vTicketFk Id del ticket - * @param vSerial Serie de factura - * @param vTaxArea Area de la factura en caso de querer forzarlo, - * en la mayoria de los casos poner NULL - * @return vInvoiceId - */ - DECLARE vIsRefEditable BOOLEAN; - CALL invoiceFromTicket(vTicketFk); - CALL invoiceOut_new(vSerial, CURDATE(), vTaxArea, vInvoiceId); - - IF vRef IS NOT NULL THEN - SELECT isRefEditable INTO vIsRefEditable - FROM invoiceOutSerial - WHERE code = vSerial; - IF NOT vIsRefEditable THEN - CALL util.throw('serial non editable'); - END IF; - - UPDATE invoiceOut - SET `ref` = vRef - WHERE id = vInvoiceId; - END IF; - - IF vSerial <> 'R' AND NOT ISNULL(vInvoiceId) AND vInvoiceId <> 0 THEN - CALL invoiceOutBooking(vInvoiceId); - END IF; -END;;$$ -DELIMITER ; diff --git a/db/changes/10340-summer/00-sample.sql b/db/changes/10340-summer/00-sample.sql deleted file mode 100644 index d4858ac72..000000000 --- a/db/changes/10340-summer/00-sample.sql +++ /dev/null @@ -1,7 +0,0 @@ -ALTER TABLE `vn`.`sample` ADD COLUMN - (`datepickerEnabled` TINYINT(1) NOT NULL DEFAULT 0); - -ALTER TABLE `vn`.`sample` MODIFY code VARCHAR(25) charset utf8 NOT NULL; - -INSERT INTO `vn`.`sample` (code, description, isVisible, hasCompany, hasPreview, datepickerEnabled) - VALUES ('client-debt-statement', 'Extracto del cliente', 1, 0, 1, 1); \ No newline at end of file diff --git a/db/changes/10340-summer/00-ticket_close.sql b/db/changes/10340-summer/00-ticket_close.sql deleted file mode 100644 index a8086549c..000000000 --- a/db/changes/10340-summer/00-ticket_close.sql +++ /dev/null @@ -1,109 +0,0 @@ -drop procedure `vn`.`ticket_close`; - -DELIMITER $$ -$$ -create - definer = root@`%` procedure `vn`.`ticket_close`() -BEGIN -/** - * Realiza el cierre de todos los - * tickets de la tabla tmp.ticket_close. - * - * @table tmp.ticket_close(ticketFk) Identificadores de los tickets a cerrar - */ - DECLARE vDone BOOL; - DECLARE vClientFk INT; - DECLARE vCurTicketFk INT; - DECLARE vIsTaxDataChecked BOOL; - DECLARE vCompanyFk INT; - DECLARE vShipped DATE; - DECLARE vNewInvoiceId INT; - DECLARE vHasDailyInvoice BOOL; - DECLARE vWithPackage BOOL; - DECLARE vHasToInvoice BOOL; - - DECLARE cur CURSOR FOR - SELECT ticketFk FROM tmp.ticket_close; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN - RESIGNAL; - END; - - OPEN cur; - - proc: LOOP - SET vDone = FALSE; - - FETCH cur INTO vCurTicketFk; - - IF vDone THEN - LEAVE proc; - END IF; - - -- Fetch ticket data - SELECT - c.id, - c.isTaxDataChecked, - t.companyFk, - t.shipped, - co.hasDailyInvoice, - w.isManaged, - c.hasToInvoice - INTO vClientFk, - vIsTaxDataChecked, - vCompanyFk, - vShipped, - vHasDailyInvoice, - vWithPackage, - vHasToInvoice - FROM ticket t - JOIN `client` c ON c.id = t.clientFk - JOIN province p ON p.id = c.provinceFk - JOIN country co ON co.id = p.countryFk - JOIN warehouse w ON w.id = t.warehouseFk - WHERE t.id = vCurTicketFk; - - INSERT INTO ticketPackaging (ticketFk, packagingFk, quantity) - (SELECT vCurTicketFk, p.id, COUNT(*) - FROM expedition e - JOIN packaging p ON p.itemFk = e.itemFk - WHERE e.ticketFk = vCurTicketFk AND p.isPackageReturnable - AND vWithPackage - GROUP BY p.itemFk); - - -- No retornables o no catalogados - INSERT INTO sale (itemFk, ticketFk, concept, quantity, price, isPriceFixed) - (SELECT e.itemFk, vCurTicketFk, i.name, COUNT(*) AS amount, getSpecialPrice(e.itemFk, vClientFk), 1 - FROM expedition e - JOIN item i ON i.id = e.itemFk - LEFT JOIN packaging p ON p.itemFk = i.id - WHERE e.ticketFk = vCurTicketFk AND IFNULL(p.isPackageReturnable, 0) = 0 - AND getSpecialPrice(e.itemFk, vClientFk) > 0 - GROUP BY e.itemFk); - - CALL vn.zonePromo_Make(); - - IF(vHasDailyInvoice) AND vHasToInvoice THEN - - -- Facturacion rapida - CALL ticketTrackingAdd(vCurTicketFk, 'DELIVERED', NULL); - -- Facturar si está contabilizado - IF vIsTaxDataChecked THEN - CALL invoiceOut_newFromClient( - vClientFk, - (SELECT invoiceSerial(vClientFk, vCompanyFk, 'M')), - vShipped, - vCompanyFk, - NULL, - NULL, - vNewInvoiceId); - END IF; - ELSE - CALL ticketTrackingAdd(vCurTicketFk, (SELECT vn.getAlert3State(vCurTicketFk)), NULL); - END IF; - END LOOP; - - CLOSE cur; -END;;$$ -DELIMITER ; diff --git a/db/changes/10340-summer/00-ticket_closeAll.sql b/db/changes/10340-summer/00-ticket_closeAll.sql deleted file mode 100644 index 6441f2c1a..000000000 --- a/db/changes/10340-summer/00-ticket_closeAll.sql +++ /dev/null @@ -1,118 +0,0 @@ -drop procedure `vn`.`ticket_closeAll`; - -DELIMITER $$ -$$ -create definer = root@`%` procedure `vn`.`ticket_closeAll__`() -BEGIN -/** - * Realiza el cierre de todos los - * tickets de la tabla tmp.ticketClosure. - * - * @param vTicketFk Id del ticket - */ - DECLARE vDone BOOL; - DECLARE vClientFk INT; - DECLARE vCurTicketFk INT; - DECLARE vIsTaxDataChecked BOOL; - DECLARE vCompanyFk INT; - DECLARE vShipped DATE; - DECLARE vNewInvoiceId INT; - DECLARE vHasDailyInvoice BOOL; - DECLARE vWithPackage BOOL; - DECLARE vHasToInvoice BOOL; - - DECLARE cur CURSOR FOR - SELECT ticketFk FROM tmp.ticketClosure; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN - RESIGNAL; - END; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketClosure2; - CREATE TEMPORARY TABLE tmp.ticketClosure2 - SELECT ticketFk FROM tmp.ticketClosure; - - INSERT INTO tmp.ticketClosure - SELECT id FROM stowaway s - JOIN tmp.ticketClosure2 tc ON s.shipFk = tc.ticketFk; - OPEN cur; - - proc: LOOP - SET vDone = FALSE; - - FETCH cur INTO vCurTicketFk; - - IF vDone THEN - LEAVE proc; - END IF; - - -- ticketClosure start - SELECT - c.id, - c.isTaxDataChecked, - t.companyFk, - t.shipped, - co.hasDailyInvoice, - w.isManaged, - c.hasToInvoice - INTO vClientFk, - vIsTaxDataChecked, - vCompanyFk, - vShipped, - vHasDailyInvoice, - vWithPackage, - vHasToInvoice - FROM ticket t - JOIN `client` c ON c.id = t.clientFk - JOIN province p ON p.id = c.provinceFk - JOIN country co ON co.id = p.countryFk - JOIN warehouse w ON w.id = t.warehouseFk - WHERE t.id = vCurTicketFk; - - INSERT INTO ticketPackaging (ticketFk, packagingFk, quantity) - (SELECT vCurTicketFk, p.id, COUNT(*) - FROM expedition e - JOIN packaging p ON p.itemFk = e.itemFk - WHERE e.ticketFk = vCurTicketFk AND p.isPackageReturnable - AND vWithPackage - GROUP BY p.itemFk); - - -- No retornables o no catalogados - INSERT INTO sale (itemFk, ticketFk, concept, quantity, price, isPriceFixed) - (SELECT e.itemFk, vCurTicketFk, i.name, COUNT(*) AS amount, getSpecialPrice(e.itemFk, vClientFk), 1 - FROM expedition e - JOIN item i ON i.id = e.itemFk - LEFT JOIN packaging p ON p.itemFk = i.id - WHERE e.ticketFk = vCurTicketFk AND IFNULL(p.isPackageReturnable, 0) = 0 - AND getSpecialPrice(e.itemFk, vClientFk) > 0 - GROUP BY e.itemFk); - - CALL vn.zonePromo_Make(); - - IF(vHasDailyInvoice) AND vHasToInvoice THEN - - -- Facturacion rapida - CALL ticketTrackingAdd(vCurTicketFk, 'DELIVERED', NULL); - -- Facturar si está contabilizado - IF vIsTaxDataChecked THEN - CALL invoiceOut_newFromClient( - vClientFk, - (SELECT invoiceSerial(vClientFk, vCompanyFk, 'M')), - vShipped, - vCompanyFk, - NULL, - NULL, - vNewInvoiceId); - END IF; - ELSE - CALL ticketTrackingAdd(vCurTicketFk, (SELECT vn.getAlert3State(vCurTicketFk)), NULL); - END IF; - END LOOP; - - CLOSE cur; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketClosure; -END;;$$ -DELIMITER ; - diff --git a/db/changes/10340-summer/00-ticket_closeByTicket.sql b/db/changes/10340-summer/00-ticket_closeByTicket.sql deleted file mode 100644 index a24ea5ad9..000000000 --- a/db/changes/10340-summer/00-ticket_closeByTicket.sql +++ /dev/null @@ -1,34 +0,0 @@ -drop procedure `vn`.`ticket_closeByTicket`; - -DELIMITER $$ -$$ -create - definer = root@`%` procedure `vn`.`ticket_closeByTicket`(IN vTicketFk int) -BEGIN - -/** - * Inserta el ticket en la tabla temporal - * para ser cerrado. - * - * @param vTicketFk Id del ticket - */ - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket_close; - CREATE TEMPORARY TABLE tmp.ticket_close ENGINE = MEMORY ( - SELECT - t.id AS ticketFk - FROM expedition e - INNER JOIN ticket t ON t.id = e.ticketFk - LEFT JOIN ticketState ts ON ts.ticketFk = t.id - JOIN alertLevel al ON al.id = ts.alertLevel - WHERE - al.code = 'PACKED' - AND t.id = vTicketFk - AND t.refFk IS NULL - GROUP BY e.ticketFk); - - CALL ticket_close(); - - DROP TEMPORARY TABLE tmp.ticket_close; -END;;$$ -DELIMITER ; diff --git a/db/changes/10340-summer/01-credit_request.sql b/db/changes/10340-summer/01-credit_request.sql deleted file mode 100644 index 821623326..000000000 --- a/db/changes/10340-summer/01-credit_request.sql +++ /dev/null @@ -1,2 +0,0 @@ -INSERT INTO `vn`.`sample` (`code`, `description`, `isVisible`, `hasCompany`, `hasPreview`) - VALUES ('credit-request', 'Solicitud de crédito', 1, 1, 1); \ No newline at end of file diff --git a/db/changes/10350-august/00-supplierAccountTrigger.sql b/db/changes/10350-august/00-supplierAccountTrigger.sql deleted file mode 100644 index a71b01126..000000000 --- a/db/changes/10350-august/00-supplierAccountTrigger.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TRIGGER vn.supplierAccount_AfterInsert; diff --git a/db/changes/10350-august/00-ticket_afterUpdate.sql b/db/changes/10350-august/00-ticket_afterUpdate.sql deleted file mode 100644 index 7f579d7b6..000000000 --- a/db/changes/10350-august/00-ticket_afterUpdate.sql +++ /dev/null @@ -1,33 +0,0 @@ -DROP TRIGGER IF EXISTS vn.ticket_afterUpdate; - -DELIMITER $$ -$$ -CREATE DEFINER=`root`@`%` TRIGGER vn.`ticket_afterUpdate` - AFTER UPDATE ON `ticket` - FOR EACH ROW -BEGIN - - IF !(NEW.id <=> OLD.id) - OR !(NEW.warehouseFk <=> OLD.warehouseFk) - OR !(NEW.shipped <=> OLD.shipped) THEN - CALL stock.log_add('ticket', NEW.id, OLD.id); - END IF; - - IF !(NEW.clientFk <=> OLD.clientFk) - OR !(NEW.addressFk <=> OLD.addressFk) - OR !(NEW.companyFk <=> OLD.companyFk) THEN - CALL ticket_requestRecalc(NEW.id); - END IF; - - IF NEW.clientFk = 2067 AND !(NEW.clientFk <=> OLD.clientFk) THEN - -- Fallo que se insertan no se sabe como tickets en este cliente - INSERT INTO vn.mail SET - `sender` = 'jgallego@verdnatura.es', - `replyTo` = 'jgallego@verdnatura.es', - `subject` = 'Modificado ticket al cliente 2067', - `body` = CONCAT(account.myUserGetName(), ' ha modificado el ticket ', - NEW.id); - END IF; - -END$$ -DELIMITER ; diff --git a/db/changes/10370-pickles/00-ACL.sql b/db/changes/10370-pickles/00-ACL.sql new file mode 100644 index 000000000..c5e10dec5 --- /dev/null +++ b/db/changes/10370-pickles/00-ACL.sql @@ -0,0 +1 @@ +UPDATE salix.ACL t SET t.principalId = 'employee' WHERE t.id = 269; diff --git a/db/changes/10370-pickles/00-accountingType.sql b/db/changes/10370-pickles/00-accountingType.sql new file mode 100644 index 000000000..1313e8223 --- /dev/null +++ b/db/changes/10370-pickles/00-accountingType.sql @@ -0,0 +1,3 @@ +ALTER TABLE vn.accountingType ADD maxAmount INT DEFAULT NULL NULL; + +UPDATE vn.accountingType SET maxAmount = 1000 WHERE code = 'cash'; diff --git a/db/changes/10370-pickles/00-item_getBalance.sql b/db/changes/10370-pickles/00-item_getBalance.sql new file mode 100644 index 000000000..91e5c3681 --- /dev/null +++ b/db/changes/10370-pickles/00-item_getBalance.sql @@ -0,0 +1,144 @@ +DROP PROCEDURE IF EXISTS vn.item_getBalance; + +DELIMITER $$ +$$ +CREATE + definer = root@`%` procedure vn.item_getBalance(IN vItemId int, IN vWarehouse int) +BEGIN + DECLARE vDateInventory DATETIME; + DECLARE vCurdate DATE DEFAULT CURDATE(); + DECLARE vDayEnd DATETIME DEFAULT util.dayEnd(vCurdate); + + SELECT inventoried INTO vDateInventory FROM config; + SET @a = 0; + SET @currentLineFk = 0; + SET @shipped = ''; + + SELECT DATE(@shipped:= shipped) shipped, + alertLevel, + stateName, + origin, + reference, + clientFk, + name, + `in` AS invalue, + `out`, + @a := @a + IFNULL(`in`,0) - IFNULL(`out`,0) as balance, + @currentLineFk := IF (@shipped < CURDATE() + OR (@shipped = CURDATE() AND (isPicked OR alertLevel >= 2)), + lineFk,@currentLineFk) lastPreparedLineFk, + isTicket, + lineFk, + isPicked, + clientType, + claimFk + FROM + ( SELECT tr.landed AS shipped, + b.quantity AS `in`, + NULL AS `out`, + al.id AS alertLevel, + st.name AS stateName, + s.name AS name, + e.ref AS reference, + e.id AS origin, + s.id AS clientFk, + IF(al.id = 3, TRUE, FALSE) isPicked, + FALSE AS isTicket, + b.id lineFk, + NULL `order`, + NULL AS clientType, + NULL AS claimFk + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel tr ON tr.id = e.travelFk + JOIN supplier s ON s.id = e.supplierFk + JOIN alertLevel al ON al.id = + CASE + WHEN tr.shipped < CURDATE() THEN 3 + WHEN tr.shipped = CURDATE() AND tr.isReceived = TRUE THEN 3 + ELSE 0 + END + JOIN state st ON st.code = al.code + WHERE tr.landed >= vDateInventory + AND vWarehouse = tr.warehouseInFk + AND b.itemFk = vItemId + AND e.isInventory = FALSE + AND e.isRaid = FALSE + UNION ALL + + SELECT tr.shipped, + NULL, + b.quantity, + al.id, + st.name, + s.name, + e.ref, + e.id, + s.id, + IF(al.id = 3, TRUE, FALSE), + FALSE, + b.id, + NULL, + NULL, + NULL + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel tr ON tr.id = e.travelFk + JOIN warehouse w ON w.id = tr.warehouseOutFk + JOIN supplier s ON s.id = e.supplierFk + JOIN alertLevel al ON al.id = + CASE + WHEN tr.shipped < CURDATE() THEN 3 + WHEN tr.shipped = CURDATE() AND tr.isReceived = TRUE THEN 3 + ELSE 0 + END + JOIN state st ON st.code = al.code + WHERE tr.shipped >= vDateInventory + AND vWarehouse =tr.warehouseOutFk + AND s.id <> 4 + AND b.itemFk = vItemId + AND e.isInventory = FALSE + AND w.isFeedStock = FALSE + AND e.isRaid = FALSE + UNION ALL + + SELECT DATE(t.shipped), + NULL, + s.quantity, + al.id, + st.name, + t.nickname, + t.refFk, + t.id, + t.clientFk, + stk.id, + TRUE, + s.id, + st.`order`, + ct.code, + cl.id + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + LEFT JOIN ticketState ts ON ts.ticket = t.id + LEFT JOIN state st ON st.code = ts.code + JOIN client c ON c.id = t.clientFk + JOIN clientType ct ON ct.id = c.clientTypeFk + JOIN alertLevel al ON al.id = + CASE + WHEN t.shipped < curdate() THEN 3 + WHEN t.shipped > util.dayEnd(curdate()) THEN 0 + ELSE IFNULL(ts.alertLevel, 0) + END + LEFT JOIN state stPrep ON stPrep.`code` = 'PREPARED' + LEFT JOIN saleTracking stk ON stk.saleFk = s.id AND stk.stateFk = stPrep.id + LEFT JOIN claim cl ON cl.ticketFk = t.id + WHERE t.shipped >= vDateInventory + AND s.itemFk = vItemId + AND vWarehouse =t.warehouseFk + ORDER BY shipped, alertLevel DESC, isTicket, `order` DESC, isPicked DESC, `in` DESC, `out` DESC + ) AS itemDiary; + +END; +$$ +DELIMITER ; + diff --git a/db/changes/10370-pickles/00-payMethod.sql b/db/changes/10370-pickles/00-payMethod.sql new file mode 100644 index 000000000..ac6429b99 --- /dev/null +++ b/db/changes/10370-pickles/00-payMethod.sql @@ -0,0 +1,4 @@ +ALTER TABLE vn.payMethod CHANGE ibanRequired ibanRequiredForClients tinyint(3) DEFAULT 0 NULL; +ALTER TABLE vn.payMethod ADD ibanRequiredForSuppliers tinyint(3) DEFAULT 0 NULL; +ALTER TABLE vn.payMethod CHANGE ibanRequiredForSuppliers ibanRequiredForSuppliers tinyint(3) DEFAULT 0 NULL AFTER ibanRequiredForClients; +UPDATE vn.payMethod SET ibanRequiredForSuppliers = 1 WHERE code = 'wireTransfer'; \ No newline at end of file diff --git a/db/changes/10370-pickles/00-silexACL.sql b/db/changes/10370-pickles/00-silexACL.sql new file mode 100644 index 000000000..82623baf0 --- /dev/null +++ b/db/changes/10370-pickles/00-silexACL.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.silexACL MODIFY module VARCHAR(50) NOT NULL; +ALTER TABLE vn.silexACL MODIFY method VARCHAR(50) NOT NULL; \ No newline at end of file diff --git a/db/changes/10370-pickles/00-ticket_getProblems.sql b/db/changes/10370-pickles/00-ticket_getProblems.sql new file mode 100644 index 000000000..2ee057cd2 --- /dev/null +++ b/db/changes/10370-pickles/00-ticket_getProblems.sql @@ -0,0 +1,48 @@ +drop procedure `vn`.`ticket_getProblems`; + +DELIMITER $$ +$$ +create + definer = root@`%` procedure `vn`.`ticket_getProblems`(IN vIsTodayRelative tinyint(1)) +BEGIN +/** + * Calcula los problemas para un conjunto de tickets. + * Agrupados por ticket + * + * @table tmp.sale_getProblems(ticketFk, clientFk, warehouseFk, shipped) Identificadores de los tickets a calcular + * @return tmp.ticket_problems + */ + CALL sale_getProblems(vIsTodayRelative); + + DROP TEMPORARY TABLE IF EXISTS tmp.ticket_problems; + CREATE TEMPORARY TABLE tmp.ticket_problems + (PRIMARY KEY (ticketFk)) + ENGINE = MEMORY + SELECT + ticketFk, + MAX(p.isFreezed) AS isFreezed, + MAX(p.risk) AS risk, + MAX(p.hasHighRisk) AS hasHighRisk, + MAX(p.hasTicketRequest) AS hasTicketRequest, + MIN(p.isAvailable) AS isAvailable, + MAX(p.itemShortage) AS itemShortage, + MIN(p.isTaxDataChecked) AS isTaxDataChecked, + MAX(p.hasComponentLack) AS hasComponentLack, + 0 AS totalProblems + FROM tmp.sale_problems p + GROUP BY ticketFk; + + UPDATE tmp.ticket_problems tp + SET tp.totalProblems = ( + (tp.isFreezed) + + IF(tp.risk, TRUE, FALSE) + + (tp.hasTicketRequest) + + (tp.isAvailable = 0) + + (tp.isTaxDataChecked = 0) + + (tp.hasComponentLack) + ); + + DROP TEMPORARY TABLE + tmp.sale_problems; +END;;$$ +DELIMITER ; \ No newline at end of file diff --git a/db/changes/10380-allsaints/00-defaultViewConfig.sql b/db/changes/10380-allsaints/00-defaultViewConfig.sql new file mode 100644 index 000000000..e4b2f6c3d --- /dev/null +++ b/db/changes/10380-allsaints/00-defaultViewConfig.sql @@ -0,0 +1,14 @@ +CREATE TABLE `salix`.`defaultViewConfig` +( + tableCode VARCHAR(25) not null, + columns JSON not null +) +comment 'The default configuration of columns for views'; + +INSERT INTO `salix`.`defaultViewConfig` (tableCode, columns) + VALUES + ('itemsIndex', '{"intrastat":false,"stemMultiplier":false,"landed":false}'), + ('latestBuys', '{"intrastat":false,"description":false,"density":false,"isActive":false,"freightValue":false,"packageValue":false,"isIgnored":false,"price2":false,"minPrice":true,"ektFk":false,"weight":false,"id":true,"packing":true,"grouping":true,"quantity":true,"size":false,"name":true,"code":true,"origin":true,"family":true,"entryFk":true,"buyingValue":true,"comissionValue":false,"price3":true,"packageFk":true,"packingOut":true}'), + ('ticketsMonitor', '{"id":false}'); + + \ No newline at end of file diff --git a/db/dump/dumpedFixtures.sql b/db/dump/dumpedFixtures.sql index 9cb7e9a0c..3b2d3f431 100644 --- a/db/dump/dumpedFixtures.sql +++ b/db/dump/dumpedFixtures.sql @@ -22,7 +22,7 @@ USE `util`; LOCK TABLES `config` WRITE; /*!40000 ALTER TABLE `config` DISABLE KEYS */; -INSERT INTO `config` VALUES (1,'10330',0,'production',NULL); +INSERT INTO `config` VALUES (1,'10360',0,'production',NULL); /*!40000 ALTER TABLE `config` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -34,7 +34,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-08-31 14:42:28 +-- Dump completed on 2021-11-08 8:19:54 USE `account`; -- MariaDB dump 10.19 Distrib 10.6.4-MariaDB, for Linux (x86_64) -- @@ -58,7 +58,7 @@ USE `account`; LOCK TABLES `role` WRITE; /*!40000 ALTER TABLE `role` DISABLE KEYS */; -INSERT INTO `role` VALUES (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 equipo/departamento',1,'2017-05-19 07:04:58','2021-06-30 13:29:30'),(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',1,'2018-02-26 15:28:23','2021-02-12 09:42:35'),(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'),(71,'checker','Rol de revisor con privilegios de itemPicker',1,'2020-10-02 10:50:07','2020-10-02 10:50:07'),(72,'claimManager','Personal de reclamaciones',1,'2020-10-13 10:01:32','2020-10-26 07:29:46'),(73,'financial','Departamento de finanzas',1,'2020-11-16 09:30:27','2020-11-16 09:30:27'),(74,'userPhotos','Privilegios para subir fotos de usuario',1,'2021-02-03 10:24:27','2021-02-03 10:24:27'),(75,'catalogPhotos','Privilegios para subir fotos del catálogo',1,'2021-02-03 10:24:27','2021-02-03 10:24:27'),(76,'chat','Rol para utilizar el rocket chat',1,'2020-11-27 13:06:50','2020-12-17 07:49:41'),(100,'root','Rol con todos los privilegios',0,'2018-04-23 14:33:36','2020-11-12 06:50:07'),(101,'buyerBoss','Jefe del departamento de compras',1,'2021-06-16 09:53:17','2021-06-16 09:53:17'); +INSERT INTO `role` VALUES (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 equipo/departamento',1,'2017-05-19 07:04:58','2021-06-30 13:29:30'),(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',1,'2018-02-26 15:28:23','2021-02-12 09:42:35'),(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'),(71,'checker','Rol de revisor con privilegios de itemPicker',1,'2020-10-02 10:50:07','2020-10-02 10:50:07'),(72,'claimManager','Personal de reclamaciones',1,'2020-10-13 10:01:32','2020-10-26 07:29:46'),(73,'financial','Departamento de finanzas',1,'2020-11-16 09:30:27','2020-11-16 09:30:27'),(74,'userPhotos','Privilegios para subir fotos de usuario',1,'2021-02-03 10:24:27','2021-02-03 10:24:27'),(75,'catalogPhotos','Privilegios para subir fotos del catálogo',1,'2021-02-03 10:24:27','2021-02-03 10:24:27'),(76,'chat','Rol para utilizar el rocket chat',1,'2020-11-27 13:06:50','2020-12-17 07:49:41'),(100,'root','Rol con todos los privilegios',0,'2018-04-23 14:33:36','2020-11-12 06:50:07'),(101,'buyerBoss','Jefe del departamento de compras',1,'2021-06-16 09:53:17','2021-06-16 09:53:17'),(102,'preservedBoss','Responsable preservado',1,'2021-09-14 13:45:37','2021-09-14 13:45:37'); /*!40000 ALTER TABLE `role` ENABLE KEYS */; UNLOCK TABLES; @@ -68,7 +68,7 @@ UNLOCK TABLES; LOCK TABLES `roleInherit` WRITE; /*!40000 ALTER TABLE `roleInherit` DISABLE KEYS */; -INSERT INTO `roleInherit` VALUES (1,1,2),(2,1,3),(3,1,70),(4,2,11),(5,3,11),(6,5,1),(7,5,21),(8,5,33),(124,5,76),(123,9,76),(9,9,100),(10,11,6),(11,13,1),(12,15,35),(143,15,49),(150,15,56),(114,15,76),(14,16,13),(15,16,15),(127,16,76),(16,17,20),(17,17,37),(18,17,39),(19,17,64),(145,17,67),(136,17,76),(20,18,1),(132,18,76),(21,19,21),(22,20,13),(23,20,16),(24,20,65),(134,20,76),(25,21,13),(26,21,18),(27,21,53),(131,21,76),(28,22,13),(29,22,21),(30,30,5),(31,30,20),(32,30,22),(33,30,53),(34,30,64),(118,30,76),(35,31,1),(36,32,1),(37,34,1),(38,34,13),(39,34,33),(40,35,1),(142,35,75),(129,35,76),(41,36,44),(42,36,47),(43,37,1),(139,37,74),(125,37,76),(146,38,13),(44,38,37),(45,38,64),(126,38,76),(46,39,5),(47,39,21),(48,39,57),(115,39,76),(49,40,1),(50,40,49),(51,41,13),(52,41,35),(53,41,40),(135,41,76),(54,42,35),(55,42,49),(128,42,76),(56,43,13),(57,43,42),(58,44,1),(59,45,13),(60,45,44),(61,47,1),(62,48,13),(153,48,35),(63,48,47),(64,49,36),(65,49,58),(66,50,13),(67,50,21),(68,50,35),(69,50,49),(70,50,57),(71,50,59),(133,50,76),(72,51,1),(140,51,74),(141,51,75),(73,52,13),(74,52,19),(75,52,35),(76,52,51),(137,52,76),(77,53,1),(78,54,1),(79,55,13),(80,55,54),(81,56,1),(82,57,13),(83,57,56),(138,57,76),(84,58,1),(85,59,13),(109,59,50),(87,60,5),(88,60,37),(89,60,50),(90,60,57),(130,60,76),(91,61,13),(92,61,36),(93,65,19),(94,65,35),(95,65,50),(117,65,76),(122,66,76),(96,66,100),(97,67,5),(98,67,37),(99,69,35),(152,69,47),(101,70,11),(144,70,76),(102,71,1),(103,71,58),(104,72,13),(105,72,18),(106,73,5),(108,73,19),(107,73,64),(148,101,13),(147,101,35); +INSERT INTO `roleInherit` VALUES (1,1,2),(2,1,3),(3,1,70),(4,2,11),(5,3,11),(6,5,1),(7,5,21),(8,5,33),(124,5,76),(123,9,76),(9,9,100),(10,11,6),(11,13,1),(12,15,35),(143,15,49),(150,15,56),(114,15,76),(14,16,13),(15,16,15),(127,16,76),(16,17,20),(17,17,37),(18,17,39),(19,17,64),(145,17,67),(136,17,76),(20,18,1),(132,18,76),(21,19,21),(22,20,13),(23,20,16),(24,20,65),(134,20,76),(25,21,13),(26,21,18),(27,21,53),(131,21,76),(28,22,13),(29,22,21),(30,30,5),(31,30,20),(32,30,22),(33,30,53),(34,30,64),(118,30,76),(35,31,1),(36,32,1),(37,34,1),(38,34,13),(39,34,33),(40,35,1),(142,35,75),(129,35,76),(41,36,44),(42,36,47),(43,37,1),(139,37,74),(125,37,76),(146,38,13),(44,38,37),(45,38,64),(126,38,76),(46,39,5),(47,39,21),(48,39,57),(115,39,76),(49,40,1),(50,40,49),(51,41,13),(52,41,35),(53,41,40),(135,41,76),(54,42,35),(55,42,49),(128,42,76),(56,43,13),(57,43,42),(58,44,1),(59,45,13),(60,45,44),(61,47,1),(62,48,13),(153,48,35),(63,48,47),(64,49,36),(65,49,58),(66,50,13),(67,50,21),(68,50,35),(69,50,49),(70,50,57),(71,50,59),(133,50,76),(72,51,1),(140,51,74),(141,51,75),(73,52,13),(74,52,19),(75,52,35),(76,52,51),(137,52,76),(77,53,1),(78,54,1),(79,55,13),(80,55,54),(81,56,1),(82,57,13),(83,57,56),(138,57,76),(84,58,1),(85,59,13),(109,59,50),(87,60,5),(88,60,37),(89,60,50),(90,60,57),(130,60,76),(91,61,13),(92,61,36),(93,65,19),(94,65,35),(95,65,50),(117,65,76),(122,66,76),(96,66,100),(97,67,5),(98,67,37),(99,69,35),(152,69,47),(101,70,11),(144,70,76),(102,71,1),(103,71,58),(104,72,13),(105,72,18),(106,73,5),(108,73,19),(107,73,64),(148,101,13),(147,101,35),(154,102,1); /*!40000 ALTER TABLE `roleInherit` ENABLE KEYS */; UNLOCK TABLES; @@ -78,7 +78,7 @@ UNLOCK TABLES; LOCK TABLES `roleRole` WRITE; /*!40000 ALTER TABLE `roleRole` DISABLE KEYS */; -INSERT INTO `roleRole` VALUES (44924,1,1),(44925,1,2),(44926,1,3),(44930,1,6),(44929,1,11),(44927,1,70),(44928,1,76),(44841,2,2),(44843,2,6),(44842,2,11),(44723,3,3),(44725,3,6),(44724,3,11),(44695,5,1),(44702,5,2),(44701,5,3),(44694,5,5),(44706,5,6),(44705,5,11),(44699,5,13),(44703,5,18),(44696,5,21),(44697,5,33),(44704,5,53),(44700,5,70),(44698,5,76),(44995,6,6),(44888,9,1),(44885,9,2),(44872,9,3),(44870,9,5),(44893,9,6),(44862,9,9),(44867,9,11),(44920,9,13),(44902,9,15),(44903,9,16),(44869,9,17),(44918,9,18),(44917,9,19),(44904,9,20),(44916,9,21),(44921,9,22),(44891,9,30),(44892,9,31),(44889,9,32),(44899,9,33),(44873,9,34),(44877,9,35),(44914,9,36),(44896,9,37),(44897,9,38),(44868,9,39),(44894,9,40),(44895,9,41),(44874,9,42),(44875,9,43),(44865,9,44),(44866,9,45),(44882,9,47),(44884,9,48),(44911,9,49),(44913,9,50),(44905,9,51),(44906,9,52),(44898,9,53),(44900,9,54),(44901,9,55),(44886,9,56),(44887,9,57),(44909,9,58),(44910,9,59),(44912,9,60),(44915,9,61),(44907,9,62),(44876,9,64),(44908,9,65),(44919,9,66),(44871,9,67),(44883,9,69),(44922,9,70),(44880,9,71),(44881,9,72),(44890,9,73),(44923,9,74),(44879,9,75),(44863,9,76),(44864,9,100),(44878,9,101),(44642,11,6),(44641,11,11),(45456,13,1),(45457,13,2),(45458,13,3),(45462,13,6),(45461,13,11),(45455,13,13),(45459,13,70),(45460,13,76),(45082,15,1),(45086,15,2),(45085,15,3),(45089,15,6),(45088,15,11),(45074,15,15),(45075,15,35),(45080,15,36),(45083,15,44),(45087,15,47),(45076,15,49),(45077,15,56),(45079,15,58),(45084,15,70),(45081,15,75),(45078,15,76),(45096,16,1),(45101,16,2),(45100,16,3),(45107,16,6),(45106,16,11),(45091,16,13),(45092,16,15),(45090,16,16),(45095,16,35),(45102,16,36),(45105,16,44),(45104,16,47),(45094,16,49),(45097,16,56),(45103,16,58),(45099,16,70),(45098,16,75),(45093,16,76),(44668,17,1),(44677,17,2),(44676,17,3),(44666,17,5),(44689,17,6),(44685,17,11),(44671,17,13),(44681,17,15),(44670,17,16),(44659,17,17),(44682,17,18),(44680,17,19),(44660,17,20),(44672,17,21),(44674,17,33),(44679,17,35),(44691,17,36),(44661,17,37),(44662,17,39),(44693,17,44),(44692,17,47),(44688,17,49),(44678,17,50),(44683,17,53),(44684,17,56),(44673,17,57),(44690,17,58),(44686,17,59),(44663,17,64),(44669,17,65),(44664,17,67),(44675,17,70),(44667,17,74),(44687,17,75),(44665,17,76),(45386,18,1),(45389,18,2),(45388,18,3),(45392,18,6),(45391,18,11),(45385,18,18),(45390,18,70),(45387,18,76),(45379,19,1),(45382,19,2),(45381,19,3),(45384,19,6),(45383,19,11),(45375,19,13),(45376,19,18),(45373,19,19),(45374,19,21),(45377,19,53),(45380,19,70),(45378,19,76),(45116,20,1),(45122,20,2),(45121,20,3),(45134,20,6),(45131,20,11),(45109,20,13),(45115,20,15),(45110,20,16),(45128,20,18),(45114,20,19),(45108,20,20),(45123,20,21),(45113,20,35),(45130,20,36),(45133,20,44),(45132,20,47),(45119,20,49),(45117,20,50),(45127,20,53),(45118,20,56),(45125,20,57),(45129,20,58),(45126,20,59),(45111,20,65),(45120,20,70),(45124,20,75),(45112,20,76),(45367,21,1),(45370,21,2),(45369,21,3),(45372,21,6),(45371,21,11),(45363,21,13),(45364,21,18),(45362,21,21),(45365,21,53),(45368,21,70),(45366,21,76),(45467,22,1),(45472,22,2),(45471,22,3),(45474,22,6),(45473,22,11),(45464,22,13),(45466,22,18),(45465,22,21),(45463,22,22),(45468,22,53),(45470,22,70),(45469,22,76),(44967,30,1),(44973,30,2),(44972,30,3),(44956,30,5),(44984,30,6),(44981,30,11),(44964,30,13),(44969,30,15),(44963,30,16),(44970,30,18),(44968,30,19),(44957,30,20),(44966,30,21),(44958,30,22),(44955,30,30),(44965,30,33),(44974,30,35),(44983,30,36),(44986,30,44),(44985,30,47),(44980,30,49),(44975,30,50),(44959,30,53),(44979,30,56),(44977,30,57),(44982,30,58),(44976,30,59),(44960,30,64),(44962,30,65),(44971,30,70),(44978,30,75),(44961,30,76),(44988,31,1),(44989,31,2),(44990,31,3),(44994,31,6),(44993,31,11),(44987,31,31),(44991,31,70),(44992,31,76),(44932,32,1),(44933,32,2),(44934,32,3),(44938,32,6),(44937,32,11),(44931,32,32),(44935,32,70),(44936,32,76),(45055,33,33),(44727,34,1),(44732,34,2),(44731,34,3),(44735,34,6),(44734,34,11),(44728,34,13),(44729,34,33),(44726,34,34),(44730,34,70),(44733,34,76),(44770,35,1),(44775,35,2),(44774,35,3),(44777,35,6),(44776,35,11),(44769,35,35),(44773,35,70),(44771,35,75),(44772,35,76),(45281,36,1),(45283,36,2),(45282,36,3),(45287,36,6),(45286,36,11),(45278,36,36),(45279,36,44),(45280,36,47),(45284,36,70),(45285,36,76),(45027,37,1),(45032,37,2),(45031,37,3),(45034,37,6),(45033,37,11),(45026,37,37),(45030,37,70),(45028,37,74),(45029,37,76),(45041,38,1),(45044,38,2),(45043,38,3),(45046,38,6),(45045,38,11),(45036,38,13),(45037,38,37),(45035,38,38),(45038,38,64),(45042,38,70),(45040,38,74),(45039,38,76),(44651,39,1),(44656,39,2),(44655,39,3),(44644,39,5),(44658,39,6),(44657,39,11),(44649,39,13),(44648,39,18),(44645,39,21),(44650,39,33),(44643,39,39),(44652,39,53),(44653,39,56),(44646,39,57),(44654,39,70),(44647,39,76),(44997,40,1),(45000,40,2),(44999,40,3),(45008,40,6),(45007,40,11),(45002,40,36),(44996,40,40),(45005,40,44),(45004,40,47),(44998,40,49),(45003,40,58),(45001,40,70),(45006,40,76),(45016,41,1),(45020,41,2),(45019,41,3),(45025,41,6),(45024,41,11),(45010,41,13),(45011,41,35),(45017,41,36),(45012,41,40),(45009,41,41),(45023,41,44),(45022,41,47),(45014,41,49),(45021,41,58),(45018,41,70),(45015,41,75),(45013,41,76),(44742,42,1),(44747,42,2),(44746,42,3),(44750,42,6),(44749,42,11),(44737,42,35),(44740,42,36),(44736,42,42),(44744,42,44),(44748,42,47),(44738,42,49),(44743,42,58),(44745,42,70),(44741,42,75),(44739,42,76),(44755,43,1),(44761,43,2),(44760,43,3),(44767,43,6),(44766,43,11),(44752,43,13),(44754,43,35),(44762,43,36),(44753,43,42),(44751,43,43),(44765,43,44),(44764,43,47),(44756,43,49),(44763,43,58),(44759,43,70),(44758,43,75),(44757,43,76),(44624,44,1),(44625,44,2),(44626,44,3),(44630,44,6),(44629,44,11),(44623,44,44),(44627,44,70),(44628,44,76),(44634,45,1),(44636,45,2),(44635,45,3),(44640,45,6),(44639,45,11),(44632,45,13),(44633,45,44),(44631,45,45),(44637,45,70),(44638,45,76),(44811,47,1),(44812,47,2),(44813,47,3),(44817,47,6),(44816,47,11),(44810,47,47),(44814,47,70),(44815,47,76),(44835,48,1),(44838,48,2),(44837,48,3),(44840,48,6),(44839,48,11),(44830,48,13),(44831,48,35),(44832,48,47),(44829,48,48),(44836,48,70),(44834,48,75),(44833,48,76),(45222,49,1),(45225,49,2),(45224,49,3),(45228,49,6),(45227,49,11),(45218,49,36),(45221,49,44),(45220,49,47),(45217,49,49),(45219,49,58),(45223,49,70),(45226,49,76),(45270,50,1),(45275,50,2),(45274,50,3),(45277,50,6),(45276,50,11),(45257,50,13),(45269,50,18),(45258,50,21),(45259,50,35),(45266,50,36),(45272,50,44),(45271,50,47),(45260,50,49),(45256,50,50),(45268,50,53),(45264,50,56),(45261,50,57),(45265,50,58),(45262,50,59),(45273,50,70),(45267,50,75),(45263,50,76),(45136,51,1),(45141,51,2),(45140,51,3),(45144,51,6),(45143,51,11),(45135,51,51),(45139,51,70),(45137,51,74),(45138,51,75),(45142,51,76),(45154,52,1),(45159,52,2),(45158,52,3),(45161,52,6),(45160,52,11),(45146,52,13),(45156,52,18),(45147,52,19),(45153,52,21),(45148,52,35),(45149,52,51),(45145,52,52),(45155,52,53),(45157,52,70),(45151,52,74),(45152,52,75),(45150,52,76),(45048,53,1),(45049,53,2),(45050,53,3),(45054,53,6),(45053,53,11),(45047,53,53),(45051,53,70),(45052,53,76),(45057,54,1),(45058,54,2),(45059,54,3),(45063,54,6),(45062,54,11),(45056,54,54),(45060,54,70),(45061,54,76),(45067,55,1),(45069,55,2),(45068,55,3),(45073,55,6),(45072,55,11),(45065,55,13),(45066,55,54),(45064,55,55),(45070,55,70),(45071,55,76),(44845,56,1),(44846,56,2),(44847,56,3),(44851,56,6),(44850,56,11),(44844,56,56),(44848,56,70),(44849,56,76),(44856,57,1),(44859,57,2),(44858,57,3),(44861,57,6),(44860,57,11),(44853,57,13),(44854,57,56),(44852,57,57),(44857,57,70),(44855,57,76),(45188,58,1),(45189,58,2),(45190,58,3),(45194,58,6),(45193,58,11),(45187,58,58),(45191,58,70),(45192,58,76),(45199,59,1),(45209,59,2),(45208,59,3),(45216,59,6),(45215,59,11),(45196,59,13),(45206,59,18),(45198,59,21),(45200,59,35),(45210,59,36),(45214,59,44),(45213,59,47),(45201,59,49),(45197,59,50),(45205,59,53),(45212,59,56),(45202,59,57),(45211,59,58),(45195,59,59),(45207,59,70),(45204,59,75),(45203,59,76),(45239,60,1),(45251,60,2),(45250,60,3),(45230,60,5),(45255,60,6),(45254,60,11),(45235,60,13),(45248,60,18),(45238,60,21),(45237,60,33),(45240,60,35),(45245,60,36),(45231,60,37),(45253,60,44),(45252,60,47),(45241,60,49),(45232,60,50),(45247,60,53),(45243,60,56),(45233,60,57),(45244,60,58),(45242,60,59),(45229,60,60),(45249,60,70),(45236,60,74),(45246,60,75),(45234,60,76),(45292,61,1),(45296,61,2),(45295,61,3),(45299,61,6),(45298,61,11),(45289,61,13),(45290,61,36),(45291,61,44),(45293,61,47),(45288,61,61),(45294,61,70),(45297,61,76),(45162,62,62),(44768,64,64),(45170,65,1),(45179,65,2),(45178,65,3),(45186,65,6),(45185,65,11),(45168,65,13),(45181,65,18),(45164,65,19),(45171,65,21),(45165,65,35),(45176,65,36),(45184,65,44),(45183,65,47),(45172,65,49),(45166,65,50),(45180,65,53),(45182,65,56),(45173,65,57),(45175,65,58),(45174,65,59),(45163,65,65),(45177,65,70),(45169,65,75),(45167,65,76),(45420,66,1),(45416,66,2),(45403,66,3),(45401,66,5),(45425,66,6),(45419,66,9),(45398,66,11),(45451,66,13),(45434,66,15),(45435,66,16),(45400,66,17),(45450,66,18),(45449,66,19),(45436,66,20),(45448,66,21),(45452,66,22),(45423,66,30),(45424,66,31),(45421,66,32),(45431,66,33),(45404,66,34),(45408,66,35),(45446,66,36),(45428,66,37),(45429,66,38),(45399,66,39),(45426,66,40),(45427,66,41),(45405,66,42),(45406,66,43),(45396,66,44),(45397,66,45),(45413,66,47),(45415,66,48),(45443,66,49),(45445,66,50),(45437,66,51),(45438,66,52),(45430,66,53),(45432,66,54),(45433,66,55),(45417,66,56),(45418,66,57),(45441,66,58),(45442,66,59),(45444,66,60),(45447,66,61),(45439,66,62),(45407,66,64),(45440,66,65),(45393,66,66),(45402,66,67),(45414,66,69),(45453,66,70),(45411,66,71),(45412,66,72),(45422,66,73),(45454,66,74),(45410,66,75),(45394,66,76),(45395,66,100),(45409,66,101),(44711,67,1),(44719,67,2),(44718,67,3),(44708,67,5),(44722,67,6),(44721,67,11),(44716,67,13),(44715,67,18),(44710,67,21),(44712,67,33),(44709,67,37),(44720,67,53),(44707,67,67),(44717,67,70),(44714,67,74),(44713,67,76),(44822,69,1),(44826,69,2),(44825,69,3),(44828,69,6),(44827,69,11),(44819,69,35),(44820,69,47),(44818,69,69),(44824,69,70),(44821,69,75),(44823,69,76),(45478,70,6),(45476,70,11),(45475,70,70),(45477,70,76),(44792,71,1),(44795,71,2),(44794,71,3),(44799,71,6),(44798,71,11),(44793,71,58),(44796,71,70),(44791,71,71),(44797,71,76),(44804,72,1),(44806,72,2),(44805,72,3),(44809,72,6),(44808,72,11),(44801,72,13),(44802,72,18),(44807,72,70),(44800,72,72),(44803,72,76),(44945,73,1),(44950,73,2),(44949,73,3),(44940,73,5),(44954,73,6),(44953,73,11),(44947,73,13),(44951,73,18),(44941,73,19),(44944,73,21),(44943,73,33),(44952,73,53),(44942,73,64),(44948,73,70),(44939,73,73),(44946,73,76),(45479,74,74),(44789,75,75),(44790,76,76),(45326,100,1),(45322,100,2),(45308,100,3),(45306,100,5),(45331,100,6),(45325,100,9),(45303,100,11),(45358,100,13),(45340,100,15),(45341,100,16),(45305,100,17),(45356,100,18),(45355,100,19),(45342,100,20),(45354,100,21),(45359,100,22),(45329,100,30),(45330,100,31),(45327,100,32),(45337,100,33),(45309,100,34),(45313,100,35),(45352,100,36),(45334,100,37),(45335,100,38),(45304,100,39),(45332,100,40),(45333,100,41),(45310,100,42),(45311,100,43),(45301,100,44),(45302,100,45),(45319,100,47),(45321,100,48),(45349,100,49),(45351,100,50),(45343,100,51),(45344,100,52),(45336,100,53),(45338,100,54),(45339,100,55),(45323,100,56),(45324,100,57),(45347,100,58),(45348,100,59),(45350,100,60),(45353,100,61),(45345,100,62),(45312,100,64),(45346,100,65),(45357,100,66),(45307,100,67),(45320,100,69),(45360,100,70),(45317,100,71),(45318,100,72),(45328,100,73),(45361,100,74),(45315,100,75),(45316,100,76),(45300,100,100),(45314,100,101),(44782,101,1),(44786,101,2),(44785,101,3),(44788,101,6),(44787,101,11),(44779,101,13),(44780,101,35),(44784,101,70),(44781,101,75),(44783,101,76),(44778,101,101); +INSERT INTO `roleRole` VALUES (45782,1,1),(45783,1,2),(45784,1,3),(45788,1,6),(45787,1,11),(45785,1,70),(45786,1,76),(45698,2,2),(45700,2,6),(45699,2,11),(45580,3,3),(45582,3,6),(45581,3,11),(45552,5,1),(45559,5,2),(45558,5,3),(45551,5,5),(45563,5,6),(45562,5,11),(45556,5,13),(45560,5,18),(45553,5,21),(45554,5,33),(45561,5,53),(45557,5,70),(45555,5,76),(45853,6,6),(45745,9,1),(45742,9,2),(45729,9,3),(45727,9,5),(45750,9,6),(45719,9,9),(45724,9,11),(45778,9,13),(45759,9,15),(45760,9,16),(45726,9,17),(45776,9,18),(45775,9,19),(45761,9,20),(45774,9,21),(45779,9,22),(45748,9,30),(45749,9,31),(45746,9,32),(45756,9,33),(45730,9,34),(45734,9,35),(45772,9,36),(45753,9,37),(45754,9,38),(45725,9,39),(45751,9,40),(45752,9,41),(45731,9,42),(45732,9,43),(45722,9,44),(45723,9,45),(45739,9,47),(45741,9,48),(45769,9,49),(45771,9,50),(45762,9,51),(45763,9,52),(45755,9,53),(45757,9,54),(45758,9,55),(45743,9,56),(45744,9,57),(45766,9,58),(45767,9,59),(45770,9,60),(45773,9,61),(45764,9,62),(45733,9,64),(45765,9,65),(45777,9,66),(45728,9,67),(45740,9,69),(45780,9,70),(45737,9,71),(45738,9,72),(45747,9,73),(45781,9,74),(45736,9,75),(45720,9,76),(45721,9,100),(45735,9,101),(45768,9,102),(45499,11,6),(45498,11,11),(46324,13,1),(46325,13,2),(46326,13,3),(46330,13,6),(46329,13,11),(46323,13,13),(46327,13,70),(46328,13,76),(45940,15,1),(45944,15,2),(45943,15,3),(45947,15,6),(45946,15,11),(45932,15,15),(45933,15,35),(45938,15,36),(45941,15,44),(45945,15,47),(45934,15,49),(45935,15,56),(45937,15,58),(45942,15,70),(45939,15,75),(45936,15,76),(45954,16,1),(45959,16,2),(45958,16,3),(45965,16,6),(45964,16,11),(45949,16,13),(45950,16,15),(45948,16,16),(45953,16,35),(45960,16,36),(45963,16,44),(45962,16,47),(45952,16,49),(45955,16,56),(45961,16,58),(45957,16,70),(45956,16,75),(45951,16,76),(45525,17,1),(45534,17,2),(45533,17,3),(45523,17,5),(45546,17,6),(45542,17,11),(45528,17,13),(45538,17,15),(45527,17,16),(45516,17,17),(45539,17,18),(45537,17,19),(45517,17,20),(45529,17,21),(45531,17,33),(45536,17,35),(45548,17,36),(45518,17,37),(45519,17,39),(45550,17,44),(45549,17,47),(45545,17,49),(45535,17,50),(45540,17,53),(45541,17,56),(45530,17,57),(45547,17,58),(45543,17,59),(45520,17,64),(45526,17,65),(45521,17,67),(45532,17,70),(45524,17,74),(45544,17,75),(45522,17,76),(46253,18,1),(46256,18,2),(46255,18,3),(46259,18,6),(46258,18,11),(46252,18,18),(46257,18,70),(46254,18,76),(46246,19,1),(46249,19,2),(46248,19,3),(46251,19,6),(46250,19,11),(46242,19,13),(46243,19,18),(46240,19,19),(46241,19,21),(46244,19,53),(46247,19,70),(46245,19,76),(45974,20,1),(45980,20,2),(45979,20,3),(45992,20,6),(45989,20,11),(45967,20,13),(45973,20,15),(45968,20,16),(45986,20,18),(45972,20,19),(45966,20,20),(45981,20,21),(45971,20,35),(45988,20,36),(45991,20,44),(45990,20,47),(45977,20,49),(45975,20,50),(45985,20,53),(45976,20,56),(45983,20,57),(45987,20,58),(45984,20,59),(45969,20,65),(45978,20,70),(45982,20,75),(45970,20,76),(46234,21,1),(46237,21,2),(46236,21,3),(46239,21,6),(46238,21,11),(46230,21,13),(46231,21,18),(46229,21,21),(46232,21,53),(46235,21,70),(46233,21,76),(46335,22,1),(46340,22,2),(46339,22,3),(46342,22,6),(46341,22,11),(46332,22,13),(46334,22,18),(46333,22,21),(46331,22,22),(46336,22,53),(46338,22,70),(46337,22,76),(45825,30,1),(45831,30,2),(45830,30,3),(45814,30,5),(45842,30,6),(45839,30,11),(45822,30,13),(45827,30,15),(45821,30,16),(45828,30,18),(45826,30,19),(45815,30,20),(45824,30,21),(45816,30,22),(45813,30,30),(45823,30,33),(45832,30,35),(45841,30,36),(45844,30,44),(45843,30,47),(45838,30,49),(45833,30,50),(45817,30,53),(45837,30,56),(45835,30,57),(45840,30,58),(45834,30,59),(45818,30,64),(45820,30,65),(45829,30,70),(45836,30,75),(45819,30,76),(45846,31,1),(45847,31,2),(45848,31,3),(45852,31,6),(45851,31,11),(45845,31,31),(45849,31,70),(45850,31,76),(45790,32,1),(45791,32,2),(45792,32,3),(45796,32,6),(45795,32,11),(45789,32,32),(45793,32,70),(45794,32,76),(45913,33,33),(45584,34,1),(45589,34,2),(45588,34,3),(45592,34,6),(45591,34,11),(45585,34,13),(45586,34,33),(45583,34,34),(45587,34,70),(45590,34,76),(45627,35,1),(45632,35,2),(45631,35,3),(45634,35,6),(45633,35,11),(45626,35,35),(45630,35,70),(45628,35,75),(45629,35,76),(46147,36,1),(46149,36,2),(46148,36,3),(46153,36,6),(46152,36,11),(46144,36,36),(46145,36,44),(46146,36,47),(46150,36,70),(46151,36,76),(45885,37,1),(45890,37,2),(45889,37,3),(45892,37,6),(45891,37,11),(45884,37,37),(45888,37,70),(45886,37,74),(45887,37,76),(45899,38,1),(45902,38,2),(45901,38,3),(45904,38,6),(45903,38,11),(45894,38,13),(45895,38,37),(45893,38,38),(45896,38,64),(45900,38,70),(45898,38,74),(45897,38,76),(45508,39,1),(45513,39,2),(45512,39,3),(45501,39,5),(45515,39,6),(45514,39,11),(45506,39,13),(45505,39,18),(45502,39,21),(45507,39,33),(45500,39,39),(45509,39,53),(45510,39,56),(45503,39,57),(45511,39,70),(45504,39,76),(45855,40,1),(45858,40,2),(45857,40,3),(45866,40,6),(45865,40,11),(45860,40,36),(45854,40,40),(45863,40,44),(45862,40,47),(45856,40,49),(45861,40,58),(45859,40,70),(45864,40,76),(45874,41,1),(45878,41,2),(45877,41,3),(45883,41,6),(45882,41,11),(45868,41,13),(45869,41,35),(45875,41,36),(45870,41,40),(45867,41,41),(45881,41,44),(45880,41,47),(45872,41,49),(45879,41,58),(45876,41,70),(45873,41,75),(45871,41,76),(45599,42,1),(45604,42,2),(45603,42,3),(45607,42,6),(45606,42,11),(45594,42,35),(45597,42,36),(45593,42,42),(45601,42,44),(45605,42,47),(45595,42,49),(45600,42,58),(45602,42,70),(45598,42,75),(45596,42,76),(45612,43,1),(45618,43,2),(45617,43,3),(45624,43,6),(45623,43,11),(45609,43,13),(45611,43,35),(45619,43,36),(45610,43,42),(45608,43,43),(45622,43,44),(45621,43,47),(45613,43,49),(45620,43,58),(45616,43,70),(45615,43,75),(45614,43,76),(45481,44,1),(45482,44,2),(45483,44,3),(45487,44,6),(45486,44,11),(45480,44,44),(45484,44,70),(45485,44,76),(45491,45,1),(45493,45,2),(45492,45,3),(45497,45,6),(45496,45,11),(45489,45,13),(45490,45,44),(45488,45,45),(45494,45,70),(45495,45,76),(45668,47,1),(45669,47,2),(45670,47,3),(45674,47,6),(45673,47,11),(45667,47,47),(45671,47,70),(45672,47,76),(45692,48,1),(45695,48,2),(45694,48,3),(45697,48,6),(45696,48,11),(45687,48,13),(45688,48,35),(45689,48,47),(45686,48,48),(45693,48,70),(45691,48,75),(45690,48,76),(46088,49,1),(46091,49,2),(46090,49,3),(46094,49,6),(46093,49,11),(46084,49,36),(46087,49,44),(46086,49,47),(46083,49,49),(46085,49,58),(46089,49,70),(46092,49,76),(46136,50,1),(46141,50,2),(46140,50,3),(46143,50,6),(46142,50,11),(46123,50,13),(46135,50,18),(46124,50,21),(46125,50,35),(46132,50,36),(46138,50,44),(46137,50,47),(46126,50,49),(46122,50,50),(46134,50,53),(46130,50,56),(46127,50,57),(46131,50,58),(46128,50,59),(46139,50,70),(46133,50,75),(46129,50,76),(45994,51,1),(45999,51,2),(45998,51,3),(46002,51,6),(46001,51,11),(45993,51,51),(45997,51,70),(45995,51,74),(45996,51,75),(46000,51,76),(46012,52,1),(46017,52,2),(46016,52,3),(46019,52,6),(46018,52,11),(46004,52,13),(46014,52,18),(46005,52,19),(46011,52,21),(46006,52,35),(46007,52,51),(46003,52,52),(46013,52,53),(46015,52,70),(46009,52,74),(46010,52,75),(46008,52,76),(45906,53,1),(45907,53,2),(45908,53,3),(45912,53,6),(45911,53,11),(45905,53,53),(45909,53,70),(45910,53,76),(45915,54,1),(45916,54,2),(45917,54,3),(45921,54,6),(45920,54,11),(45914,54,54),(45918,54,70),(45919,54,76),(45925,55,1),(45927,55,2),(45926,55,3),(45931,55,6),(45930,55,11),(45923,55,13),(45924,55,54),(45922,55,55),(45928,55,70),(45929,55,76),(45702,56,1),(45703,56,2),(45704,56,3),(45708,56,6),(45707,56,11),(45701,56,56),(45705,56,70),(45706,56,76),(45713,57,1),(45716,57,2),(45715,57,3),(45718,57,6),(45717,57,11),(45710,57,13),(45711,57,56),(45709,57,57),(45714,57,70),(45712,57,76),(46046,58,1),(46047,58,2),(46048,58,3),(46052,58,6),(46051,58,11),(46045,58,58),(46049,58,70),(46050,58,76),(46057,59,1),(46067,59,2),(46066,59,3),(46074,59,6),(46073,59,11),(46054,59,13),(46064,59,18),(46056,59,21),(46058,59,35),(46068,59,36),(46072,59,44),(46071,59,47),(46059,59,49),(46055,59,50),(46063,59,53),(46070,59,56),(46060,59,57),(46069,59,58),(46053,59,59),(46065,59,70),(46062,59,75),(46061,59,76),(46105,60,1),(46117,60,2),(46116,60,3),(46096,60,5),(46121,60,6),(46120,60,11),(46101,60,13),(46114,60,18),(46104,60,21),(46103,60,33),(46106,60,35),(46111,60,36),(46097,60,37),(46119,60,44),(46118,60,47),(46107,60,49),(46098,60,50),(46113,60,53),(46109,60,56),(46099,60,57),(46110,60,58),(46108,60,59),(46095,60,60),(46115,60,70),(46102,60,74),(46112,60,75),(46100,60,76),(46158,61,1),(46162,61,2),(46161,61,3),(46165,61,6),(46164,61,11),(46155,61,13),(46156,61,36),(46157,61,44),(46159,61,47),(46154,61,61),(46160,61,70),(46163,61,76),(46020,62,62),(45625,64,64),(46028,65,1),(46037,65,2),(46036,65,3),(46044,65,6),(46043,65,11),(46026,65,13),(46039,65,18),(46022,65,19),(46029,65,21),(46023,65,35),(46034,65,36),(46042,65,44),(46041,65,47),(46030,65,49),(46024,65,50),(46038,65,53),(46040,65,56),(46031,65,57),(46033,65,58),(46032,65,59),(46021,65,65),(46035,65,70),(46027,65,75),(46025,65,76),(46287,66,1),(46283,66,2),(46270,66,3),(46268,66,5),(46292,66,6),(46286,66,9),(46265,66,11),(46319,66,13),(46301,66,15),(46302,66,16),(46267,66,17),(46318,66,18),(46317,66,19),(46303,66,20),(46316,66,21),(46320,66,22),(46290,66,30),(46291,66,31),(46288,66,32),(46298,66,33),(46271,66,34),(46275,66,35),(46314,66,36),(46295,66,37),(46296,66,38),(46266,66,39),(46293,66,40),(46294,66,41),(46272,66,42),(46273,66,43),(46263,66,44),(46264,66,45),(46280,66,47),(46282,66,48),(46311,66,49),(46313,66,50),(46304,66,51),(46305,66,52),(46297,66,53),(46299,66,54),(46300,66,55),(46284,66,56),(46285,66,57),(46308,66,58),(46309,66,59),(46312,66,60),(46315,66,61),(46306,66,62),(46274,66,64),(46307,66,65),(46260,66,66),(46269,66,67),(46281,66,69),(46321,66,70),(46278,66,71),(46279,66,72),(46289,66,73),(46322,66,74),(46277,66,75),(46261,66,76),(46262,66,100),(46276,66,101),(46310,66,102),(45568,67,1),(45576,67,2),(45575,67,3),(45565,67,5),(45579,67,6),(45578,67,11),(45573,67,13),(45572,67,18),(45567,67,21),(45569,67,33),(45566,67,37),(45577,67,53),(45564,67,67),(45574,67,70),(45571,67,74),(45570,67,76),(45679,69,1),(45683,69,2),(45682,69,3),(45685,69,6),(45684,69,11),(45676,69,35),(45677,69,47),(45675,69,69),(45681,69,70),(45678,69,75),(45680,69,76),(46346,70,6),(46344,70,11),(46343,70,70),(46345,70,76),(45649,71,1),(45652,71,2),(45651,71,3),(45656,71,6),(45655,71,11),(45650,71,58),(45653,71,70),(45648,71,71),(45654,71,76),(45661,72,1),(45663,72,2),(45662,72,3),(45666,72,6),(45665,72,11),(45658,72,13),(45659,72,18),(45664,72,70),(45657,72,72),(45660,72,76),(45803,73,1),(45808,73,2),(45807,73,3),(45798,73,5),(45812,73,6),(45811,73,11),(45805,73,13),(45809,73,18),(45799,73,19),(45802,73,21),(45801,73,33),(45810,73,53),(45800,73,64),(45806,73,70),(45797,73,73),(45804,73,76),(46347,74,74),(45646,75,75),(45647,76,76),(46192,100,1),(46188,100,2),(46174,100,3),(46172,100,5),(46197,100,6),(46191,100,9),(46169,100,11),(46225,100,13),(46206,100,15),(46207,100,16),(46171,100,17),(46223,100,18),(46222,100,19),(46208,100,20),(46221,100,21),(46226,100,22),(46195,100,30),(46196,100,31),(46193,100,32),(46203,100,33),(46175,100,34),(46179,100,35),(46219,100,36),(46200,100,37),(46201,100,38),(46170,100,39),(46198,100,40),(46199,100,41),(46176,100,42),(46177,100,43),(46167,100,44),(46168,100,45),(46185,100,47),(46187,100,48),(46216,100,49),(46218,100,50),(46209,100,51),(46210,100,52),(46202,100,53),(46204,100,54),(46205,100,55),(46189,100,56),(46190,100,57),(46213,100,58),(46214,100,59),(46217,100,60),(46220,100,61),(46211,100,62),(46178,100,64),(46212,100,65),(46224,100,66),(46173,100,67),(46186,100,69),(46227,100,70),(46183,100,71),(46184,100,72),(46194,100,73),(46228,100,74),(46181,100,75),(46182,100,76),(46166,100,100),(46180,100,101),(46215,100,102),(45639,101,1),(45643,101,2),(45642,101,3),(45645,101,6),(45644,101,11),(45636,101,13),(45637,101,35),(45641,101,70),(45638,101,75),(45640,101,76),(45635,101,101),(46076,102,1),(46077,102,2),(46078,102,3),(46082,102,6),(46081,102,11),(46079,102,70),(46080,102,76),(46075,102,102); /*!40000 ALTER TABLE `roleRole` ENABLE KEYS */; UNLOCK TABLES; @@ -120,7 +120,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-08-31 14:42:28 +-- Dump completed on 2021-11-08 8:19:55 USE `salix`; -- MariaDB dump 10.19 Distrib 10.6.4-MariaDB, for Linux (x86_64) -- @@ -144,7 +144,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','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','deleteSales','*','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','claimManager'),(98,'ClaimBeginning','*','*','ALLOW','ROLE','employee'),(99,'ClaimDevelopment','*','READ','ALLOW','ROLE','employee'),(100,'ClaimDevelopment','*','WRITE','ALLOW','ROLE','claimManager'),(101,'Claim','*','*','ALLOW','ROLE','employee'),(102,'Claim','createFromSales','*','ALLOW','ROLE','employee'),(103,'ClaimEnd','importTicketSales','WRITE','ALLOW','ROLE','claimManager'),(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,'Calendar','*','READ','ALLOW','ROLE','hr'),(156,'WorkerLabour','*','READ','ALLOW','ROLE','hr'),(157,'Calendar','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','deliveryBoss'),(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','claimManager'),(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','*','WRITE','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'),(230,'ClientCredit','*','READ','ALLOW','ROLE','trainee'),(231,'ClientContact','*','READ','ALLOW','ROLE','trainee'),(232,'ClientSample','*','READ','ALLOW','ROLE','trainee'),(233,'EntryLog','*','READ','ALLOW','ROLE','buyer'),(234,'WorkerLog','*','READ','ALLOW','ROLE','salesAssistant'),(235,'CustomsAgent','*','*','ALLOW','ROLE','employee'),(236,'Buy','*','*','ALLOW','ROLE','buyer'),(237,'WorkerDms','filter','*','ALLOW','ROLE','employee'),(238,'Town','*','WRITE','ALLOW','ROLE','deliveryBoss'),(239,'Province','*','WRITE','ALLOW','ROLE','deliveryBoss'),(240,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(241,'SupplierContact','*','WRITE','ALLOW','ROLE','administrative'),(242,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(244,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(246,'Account','changePassword','*','ALLOW','ROLE','account'),(247,'UserAccount','exists','*','ALLOW','ROLE','account'),(248,'RoleMapping','*','READ','ALLOW','ROLE','account'),(249,'UserPassword','*','READ','ALLOW','ROLE','account'),(250,'Town','*','WRITE','ALLOW','ROLE','deliveryBoss'),(251,'Province','*','WRITE','ALLOW','ROLE','deliveryBoss'),(252,'Supplier','*','READ','ALLOW','ROLE','employee'),(253,'Supplier','*','WRITE','ALLOW','ROLE','administrative'),(254,'SupplierLog','*','READ','ALLOW','ROLE','employee'),(256,'Image','*','WRITE','ALLOW','ROLE','employee'),(257,'FixedPrice','*','*','ALLOW','ROLE','buyer'),(258,'PayDem','*','READ','ALLOW','ROLE','employee'),(259,'Client','createReceipt','*','ALLOW','ROLE','salesAssistant'),(260,'PrintServerQueue','*','WRITE','ALLOW','ROLE','employee'),(261,'SupplierAccount','*','*','ALLOW','ROLE','administrative'),(262,'Entry','*','*','ALLOW','ROLE','administrative'),(263,'InvoiceIn','*','*','ALLOW','ROLE','administrative'),(264,'StarredModule','*','*','ALLOW','ROLE','employee'),(265,'ItemBotanical','*','WRITE','ALLOW','ROLE','logisticBoss'),(266,'ZoneLog','*','READ','ALLOW','ROLE','employee'),(267,'Genus','*','WRITE','ALLOW','ROLE','logisticBoss'),(268,'Specie','*','WRITE','ALLOW','ROLE','logisticBoss'),(269,'InvoiceOut','createPdf','WRITE','ALLOW','ROLE','invoicing'),(270,'SupplierAddress','*','*','ALLOW','ROLE','employee'),(271,'SalesMonitor','*','*','ALLOW','ROLE','employee'),(272,'InvoiceInLog','*','*','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','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'),(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','deleteSales','*','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','claimManager'),(98,'ClaimBeginning','*','*','ALLOW','ROLE','employee'),(99,'ClaimDevelopment','*','READ','ALLOW','ROLE','employee'),(100,'ClaimDevelopment','*','WRITE','ALLOW','ROLE','claimManager'),(101,'Claim','*','*','ALLOW','ROLE','employee'),(102,'Claim','createFromSales','*','ALLOW','ROLE','employee'),(103,'ClaimEnd','importTicketSales','WRITE','ALLOW','ROLE','claimManager'),(104,'Item','*','WRITE','ALLOW','ROLE','marketingBoss'),(105,'ItemBarcode','*','WRITE','ALLOW','ROLE','marketingBoss'),(106,'ItemBotanical','*','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,'Calendar','*','READ','ALLOW','ROLE','hr'),(156,'WorkerLabour','*','READ','ALLOW','ROLE','hr'),(157,'Calendar','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'),(165,'TicketDms','*','*','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'),(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','deliveryBoss'),(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','claimManager'),(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','*','WRITE','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'),(230,'ClientCredit','*','READ','ALLOW','ROLE','trainee'),(231,'ClientContact','*','READ','ALLOW','ROLE','trainee'),(232,'ClientSample','*','READ','ALLOW','ROLE','trainee'),(233,'EntryLog','*','READ','ALLOW','ROLE','buyer'),(234,'WorkerLog','*','READ','ALLOW','ROLE','salesAssistant'),(235,'CustomsAgent','*','*','ALLOW','ROLE','employee'),(236,'Buy','*','*','ALLOW','ROLE','buyer'),(237,'WorkerDms','filter','*','ALLOW','ROLE','employee'),(238,'Town','*','WRITE','ALLOW','ROLE','deliveryBoss'),(239,'Province','*','WRITE','ALLOW','ROLE','deliveryBoss'),(240,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(241,'SupplierContact','*','WRITE','ALLOW','ROLE','administrative'),(242,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(244,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(246,'Account','changePassword','*','ALLOW','ROLE','account'),(247,'UserAccount','exists','*','ALLOW','ROLE','account'),(248,'RoleMapping','*','READ','ALLOW','ROLE','account'),(249,'UserPassword','*','READ','ALLOW','ROLE','account'),(250,'Town','*','WRITE','ALLOW','ROLE','deliveryBoss'),(251,'Province','*','WRITE','ALLOW','ROLE','deliveryBoss'),(252,'Supplier','*','READ','ALLOW','ROLE','employee'),(253,'Supplier','*','WRITE','ALLOW','ROLE','administrative'),(254,'SupplierLog','*','READ','ALLOW','ROLE','employee'),(256,'Image','*','WRITE','ALLOW','ROLE','employee'),(257,'FixedPrice','*','*','ALLOW','ROLE','buyer'),(258,'PayDem','*','READ','ALLOW','ROLE','employee'),(259,'Client','createReceipt','*','ALLOW','ROLE','salesAssistant'),(260,'PrintServerQueue','*','WRITE','ALLOW','ROLE','employee'),(261,'SupplierAccount','*','*','ALLOW','ROLE','administrative'),(262,'Entry','*','*','ALLOW','ROLE','administrative'),(263,'InvoiceIn','*','*','ALLOW','ROLE','administrative'),(264,'StarredModule','*','*','ALLOW','ROLE','employee'),(265,'ItemBotanical','*','WRITE','ALLOW','ROLE','logisticBoss'),(266,'ZoneLog','*','READ','ALLOW','ROLE','employee'),(267,'Genus','*','WRITE','ALLOW','ROLE','logisticBoss'),(268,'Specie','*','WRITE','ALLOW','ROLE','logisticBoss'),(269,'InvoiceOut','createPdf','WRITE','ALLOW','ROLE','employee'),(270,'SupplierAddress','*','*','ALLOW','ROLE','employee'),(271,'SalesMonitor','*','*','ALLOW','ROLE','employee'),(272,'InvoiceInLog','*','*','ALLOW','ROLE','employee'),(273,'InvoiceInTax','*','*','ALLOW','ROLE','administrative'),(274,'InvoiceInLog','*','READ','ALLOW','ROLE','administrative'),(275,'InvoiceOut','createManualInvoice','WRITE','ALLOW','ROLE','invoicing'),(276,'InvoiceOut','globalInvoicing','WRITE','ALLOW','ROLE','invoicing'); /*!40000 ALTER TABLE `ACL` ENABLE KEYS */; UNLOCK TABLES; @@ -176,7 +176,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-08-31 14:42:29 +-- Dump completed on 2021-11-08 8:19:56 USE `vn`; -- MariaDB dump 10.19 Distrib 10.6.4-MariaDB, for Linux (x86_64) -- @@ -200,7 +200,7 @@ USE `vn`; LOCK TABLES `alertLevel` WRITE; /*!40000 ALTER TABLE `alertLevel` DISABLE KEYS */; -INSERT INTO `alertLevel` VALUES ('FREE',0,0),('ON_PREPARATION',1,1),('PACKED',2,2),('DELIVERED',3,3); +INSERT INTO `alertLevel` VALUES ('FREE',0),('ON_PREPARATION',1),('PACKED',2),('DELIVERED',3); /*!40000 ALTER TABLE `alertLevel` ENABLE KEYS */; UNLOCK TABLES; @@ -210,7 +210,7 @@ UNLOCK TABLES; LOCK TABLES `bookingPlanner` WRITE; /*!40000 ALTER TABLE `bookingPlanner` DISABLE KEYS */; -INSERT INTO `bookingPlanner` VALUES (5,'2017-06-30 22:00:00','4770000002','WORLD',7,4,1),(6,'2017-06-30 22:00:00','4770000010','NATIONAL',3,1,1),(8,'2017-06-30 22:00:00','4770000021','NATIONAL',1,2,1),(9,'2017-06-30 22:00:00','4770000101','EQU',3,1,1),(11,'2017-06-30 22:00:00','4770000110','EQU',4,1,1),(12,'2017-06-30 22:00:00','4770000215','EQU',1,2,1),(13,'2017-06-30 22:00:00','4770000521','EQU',2,2,1),(15,'2017-06-30 22:00:00','4771000000','CEE',3,1,1),(16,'2017-06-30 22:00:00','4771000001','CEE',8,3,1),(19,'2017-07-05 11:54:58','4770000020','NATIONAL',7,4,1),(20,'2017-07-05 12:09:24','4771000000','CEE',1,2,1),(21,'2017-07-05 12:09:24','4771000000','CEE',7,4,1),(22,'2017-07-05 12:12:14','4770000002','WORLD',3,1,1),(23,'2017-07-05 12:12:14','4770000002','WORLD',1,2,1),(24,'2017-07-06 08:07:21','4770000002','WORLD',7,4,5),(25,'2017-07-06 08:07:21','HolandaRED','NATIONAL',3,1,5),(27,'2017-07-06 08:07:21','HolandaGEN','NATIONAL',1,2,5),(32,'2017-07-06 08:07:21','4771000000','CEE',3,1,5),(33,'2017-07-06 08:07:21','4771000001','CEE',8,3,5),(34,'2017-07-06 08:07:21','4770000020','NATIONAL',7,4,5),(35,'2017-07-06 08:07:21','4771000000','CEE',1,2,5),(36,'2017-07-06 08:07:21','4771000000','CEE',7,4,5),(37,'2017-07-06 08:07:21','4770000002','WORLD',3,1,5),(38,'2017-07-06 08:07:21','4770000002','WORLD',1,2,5),(70,'2017-07-06 08:08:48','4770000002','WORLD',7,4,30),(71,'2017-07-06 08:08:48','IGIC reduc','NATIONAL',3,1,30),(72,'2017-07-06 08:08:48','4770000020','NATIONAL',7,4,30),(73,'2017-07-06 08:08:48','IGIC gener','NATIONAL',1,2,30),(78,'2017-07-06 08:08:48','4770000020','NATIONAL',7,4,30),(79,'2017-07-06 08:08:48','4770000002','WORLD',3,1,30),(80,'2017-07-06 08:08:48','4770000002','WORLD',1,2,30),(81,'2017-07-05 22:00:00','IGIC cero','NATIONAL',5,5,30),(82,'2019-01-01 11:51:56','4770000504','EQU',5,5,1),(83,'2019-09-11 10:54:03','4770000405','EQU',6,5,1),(84,'2019-09-11 10:58:17','4770000004','NATIONAL',5,5,1),(85,'2019-09-18 22:00:00','4771000000','CEE',5,5,1); +INSERT INTO `bookingPlanner` VALUES (5,'2017-06-30 22:00:00','4770000002','WORLD',7,4,1),(6,'2017-06-30 22:00:00','4770000010','NATIONAL',3,1,1),(8,'2017-06-30 22:00:00','4770000021','NATIONAL',1,2,1),(9,'2017-06-30 22:00:00','4770000101','EQU',3,1,1),(11,'2017-06-30 22:00:00','4770000110','EQU',4,1,1),(12,'2017-06-30 22:00:00','4770000215','EQU',1,2,1),(13,'2017-06-30 22:00:00','4770000521','EQU',2,2,1),(15,'2017-06-30 22:00:00','4771000000','CEE',3,1,1),(16,'2017-06-30 22:00:00','4771000001','CEE',8,3,1),(19,'2017-07-05 11:54:58','4770000020','NATIONAL',7,4,1),(20,'2017-07-05 12:09:24','4771000000','CEE',1,2,1),(21,'2017-07-05 12:09:24','4771000000','CEE',7,4,1),(22,'2017-07-05 12:12:14','4770000002','WORLD',3,1,1),(23,'2017-07-05 12:12:14','4770000002','WORLD',1,2,1),(24,'2017-07-06 08:07:21','4770000002','WORLD',7,4,5),(25,'2017-07-06 08:07:21','HolandaRED','NATIONAL',3,1,5),(27,'2017-07-06 08:07:21','HolandaGEN','NATIONAL',1,2,5),(32,'2017-07-06 08:07:21','4771000000','CEE',3,1,5),(33,'2017-07-06 08:07:21','4771000001','CEE',8,3,5),(34,'2017-07-06 08:07:21','4770000020','NATIONAL',7,4,5),(35,'2017-07-06 08:07:21','4771000000','CEE',1,2,5),(36,'2017-07-06 08:07:21','4771000000','CEE',7,4,5),(37,'2017-07-06 08:07:21','4770000002','WORLD',3,1,5),(38,'2017-07-06 08:07:21','4770000002','WORLD',1,2,5),(70,'2017-07-06 08:08:48','4770000002','WORLD',7,4,30),(71,'2017-07-06 08:08:48','IGIC reduc','NATIONAL',3,1,30),(72,'2017-07-06 08:08:48','4770000020','NATIONAL',7,4,30),(73,'2017-07-06 08:08:48','IGIC gener','NATIONAL',1,2,30),(78,'2017-07-06 08:08:48','4770000020','NATIONAL',7,4,30),(79,'2017-07-06 08:08:48','4770000002','WORLD',3,1,30),(80,'2017-07-06 08:08:48','4770000002','WORLD',1,2,30),(81,'2017-07-05 22:00:00','IGIC cero','NATIONAL',5,5,30),(82,'2019-01-01 11:51:56','4770000504','EQU',5,5,1),(83,'2019-09-11 10:54:03','4770000405','EQU',6,5,1),(84,'2019-09-11 10:58:17','4770000004','NATIONAL',5,5,1),(85,'2019-09-18 22:00:00','4771000000','CEE',5,5,1),(86,'2021-10-13 22:00:00','4770000002','WORLD',5,5,1); /*!40000 ALTER TABLE `bookingPlanner` ENABLE KEYS */; UNLOCK TABLES; @@ -220,7 +220,7 @@ UNLOCK TABLES; LOCK TABLES `businessType` WRITE; /*!40000 ALTER TABLE `businessType` DISABLE KEYS */; -INSERT INTO `businessType` VALUES ('decoration','Decoración'),('events','Eventos'),('florist','Floristería'),('mortuary','Funeraria'),('others','Otros'),('restoration','Restauración'),('wholesaler','Mayorista'); +INSERT INTO `businessType` VALUES ('decoration','Decoración'),('events','Eventos'),('florist','Floristería'),('gardenCentre','Vivero'),('mortuary','Funeraria'),('officialOrganism','Organismo oficial'),('others','Otros'),('restoration','Restauración'),('wholesaler','Mayorista'); /*!40000 ALTER TABLE `businessType` ENABLE KEYS */; UNLOCK TABLES; @@ -360,7 +360,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,0,4,1),(2,'Libre',2,0,'FREE',NULL,2,1,0,0,0,1,0,4,1),(3,'OK',3,0,'OK',3,28,1,0,0,0,1,1,3,0),(4,'Impreso',4,0,'PRINTED',2,29,1,0,1,0,0,1,2,0),(5,'Preparación',6,1,'ON_PREPARATION',7,5,0,0,0,2,0,0,2,0),(6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0,1,0,3,0,0,1,0),(7,'Sin Acabar',1,0,'NOT_READY',NULL,7,0,0,0,0,0,0,4,1),(8,'Revisado',8,1,'CHECKED',NULL,8,0,1,0,3,0,0,1,0),(9,'Encajando',9,2,'PACKING',NULL,9,0,1,0,0,0,0,1,0),(10,'Encajado',10,2,'PACKED',NULL,10,0,1,0,0,0,0,0,0),(11,'Facturado',0,3,'INVOICED',NULL,11,0,1,0,0,0,0,0,0),(12,'Bloqueado',0,0,'BLOCKED',NULL,12,0,0,0,0,0,0,4,1),(13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0,1,0,0,0,0,0,0),(14,'Preparado',6,1,'PREPARED',NULL,14,0,1,0,2,0,0,1,0),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0,1,0,0,0,0,0,0),(16,'Entregado',13,3,'DELIVERED',NULL,16,0,1,0,0,0,0,0,0),(20,'Asignado',4,0,'PICKER_DESIGNED',NULL,20,1,0,0,0,0,0,2,0),(21,'Retornado',4,1,'PRINTED_BACK',6,21,0,0,0,0,0,0,2,0),(22,'¿Fecha?',2,0,'WRONG_DATE',NULL,22,0,0,0,0,0,0,4,1),(23,'URGENTE',5,1,'LAST_CALL',NULL,23,1,0,1,0,0,0,4,1),(24,'Encadenado',4,0,'CHAINED',4,24,0,0,0,0,0,0,3,1),(25,'Embarcando',3,0,'BOARDING',5,25,1,0,0,0,0,0,3,0),(26,'Prep Previa',5,1,'PREVIOUS_PREPARATION',1,26,0,0,0,1,0,0,2,0),(27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0,0,0,0,0,0,2,0),(28,'Previa OK',3,1,'OK PREVIOUS',3,28,0,0,0,1,1,1,3,0),(29,'Previa Impreso',4,1,'PRINTED PREVIOUS',2,29,0,0,1,1,0,1,3,0),(30,'Embarcado',4,1,'BOARD',5,30,0,0,0,2,0,0,3,0),(31,'Polizon Impreso',4,1,'PRINTED STOWAWAY',2,29,1,0,1,0,0,1,3,0),(32,'Polizon OK',3,1,'OK STOWAWAY',3,31,1,0,0,1,1,1,3,0),(33,'Auto_Impreso',4,0,'PRINTED_AUTO',2,29,1,0,1,0,0,1,2,0),(34,'Pte Pago',3,0,'WAITING_FOR_PAYMENT',NULL,34,0,0,0,0,0,0,4,1),(35,'Semi-Encajado',9,2,'HALF_PACKED',NULL,10,0,1,0,0,0,0,1,0); +INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING',NULL,1,0,0,0,0,0,0,4,1),(2,'Libre',2,0,'FREE',NULL,2,1,0,0,0,1,0,4,1),(3,'OK',3,0,'OK',3,28,1,0,0,0,1,1,3,0),(4,'Impreso',4,0,'PRINTED',2,29,1,0,1,0,0,1,2,0),(5,'Preparación',6,1,'ON_PREPARATION',7,5,0,0,0,2,0,0,2,0),(6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0,1,0,3,0,0,1,0),(7,'Sin Acabar',1,0,'NOT_READY',NULL,7,0,0,0,0,0,0,4,1),(8,'Revisado',8,1,'CHECKED',NULL,8,0,1,0,3,0,0,1,0),(9,'Encajando',9,2,'PACKING',NULL,9,0,1,0,0,0,0,1,0),(10,'Encajado',10,2,'PACKED',NULL,10,0,1,0,0,0,0,0,0),(11,'Facturado',0,3,'INVOICED',NULL,11,0,1,0,0,0,0,0,0),(12,'Bloqueado',0,0,'BLOCKED',NULL,12,0,0,0,0,0,0,4,1),(13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0,1,0,0,0,0,0,0),(14,'Preparado',6,1,'PREPARED',NULL,14,0,1,0,2,0,0,1,0),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0,1,0,0,0,0,0,0),(16,'Entregado',13,3,'DELIVERED',NULL,16,0,1,0,0,0,0,0,0),(20,'Asignado',4,0,'PICKER_DESIGNED',NULL,20,1,0,0,0,0,0,2,0),(21,'Retornado',4,1,'PRINTED_BACK',6,21,0,0,0,0,0,0,2,0),(22,'¿Fecha?',2,0,'WRONG_DATE',NULL,22,0,0,0,0,0,0,4,1),(23,'URGENTE',5,1,'LAST_CALL',NULL,23,1,0,1,0,0,0,4,1),(24,'Encadenado',4,0,'CHAINED',4,24,0,0,0,0,0,0,3,1),(25,'Embarcando',3,0,'BOARDING',5,25,1,0,0,0,0,0,3,0),(26,'Prep Previa',5,1,'PREVIOUS_PREPARATION',1,26,0,0,0,1,0,0,2,0),(27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0,0,0,0,0,0,2,0),(28,'Previa OK',3,1,'OK PREVIOUS',3,28,0,0,0,1,1,1,3,0),(29,'Previa Impreso',4,1,'PRINTED PREVIOUS',2,29,0,0,1,1,0,1,3,0),(30,'Embarcado',4,1,'BOARD',5,30,0,0,0,2,0,0,3,0),(31,'Polizon Impreso',4,1,'PRINTED STOWAWAY',2,29,1,0,1,0,0,1,3,0),(32,'Polizon OK',3,1,'OK STOWAWAY',3,31,1,0,0,1,1,1,3,0),(33,'Auto_Impreso',4,0,'PRINTED_AUTO',2,29,1,0,1,0,0,1,2,0),(34,'Pte Pago',3,0,'WAITING_FOR_PAYMENT',NULL,34,0,0,0,0,0,0,4,1),(35,'Semi-Encajado',9,2,'HALF_PACKED',NULL,10,0,1,0,0,0,0,1,0),(36,'Control Previa',3,1,'PREVIOUS_CONTROL',1,36,0,1,0,1,0,1,3,0); /*!40000 ALTER TABLE `state` ENABLE KEYS */; UNLOCK TABLES; @@ -370,7 +370,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,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); +INSERT INTO `sample` VALUES (1,'Carta_1','Aviso inicial por saldo deudor',0,0,1,0),(2,'Carta_2','Reiteracion de aviso por saldo deudor',0,0,1,0),(3,'Cred_Up','Notificación de aumento de crédito',0,0,1,0),(4,'Cred_down','Notificación de reducción de crédito',0,0,1,0),(5,'Pet_CC','Petición de datos bancarios B2B',0,0,1,0),(6,'SolCredito','Solicitud de crédito',0,0,1,0),(7,'LeyPago','Ley de pagos',0,0,1,0),(8,'Pet_CC_Core','Petición de datos bancarios CORE',0,0,1,0),(9,'nueva_alta','Documento de nueva alta de cliente',0,0,1,0),(10,'client_welcome','Email de bienvenida para nuevo cliente',0,0,1,0),(11,'setup_printer','Email de instalación de impresora',0,0,1,0),(12,'client-welcome','Bienvenida como nuevo cliente',1,0,1,0),(13,'printer-setup','Instalación y configuración de impresora de coronas',1,0,1,0),(14,'sepa-core','Solicitud de domiciliación bancaria',1,1,0,0),(15,'letter-debtor-st','Aviso inicial por saldo deudor',1,1,1,0),(16,'letter-debtor-nd','Aviso reiterado por saldo deudor',1,1,1,0),(17,'client-lcr','Email de solicitud de datos bancarios LCR',0,1,1,0),(18,'client-debt-statement','Extracto del cliente',1,0,1,1),(19,'credit-request','Solicitud de crédito',1,1,1,0); /*!40000 ALTER TABLE `sample` ENABLE KEYS */; UNLOCK TABLES; @@ -380,7 +380,7 @@ UNLOCK TABLES; LOCK TABLES `department` WRITE; /*!40000 ALTER TABLE `department` DISABLE KEYS */; -INSERT INTO `department` VALUES (1,NULL,'VERDNATURA',1,2,763,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,0,NULL,0),(22,NULL,'COMPRAS',3,4,NULL,72,596,2,5,0,0,0,0,NULL,'/',NULL,1,NULL,1),(23,NULL,'CAMARA',14,19,NULL,72,604,2,6,1,0,1,2,37,'/37/',NULL,0,NULL,0),(31,'IT','INFORMATICA',5,6,NULL,72,127,3,9,0,0,0,0,NULL,'/','informatica-cau',1,NULL,1),(34,NULL,'CONTABILIDAD',7,8,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,1,NULL,1),(35,NULL,'FINANZAS',9,10,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,1,NULL,1),(36,NULL,'LABORAL',11,12,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,1,NULL,1),(37,NULL,'PRODUCCION',13,52,NULL,72,230,3,11,1,0,0,17,NULL,'/',NULL,0,NULL,0),(38,NULL,'SACADO',20,21,NULL,72,230,4,14,1,0,1,0,37,'/37/',NULL,0,NULL,0),(39,NULL,'ENCAJADO',22,23,NULL,72,230,4,12,1,0,1,0,37,'/37/',NULL,0,NULL,0),(41,NULL,'ADMINISTRACION',53,54,NULL,72,599,3,8,0,0,0,0,NULL,'/',NULL,1,NULL,1),(43,NULL,'VENTAS',55,78,NULL,0,NULL,NULL,NULL,0,0,0,11,NULL,'/',NULL,1,'direccioncomercial@verdnatura.es',1),(44,NULL,'GERENCIA',79,80,NULL,72,300,2,7,0,0,0,0,NULL,'/',NULL,0,NULL,0),(45,NULL,'LOGISTICA',81,82,NULL,72,596,3,19,0,0,0,0,NULL,'/',NULL,1,NULL,1),(46,NULL,'REPARTO',83,86,NULL,72,659,3,10,0,0,0,1,NULL,'/',NULL,0,NULL,0),(48,NULL,'ALMACENAJE',87,88,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL,0,NULL,0),(49,NULL,'PROPIEDAD',89,90,NULL,72,1008,1,1,0,0,0,0,NULL,'/',NULL,0,NULL,0),(52,NULL,'CARGA AEREA',91,92,NULL,72,163,4,28,0,0,0,0,NULL,'/',NULL,0,NULL,0),(53,NULL,'MARKETING Y COMUNICACIÓN',93,94,NULL,72,1238,0,0,0,0,0,0,NULL,'/',NULL,1,NULL,1),(54,NULL,'ORNAMENTALES',95,96,NULL,72,433,3,21,0,0,0,0,NULL,'/',NULL,0,NULL,0),(55,NULL,'TALLER NATURAL',97,98,NULL,72,695,2,23,0,0,0,0,NULL,'/',NULL,0,NULL,0),(56,NULL,'TALLER ARTIFICIAL',99,100,NULL,72,1780,2,24,0,0,0,0,NULL,'/',NULL,0,NULL,0),(58,NULL,'CAMPOS',101,102,NULL,72,225,2,2,0,0,0,0,NULL,'/',NULL,0,NULL,1),(59,NULL,'MANTENIMIENTO',103,104,NULL,72,1907,4,16,0,0,0,0,NULL,'/',NULL,0,NULL,0),(60,NULL,'RECLAMACIONES',105,106,NULL,72,563,3,20,0,0,0,0,NULL,'/',NULL,1,NULL,1),(61,NULL,'VNH',107,108,NULL,73,1297,3,17,0,0,0,0,NULL,'/',NULL,0,NULL,0),(63,NULL,'VENTAS FRANCIA',56,57,NULL,72,277,2,27,0,0,1,0,43,'/43/',NULL,0,NULL,0),(66,NULL,'VERDNAMADRID',109,110,NULL,72,163,3,18,0,0,0,0,NULL,'/',NULL,0,NULL,0),(68,NULL,'COMPLEMENTOS',24,25,NULL,72,617,3,26,1,0,1,0,37,'/37/',NULL,0,NULL,0),(69,NULL,'VERDNABARNA',111,112,NULL,74,432,3,22,0,0,0,0,NULL,'/',NULL,0,NULL,0),(77,NULL,'PALETIZADO',84,85,NULL,72,230,4,15,1,0,1,0,46,'/46/',NULL,0,NULL,0),(80,NULL,'EQUIPO J VALLES',58,59,NULL,72,693,3,4,0,0,1,0,43,'/43/','jvp_equipo',1,NULL,1),(86,NULL,'LIMPIEZA',113,114,NULL,72,599,0,0,0,0,0,0,NULL,'/',NULL,0,NULL,0),(89,NULL,'COORDINACION',115,116,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL,0,NULL,0),(90,NULL,'TRAILER',117,118,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,0,NULL,0),(91,NULL,'ARTIFICIAL',26,27,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0),(92,NULL,'EQUIPO SILVERIO',60,61,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','sdc_equipo',1,NULL,1),(93,NULL,'CONFECCION',119,120,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,0,NULL,0),(94,NULL,'EQUIPO J BROCAL',62,63,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jes_equipo',1,NULL,1),(95,NULL,'EQUIPO C ZAMBRANO',64,65,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','czg_equipo',1,NULL,1),(96,NULL,'EQUIPO C LOPEZ',66,67,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','cla_equipo',1,NULL,1),(98,NULL,'EQUIPO RODRIGO',68,69,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','rhr_equipo',1,NULL,1),(101,NULL,'EQUIPO J IBAÑEZ',70,71,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jmi_equipo',1,NULL,1),(102,NULL,'EQ ROJO FV RUBEN C',28,29,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0),(103,NULL,'EQ AZUL FV A FOLQUES',30,31,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0),(104,NULL,'EQ AMARILLO FV NORMAN G',32,33,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0),(105,NULL,'EQ MORADO FV MATOU',34,35,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0),(106,NULL,'EQ VERDE PCA KEVIN GIMENEZ',36,37,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0),(107,NULL,'EQ NARANJA PCA RUBEN ZANON',38,39,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0),(110,NULL,'EQ ROSA PCA J BONDIA',40,41,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0),(111,NULL,'EQ REPONEDOR CAJAS',42,43,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0),(112,NULL,'CAMARA EQ EDGAR LLEO',15,16,NULL,0,NULL,NULL,NULL,1,0,2,0,23,'/37/23/',NULL,0,NULL,0),(113,NULL,'CAMARA EQ MARC ROCA',17,18,NULL,0,NULL,NULL,NULL,1,0,2,0,23,'/37/23/',NULL,0,NULL,0),(114,NULL,'EQ MARRON PCA JL NUEVO',44,45,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0),(115,NULL,'EQUIPO CLAUDI',72,73,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','csr_equipo',1,NULL,1),(120,NULL,'PCA PRODUCCION',46,47,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0),(121,NULL,'FV PRODUCCION',48,49,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0),(122,NULL,'PCA ALMACEN',50,51,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0),(123,NULL,'EQUIPO ELENA BASCUÑANA',74,75,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','ebt_equipo',1,NULL,1),(124,NULL,'CONTROL INTERNO',121,122,NULL,72,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,1,NULL,1),(125,NULL,'EQUIPO MIRIAM MAR',76,77,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','mir_equipo',0,NULL,0),(126,NULL,'TALLER PRESERVADO',123,124,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,0,NULL,0); +INSERT INTO `department` VALUES (1,NULL,'VERDNATURA',1,2,763,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,0,NULL,0,0),(22,NULL,'COMPRAS',3,4,NULL,72,596,2,5,0,0,0,0,NULL,'/',NULL,1,NULL,1,0),(23,NULL,'CAMARA',14,19,NULL,72,604,2,6,1,0,1,2,37,'/37/',NULL,0,NULL,0,1),(31,'IT','INFORMATICA',5,6,NULL,72,127,3,9,0,0,0,0,NULL,'/','informatica-cau',1,NULL,1,0),(34,NULL,'CONTABILIDAD',7,8,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,1,NULL,1,0),(35,NULL,'FINANZAS',9,10,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,1,NULL,1,0),(36,NULL,'LABORAL',11,12,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,1,NULL,1,0),(37,NULL,'PRODUCCION',13,52,NULL,72,230,3,11,1,0,0,17,NULL,'/',NULL,0,NULL,0,1),(38,NULL,'SACADO',20,21,NULL,72,230,4,14,1,0,1,0,37,'/37/',NULL,0,NULL,0,0),(39,NULL,'ENCAJADO',22,23,NULL,72,230,4,12,1,0,1,0,37,'/37/',NULL,0,NULL,0,0),(41,NULL,'ADMINISTRACION',53,54,NULL,72,599,3,8,0,0,0,0,NULL,'/',NULL,1,NULL,1,0),(43,NULL,'VENTAS',55,78,NULL,0,NULL,NULL,NULL,0,0,0,11,NULL,'/',NULL,1,'direccioncomercial@verdnatura.es',1,0),(44,NULL,'GERENCIA',79,80,NULL,72,300,2,7,0,0,0,0,NULL,'/',NULL,0,NULL,0,0),(45,NULL,'LOGISTICA',81,82,NULL,72,596,3,19,0,0,0,0,NULL,'/',NULL,1,NULL,1,0),(46,NULL,'REPARTO',83,86,NULL,72,659,3,10,0,0,0,1,NULL,'/',NULL,0,NULL,0,0),(48,NULL,'ALMACENAJE',87,88,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL,0,NULL,0,0),(49,NULL,'PROPIEDAD',89,90,NULL,72,1008,1,1,0,0,0,0,NULL,'/',NULL,0,NULL,0,0),(52,NULL,'CARGA AEREA',91,92,NULL,72,163,4,28,0,0,0,0,NULL,'/',NULL,0,NULL,0,0),(53,NULL,'MARKETING Y COMUNICACIÓN',93,94,NULL,72,1238,0,0,0,0,0,0,NULL,'/',NULL,1,NULL,1,0),(54,NULL,'ORNAMENTALES',95,96,NULL,72,433,3,21,0,0,0,0,NULL,'/',NULL,0,NULL,0,0),(55,NULL,'TALLER NATURAL',97,98,NULL,72,695,2,23,0,0,0,0,NULL,'/',NULL,0,NULL,0,1),(56,NULL,'TALLER ARTIFICIAL',99,100,NULL,72,1780,2,24,0,0,0,0,NULL,'/',NULL,0,NULL,0,1),(58,NULL,'CAMPOS',101,102,NULL,72,225,2,2,0,0,0,0,NULL,'/',NULL,0,NULL,1,0),(59,NULL,'MANTENIMIENTO',103,104,NULL,72,1907,4,16,0,0,0,0,NULL,'/',NULL,0,NULL,0,0),(60,NULL,'RECLAMACIONES',105,106,NULL,72,563,3,20,0,0,0,0,NULL,'/',NULL,1,NULL,1,0),(61,NULL,'VNH',107,108,NULL,73,1297,3,17,0,0,0,0,NULL,'/',NULL,0,NULL,0,0),(63,NULL,'VENTAS FRANCIA',56,57,NULL,72,277,2,27,0,0,1,0,43,'/43/',NULL,0,NULL,0,0),(66,NULL,'VERDNAMADRID',109,110,NULL,72,163,3,18,0,0,0,0,NULL,'/',NULL,0,NULL,0,0),(68,NULL,'COMPLEMENTOS',24,25,NULL,72,617,3,26,1,0,1,0,37,'/37/',NULL,0,NULL,0,0),(69,NULL,'VERDNABARNA',111,112,NULL,74,432,3,22,0,0,0,0,NULL,'/',NULL,0,NULL,0,0),(77,NULL,'PALETIZADO',84,85,NULL,72,230,4,15,1,0,1,0,46,'/46/',NULL,0,NULL,0,0),(80,NULL,'EQUIPO J VALLES',58,59,NULL,72,693,3,4,0,0,1,0,43,'/43/','jvp_equipo',1,NULL,1,0),(86,NULL,'LIMPIEZA',113,114,NULL,72,599,0,0,0,0,0,0,NULL,'/',NULL,0,NULL,0,0),(89,NULL,'COORDINACION',115,116,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL,0,NULL,0,0),(90,NULL,'TRAILER',117,118,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,0,NULL,0,0),(91,NULL,'ARTIFICIAL',26,27,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0,0),(92,NULL,'EQUIPO SILVERIO',60,61,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','sdc_equipo',1,NULL,1,0),(93,NULL,'CONFECCION',119,120,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,0,NULL,0,0),(94,NULL,'EQUIPO J BROCAL',62,63,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jes_equipo',1,NULL,1,0),(95,NULL,'EQUIPO C ZAMBRANO',64,65,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','czg_equipo',1,NULL,1,0),(96,NULL,'EQUIPO C LOPEZ',66,67,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','cla_equipo',1,NULL,1,0),(98,NULL,'EQUIPO RODRIGO',68,69,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','rhr_equipo',1,NULL,1,0),(101,NULL,'EQUIPO J IBAÑEZ',70,71,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jmi_equipo',1,NULL,1,0),(102,NULL,'EQ ROJO FV RUBEN C',28,29,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0,0),(103,NULL,'EQ AZUL FV A FOLQUES',30,31,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0,0),(104,NULL,'EQ AMARILLO FV NORMAN G',32,33,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0,0),(105,NULL,'EQ MORADO FV MATOU',34,35,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0,0),(106,NULL,'EQ VERDE PCA KEVIN GIMENEZ',36,37,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0,0),(107,NULL,'EQ NARANJA PCA RUBEN ZANON',38,39,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0,0),(110,NULL,'EQ ROSA PCA J BONDIA',40,41,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0,0),(111,NULL,'EQ REPONEDOR CAJAS',42,43,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0,0),(112,NULL,'CAMARA EQ EDGAR LLEO',15,16,NULL,0,NULL,NULL,NULL,1,0,2,0,23,'/37/23/',NULL,0,NULL,0,0),(113,NULL,'CAMARA EQ MARC ROCA',17,18,NULL,0,NULL,NULL,NULL,1,0,2,0,23,'/37/23/',NULL,0,NULL,0,0),(114,NULL,'EQ MARRON PCA JL NUEVO',44,45,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0,0),(115,NULL,'EQUIPO CLAUDI',72,73,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','csr_equipo',1,NULL,1,0),(120,NULL,'PCA PRODUCCION',46,47,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0,0),(121,NULL,'FV PRODUCCION',48,49,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0,0),(122,NULL,'PCA ALMACEN',50,51,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL,0,0),(123,NULL,'EQUIPO ELENA BASCUÑANA',74,75,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','ebt_equipo',1,NULL,1,0),(124,NULL,'CONTROL INTERNO',121,122,NULL,72,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,1,NULL,1,0),(125,NULL,'EQUIPO MIRIAM MAR',76,77,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','mir_equipo',0,NULL,0,0),(126,NULL,'PRESERVADO',123,124,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,0,NULL,0,0); /*!40000 ALTER TABLE `department` ENABLE KEYS */; UNLOCK TABLES; @@ -432,7 +432,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-08-31 14:42:30 +-- Dump completed on 2021-11-08 8:20:01 USE `cache`; -- MariaDB dump 10.19 Distrib 10.6.4-MariaDB, for Linux (x86_64) -- @@ -456,7 +456,7 @@ USE `cache`; LOCK TABLES `cache` WRITE; /*!40000 ALTER TABLE `cache` DISABLE KEYS */; -INSERT INTO `cache` VALUES (1,'equalizator','00:19:00'),(2,'available','00:06:00'),(3,'stock','00:30:00'),(4,'last_buy','00:30:00'),(5,'weekly_sales','12:00:00'),(6,'bionic','00:06:00'),(7,'sales','00:04:00'),(8,'visible','00:04:00'),(9,'item_range','00:03:00'),(10,'barcodes','01:00:00'),(11,'prod_graphic','00:17:00'),(12,'ticketShipping','00:01:00'),(13,'availableNoRaids','00:06:00'),(14,'lastBuy','00:30:00'); +INSERT INTO `cache` VALUES (1,'equalizator','00:19:00'),(2,'available','00:06:00'),(3,'stock','00:30:00'),(4,'last_buy','23:59:00'),(5,'weekly_sales','12:00:00'),(6,'bionic','00:06:00'),(7,'sales','00:04:00'),(8,'visible','00:04:00'),(9,'item_range','00:03:00'),(10,'barcodes','01:00:00'),(11,'prod_graphic','00:17:00'),(12,'ticketShipping','00:01:00'),(13,'availableNoRaids','00:06:00'),(14,'lastBuy','23:59:00'); /*!40000 ALTER TABLE `cache` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -468,7 +468,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-08-31 14:42:31 +-- Dump completed on 2021-11-08 8:20:02 USE `hedera`; -- MariaDB dump 10.19 Distrib 10.6.4-MariaDB, for Linux (x86_64) -- @@ -534,7 +534,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-08-31 14:42:31 +-- Dump completed on 2021-11-08 8:20:03 USE `postgresql`; -- MariaDB dump 10.19 Distrib 10.6.4-MariaDB, for Linux (x86_64) -- @@ -608,7 +608,7 @@ UNLOCK TABLES; LOCK TABLES `workcenter` WRITE; /*!40000 ALTER TABLE `workcenter` DISABLE KEYS */; -INSERT INTO `workcenter` VALUES (1,'Silla',20,NULL,1,'Av espioca 100',552703),(2,'Mercaflor',19,NULL,NULL,NULL,NULL),(3,'Marjales',26,20008,NULL,NULL,NULL),(4,'VNH',NULL,NULL,3,NULL,NULL),(5,'Madrid',28,2865,5,'Av constitución 3',554145),(6,'Vilassar',88,88036,2,'Cami del Crist, 33',556412),(7,'Tenerife',NULL,NULL,10,NULL,NULL),(8,NULL,NULL,NULL,NULL,NULL,NULL),(9,'Algemesi',20,1266,60,'Fenollars, 2',523549),(10,NULL,NULL,NULL,NULL,NULL,NULL); +INSERT INTO `workcenter` VALUES (1,'Silla',20,NULL,1,'Av espioca 100',552703),(2,'Mercaflor',19,NULL,NULL,NULL,NULL),(3,'Marjales',26,20008,NULL,NULL,NULL),(4,'VNH',NULL,NULL,3,NULL,NULL),(5,'Madrid',28,2868,5,'Av constitución 3',554145),(6,'Vilassar',88,88038,2,'Cami del Crist, 33',556412),(7,'Tenerife',NULL,NULL,10,NULL,NULL),(8,NULL,NULL,NULL,NULL,NULL,NULL),(9,'Algemesi',20,1351,60,'Fenollars, 2',523549),(10,NULL,NULL,NULL,NULL,NULL,NULL); /*!40000 ALTER TABLE `workcenter` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -620,7 +620,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-08-31 14:42:32 +-- Dump completed on 2021-11-08 8:20:05 USE `sage`; -- MariaDB dump 10.19 Distrib 10.6.4-MariaDB, for Linux (x86_64) -- @@ -676,4 +676,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-08-31 14:42:32 +-- Dump completed on 2021-11-08 8:20:06 diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index b949027a2..b467eedc0 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -7,7 +7,7 @@ ALTER TABLE `vn`.`zoneGeo` AUTO_INCREMENT = 1; ALTER TABLE `vn`.`ticket` AUTO_INCREMENT = 1; INSERT INTO `salix`.`AccessToken` (`id`, `ttl`, `created`, `userId`) - VALUES + VALUES ('TOTALLY_SECURE_TOKEN', '1209600', CURDATE(), 66); @@ -154,16 +154,16 @@ INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `park ('GVC', '1', '0', '1', '0', '1106'), ('HEJ', '2', '0', '1', '0', '1106'); -INSERT INTO `vn`.`accountingType`(`id`, `description`, `receiptDescription`,`code`) +INSERT INTO `vn`.`accountingType`(`id`, `description`, `receiptDescription`,`code`, `maxAmount`) VALUES - (1, 'CC y Polizas de crédito', NULL, NULL), - (2, 'Cash', 'Cash', 'cash'), - (3, 'Credit card', 'Credit Card', 'creditCard'), - (4, 'Finalcial lines', NULL, NULL), - (5, 'Other products', NULL, NULL), - (6, 'Loans', NULL, NULL), - (7, 'Leasing', NULL, NULL), - (8, 'Compensations', 'Compensations', 'compensation'); + (1, 'CC y Polizas de crédito', NULL, NULL, NULL), + (2, 'Cash', 'Cash', 'cash', 1000), + (3, 'Credit card', 'Credit Card', 'creditCard', NULL), + (4, 'Finalcial lines', NULL, NULL, NULL), + (5, 'Other products', NULL, NULL, NULL), + (6, 'Loans', NULL, NULL, NULL), + (7, 'Leasing', NULL, NULL, NULL), + (8, 'Compensations', 'Compensations', 'compensation', NULL); INSERT INTO `vn`.`bank`(`id`, `bank`, `account`, `cash`, `entityFk`, `isActive`, `currencyFk`) VALUES @@ -217,14 +217,14 @@ UPDATE `vn`.`agencyMode` SET `web` = 1, `reportMail` = 'no-reply@gothamcity.com' UPDATE `vn`.`agencyMode` SET `code` = 'refund' WHERE `id` = 23; -INSERT INTO `vn`.`payMethod`(`id`,`code`, `name`, `graceDays`, `outstandingDebt`, `ibanRequired`) +INSERT INTO `vn`.`payMethod`(`id`,`code`, `name`, `graceDays`, `outstandingDebt`, `ibanRequiredForClients`, `ibanRequiredForSuppliers`) VALUES - (1, NULL, 'PayMethod one', 0, 001, 0), - (2, NULL, 'PayMethod two', 10, 001, 0), - (3, 'compensation', 'PayMethod three', 0, 001, 0), - (4, NULL, 'PayMethod with IBAN', 0, 001, 1), - (5, NULL, 'PayMethod five', 10, 001, 0), - (8,'wireTransfer', 'WireTransfer', 5, 001, 1); + (1, NULL, 'PayMethod one', 0, 001, 0, 0), + (2, NULL, 'PayMethod two', 10, 001, 0, 0), + (3, 'compensation', 'PayMethod three', 0, 001, 0, 0), + (4, NULL, 'PayMethod with IBAN', 0, 001, 1, 0), + (5, NULL, 'PayMethod five', 10, 001, 0, 0), + (8,'wireTransfer', 'WireTransfer', 5, 001, 1, 1); INSERT INTO `vn`.`payDem`(`id`, `payDem`) VALUES @@ -485,15 +485,16 @@ INSERT INTO `vn`.`invoiceOutSerial` (`code`, `description`, `isTaxed`, `taxAreaF VALUES ('A', 'Global nacional', 1, 'NATIONAL', 0), ('T', 'Española rapida', 1, 'NATIONAL', 0), - ('V', 'Intracomunitaria global', 0, 'CEE', 1); + ('V', 'Intracomunitaria global', 0, 'CEE', 1), + ('M', 'Múltiple nacional', 1, 'NATIONAL', 0); INSERT INTO `vn`.`invoiceOut`(`id`, `serial`, `amount`, `issued`,`clientFk`, `created`, `companyFk`, `dued`, `booked`, `bankFk`, `hasPdf`) VALUES - (1, 'T', 1014.24, CURDATE(), 1101, CURDATE(), 442, CURDATE(), CURDATE(), 1, 1), - (2, 'T', 121.36, CURDATE(), 1102, CURDATE(), 442, CURDATE(), CURDATE(), 1, 1), - (3, 'T', 8.88, CURDATE(), 1103, CURDATE(), 442, CURDATE(), CURDATE(), 1, 1), - (4, 'T', 8.88, CURDATE(), 1103, CURDATE(), 442, CURDATE(), CURDATE(), 1, 1), - (5, 'A', 8.88, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1103, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 442, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 1); + (1, 'T', 1014.24, CURDATE(), 1101, CURDATE(), 442, CURDATE(), CURDATE(), 1, 0), + (2, 'T', 121.36, CURDATE(), 1102, CURDATE(), 442, CURDATE(), CURDATE(), 1, 0), + (3, 'T', 8.88, CURDATE(), 1103, CURDATE(), 442, CURDATE(), CURDATE(), 1, 0), + (4, 'T', 8.88, CURDATE(), 1103, CURDATE(), 442, CURDATE(), CURDATE(), 1, 0), + (5, 'A', 8.88, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1103, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 442, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 0); UPDATE `vn`.`invoiceOut` SET ref = 'T1111111' WHERE id = 1; UPDATE `vn`.`invoiceOut` SET ref = 'T2222222' WHERE id = 2; @@ -532,21 +533,21 @@ INSERT INTO `vn`.`invoiceOutExpence`(`id`, `invoiceOutFk`, `amount`, `expenceFk` (6, 4, 8.07, 2000000000, CURDATE()), (7, 5, 8.07, 2000000000, CURDATE()); -INSERT INTO `vn`.`zone` (`id`, `name`, `hour`, `agencyModeFk`, `travelingDays`, `price`, `bonus`, `m3Max`) +INSERT INTO `vn`.`zone` (`id`, `name`, `hour`, `agencyModeFk`, `travelingDays`, `price`, `bonus`, `itemMaxSize`) VALUES - (1, 'Zone pickup A', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 1, 0, 0, 0, 30.50), - (2, 'Zone pickup B', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 1, 0, 0, 0, 30.50), - (3, 'Zone 247 A', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 7, 1, 2, 0, 40.50), - (4, 'Zone 247 B', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 7, 1, 2, 0, 40.50), - (5, 'Zone expensive A', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 8, 1, 1000, 0, 50.50), - (6, 'Zone expensive B', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 8, 1, 1000, 0, 50.50), - (7, 'Zone refund', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 23, 0, 0, 0, 60.50), - (8, 'Zone others', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 10, 0, 0, 0, 60.50), - (9, 'Zone superMan', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 2, 0, 0, 0, NULL), - (10, 'Zone teleportation', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 3, 0, 0, 0, NULL), - (11, 'Zone pickup C', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 1, 0, 0, 0, NULL), - (12, 'Zone entanglement', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 4, 0, 0, 0, NULL), - (13, 'Zone quantum break', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 5, 0, 0, 0, NULL); + (1, 'Zone pickup A', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 1, 0, 0, 0, 100), + (2, 'Zone pickup B', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 1, 0, 0, 0, 100), + (3, 'Zone 247 A', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 7, 1, 2, 0, 100), + (4, 'Zone 247 B', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 7, 1, 2, 0, 100), + (5, 'Zone expensive A', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 8, 1, 1000, 0, 100), + (6, 'Zone expensive B', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 8, 1, 1000, 0, 100), + (7, 'Zone refund', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 23, 0, 0, 0, 100), + (8, 'Zone others', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 10, 0, 0, 0, 100), + (9, 'Zone superMan', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 2, 0, 0, 0, 100), + (10, 'Zone teleportation', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 3, 0, 0, 0, 100), + (11, 'Zone pickup C', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 1, 0, 0, 0, 100), + (12, 'Zone entanglement', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 4, 0, 0, 0, 100), + (13, 'Zone quantum break', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 5, 0, 0, 0, 100); INSERT INTO `vn`.`zoneWarehouse` (`id`, `zoneFk`, `warehouseFk`) VALUES @@ -795,25 +796,25 @@ INSERT INTO `vn`.`itemFamily`(`code`, `description`) ('SER', 'Services'), ('VT', 'Sales'); -INSERT INTO `vn`.`item`(`id`, `typeFk`, `size`, `inkFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `isOnOffer`, `expenceFk`, `isBargain`, `comment`, `relevancy`, `image`, `subName`, `minPrice`, `stars`, `family`) +INSERT INTO `vn`.`item`(`id`, `typeFk`, `size`, `inkFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenceFk`, `comment`, `relevancy`, `image`, `subName`, `minPrice`, `stars`, `family`) VALUES - (1, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 0, 2000000000, 0, NULL, 0, '1', NULL, 0, 1, 'VT'), - (2, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 0, 2000000000, 0, NULL, 0, '2', NULL, 0, 2, 'VT'), - (3, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 0, 4751000000, 0, NULL, 0, '3', NULL, 0, 5, 'VT'), - (4, 1, 60, 'YEL', 1, 1, 'Increases block', 1, 05080000, 1, 4751000000, 0, NULL, 0, '4', NULL, 0, 3, 'VT'), - (5, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 1, 4751000000, 0, NULL, 0, '5', NULL, 0, 3, 'VT'), - (6, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, '6', NULL, 0, 4, 'VT'), - (7, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, '7', NULL, 0, 4, 'VT'), - (8, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 0, 2000000000, 0, NULL, 0, '8', NULL, 0, 5, 'VT'), - (9, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 0, 2000000000, 0, NULL, 0, '9', NULL, 0, 4, 'VT'), - (10, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 0, 4751000000, 0, NULL, 0, '10', NULL, 0, 4, 'VT'), - (11, 1, 60, 'YEL', 1, 1, NULL, 1, 05080000, 1, 4751000000, 0, NULL, 0, '11', NULL, 0, 4, 'VT'), - (12, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 1, 4751000000, 0, NULL, 0, '12', NULL, 0, 3, 'VT'), - (13, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, '13', NULL, 0, 2, 'VT'), - (14, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, '', NULL, 0, 4, 'VT'), - (15, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, '', NULL, 0, 0, 'EMB'), - (16, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, '', NULL, 0, 0, 'EMB'), - (71, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 1, 4751000000, 0, NULL, 0, '', NULL, 0, 0, 'VT'); + (1, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 1, 'VT'), + (2, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 2, 'VT'), + (3, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 5, 'VT'), + (4, 1, 60, 'YEL', 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 3, 'VT'), + (5, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 3, 'VT'), + (6, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 4, 'VT'), + (7, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 4, 'VT'), + (8, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 5, 'VT'), + (9, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 4, 'VT'), + (10, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 4, 'VT'), + (11, 1, 60, 'YEL', 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 4, 'VT'), + (12, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 3, 'VT'), + (13, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 0, 2, 'VT'), + (14, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 4, 'VT'), + (15, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB'), + (16, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB'), + (71, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'VT'); -- Update the taxClass after insert of the items UPDATE `vn`.`itemTaxCountry` SET `taxClassFk` = 2 @@ -1284,11 +1285,11 @@ INSERT INTO `vn`.`supplierAddress`(`id`, `supplierFk`, `nickname`, `street`, `pr (5, 442, 'GCR building', 'Bristol district', 1, '46000', 'Gotham', '111111111', '222222222'), (6, 442, 'The Gotham Tonight building', 'Bristol district', 1, '46000', 'Gotham', '111111111', '222222222'); -INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`,`isFarmer`,`commission`, `created`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`, `taxTypeSageFk`, `withholdingSageFk`, `transactionTypeSageFk`, `workerFk`, `supplierActivityFk`) +INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`,`isFarmer`,`commission`, `created`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`, `taxTypeSageFk`, `withholdingSageFk`, `transactionTypeSageFk`, `workerFk`, `supplierActivityFk`, `isPayMethodChecked`) VALUES - (1, 'Plants SL', 'Plants nick', 4100000001, 1, '06089160W', 0, 0, CURDATE(), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants'), - (2, 'Farmer King', 'The farmer', 4000020002, 1, '87945234L', 1, 0, CURDATE(), 1, 'supplier address 2', 'SILLA', 2, 43022, 1, 2, 10, 93, 2, 8, 18, 'animals'), - (442, 'Verdnatura Levante SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, 0, CURDATE(), 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'flowerPlants'); + (1, 'Plants SL', 'Plants nick', 4100000001, 1, '06089160W', 0, 0, CURDATE(), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1), + (2, 'Farmer King', 'The farmer', 4000020002, 1, '87945234L', 1, 0, CURDATE(), 1, 'supplier address 2', 'SILLA', 2, 43022, 1, 2, 10, 93, 2, 8, 18, 'animals', 1), + (442, 'Verdnatura Levante SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, 0, CURDATE(), 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'flowerPlants', 1); INSERT INTO `vn`.`supplierContact`(`id`, `supplierFk`, `phone`, `mobile`, `email`, `observation`, `name`) VALUES @@ -1765,16 +1766,16 @@ INSERT INTO `vn`.`orderTicket`(`orderFk`, `ticketFk`) INSERT INTO `vn`.`userConfig` (`userFk`, `warehouseFk`, `companyFk`) VALUES (1, 1, 69), - (5, 1, 442), + (5, 1, 442), (9, 1, 442), (18, 3, 567); - -INSERT INTO `vn`.`receipt`(`id`, `invoiceFk`, `amountPaid`, `amountUnpaid`, `payed`, `workerFk`, `bankFk`, `clientFk`, `created`, `companyFk`, `isConciliate`) + +INSERT INTO `vn`.`receipt`(`id`, `invoiceFk`, `amountPaid`, `payed`, `workerFk`, `bankFk`, `clientFk`, `created`, `companyFk`, `isConciliate`) VALUES - (1, 'Cobro web', 100.50, 0.00, CURDATE(), 9, 1, 1101, CURDATE(), 442, 1), - (2, 'Cobro web', 200.50, 0.00, DATE_ADD(CURDATE(), INTERVAL -5 DAY), 9, 1, 1101, DATE_ADD(CURDATE(), INTERVAL -5 DAY), 442, 1), - (3, 'Cobro en efectivo', 300.00, 100.00, DATE_ADD(CURDATE(), INTERVAL -10 DAY), 9, 1, 1102, DATE_ADD(CURDATE(), INTERVAL -10 DAY), 442, 0), - (4, 'Cobro en efectivo', 400.00, -50.00, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 9, 1, 1103, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 442, 0); + (1, 'Cobro web', 100.50, CURDATE(), 9, 1, 1101, CURDATE(), 442, 1), + (2, 'Cobro web', 200.50, DATE_ADD(CURDATE(), INTERVAL -5 DAY), 9, 1, 1101, DATE_ADD(CURDATE(), INTERVAL -5 DAY), 442, 1), + (3, 'Cobro en efectivo', 300.00, DATE_ADD(CURDATE(), INTERVAL -10 DAY), 9, 1, 1102, DATE_ADD(CURDATE(), INTERVAL -10 DAY), 442, 0), + (4, 'Cobro en efectivo', 400.00, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 9, 1, 1103, DATE_ADD(CURDATE(), INTERVAL -15 DAY), 442, 0); INSERT INTO `vn`.`workerTeam`(`id`, `team`, `workerFk`) VALUES @@ -2232,8 +2233,8 @@ INSERT IGNORE INTO `vn`.`greugeConfig` (`id`, `freightPickUpPrice`) VALUES ('1', INSERT INTO `vn`.`temperature`(`code`, `name`, `description`) VALUES - ('WARM', 'Warm', 'Warm'), - ('COOL', 'Cool', 'Cool'); + ('warm', 'Warm', 'Warm'), + ('cool', 'Cool', 'Cool'); INSERT INTO `vn`.`thermograph`(`id`, `model`) VALUES diff --git a/db/dump/structure.sql b/db/dump/structure.sql index 1565e029f..68f320ec6 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -198,6 +198,22 @@ CREATE TABLE `mailAliasAccount` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Mail alias that is assigned to each account'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `mailClientAccess` +-- + +DROP TABLE IF EXISTS `mailClientAccess`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `mailClientAccess` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `client` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, + `action` set('OK','REJECT') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'REJECT', + PRIMARY KEY (`id`), + UNIQUE KEY `mailFrom` (`client`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `mailConfig` -- @@ -227,6 +243,22 @@ CREATE TABLE `mailForward` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Mail forwarding'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `mailSenderAccess` +-- + +DROP TABLE IF EXISTS `mailSenderAccess`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `mailSenderAccess` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `sender` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, + `action` set('OK','REJECT') NOT NULL DEFAULT 'REJECT', + PRIMARY KEY (`id`), + UNIQUE KEY `mailFrom` (`sender`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Temporary table structure for view `myRole` -- @@ -501,7 +533,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER user_afterUpdate AFTER UPDATE @@ -521,12 +553,14 @@ BEGIN IF !(NEW.`role` <=> OLD.`role`) THEN - INSERT INTO vn.mail SET - `sender` = 'jgallego@verdnatura.es', - `replyTo` = 'jgallego@verdnatura.es', - `subject` = 'Rol modificado', - `body` = CONCAT(myUserGetName(), ' ha modificado el rol del usuario ', - NEW.`name`, ' de ', OLD.role, ' a ', NEW.role); + CALL vn.mail_insert('jgallego@verdnatura.es', + 'jgallego@verdnatura.es', + 'Rol modificado', + CONCAT( + myUserGetName(), + ' ha modificado el rol del usuario ', + NEW.`name`, ' de ', OLD.role, ' a ', NEW.role) + ); END IF; END */;; DELIMITER ; @@ -1641,7 +1675,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `role_syncPrivileges`() +CREATE DEFINER=`root`@`localhost` PROCEDURE `role_syncPrivileges`() BEGIN /** * Synchronizes permissions of MySQL role users based on role hierarchy. @@ -1658,9 +1692,9 @@ BEGIN DECLARE vIsMysql BOOL DEFAULT VERSION() NOT LIKE '%MariaDB%'; DECLARE vVersion INT DEFAULT SUBSTRING_INDEX(VERSION(), '.', 1); DECLARE vTplUser VARCHAR(255) DEFAULT 'any'; - DECLARE vTplHost VARCHAR(255) DEFAULT '%'; - DECLARE vRoleHost VARCHAR(255) DEFAULT 'localhost'; - DECLARE vAllHost VARCHAR(255) DEFAULT '%'; + DECLARE vTplHost VARCHAR(255); + DECLARE vUserHost VARCHAR(255) DEFAULT '%'; + DECLARE vRoleHost VARCHAR(255); DECLARE vPrefix VARCHAR(2) DEFAULT 'z-'; DECLARE vPrefixedLike VARCHAR(255); DECLARE vPassword VARCHAR(255) DEFAULT ''; @@ -1668,13 +1702,23 @@ BEGIN -- Deletes computed role users SET vPrefixedLike = CONCAT(vPrefix, '%'); + SET vRoleHost = vUserHost; IF vIsMysql THEN + SET vTplHost = 'localhost'; + DELETE FROM mysql.user WHERE `User` LIKE vPrefixedLike; ELSE + SET vTplHost = ''; + DELETE FROM mysql.global_priv - WHERE `User` LIKE vPrefixedLike; + WHERE `User` LIKE vPrefixedLike + OR JSON_EXTRACT(`Priv`, '$.plugin') = 'pam'; + + DELETE FROM mysql.roles_mapping + WHERE `User` LIKE vPrefixedLike + OR `Role` LIKE vPrefixedLike; END IF; DELETE FROM mysql.db @@ -1700,21 +1744,10 @@ BEGIN ENGINE = MEMORY SELECT id, - `name` role, + `name` `role`, CONCAT(vPrefix, `name`) prefixedRole - FROM role - WHERE hasLogin; - - DROP TEMPORARY TABLE IF EXISTS tRoleInherit; - CREATE TEMPORARY TABLE tRoleInherit - (INDEX (inheritsFrom)) - ENGINE = MEMORY - SELECT - r.prefixedRole, - ri.`name` inheritsFrom - FROM tRole r - JOIN roleRole rr ON rr.role = r.id - JOIN role ri ON ri.id = rr.inheritsFrom; + FROM `role` + WHERE hasLogin; -- Recreate role users @@ -1723,7 +1756,7 @@ BEGIN CREATE TEMPORARY TABLE tUser SELECT r.prefixedRole `User`, - vTplHost `Host`, + vRoleHost `Host`, IFNULL(t.`authentication_string`, '') `authentication_string`, IFNULL(t.`plugin`, @@ -1755,16 +1788,16 @@ BEGIN FROM tRole r LEFT JOIN mysql.user t ON t.`User` = vTplUser - AND t.`Host` = vRoleHost + AND t.`Host` = vTplHost LEFT JOIN mysql.user u ON u.`User` = r.role - AND u.`Host` = vRoleHost; + AND u.`Host` = vTplHost; IF vVersion <= 5 THEN SELECT `Password` INTO vPassword FROM mysql.user WHERE `User` = vTplUser - AND `Host` = vRoleHost; + AND `Host` = vTplHost; INSERT INTO mysql.user ( `User`, @@ -1827,55 +1860,41 @@ BEGIN FROM tUser; END IF; - DROP TEMPORARY TABLE IF EXISTS tUser; - ELSE - INSERT INTO mysql.global_priv ( - `User`, - `Host`, - `Priv` - ) - SELECT + DROP TEMPORARY TABLE tUser; + + -- Get role inheritance + + DROP TEMPORARY TABLE IF EXISTS tRoleInherit; + CREATE TEMPORARY TABLE tRoleInherit + (INDEX (inheritsFrom)) + ENGINE = MEMORY + SELECT r.prefixedRole, - vTplHost, - JSON_MERGE_PATCH( - IFNULL(t.`Priv`, '{}'), - IFNULL(u.`Priv`, '{}'), - JSON_OBJECT( - 'mysql_old_password', JSON_VALUE(t.`Priv`, '$.mysql_old_password'), - 'mysql_native_password', JSON_VALUE(t.`Priv`, '$.mysql_native_password'), - 'authentication_string', JSON_VALUE(t.`Priv`, '$.authentication_string'), - 'ssl_type', JSON_VALUE(t.`Priv`, '$.ssl_type') - ) - ) + ri.`name` inheritsFrom FROM tRole r - LEFT JOIN mysql.global_priv t - ON t.`User` = vTplUser - AND t.`Host` = vRoleHost - LEFT JOIN mysql.global_priv u - ON u.`User` = r.role - AND u.`Host` = vRoleHost; - END IF; + JOIN `roleRole` rr ON rr.role = r.id + JOIN `role` ri ON ri.id = rr.inheritsFrom; - INSERT INTO mysql.proxies_priv ( - `User`, - `Host`, - `Proxied_user`, - `Proxied_host`, - `Grantor` - ) - SELECT - '', - vAllHost, - prefixedRole, - vTplHost, - CONCAT(prefixedRole, '@', vTplHost) - FROM tRole; + -- Proxy privileges - -- Copies global privileges + INSERT INTO mysql.proxies_priv ( + `User`, + `Host`, + `Proxied_user`, + `Proxied_host`, + `Grantor` + ) + SELECT + '', + vUserHost, + prefixedRole, + vRoleHost, + CONCAT(prefixedRole, '@', vRoleHost) + FROM tRole; - DROP TEMPORARY TABLE IF EXISTS tUserPriv; + -- Global privileges - IF vIsMysql THEN + DROP TEMPORARY TABLE IF EXISTS tUserPriv; CREATE TEMPORARY TABLE tUserPriv (INDEX (prefixedRole)) ENGINE = MEMORY @@ -1913,13 +1932,13 @@ BEGIN FROM tRoleInherit r JOIN mysql.user u ON u.`User` = r.inheritsFrom - AND u.`Host`= vRoleHost + AND u.`Host`= vTplHost GROUP BY r.prefixedRole; UPDATE mysql.user u JOIN tUserPriv t ON u.`User` = t.prefixedRole - AND u.`Host` = vTplHost + AND u.`Host` = vRoleHost SET u.`Select_priv` = t.`Select_priv`, @@ -1979,167 +1998,226 @@ BEGIN = t.`Trigger_priv`, u.`Create_tablespace_priv` = t.`Create_tablespace_priv`; - ELSE - CREATE TEMPORARY TABLE tUserPriv - (INDEX (prefixedRole)) + + DROP TEMPORARY TABLE tUserPriv; + + -- Schema level privileges + + INSERT INTO mysql.db ( + `User`, + `Host`, + `Db`, + `Select_priv`, + `Insert_priv`, + `Update_priv`, + `Delete_priv`, + `Create_priv`, + `Drop_priv`, + `Grant_priv`, + `References_priv`, + `Index_priv`, + `Alter_priv`, + `Create_tmp_table_priv`, + `Lock_tables_priv`, + `Create_view_priv`, + `Show_view_priv`, + `Create_routine_priv`, + `Alter_routine_priv`, + `Execute_priv`, + `Event_priv`, + `Trigger_priv` + ) SELECT r.prefixedRole, - BIT_OR(JSON_VALUE(p.`Priv`, '$.access')) access + vRoleHost, + t.`Db`, + MAX(t.`Select_priv`), + MAX(t.`Insert_priv`), + MAX(t.`Update_priv`), + MAX(t.`Delete_priv`), + MAX(t.`Create_priv`), + MAX(t.`Drop_priv`), + MAX(t.`Grant_priv`), + MAX(t.`References_priv`), + MAX(t.`Index_priv`), + MAX(t.`Alter_priv`), + MAX(t.`Create_tmp_table_priv`), + MAX(t.`Lock_tables_priv`), + MAX(t.`Create_view_priv`), + MAX(t.`Show_view_priv`), + MAX(t.`Create_routine_priv`), + MAX(t.`Alter_routine_priv`), + MAX(t.`Execute_priv`), + MAX(t.`Event_priv`), + MAX(t.`Trigger_priv`) FROM tRoleInherit r + JOIN mysql.db t + ON t.`User` = r.inheritsFrom + AND t.`Host`= vTplHost + GROUP BY r.prefixedRole, t.`Db`; + + -- Table level privileges + + INSERT INTO mysql.tables_priv ( + `User`, + `Host`, + `Db`, + `Table_name`, + `Grantor`, + `Timestamp`, + `Table_priv`, + `Column_priv` + ) + SELECT + r.prefixedRole, + vRoleHost, + t.`Db`, + t.`Table_name`, + t.`Grantor`, + MAX(t.`Timestamp`), + IFNULL(GROUP_CONCAT(NULLIF(t.`Table_priv`, '')), ''), + IFNULL(GROUP_CONCAT(NULLIF(t.`Column_priv`, '')), '') + FROM tRoleInherit r + JOIN mysql.tables_priv t + ON t.`User` = r.inheritsFrom + AND t.`Host`= vTplHost + GROUP BY r.prefixedRole, t.`Db`, t.`Table_name`; + + -- Column level privileges + + INSERT INTO mysql.columns_priv ( + `User`, + `Host`, + `Db`, + `Table_name`, + `Column_name`, + `Timestamp`, + `Column_priv` + ) + SELECT + r.prefixedRole, + vRoleHost, + t.`Db`, + t.`Table_name`, + t.`Column_name`, + MAX(t.`Timestamp`), + IFNULL(GROUP_CONCAT(NULLIF(t.`Column_priv`, '')), '') + FROM tRoleInherit r + JOIN mysql.columns_priv t + ON t.`User` = r.inheritsFrom + AND t.`Host`= vTplHost + GROUP BY r.prefixedRole, t.`Db`, t.`Table_name`, t.`Column_name`; + + -- Routine privileges + + INSERT IGNORE INTO mysql.procs_priv ( + `User`, + `Host`, + `Db`, + `Routine_name`, + `Routine_type`, + `Grantor`, + `Timestamp`, + `Proc_priv` + ) + SELECT + r.prefixedRole, + vRoleHost, + t.`Db`, + t.`Routine_name`, + t.`Routine_type`, + t.`Grantor`, + t.`Timestamp`, + t.`Proc_priv` + FROM tRoleInherit r + JOIN mysql.procs_priv t + ON t.`User` = r.inheritsFrom + AND t.`Host`= vTplHost; + + -- Cleanup + + DROP TEMPORARY TABLE tRoleInherit; + ELSE + -- Roles + + INSERT INTO mysql.global_priv (`Host`, `User`, `Priv`) + SELECT vTplHost, prefixedRole, + JSON_OBJECT( + 'access', 0, + 'is_role', true + ) + FROM tRole r; + + INSERT INTO mysql.roles_mapping (`Host`, `User`, `Role`, `Admin_option`) + SELECT vTplHost, r.prefixedRole, i.`name`, 'N' + FROM tRole r + JOIN roleRole ri + ON ri.`role` = r.id + JOIN `role` i + ON ri.`inheritsFrom` = i.id JOIN mysql.global_priv p - ON p.`User` = r.inheritsFrom - AND p.`Host`= vRoleHost - GROUP BY r.prefixedRole; - - UPDATE mysql.global_priv p - JOIN tUserPriv t - ON p.`User` = t.prefixedRole - AND p.`Host` = vTplHost - SET - p.`Priv` = JSON_SET(p.`Priv`, '$.access', t.access); + ON p.`User` = i.`name` AND p.`Host` = vTplHost; + + -- Backward compatibility + + INSERT INTO mysql.global_priv ( + `User`, + `Host`, + `Priv` + ) + SELECT + r.prefixedRole, + vRoleHost, + JSON_MERGE_PATCH( + IFNULL(t.`Priv`, '{}'), + IFNULL(u.`Priv`, '{}'), + JSON_OBJECT( + 'mysql_old_password', JSON_VALUE(t.`Priv`, '$.mysql_old_password'), + 'mysql_native_password', JSON_VALUE(t.`Priv`, '$.mysql_native_password'), + 'authentication_string', JSON_VALUE(t.`Priv`, '$.authentication_string'), + 'ssl_type', JSON_VALUE(t.`Priv`, '$.ssl_type'), + 'default_role', r.prefixedRole, + 'is_role', FALSE + ) + ) + FROM tRole r + LEFT JOIN mysql.global_priv t + ON t.`User` = vTplUser + AND t.Host = vTplHost + LEFT JOIN mysql.global_priv u + ON u.`User` = r.role + AND u.Host = vTplHost; + + INSERT INTO mysql.roles_mapping (`Host`, `User`, `Role`, `Admin_option`) + SELECT vRoleHost, prefixedRole, prefixedRole, 'N' + FROM tRole; + + -- Accounts + + INSERT INTO mysql.global_priv (`Host`, `User`, `Priv`) + SELECT vUserHost, u.`name`, + JSON_OBJECT( + 'access', 0, + 'plugin', 'pam', + 'authentication_string', '', + 'default_role', r.`prefixedRole` + ) + FROM `user` u + JOIN account a ON a.`id` = u.`id` + JOIN tRole r ON r.`id` = u.`role` + WHERE u.`active`; + + INSERT INTO mysql.roles_mapping (`Host`, `User`, `Role`, `Admin_option`) + SELECT vUserHost, u.`name`, r.prefixedRole, 'N' + FROM `user` u + JOIN account a ON a.`id` = u.`id` + JOIN tRole r ON r.`id` = u.`role` + WHERE u.`active`; END IF; - DROP TEMPORARY TABLE tUserPriv; - - -- Copy schema level privileges - - INSERT INTO mysql.db ( - `User`, - `Host`, - `Db`, - `Select_priv`, - `Insert_priv`, - `Update_priv`, - `Delete_priv`, - `Create_priv`, - `Drop_priv`, - `Grant_priv`, - `References_priv`, - `Index_priv`, - `Alter_priv`, - `Create_tmp_table_priv`, - `Lock_tables_priv`, - `Create_view_priv`, - `Show_view_priv`, - `Create_routine_priv`, - `Alter_routine_priv`, - `Execute_priv`, - `Event_priv`, - `Trigger_priv` - ) - SELECT - r.prefixedRole, - vTplHost, - t.`Db`, - MAX(t.`Select_priv`), - MAX(t.`Insert_priv`), - MAX(t.`Update_priv`), - MAX(t.`Delete_priv`), - MAX(t.`Create_priv`), - MAX(t.`Drop_priv`), - MAX(t.`Grant_priv`), - MAX(t.`References_priv`), - MAX(t.`Index_priv`), - MAX(t.`Alter_priv`), - MAX(t.`Create_tmp_table_priv`), - MAX(t.`Lock_tables_priv`), - MAX(t.`Create_view_priv`), - MAX(t.`Show_view_priv`), - MAX(t.`Create_routine_priv`), - MAX(t.`Alter_routine_priv`), - MAX(t.`Execute_priv`), - MAX(t.`Event_priv`), - MAX(t.`Trigger_priv`) - FROM tRoleInherit r - JOIN mysql.db t - ON t.`User` = r.inheritsFrom - AND t.`Host`= vRoleHost - GROUP BY r.prefixedRole, t.`Db`; - - -- Copy table level privileges - - INSERT INTO mysql.tables_priv ( - `User`, - `Host`, - `Db`, - `Table_name`, - `Grantor`, - `Timestamp`, - `Table_priv`, - `Column_priv` - ) - SELECT - r.prefixedRole, - vTplHost, - t.`Db`, - t.`Table_name`, - t.`Grantor`, - MAX(t.`Timestamp`), - IFNULL(GROUP_CONCAT(NULLIF(t.`Table_priv`, '')), ''), - IFNULL(GROUP_CONCAT(NULLIF(t.`Column_priv`, '')), '') - FROM tRoleInherit r - JOIN mysql.tables_priv t - ON t.`User` = r.inheritsFrom - AND t.`Host`= vRoleHost - GROUP BY r.prefixedRole, t.`Db`, t.`Table_name`; - - -- Copy column level privileges - - INSERT INTO mysql.columns_priv ( - `User`, - `Host`, - `Db`, - `Table_name`, - `Column_name`, - `Timestamp`, - `Column_priv` - ) - SELECT - r.prefixedRole, - vTplHost, - t.`Db`, - t.`Table_name`, - t.`Column_name`, - MAX(t.`Timestamp`), - IFNULL(GROUP_CONCAT(NULLIF(t.`Column_priv`, '')), '') - FROM tRoleInherit r - JOIN mysql.columns_priv t - ON t.`User` = r.inheritsFrom - AND t.`Host`= vRoleHost - GROUP BY r.prefixedRole, t.`Db`, t.`Table_name`, t.`Column_name`; - - -- Copy routine privileges - - INSERT IGNORE INTO mysql.procs_priv ( - `User`, - `Host`, - `Db`, - `Routine_name`, - `Routine_type`, - `Grantor`, - `Timestamp`, - `Proc_priv` - ) - SELECT - r.prefixedRole, - vTplHost, - t.`Db`, - t.`Routine_name`, - t.`Routine_type`, - t.`Grantor`, - t.`Timestamp`, - t.`Proc_priv` - FROM tRoleInherit r - JOIN mysql.procs_priv t - ON t.`User` = r.inheritsFrom - AND t.`Host`= vRoleHost; - - -- Free memory - - DROP TEMPORARY TABLE - tRole, - tRoleInherit; + -- Cleanup + DROP TEMPORARY TABLE tRole; FLUSH PRIVILEGES; END ;; DELIMITER ; @@ -2735,14 +2813,14 @@ CREATE TABLE `indicators` ( `lastMonthLostClients` int(11) DEFAULT NULL, `lastMonthNewClients` int(11) DEFAULT NULL, `lastMonthWebBuyingRate` decimal(5,4) DEFAULT NULL, - `productionHours` decimal(10,1) DEFAULT NULL, - `dailyWorkersCost` decimal(10,0) DEFAULT NULL, - `volumeM3` decimal(10,0) DEFAULT NULL, - `salesValue` decimal(10,0) DEFAULT NULL, - `valueM3` decimal(10,0) DEFAULT NULL, - `hoursM3` decimal(5,2) DEFAULT NULL, - `workerCostM3` decimal(10,1) DEFAULT NULL, - `salesWorkersCostRate` decimal(10,2) DEFAULT NULL, + `productionHours__` decimal(10,1) DEFAULT NULL, + `dailyWorkersCost__` decimal(10,0) DEFAULT NULL, + `volumeM3__` decimal(10,0) DEFAULT NULL, + `salesValue__` decimal(10,0) DEFAULT NULL, + `valueM3__` decimal(10,0) DEFAULT NULL, + `hoursM3__` decimal(5,2) DEFAULT NULL, + `workerCostM3__` decimal(10,1) DEFAULT NULL, + `salesWorkersCostRate__` decimal(10,2) DEFAULT NULL, `thisWeekSales` decimal(10,2) DEFAULT NULL, `lastYearWeekSales` decimal(10,2) DEFAULT NULL, PRIMARY KEY (`updated`) @@ -2801,14 +2879,14 @@ SET character_set_client = utf8; `incLastMonthNewClients` tinyint NOT NULL, `lastMonthWebBuyingRate` tinyint NOT NULL, `incLastMonthWebBuyingRate` tinyint NOT NULL, - `productionHours` tinyint NOT NULL, - `dailyWorkersCost` tinyint NOT NULL, - `volumeM3` tinyint NOT NULL, - `salesValue` tinyint NOT NULL, - `valueM3` tinyint NOT NULL, - `hoursM3` tinyint NOT NULL, - `workerCostM3` tinyint NOT NULL, - `salesWorkersCostRate` tinyint NOT NULL, + `productionHours__` tinyint NOT NULL, + `dailyWorkersCost__` tinyint NOT NULL, + `volumeM3__` tinyint NOT NULL, + `salesValue__` tinyint NOT NULL, + `valueM3__` tinyint NOT NULL, + `hoursM3__` tinyint NOT NULL, + `workerCostM3__` tinyint NOT NULL, + `salesWorkersCostRate__` tinyint NOT NULL, `thisWeekSales` tinyint NOT NULL, `lastYearWeekSales` tinyint NOT NULL ) ENGINE=MyISAM */; @@ -2838,14 +2916,14 @@ CREATE TABLE `m3` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `m3Silla` +-- Temporary table structure for view `m3Silla__` -- -DROP TABLE IF EXISTS `m3Silla`; -/*!50001 DROP VIEW IF EXISTS `m3Silla`*/; +DROP TABLE IF EXISTS `m3Silla__`; +/*!50001 DROP VIEW IF EXISTS `m3Silla__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE TABLE `m3Silla` ( +/*!50001 CREATE TABLE `m3Silla__` ( `fecha` tinyint NOT NULL, `year` tinyint NOT NULL, `month` tinyint NOT NULL, @@ -2857,34 +2935,6 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; --- --- Temporary table structure for view `m3analisis` --- - -DROP TABLE IF EXISTS `m3analisis`; -/*!50001 DROP VIEW IF EXISTS `m3analisis`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `m3analisis` ( - `fecha` tinyint NOT NULL, - `year` tinyint NOT NULL, - `month` tinyint NOT NULL, - `week` tinyint NOT NULL, - `day` tinyint NOT NULL, - `dayName` tinyint NOT NULL, - `Volumen` tinyint NOT NULL, - `Euros` tinyint NOT NULL, - `Departamento` tinyint NOT NULL, - `Horas` tinyint NOT NULL, - `Salarios` tinyint NOT NULL, - `tiempoM3` tinyint NOT NULL, - `valorM3` tinyint NOT NULL, - `costeLaboralM3` tinyint NOT NULL, - `costeEuros` tinyint NOT NULL, - `precioHora` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - -- -- Temporary table structure for view `manaCustomer` -- @@ -2962,28 +3012,6 @@ CREATE TABLE `mermasCache__` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Temporary table structure for view `mermas__` --- - -DROP TABLE IF EXISTS `mermas__`; -/*!50001 DROP VIEW IF EXISTS `mermas__`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `mermas__` ( - `Comprador` tinyint NOT NULL, - `Familia` tinyint NOT NULL, - `Referencia` tinyint NOT NULL, - `Item` tinyint NOT NULL, - `Cantidad` tinyint NOT NULL, - `Coste_Unitario` tinyint NOT NULL, - `Importe` tinyint NOT NULL, - `Cliente` tinyint NOT NULL, - `ticketFk` tinyint NOT NULL, - `Fecha` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - -- -- Table structure for table `nightTask` -- @@ -3139,6 +3167,47 @@ CREATE TABLE `produccion` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Temporary table structure for view `s1_ticketDetail` +-- + +DROP TABLE IF EXISTS `s1_ticketDetail`; +/*!50001 DROP VIEW IF EXISTS `s1_ticketDetail`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `s1_ticketDetail` ( + `ticketFk` tinyint NOT NULL, + `ticketAmount` tinyint NOT NULL, + `ticketLines` tinyint NOT NULL, + `ticketM3` tinyint NOT NULL, + `shipped` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `s21_saleDetail` +-- + +DROP TABLE IF EXISTS `s21_saleDetail`; +/*!50001 DROP VIEW IF EXISTS `s21_saleDetail`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `s21_saleDetail` ( + `dia` tinyint NOT NULL, + `año` tinyint NOT NULL, + `mes` tinyint NOT NULL, + `concepto` tinyint NOT NULL, + `unidades` tinyint NOT NULL, + `precio` tinyint NOT NULL, + `venta` tinyint NOT NULL, + `familia` tinyint NOT NULL, + `comprador` tinyint NOT NULL, + `itemFk` tinyint NOT NULL, + `ticketFk` tinyint NOT NULL, + `volume` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `salaries2018` -- @@ -3425,6 +3494,25 @@ CREATE TABLE `waste` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `workerLabourDataByMonth` +-- + +DROP TABLE IF EXISTS `workerLabourDataByMonth`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `workerLabourDataByMonth` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `code` varchar(25) COLLATE utf8_unicode_ci NOT NULL, + `month` int(2) NOT NULL, + `year` int(4) NOT NULL, + `total` int(5) NOT NULL COMMENT 'Número de empleados', + `permanent` int(5) NOT NULL COMMENT 'Número de empleados fijos', + PRIMARY KEY (`id`), + KEY `workerLabourDataByMonth_graph_idx` (`code`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Temporary table structure for view `workerMana` -- @@ -3498,13 +3586,13 @@ CREATE TABLE `workerSpeed__` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `zone_ETD` +-- Table structure for table `zone_ETD__` -- -DROP TABLE IF EXISTS `zone_ETD`; +DROP TABLE IF EXISTS `zone_ETD__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `zone_ETD` ( +CREATE TABLE `zone_ETD__` ( `zoneFk` int(11) DEFAULT NULL, `totalVolume` decimal(5,1) DEFAULT NULL, `remainingVolume` decimal(5,1) DEFAULT NULL, @@ -3545,7 +3633,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`z-sysadmin`@`%`*/ /*!50106 EVENT `nightTask_launchAll` ON SCHEDULE EVERY 1 DAY STARTS '2020-08-05 03:00:00' ON COMPLETION PRESERVE ENABLE DO CALL bs.nightTask_launchAll */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`%`*/ /*!50106 EVENT `nightTask_launchAll` ON SCHEDULE EVERY 1 DAY STARTS '2020-08-05 03:00:00' ON COMPLETION PRESERVE ENABLE DO CALL bs.nightTask_launchAll */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -3987,6 +4075,38 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; ALTER DATABASE `bs` CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci ; +/*!50003 DROP PROCEDURE IF EXISTS `carteras_add2` */; +/*!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 `carteras_add2`() +BEGIN +/** + * Inserta en "bs.carteras". + */ + DELETE FROM bs.carteras + WHERE Año >= YEAR(CURDATE()) - 1; + + INSERT INTO bs.carteras(Año,Mes,CodigoTrabajador,Peso) + SELECT t.year AS Año, t.month AS Mes, w.code AS CodigoTrabajador, SUM(v.importe) AS Peso + FROM vn.time t + JOIN bs.ventas v on t.dated = v.fecha + JOIN vn.client c on c.id = v.Id_Cliente + JOIN vn.worker w ON w.id = c.salesPersonFk + WHERE t.year >= YEAR(CURDATE()) - 1 + GROUP BY w.code, t.year , t.month; +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 `clean` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -4449,6 +4569,40 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; ALTER DATABASE `bs` CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci ; +/*!50003 DROP PROCEDURE IF EXISTS `compradores_add2` */; +/*!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 `compradores_add2`(IN vYear INT, IN vWeekFrom INT, IN vWeekTo INT) +BEGIN +/** + * Sustituye los registros de "bs.compradores". + * + * @param vYear: año ventas + * @param vWeekFrom: semana desde + * @param vWeekTo: semana hastas + */ + REPLACE bs.compradores + SELECT it.workerFk AS Id_Trabajador, vYear AS año, tm.week AS semana, SUM(importe) AS importe, 0 AS comision + FROM bs.ventas v + JOIN vn.time tm ON tm.dated = v.fecha + JOIN vn.itemType it ON it.id = v.tipo_id + WHERE tm.year = vYear + AND tm.week BETWEEN vWeekFrom AND vWeekTo + AND it.categoryFk != 6 + GROUP BY it.workerFk, tm.week; +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 `compradores_add_launcher` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -4679,6 +4833,84 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; ALTER DATABASE `bs` CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci ; +/*!50003 DROP PROCEDURE IF EXISTS `fondo_evolution_add2` */; +/*!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 `fondo_evolution_add2`() +BEGIN +/** + * Inserta en la tabla fondo_maniobra los saldos acumulados en los ultimos 365 dias + */ + DECLARE datFEC DATE DEFAULT '2015-01-01'; + + SELECT TIMESTAMPADD(DAY,1,MAX(fecha)) + INTO datFEC + FROM bs.fondo_maniobra; + + WHILE datFEC < CURDATE() DO + + IF DAY(datFEC) MOD 28 = 0 THEN -- esto solo sirve para no aburrirse mientras esperamos... + SELECT datFEC; + END IF; + + REPLACE bs.fondo_maniobra(Fecha, clientes_facturas, clientes_cobros,proveedores_facturas,proveedores_pagos, fondo) + SELECT datFEC AS Fecha, Facturas, Cobros,Recibidas,Pagos, Facturas + Cobros + Recibidas + Pagos + FROM ( + SELECT SUM(io.amount) AS Facturas + FROM vn.invoiceOut io + JOIN vn.client c ON io.clientFk = c.id + WHERE c.isRelevant + AND io.companyFk <> 1381 + AND io.issued BETWEEN '2011-01-01' AND datFEC + ) fac + JOIN ( + SELECT - SUM(r.amountPaid) AS Cobros + FROM vn.receipt r + JOIN vn.client c ON r.clientFk = c.id + WHERE c.isRelevant + AND r.companyFk <> 1381 + AND r.payed BETWEEN '2011-01-01' AND datFEC + ) cob + JOIN ( + SELECT - SUM(id.amount) AS Recibidas + FROM vn.invoiceIn ii + JOIN vn.invoiceInDueDay id ON ii.id = id.invoiceInFk + WHERE ii.companyFk <> 1381 + AND ii.issued BETWEEN '2015-01-01' AND datFEC + ) rec + JOIN ( + SELECT SUM(p.amount) AS Pagos + FROM vn.payment p + WHERE p.companyFk <>1381 + AND p.received BETWEEN '2015-01-01' AND datFEC + ) pag; + + UPDATE bs.fondo_maniobra + JOIN ( + SELECT AVG(fondo) AS media + FROM bs.fondo_maniobra + WHERE fecha <= datFEC + ) sub + SET fondo_medio = media WHERE fecha = datFEC; + + SET datFEC = TIMESTAMPADD(DAY,1,datFEC); + + 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 `fruitsEvolution` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -4713,9 +4945,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 ;; @@ -4752,8 +4984,7 @@ BEGIN WHERE shipped <= vDated ) WHERE updated = vDated; - - + -- Tasa de morosidad con respecto a las ventas del último mes UPDATE indicators SET latePaymentRate = @@ -4847,7 +5078,8 @@ BEGIN WHERE date_send BETWEEN oneMonthBefore AND vDated ) WHERE updated = vDated; - + + /* -- Indicadores de producción UPDATE indicators i JOIN productionIndicators pi ON pi.dated = i.updated @@ -4860,7 +5092,8 @@ BEGIN i.workerCostM3 = pi.workerCostM3, i.salesWorkersCostRate = pi.salesWorkersCostRate WHERE updated BETWEEN oneMonthBefore AND vDated; - + */ + -- CAP Para el calculo de las ventas agrupado por semanas SELECT week @@ -5281,13 +5514,15 @@ BEGIN FROM nightTaskConfig LIMIT 1; IF vNErrors > 0 AND vLogMail IS NOT NULL THEN - INSERT INTO vn.mail SET - `sender` = vLogMail, - `subject` = 'Nightly task failed', - `body` = CONCAT( + CALL vn.mail_insert( + vLogMail, + NULL, + 'Nightly task failed', + CONCAT( vNErrors, ' procedures of nightly tasks have failed. ', 'Please, see `', SCHEMA() ,'`.`nightTask` table for more info.' - ); + ) + ); END IF; END ;; DELIMITER ; @@ -5386,7 +5621,6 @@ BEGIN DECLARE myDepLft INT; DECLARE myDepRgt INT; - -- Trabajadores CALL vn.dayMinuteWorker(vDateStart,vDateEnd); -- Genera la tabla tmp.dayMinuteWorker CALL vn.workerDepartmentByDate(vDate); @@ -5396,17 +5630,16 @@ BEGIN 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) + WHERE warehouseName = 'Algemesi' 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' + AND w.name = 'Algemesi' ) sub SET p.m3 = sub.m3, p.eurosM3 = p.cost / sub.m3 @@ -5415,7 +5648,6 @@ BEGIN DROP TEMPORARY TABLE tmp.dayMinuteWorker; DROP TEMPORARY TABLE tmp.workerDepartmentByDate; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -5693,9 +5925,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 ;; @@ -5833,16 +6065,6 @@ BEGIN GROUP BY scd.substituteFk, c.id, t.`month` ON DUPLICATE KEY UPDATE substitutionBorrowed = VALUES(substitutionBorrowed); - DROP TEMPORARY TABLE IF EXISTS tmp.workerItemType; - - CREATE TEMPORARY TABLE tmp.workerItemType - (INDEX(ownerWorkerFk, itemTypeFk)) - SELECT wd.workerFk ownerWorkerFk, itemTypeFk, dit.workerFk substituteFk - FROM vn.departmentItemType dit - JOIN vn.workerDepartment wd ON wd.departmentFk = dit.departmentFk; - - DROP TEMPORARY TABLE tmp.workerItemType; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -6702,6 +6924,129 @@ 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 `workerLabour_getData` */; +/*!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 `workerLabour_getData`() +BEGIN +/** + * Carga los datos de la plantilla de trabajadores, altas y bajas en la tabla workerLabourDataByMonth para facilitar el cálculo del gráfico en grafana. + * Se carga el día 21 de cada mes, elimina los registros del último año y los vuelve a calcular + * + */ + DECLARE vFristDay DATE; + DECLARE vLastDay DATE; + DECLARE vDone BOOL DEFAULT FALSE; + DECLARE vDateStarted DATE; + DECLARE vDateEnded DATE; + + DECLARE vCursor CURSOR FOR + SELECT util.firstDayOfMonth(t.dated), LAST_DAY(t.dated) + FROM vn.time t + WHERE t.dated BETWEEN vDateStarted AND vDateEnded + GROUP BY year,month; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + IF DAY(CURDATE()) = 21 THEN + + SELECT util.firstDayOfMonth(DATE_SUB(CURDATE(), INTERVAL 12 MONTH)), + LAST_DAY(DATE_SUB(CURDATE(), INTERVAL 1 MONTH)) + INTO vDateStarted, + vDateEnded; + + DELETE FROM workerLabourDataByMonth + WHERE CONCAT(`year`, '-',`month`, '-01') BETWEEN vDateStarted AND vDateEnded; + + OPEN vCursor; + + l: LOOP + SET vDone = FALSE; + + FETCH vCursor INTO vFristDay, vLastDay; + + IF vDone THEN + LEAVE l; + END IF; + + -- Altas periodo + INSERT INTO workerLabourDataByMonth (code, month, year, total, permanent) + SELECT 'hiring', MONTH(vFristDay), YEAR(vFristDay), COUNT(*), SUM(pc.isPermanent) + FROM vn.workerLabour w + JOIN postgresql.workcenter wc ON wc.workcenter_id = w.workCenterFk + JOIN postgresql.business_labour_payroll bl ON bl.business_id = w.businessFk + JOIN postgresql.person p ON p.id_trabajador = w.workerFk + LEFT JOIN vn2008.payroll_contratos pc ON pc.CodContrato = bl.cod_contrato + LEFT JOIN (SELECT w.workerFk + FROM vn.workerLabour w + LEFT JOIN (SELECT ended, workerFk FROM vn.workerLabour) wl ON wl.ended = DATE_SUB(w.started, INTERVAL 1 DAY) + AND wl.workerFk = w.workerFk + WHERE w.started BETWEEN vFristDay AND vLastDay AND wl.ended + )sub ON sub.workerFk = w.workerFk + WHERE wc.center_id IS NOT NULL + AND w.started BETWEEN vFristDay AND vLastDay + AND sub.workerFk IS NULL + AND NOT p.isFreelance; + + -- Bajas periodo + INSERT INTO workerLabourDataByMonth (code, month, year, total, permanent) + SELECT 'layoffs', MONTH(vFristDay), YEAR(vFristDay), COUNT(*), SUM(pc.isPermanent) + FROM vn.workerLabour w + JOIN postgresql.workcenter wc ON wc.workcenter_id = w.workCenterFk + JOIN postgresql.business_labour_payroll bl ON bl.business_id = w.businessFk + JOIN postgresql.person p ON p.id_trabajador = w.workerFk + LEFT JOIN vn2008.payroll_contratos pc ON pc.CodContrato = bl.cod_contrato + LEFT JOIN (SELECT started, workerFk FROM vn.workerLabour) wl ON wl.started >= w.ended + AND wl.workerFk = w.workerFk + WHERE wc.center_id IS NOT NULL + AND w.ended BETWEEN vFristDay AND vLastDay + AND wl.started IS NULL + AND NOT p.isFreelance; + + -- Anterior al periodo + SET vLastDay = LAST_DAY(DATE_SUB(vFristDay, INTERVAL 1 DAY)); + + INSERT INTO workerLabourDataByMonth (code, month, year, total, permanent) + SELECT 'staff', MONTH(vFristDay), YEAR(vFristDay), COUNT(*), SUM(pc.isPermanent) + FROM vn.workerLabour w + JOIN postgresql.workcenter wc ON wc.workcenter_id = w.workCenterFk + JOIN postgresql.business_labour_payroll bl ON bl.business_id = w.businessFk + JOIN postgresql.person p ON p.id_trabajador = w.workerFk + LEFT JOIN vn2008.payroll_contratos pc ON pc.CodContrato = bl.cod_contrato + WHERE wc.center_id IS NOT NULL + AND vLastDay BETWEEN started AND IFNULL(ended, vLastDay) + AND NOT p.isFreelance; + + -- Discapacidad + INSERT INTO workerLabourDataByMonth (code, month, year, total, permanent) + SELECT 'disabled', MONTH(vFristDay), YEAR(vFristDay), COUNT(*), SUM(pc.isPermanent) + FROM vn.workerLabour w + JOIN postgresql.workcenter wc ON wc.workcenter_id = w.workCenterFk + JOIN postgresql.business_labour_payroll bl ON bl.business_id = w.businessFk + JOIN postgresql.person p ON p.id_trabajador = w.workerFk + LEFT JOIN vn2008.payroll_contratos pc ON pc.CodContrato = bl.cod_contrato + WHERE wc.center_id IS NOT NULL + AND vLastDay BETWEEN started AND IFNULL(ended, vLastDay) + AND p.isDisable + AND NOT p.isFreelance; + + END LOOP; + CLOSE vCursor; + + 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 `workerProductivity_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -6780,7 +7125,39 @@ BEGIN GROUP BY s.ticketFk, t.warehouseFk )sub2 JOIN account.role r ON r.name='packager' - GROUP BY sub2.warehouseFk,sub2.workerFk, sub2.shipped; + GROUP BY sub2.warehouseFk,sub2.workerFk, sub2.shipped; + + -- REVISADORES + INSERT INTO workerProductivity(dated, wareHouseFk, workerFk, volume, seconds, roleFk) + SELECT sub2.shipped, + sub2.warehouseFk, + sub2.workerFK, + SUM(sub2.volume), + SUM(sub2.seconds), + r.id + FROM (SELECT t.warehouseFk, + SUM(s.volume) volume, + sub.workerFk, + DATE(t.shipped) shipped, + sub.seconds + w.minSeconsPackager seconds + FROM vn.saleVolume s + JOIN vn.ticket t ON t.id = s.ticketFk + JOIN(SELECT st.workerFk, t.id ticketFk,TIME_TO_SEC(TIMEDIFF( MAX(st.created), MIN(st.created))) seconds + FROM vn.state ss + JOIN vn.saleTracking st ON st.stateFk = ss.id + JOIN vn.worker w ON st.workerFk = w.id + JOIN vn.sale s ON s.id = st.saleFk + JOIN vn.ticket t ON s.ticketFk = t.id + WHERE ss.code = 'CHECKED' AND + t.shipped >= vDateFrom + GROUP BY t.id + )sub ON sub.ticketFk = t.id + JOIN workerProductivityConfig w ON TRUE + WHERE t.shipped >= vDateFrom + GROUP BY s.ticketFk, t.warehouseFk + )sub2 + JOIN account.role r ON r.name='checker' + GROUP BY sub2.warehouseFk,sub2.workerFk, sub2.shipped; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -6982,24 +7359,6 @@ CREATE TABLE `last_buy` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `last_buy__` --- - -DROP TABLE IF EXISTS `last_buy__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `last_buy__` ( - `item_id` int(10) unsigned NOT NULL, - `warehouse_id` smallint(5) unsigned NOT NULL, - `buy_id` int(10) unsigned DEFAULT NULL, - `landing` date DEFAULT NULL, - UNIQUE KEY `item_id` (`item_id`,`warehouse_id`) USING HASH, - KEY `buy_id` (`buy_id`), - KEY `warehouse_id` (`warehouse_id`) USING BTREE -) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `prod_graphic_source` -- @@ -7085,7 +7444,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`z-sysadmin`@`%`*/ /*!50106 EVENT `cacheCalc_clean` ON SCHEDULE EVERY 30 MINUTE STARTS '2017-01-23 13:15:58' ON COMPLETION NOT PRESERVE ENABLE DO CALL cacheCalc_clean */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`%`*/ /*!50106 EVENT `cacheCalc_clean` ON SCHEDULE EVERY 30 MINUTE STARTS '2017-01-23 13:15:58' ON COMPLETION NOT PRESERVE ENABLE DO CALL cacheCalc_clean */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -7103,7 +7462,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`z-sysadmin`@`%`*/ /*!50106 EVENT `cache_clean` ON SCHEDULE EVERY 5 MINUTE STARTS '2019-04-29 13:06:16' ON COMPLETION NOT PRESERVE ENABLE DO CALL cache_clean */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`%`*/ /*!50106 EVENT `cache_clean` ON SCHEDULE EVERY 5 MINUTE STARTS '2019-04-29 13:06:16' ON COMPLETION NOT PRESERVE ENABLE DO CALL cache_clean */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -8371,6 +8730,8 @@ CREATE TABLE `VMPSettings` ( `firstSupplyResponseId` int(11) DEFAULT NULL, `ApiId` int(11) DEFAULT NULL, `ApiKey` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `isBlocked` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'product source not allowed', + `isVNHSupplier` tinyint(1) DEFAULT '0' COMMENT 'The account belongs to VNH', PRIMARY KEY (`VMPID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -8425,7 +8786,9 @@ DROP TABLE IF EXISTS `clientFHAdminNumber`; CREATE TABLE `clientFHAdminNumber` ( `fhAdminNumber` int(11) NOT NULL, `clientFk` int(11) NOT NULL, - PRIMARY KEY (`clientFk`) + PRIMARY KEY (`clientFk`), + KEY `clientFHAdminNumber_fk_idx` (`fhAdminNumber`), + CONSTRAINT `clientFHAdminNumber_fk` FOREIGN KEY (`fhAdminNumber`) REFERENCES `vn`.`company` (`fhAdminNumber`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -8523,7 +8886,7 @@ CREATE TABLE `ekt` ( `s6` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, `ok` tinyint(4) NOT NULL DEFAULT '0', `trolleyFk` int(11) DEFAULT NULL, - `putOrderFk` int(10) unsigned DEFAULT NULL, + `putOrderFk` bigint(20) unsigned DEFAULT NULL, `scanned` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) USING BTREE, UNIQUE KEY `barcode_year` (`barcode`,`entryYear`), @@ -9506,9 +9869,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 ;; @@ -9524,6 +9887,10 @@ BEGIN FROM supplyResponse sr LEFT JOIN edi.deliveryInformation di ON sr.ID = di.supplyResponseID WHERE di.LatestOrderDateTime < vOneWeekAgo OR di.ID IS NULL; + + DELETE FROM putOrder + WHERE created < TIMESTAMPADD(MONTH,-1,CURDATE()); + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -9671,7 +10038,8 @@ BEGIN -- Carga los datos necesarios del EKT - SELECT ref, qty, package, putOrderFk, i2.id INTO vRef, vQty, vPackage, vPutOrderFk, vItem + SELECT ref, qty, package, putOrderFk MOD 1000000, i2.id + INTO vRef, vQty, vPackage, vPutOrderFk, vItem FROM ekt e LEFT JOIN item i ON e.ref = i.id LEFT JOIN edi.putOrder po ON po.id = e.putOrderFk @@ -9988,9 +10356,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 ;; @@ -10026,7 +10394,7 @@ CREATE DEFINER=`root`@`%` PROCEDURE `exchange_new`( IN `vP2` TINYINT, IN `vAuction` SMALLINT, IN `vPackage` INT, - IN `vPutOrderFk` INT) + IN `vPutOrderFk` BIGINT) BEGIN /** * Adds a new exchange, generates it's barcode and @@ -10036,6 +10404,7 @@ BEGIN */ DECLARE vEkt INT; DECLARE vRewriteKop INT DEFAULT NULL; + DECLARE vTruncatePutOrder INT DEFAULT NULL; DECLARE vBarcode CHAR(15) DEFAULT NULL; DECLARE vIsDuplicated BOOL; DECLARE vUpdateExistent BOOL DEFAULT FALSE; @@ -10047,6 +10416,21 @@ BEGIN -- Generates the barcode IF vAgj != 0 AND vAgj IS NOT NULL + THEN + SET vBarcode = CONCAT( + LPAD(vAuction, 2, 0), + LPAD(IFNULL(vClock, 99), 2, 0), + LPAD(DAYOFYEAR(vDate), 3, 0), + IF(vClock IS NULL OR vClock = 99, + LPAD(vAgj, 8, 0), + CONCAT(LPAD(vAgj, 5, 0), '010') + ) + ); + END IF; + + -- Generates the barcode + + /*IF vAgj != 0 AND vAgj IS NOT NULL THEN SET vBarcode = CONCAT( LPAD(vAuction, 2, 0), @@ -10058,7 +10442,7 @@ BEGIN ), '0' ); - END IF; + END IF;*/ -- Rewrites the kop parameter @@ -10074,8 +10458,11 @@ BEGIN SET vKop = IFNULL(vRewriteKop, vKop); -- Inserts the new transaction - + call util.debugAdd('vBarcode',vBarcode); + call util.debugAdd('vDeliveryNumber',vDeliveryNumber); SET vIsDuplicated = FALSE; + SET vTruncatePutOrder = vPutOrderFk MOD 1000000; + INSERT INTO ekt SET barcode = IFNULL(vBarcode, barcode) ,deliveryNumber = vDeliveryNumber @@ -10108,7 +10495,7 @@ BEGIN ,k4 = vP2 ,auction = vAuction ,package = vPackage - ,putOrderFk = vPutOrderFk; + ,putOrderFk = vTruncatePutOrder; -- If it exists duplicado updates it @@ -10165,12 +10552,12 @@ BEGIN ,k4 = vP2 ,auction = vAuction ,package = vPackage - ,putOrderFk = IFNULL(vPutOrderFk, putOrderFk) + ,putOrderFk = IFNULL(vTruncatePutOrder, putOrderFk) WHERE id = vEkt; END IF; -- Registers the exchange - + INSERT INTO `exchange` SET mailFk = vMailFk ,typeFk = vType @@ -10221,6 +10608,14 @@ proc: BEGIN SET vStartingTime = NOW(); + IF NOW() < '2021-10-14 12:00' THEN + + LEAVE proc; + + END IF; + + CALL util.debugAdd('edi.floramondo_offerRefresh',CONCAT('MaxItemId:' ,(SELECT MAX(id) FROM vn.item))); + -- CALL vn.clean_logiflora(); -- Refresca las fotos de los items existentes, con prioridad baja (0.7 seg) @@ -10256,7 +10651,10 @@ proc: BEGIN -- select now(),'Antes de crear edi.offer'; DROP TEMPORARY TABLE IF EXISTS edi.offer; - CREATE TEMPORARY TABLE edi.offer (INDEX (`srID`), INDEX (`EmbalageCode`)) ENGINE = MEMORY + CREATE TEMPORARY TABLE edi.offer (INDEX (`srID`), INDEX (`EmbalageCode`), + INDEX (`ef1`), INDEX (`ef2`), INDEX (`ef3`), INDEX (`ef4`),INDEX (`ef5`), INDEX (`ef6`), + INDEX (`s1Value`), INDEX (`s2Value`), INDEX (`s3Value`), INDEX (`s4Value`),INDEX (`s5Value`), INDEX (`s6Value`)) + ENGINE = MEMORY SELECT so.*, ev1.type_description s1Value, ev2.type_description s2Value, ev3.type_description s3Value, ev4.type_description s4Value, ev5.type_description s5Value, ev6.type_description s6Value, eif1.feature ef1, eif2.feature ef2, eif3.feature ef3, eif4.feature ef4, eif5.feature ef5, eif6.feature ef6 @@ -10283,7 +10681,22 @@ proc: BEGIN DROP TEMPORARY TABLE tmp; - + DELETE o + FROM edi.offer o + LEFT JOIN vn.tag t1 ON t1.ediTypeFk = o.ef1 AND t1.overwrite = 'size' + LEFT JOIN vn.tag t2 ON t2.ediTypeFk = o.ef2 AND t2.overwrite = 'size' + LEFT JOIN vn.tag t3 ON t3.ediTypeFk = o.ef3 AND t3.overwrite = 'size' + LEFT JOIN vn.tag t4 ON t4.ediTypeFk = o.ef4 AND t4.overwrite = 'size' + LEFT JOIN vn.tag t5 ON t5.ediTypeFk = o.ef5 AND t5.overwrite = 'size' + LEFT JOIN vn.tag t6 ON t6.ediTypeFk = o.ef6 AND t6.overwrite = 'size' + JOIN vn.floramondoConfig fc ON TRUE + WHERE (t1.id IS NOT NULL AND CONVERT(s1Value, UNSIGNED) > fc.itemMaxSize) + OR(t2.id IS NOT NULL AND CONVERT(s2Value, UNSIGNED) > fc.itemMaxSize) + OR(t3.id IS NOT NULL AND CONVERT(s3Value, UNSIGNED) > fc.itemMaxSize) + OR(t4.id IS NOT NULL AND CONVERT(s4Value, UNSIGNED) > fc.itemMaxSize) + OR(t5.id IS NOT NULL AND CONVERT(s5Value, UNSIGNED) > fc.itemMaxSize) + OR(t6.id IS NOT NULL AND CONVERT(s6Value, UNSIGNED) > fc.itemMaxSize); + START TRANSACTION; -- Actualizamos el campo supplyResponseFk para aquellos articulos que ya estan creados y reutilizamos @@ -10499,8 +10912,7 @@ proc: BEGIN UPDATE vn.floramondoConfig SET nextLanded = vLanded WHERE vLanded IS NOT NULL; - - + -- Elimina la oferta obsoleta UPDATE vn.buy b JOIN vn.entry e ON e.id = b.entryFk @@ -11571,12 +11983,13 @@ ON `order` FOR EACH ROW BEGIN IF NEW.address_id = 2850 THEN -- Fallo que se insertan no se sabe como tickets en este cliente - INSERT INTO vn.mail SET - `sender` = 'jgallego@verdnatura.es', - `replyTo` = 'jgallego@verdnatura.es', - `subject` = 'Creada order al address 2850', - `body` = CONCAT(account.myUserGetName(), ' ha creado la order ', - NEW.id); + CALL vn.mail_insert( + 'jgallego@verdnatura.es', + 'noreply@verdnatura.es', + 'Creada order al address 2850', + CONCAT(account.myUserGetName(), ' ha creado la order ',NEW.id) + ); + END IF; END */;; DELIMITER ; @@ -11587,9 +12000,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 ;; @@ -11604,6 +12017,16 @@ BEGIN OR !(OLD.customer_id <=> NEW.customer_id) THEN CALL order_requestRecalc(NEW.id); END IF; + + IF !(OLD.address_id <=> NEW.address_id) AND NEW.address_id = 2850 THEN + -- Fallo que se actualiza no se sabe como tickets en este cliente + CALL vn.mail_insert( + 'jgallego@verdnatura.es', + 'noreply@verdnatura.es', + 'Actualizada order al address 2850', + CONCAT(account.myUserGetName(), ' ha creado la order ',NEW.id) + ); + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -14229,9 +14652,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 ;; @@ -14295,23 +14718,15 @@ BEGIN END; -- Carga los datos del pedido - SELECT o.date_send, o.address_id, o.note, - o.confirmed, a.clientFk, o.company_id, o.agency_id + a.clientFk, o.company_id, o.agency_id INTO vDelivery, vAddress, vNotes, - vIsConfirmed, vClientId, vCompanyId, vAgencyModeId + vClientId, vCompanyId, vAgencyModeId FROM hedera.`order` o JOIN vn.address a ON a.id = o.address_id WHERE o.id = vOrder; - -- Comprueba que el pedido no está confirmado - - IF vIsConfirmed THEN - CALL util.throw ('ORDER_ALREADY_CONFIRMED'); - END IF; - - -- Comprueba que el pedido no está vacío - + -- Comprueba que el pedido no est? vac?o SELECT COUNT(*) > 0 INTO vOk FROM order_row WHERE order_id = vOrder AND amount > 0; @@ -14319,12 +14734,10 @@ BEGIN CALL util.throw ('ORDER_EMPTY'); END IF; - -- Carga las fechas de salida de cada almacén - + -- Carga las fechas de salida de cada almac?n CALL vn.zone_getShipped (vDelivery, vAddress, vAgencyModeId, FALSE); - -- Trabajador que realiza la acción - + -- Trabajador que realiza la acci?n IF vUserId IS NULL THEN SELECT employeeFk INTO vUserId FROM orderConfig; END IF; @@ -14392,7 +14805,7 @@ BEGIN SET orderFk = vOrder, ticketFk = vTicket; - -- Añade las notas + -- A?ade las notas IF vNotes IS NOT NULL AND vNotes != '' THEN @@ -14404,7 +14817,7 @@ BEGIN `description` = CONCAT(VALUES(`description`),'. ', `description`); END IF; - -- Añade los movimientos y sus componentes + -- A?ade los movimientos y sus componentes OPEN cRows; @@ -14492,19 +14905,10 @@ BEGIN LIMIT 1; END IF; - - -- Actualiza la caché - CALL cache.available_refresh(vCalc,FALSE,vWarehouse,vShipment); - - UPDATE cache.available - SET available = GREATEST(0,available - vAmount) - WHERE item_id = vItem - AND calc_id = vCalc; - - END LOOP; - - CLOSE cRows; + END LOOP; + + CLOSE cRows; -- Fija el coste DROP TEMPORARY TABLE IF EXISTS tComponents; @@ -14529,6 +14933,18 @@ BEGIN CLOSE cDates; DELETE FROM basketOrder WHERE orderFk = vOrder; + + SELECT o.confirmed INTO vIsConfirmed + FROM hedera.`order` o + JOIN vn.address a ON a.id = o.address_id + WHERE o.id = vOrder; + + -- Comprueba que el pedido no est? confirmado + + IF vIsConfirmed THEN + CALL util.throw ('ORDER_ALREADY_CONFIRMED'); + END IF; + UPDATE `order` SET confirmed = TRUE, confirm_date = NOW() WHERE id = vOrder; @@ -17102,6 +17518,46 @@ CREATE TABLE `business` ( CONSTRAINT `bussiness_provider` FOREIGN KEY (`provider_id`) REFERENCES `profile` (`profile_id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8; /*!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 `postgresql`.`business_beforeUpdate` + BEFORE UPDATE ON `business` FOR EACH ROW +BEGIN + DECLARE isOverlapping BOOL; + + IF !(OLD.date_start <=> NEW.date_start AND OLD.date_end <=> NEW.date_end) THEN + + SELECT COUNT(*) > 0 INTO isOverlapping + FROM business b + WHERE (util.hasDateOverlapped( + NEW.date_start, + IFNULL(NEW.date_end,b.date_start), + b.date_start, + IFNULL(b.date_end,NEW.date_start)) + OR (NEW.date_end <=> NULL AND b.date_end <=> NULL)) + AND b.business_id <> OLD.business_id + AND client_id = OLD.client_id + ; + + IF isOverlapping THEN + CALL util.throw ('IS_OVERLAPPING'); + 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 */ ; -- -- Table structure for table `business_labour` @@ -17292,7 +17748,7 @@ 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 + CONSTRAINT `erte_COVID19_FK` FOREIGN KEY (`personFk`) REFERENCES `vn`.`person` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -17315,7 +17771,7 @@ CREATE TABLE `income_employee` ( KEY `fincometype_id` (`id_incomeType`), KEY `fperson_id` (`person_id`), CONSTRAINT `fincometype_id` FOREIGN KEY (`id_incomeType`) REFERENCES `incometype_employee` (`id_incometype`) ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT `fperson_id` FOREIGN KEY (`person_id`) REFERENCES `person` (`person_id`) ON DELETE NO ACTION ON UPDATE NO ACTION + CONSTRAINT `income_employee_FK` FOREIGN KEY (`person_id`) REFERENCES `vn`.`person` (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -17441,13 +17897,38 @@ CREATE TABLE `periodos` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `person` +-- Temporary table structure for view `person` -- DROP TABLE IF EXISTS `person`; +/*!50001 DROP VIEW IF EXISTS `person`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `person` ( + `person_id` tinyint NOT NULL, + `name` tinyint NOT NULL, + `nickname` tinyint NOT NULL, + `nif` tinyint NOT NULL, + `birth` tinyint NOT NULL, + `firstname` tinyint NOT NULL, + `p2` tinyint NOT NULL, + `nis` tinyint NOT NULL, + `id_trabajador` tinyint NOT NULL, + `isDisable` tinyint NOT NULL, + `isFreelance` tinyint NOT NULL, + `isSsDiscounted` tinyint NOT NULL, + `sex` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + +-- +-- Table structure for table `person__` +-- + +DROP TABLE IF EXISTS `person__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `person` ( +CREATE TABLE `person__` ( `person_id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(60) NOT NULL, `nickname` varchar(15) DEFAULT NULL, @@ -17520,7 +18001,7 @@ CREATE TABLE `profile` ( PRIMARY KEY (`profile_id`), KEY `profile_person_id_idx` (`person_id`), KEY `profile_profile_type_id_idx` (`profile_type_id`), - CONSTRAINT `person_fk` FOREIGN KEY (`person_id`) REFERENCES `person` (`person_id`) ON UPDATE CASCADE + CONSTRAINT `profile_FK` FOREIGN KEY (`person_id`) REFERENCES `vn`.`person` (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -18498,14 +18979,14 @@ BEGIN JOIN vn.XDiario x ON x.ASIEN = m.Asiento SET m.BaseIva1 = x.BASEEURO , m.PorIva1 = x.IVA, - m.CuotaIva1 = (x.IVA/100) * x.BASEEURO , + m.CuotaIva1 = CAST((x.IVA/100) * x.BASEEURO AS DECIMAL(10,2)) , m.CodigoTransaccion1 = 56 , m.CodigoIva1 = 22, m.IvaDeducible1 = TRUE, m.FechaFacturaOriginal = x.FECHA_EX, m.SuFacturaNo = x.FACTURAEX, m.FechaOperacion = x.FECHA_OP, - m.ImporteFactura = m.ImporteFactura + x.BASEEURO + (x.IVA/100) * x.BASEEURO + m.ImporteFactura = m.ImporteFactura + x.BASEEURO + CAST((x.IVA/100) * x.BASEEURO AS DECIMAL(10,2)) WHERE m.CodigoCuenta = 4700000999 AND m.enlazadoSage = FALSE AND x.SERIE='D' @@ -18515,11 +18996,11 @@ BEGIN JOIN vn.XDiario x ON x.ASIEN = m.Asiento SET m.BaseIva2 = x.BASEEURO , m.PorIva2 = x.IVA, - m.CuotaIva2 = (x.IVA/100) * x.BASEEURO , + m.CuotaIva2 = CAST((x.IVA/100) * x.BASEEURO AS DECIMAL(10,2)), m.CodigoTransaccion2 = 56 , m.CodigoIva2 = 90, m.IvaDeducible2 = TRUE, - m.ImporteFactura = m.ImporteFactura + x.BASEEURO + (x.IVA/100) * x.BASEEURO + m.ImporteFactura = m.ImporteFactura + x.BASEEURO + CAST((x.IVA/100) * x.BASEEURO AS DECIMAL(10,2)) WHERE m.CodigoCuenta = 4700000999 AND m.enlazadoSage = FALSE AND x.SERIE='D' @@ -18788,545 +19269,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 `movContaAdd__` */; -/*!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 `movContaAdd__`() -BEGIN - /* Copia en movConta los asientos de XDiario para que luego los importe el proceso automático que hay en SQL Server - */ - DECLARE vDated DATE; - SELECT CONCAT(YEAR(CURDATE()), "-01-01") INTO vDated; - TRUNCATE XDiario_movConta_IVA; - DELETE FROM movConta WHERE enlazadoSage = FALSE AND Asiento <> 1 ; - CALL clientesProveedoresAdd; - CALL planCuentasPgcAdd; - CALL XDiario_movConta_IVA_InvoiceOutAdd_Manager; - CALL XDiario_movConta_IVA_InvoiceInAdd_Manager; - INSERT INTO movConta( - TipoEntrada, -- VARCHAR(2) - Ejercicio, -- Año - CodigoEmpresa, -- ENT(2) - Asiento, -- LONG(4), nº ASIENTO - CargoAbono, -- VARCHAR(1) "D" debe ó "H" haber - CodigoCuenta, -- VARCHAR(15) partida contable - Contrapartida, -- VARCHAR(15) partida contable - FechaAsiento, -- FECHA(8) - Comentario, -- VARCHAR(40) - ImporteAsiento, -- DOBLE(19) - NumeroPeriodo, -- ENT(2) "-1" Al informar este valor se calcula automát. A partir de la fecha de asiento - FechaGrabacion, -- FECHA(8) - CodigoDivisa, -- VARCHAR(3) - ImporteCambio, -- DOBLE(19) - ImporteDivisa, -- DOBLE(19) - FactorCambio, -- DOBLE(19) - IdProcesoIME, -- GUID(16) - TipoCarteraIME, -- ENT(2) "0" para que no genere cartera - TipoAnaliticaIME, -- ENT(2) - StatusTraspasadoIME, -- BYTE "0" para dejar como no importado aún - TipoImportacionIME, -- BYTE "0" Alta "1" Baja - Metalico347, -- ENT(2) - /* ESTOS CAMPOS SOLO SE INFORMAN EN EL CASO DE SER FACTURA */ - BaseIva1, -- DOBLE(19) - PorBaseCorrectora1, -- DOBLE(19) - PorIva1, -- DOBLE(19) - CuotaIva1, -- DOBLE(19) - PorRecargoEquivalencia1,-- DOBLE(19) - RecargoEquivalencia1, -- DOBLE(19) - CodigoTransaccion1, -- BYTE "0" Nacional "1" Intracomunitario "2" Extracomunitario - BaseIva2, - PorBaseCorrectora2, - PorIva2, - CuotaIva2, - PorRecargoEquivalencia2, - RecargoEquivalencia2, - CodigoTransaccion2, - BaseIva3, - PorBaseCorrectora3, - PorIva3, - CuotaIva3, - PorRecargoEquivalencia3, - RecargoEquivalencia3, - CodigoTransaccion3, - BaseIva4, - PorBaseCorrectora4, - PorIva4, - CuotaIva4, - PorRecargoEquivalencia4, - RecargoEquivalencia4, - CodigoTransaccion4, - Año, -- ENT(2) - Serie, -- VARCHAR(10) - Factura, -- LONG(4) - SuFacturaNo, -- VARCHAR(40) - FechaFactura, -- FECHA(8) - ImporteFactura, -- DOBLE(19) - TipoFactura, -- VARCHAR(1) "E" / "R" / "I" - CodigoCuentaFactura, -- VARCHAR(15) cuenta del cliente/proveedor - CifDni, -- VARCHAR(13) - Nombre, -- VARCHAR(35) - CodigoRetencion, -- ENT(2) - BaseRetencion, -- DOBLE(19) - PorRetencion, -- DOBLE(19) - ImporteRetencion, -- DOBLE(19) - SiglaNacion, -- VARCHAR(2) "ES" por defecto - EjercicioFactura, -- ENT(2) - FechaOperacion, -- FECHA(8) - Exclusion347, -- ENT(2) - MantenerAsiento, -- BYTE "-1" mantener "0" Sage asigna nuevo - ClaveOperacionFactura_, -- VARCHAR(1) P(4721000011,4721000021)-I(4721000015-4720000005-4720000006)-D (Rectificativas) - TipoRectificativa, -- ENT(2) - FechaFacturaOriginal, -- FECHA(8) - BaseImponibleOriginal, -- DOBLE(19) - CuotaIvaOriginal, -- DOBLE(19) - ClaseAbonoRectificativas,-- ENT(2) - RecargoEquivalenciaOriginal, -- DOBLE(19) */ - LibreA1, - CodigoIva1, -- ENT(6) - CodigoIva2, -- ENT(6) - CodigoIva3, -- ENT(6) - CodigoIva4, -- ENT(6) - IvaDeducible1, -- Entero 2 ((-1)) - IvaDeducible2, -- Entero 2 ((-1)) - IvaDeducible3, -- Entero 2 ((-1)) - IvaDeducible4, -- Entero 2 ((-1))-- ENT(6) - Intracomunitaria -- INT(2) - ) - SELECT 'EN' as TipoEntrada, - YEAR(x.FECHA) AS Ejercicio, - IF (@@hostname = 'db', c.companyCode, companyCodeTest) AS CodigoEmpresa, -- ENT(2) c.companyCode AS CodigoEmpresa, - x.ASIEN AS Asiento, -- LONG(4), nº ASIENTO - IF(EURODEBE<>0 OR (EURODEBE=0 AND EUROHABER IS NULL),'D','H')AS CargoAbono, -- IF(EURODEBE IS NULL,"H","D") AS CargoAbono, VARCHAR(1) "D" debe ó "H" haber - x.SUBCTA AS CodigoCuenta, -- VARCHAR(15) partida contable - x.CONTRA AS Contrapartida, -- VARCHAR(15) partida contable - x.FECHA AS FechaAsiento, -- FECHA(8) - SUBSTRING(x.CONCEPTO, 1, 40) AS Comentario, -- VARCHAR(40) - IF(x.EURODEBE,x.EURODEBE,x.EUROHABER) AS ImporteAsiento, -- DOBLE(19) - MONTH(x.FECHA) AS NumeroPeriodo, -- ENT(2) "-1" Al informar este valor se calcula automát. A partir de la fecha de asiento - IF( sub2.FECREGCON IS NULL, sub2.FECHA_EX, sub2.FECREGCON) FechaGrabacion, -- FECHA(8) - IF(x.CAMBIO,IFNULL(xmi.CodigoDivisa, sub3.code),'') CodigoDivisa, -- VARCHAR(3) - x.CAMBIO AS ImporteCambio, -- DOBLE(19) - IFNULL(x.DEBEME,x.HABERME) AS ImporteDivisa, -- DOBLE(19) - IF(x.CAMBIO,1,0) AS FactorCambio, -- DOBLE(19) - NULL AS IdProcesoIME, -- GUID(16) - 0 AS TipoCarteraIME, -- ENT(2) "0" para que no genere cartera - 0 AS TipoAnaliticaIME, -- ENT(2) - 0 AS StatusTraspasadoIME, -- BYTE "0" para dejar como no importado aún - 0 AS TipoImportacionIME, -- BYTE "0" Alta "1" Baja - x.METAL as Metalico347, - /* ESTOS CAMPOS SOLO SE INFORMAN EN EL CASO DE SER FACTURA */ - xmi.BaseIva1, -- DOBLE(19) - xmi.PorBaseCorrectora1, -- DOBLE(19) - xmi.PorIva1, -- DOBLE(19) - xmi.CuotaIva1, -- DOBLE(19) - xmi.PorRecargoEquivalencia1,-- DOBLE(19) - xmi.RecargoEquivalencia1, -- DOBLE(19) - xmi.CodigoTransaccion1, -- BYTE "0" Nacional "1" Intracomunitario "2" Extracomunitario - xmi.BaseIva2, - xmi.PorBaseCorrectora2, - xmi.PorIva2, - xmi.CuotaIva2, - xmi.PorRecargoEquivalencia2, - xmi.RecargoEquivalencia2, - xmi.CodigoTransaccion2, - xmi.BaseIva3, - xmi.PorBaseCorrectora3, - xmi.PorIva3, - xmi.CuotaIva3, - xmi.PorRecargoEquivalencia3, - xmi.RecargoEquivalencia3, - xmi.CodigoTransaccion3, - xmi.BaseIva4, - xmi.PorBaseCorrectora4, - xmi.PorIva4, - xmi.CuotaIva4, - xmi.PorRecargoEquivalencia4, - xmi.RecargoEquivalencia4, - xmi.CodigoTransaccion4, - xmi.Año, -- ENT(2) - xmi.Serie, -- VARCHAR(10) - xmi.Factura, -- LONG(4) - xmi.SuFacturaNo, -- VARCHAR(40) - xmi.FechaFactura, -- FECHA(8) - xmi.ImporteFactura, -- DOBLE(19) - xmi.TipoFactura, -- VARCHAR(1) "E" / "R" - xmi.CodigoCuentaFactura, -- VARCHAR(15) cuenta del cliente/proveedor - xmi.CifDni, -- VARCHAR(13) - xmi.Nombre, -- VARCHAR(35) - xmi.CodigoRetencion, -- ENT(2) - xmi.BaseRetencion, -- DOBLE(19) - xmi.PorRetencion, -- DOBLE(19) - xmi.ImporteRetencion, -- DOBLE(19) - xmi.SiglaNacion, -- VARCHAR(2) "ES" por defecto - xmi.EjercicioFactura, -- ENT(2) - xmi.FechaOperacion, -- FECHA(8) - xmi.Exclusion347, -- ENT(2) - 1, -- xmi.MantenerAsiento BYTE "-1" mantener "0" Sage asigna nuevo - xmi.ClaveOperacionFactura, -- VARCHAR(1) - xmi.TipoRectificativa, -- ENT(2) - xmi.FechaFacturaOriginal, -- FECHA(8) - xmi.BaseImponibleOriginal, -- DOBLE(19) - xmi.CuotaIvaOriginal, -- DOBLE(19) - xmi.ClaseAbonoRectificativas,-- ENT(2) - xmi.RecargoEquivalenciaOriginal,-- DOBLE(19) */ - xmi.LibreA1, - xmi.CodigoIva1, -- ENT(6) - xmi.CodigoIva2, -- ENT(6) - xmi.CodigoIva3, -- ENT(6) - xmi.CodigoIva4, -- ENT(6) - xmi.IvaDeducible1, -- Entero 2 ((-1)) - xmi.IvaDeducible2, -- Entero 2 ((-1)) - xmi.IvaDeducible3, -- Entero 2 ((-1)) - xmi.IvaDeducible4, -- Entero 2 ((-1))-- ENT(6) - xmi.Intracomunitaria -- TINYINT(1) - FROM vn2008.XDiario x - JOIN vn.company c ON c.id = x.empresa_id - LEFT JOIN XDiario_movConta_IVA xmi ON xmi.id = x.id AND xmi.moveData > 0 - LEFT JOIN (SELECT ASIEN, FECREGCON, FECHA_EX - FROM (SELECT ASIEN, FECREGCON, FECHA_EX - FROM vn2008.XDiario - ORDER BY ASIEN, FECREGCON DESC, FECHA_EX DESC - ) sub GROUP BY ASIEN - )sub2 ON sub2.ASIEN = x.ASIEN - LEFT JOIN ( SELECT DISTINCT(account),cu.code - FROM vn.bank b - JOIN vn.currency cu ON cu.id = b.currencyFk - WHERE cu.code <> "EUR" -- no se informa cuando la divisa en EUR - )sub3 ON sub3.account = x.SUBCTA - WHERE x.enlazadoSage = 0 AND - c.companyCode AND - x.FECHA >= vDated; - --- Prepara Metálicos - UPDATE sage.movConta m - JOIN (SELECT Asiento, SUBSTR(c.socialName,1,35) Nombre, c.fi, n.SiglaNacion - FROM sage.movConta m - JOIN vn.client c ON c.id = IF(m.CargoAbono = "H", m.CodigoCuenta-4300000000, m.Contrapartida-4300000000 ) - LEFT JOIN Naciones n ON n.countryFk = c.countryFk - WHERE m.Metalico347 = TRUE AND - m.enlazadoSage = FALSE - ) AS sub ON m.Asiento = sub.Asiento - SET m.Metalico347 = TRUE, - m.TipoFactura = "I", - m.CifDni = sub.fi , - m.Nombre = sub.Nombre, - m.SiglaNacion = sub.SiglaNacion - WHERE m.enlazadoSage = FALSE; - - UPDATE sage.movConta m - SET Metalico347 = FALSE, - m.TipoFactura = "", - m.Metalico347 = FALSE - WHERE CargoAbono = "D" AND - m.enlazadoSage = FALSE; - --- Elimina cuentas de cliente/proveedor que no se utilizarán en la importación - DELETE cp - FROM clientesProveedores cp - JOIN (SELECT cp.codigoCuenta - FROM clientesProveedores cp - LEFT JOIN movConta mc ON mc.codigoCuenta = cp.codigoCuenta AND mc.enlazadoSage = FALSE - WHERE mc.codigoCuenta IS NULL - GROUP BY cp.codigoCuenta - ) sub ON sub.codigoCuenta = cp.codigoCuenta ; - --- Elimina cuentas contables que no se utilizarán en la importación - DELETE pc - FROM planCuentasPGC pc - JOIN ( SELECT pc.codigoCuenta - FROM planCuentasPGC pc - LEFT JOIN movConta mc ON mc.codigoCuenta = pc.codigoCuenta AND mc.enlazadoSage = FALSE - WHERE mc.codigoCuenta IS NULL - GROUP BY pc.codigoCuenta - ) sub ON sub.codigoCuenta = pc.codigoCuenta ; - --- DUAS - UPDATE movConta m - JOIN vn.XDiario x ON x.ASIEN = m.Asiento AND x.SUBCTA =m.CodigoCuenta - JOIN (SELECT ASIEN - FROM vn.invoiceIn ii - JOIN vn.XDiario x ON x.CLAVE = ii.id - WHERE enlazadoSage = 0 AND - SUBCTA = '4700000999' - )sub ON sub.ASIEN = x.Asien - SET m.BaseIva1 = x.BASEEURO , - m.PorIva1 = x.IVA, - m.CuotaIva1 = (x.IVA/100) * x.BASEEURO , - m.CodigoTransaccion1 = 56 , - m.CodigoIva1 = IF(x.IVA = 10, 22, 90), - m.IvaDeducible1 = TRUE, - m.Serie = x.SERIE, - m.Factura = x.FACTURA, - m.TipoFactura = "R", - m.FechaFacturaOriginal = x.FECHA_EX, - m.SuFacturaNo = x.FACTURAEX, - m.FechaOperacion = x.FECHA_OP - WHERE x.SERIE = 'D' AND - m.enlazadoSage = FALSE; - --- Rectificativas -UPDATE movConta m - JOIN (SELECT x.ASIEN, x.FECHA_RT, x.SERIE_RT, x.FACTU_RT - FROM movConta m - JOIN vn.XDiario x ON x.ASIEN = m.Asiento - WHERE m.TipoRectificativa>0 AND - m.enlazadoSage = FALSE AND - x.FACTU_RT IS NOT NULL - GROUP BY x.ASIEN - ) sub ON sub.ASIEN = m.Asiento - SET m.EjercicioFacturaOriginal = YEAR(sub.FECHA_RT), - m.SerieFacturaOriginal = sub.SERIE_RT, - m.NumeroFacturaOriginal = sub.FACTU_RT - WHERE m.TipoRectificativa > 0 AND - m.enlazadoSage = FALSE ; - --- Exportaciones Andorras y Canarias cambia TT (la cuenta de taxCode es compartida, id:125) -UPDATE sage.movConta m - SET CodigoTransaccion1 = 15, - CodigoTransaccion2 = IF(CodigoTransaccion2 = 0, 0, 15), - CodigoTransaccion3 = IF(CodigoTransaccion3 = 0, 0, 15), - CodigoTransaccion4 = IF(CodigoTransaccion4 = 0, 0, 15) - WHERE enlazadoSage = FALSE AND - (CodigoTransaccion1 = 14 OR CodigoTransaccion2 = 14 OR CodigoTransaccion3 = 14 OR CodigoTransaccion4 = 14) AND - SiglaNAcion IN ('XC','XB'); - - - --- Divisas - UPDATE sage.movConta - SET CodigoDivisa = IF(ImporteCambio<>0, "USD", "") - WHERE enlazadoSage = FALSE AND - ImporteCambio<>0 AND - ImporteDivisa<>0; - - -/*-- Actualiza las facturas DUA para excluirlas del 347 y marcarlas como intracomunitarias -/*UPDATE sage.movConta mc - SET - mc.Intracomunitaria = 1, - mc.Exclusion347 = 1 -WHERE - mc.CodigoCuenta = '4700000999'; */ - - --- MARCAR EN CASO DE SER INTRACOMUNITARIA -/* -UPDATE sage.movConta mc - SET - mc.Intracomunitaria = 1 -WHERE - mc.CodigoTransaccion1 IN (20,29); -*/ - - - -- LAS FACTURAS RTECTIFICATIVAS QUE TIENEN CUENTA DE IVA 477.2 SALE CON T.T. 1, TODAS ESTAS FACTURAS DEBEN DE TENER T.T. 15 - - /*UPDATE sage.movConta mc - JOIN - (SELECT - Asiento - FROM - sage.movConta - WHERE - CodigoCuenta = 4770000002) sub ON sub.Asiento = mc.Asiento -SET - CodigoTransaccion1 = CASE - WHEN CodigoTransaccion1 = 1 THEN 15 - ELSE CodigoTransaccion1 - END, - CodigoTransaccion2 = CASE - WHEN CodigoTransaccion2 = 1 THEN 15 - ELSE CodigoTransaccion2 - END, - CodigoTransaccion3 = CASE - WHEN CodigoTransaccion3 = 1 THEN 15 - ELSE CodigoTransaccion3 - END, - CodigoTransaccion4 = CASE - WHEN CodigoTransaccion4 = 1 THEN 15 - ELSE CodigoTransaccion4 - END -WHERE - serie = 'R'; - -*/ - -/* -Nombre Tipo Longitud Descripción campo / Valor por defecto -MovPosicion Guid contador 16 Automático, no informar -Ejercicio Entero 2 -1 -- Al informar este valor se calcula automát. A partir de la fecha de asiento -CodigoEmpresa Entero 2 Empresa de Sage 200c donde va destinado el asiento -Asiento Entero Largo 4 Número de asiento -CargoAbono Texto 1 "D" - Debe / "H" - Haber -CodigoCuenta Texto 15 Cuenta contable del movimiento -Contrapartida Texto 15 Es informativo, no es necesario informarlo -FechaAsiento Fecha 8 Fecha del asiento -TipoDocumento Texto 6 -DocumentoConta Texto 9 -Comentario Texto 40 Comentario del asiento -ImporteAsiento Doble 19 Importe del movimiento -CodigoDiario Entero 2 -CodigoCanal Texto 10 Centro coste analítico (no necesario informar) -CodigoActividad Texto 1 -FechaVencimiento Fecha 8 Si se tienen que generar efectos, será la fecha de vto. Del efecto. No informar -NumeroPeriodo Entero 2 -1 -- Al informar este valor se calcula automát. A partir de la fecha de asiento -CodigoUsuario Entero 2 -FechaGrabacion Fecha 8 -TipoEntrada Texto 2 -CodigoDepartamento Texto 10 Centro coste analítico (no necesario informar) -CodigoSeccion Texto 10 Centro coste analítico (no necesario informar) -CodigoDivisa Texto 3 -ImporteCambio Doble 19 -ImporteDivisa Doble 19 -FactorCambio Doble 19 -CodigoProyecto Texto 10 Centro coste analítico (no necesario informar) -LibreN1 Entero Largo 4 Campo libre numérico -LibreN2 Entero Largo 4 Campo libre numérico -LibreA1 Texto 15 Campo libre alfanumérico -LibreA2 Texto 15 Campo libre alfanumérico -IdDelegacion Texto 10 Centro coste analítico (no necesario informar) -OrdenMovimientos Contador 4 Número de orden de cada movimiento dentro de un mismo asiento, autonumerar para cada asiento -MovCartera Guid 16 -IdProcesoIME Guid 16 guid igual para todos los registros que correspondan a una misma importación. -TipoCarteraIME Entero 2 0 - Para que no genere cartera -TipoAnaliticaIME Entero 2 -StatusTraspasadoIME Byte 1 0 - Para que quede marcado el movimiento como no importado todavía. -TipoImportacionIME Byte 1 0 - Alta -BaseIva1 Doble 19 Base para el IVA 1 (idéntico para cada posible IVA hasta el 4) (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor) -PorBaseCorrectora1 Doble 19 Base correctora (en caso de que la haya) para el IVA 1 (idéntico para cada posible IVA hasta el 4) (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor) -PorIva1 Doble 19 Porcentaje IVA 1 (idéntico para cada posible IVA hasta el 4) (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor) -CuotaIva1 Doble 19 Cuota IVA 1 (idéntico para cada posible IVA hasta el 4) (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor) -PorRecargoEquivalencia1 Doble 19 Si hay recargo - Porcentaje de recargo para el IVA 1 (idéntico para cada posible IVA hasta el 4) (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor) -RecargoEquivalencia1 Doble 19 Si hay recargo - Importe de Recargo para el IVA 1 (idéntico para cada posible IVA hasta el 4) (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor) -CodigoTransaccion1 Byte 1 Ver con dpto. de contabilidad - Depende de la naturaleza del asiento (Nacional, Intracoumunitario, etc…) (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor) -BaseIva2 Doble 19 0 -PorBaseCorrectora2 Doble 19 0 -PorIva2 Doble 19 0 -CuotaIva2 Doble 19 0 -PorRecargoEquivalencia2 Doble 19 0 -RecargoEquivalencia2 Doble 19 0 -CodigoTransaccion2 Byte 1 0 -BaseIva3 Doble 19 0 -PorBaseCorrectora3 Doble 19 0 -PorIva3 Doble 19 0 -CuotaIva3 Doble 19 0 -PorRecargoEquivalencia3 Doble 19 0 -RecargoEquivalencia3 Doble 19 0 -CodigoTransaccion3 Byte 1 0 -BaseIva4 Doble 19 0 -PorBaseCorrectora4 Doble 19 0 -PorIva4 Doble 19 0 -CuotaIva4 Doble 19 0 -PorRecargoEquivalencia4 Doble 19 0 -RecargoEquivalencia4 Doble 19 0 -CodigoTransaccion4 Byte 1 0 -Año Entero 2 Ejercicio de la factura en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor) -Serie Texto 10 Serie de la factura en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor) -Factura Entero Largo 4 Número de la factura en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor) -SuFacturaNo Texto 40 Número de la factura del proveedor para factura recibidas, en el caso de que el asiento sea de una factura. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor) -FechaFactura Fecha 8 Fecha de la factura en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor) -ImporteFactura Doble 19 Importe de la factura en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor) -TipoFactura Texto 1 "E" - Factura emitida / "R" - Factura Recibida - en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor) -CodigoCuentaFactura Texto 15 Cuenta contable del cliente / proveedor en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor) -CifDni Texto 13 CIF del cliente / proveedor en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor) -Nombre Texto 35 Nombre del cliente / proveedor en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor) -CodigoRetencion Entero 2 Código de retención de la factura en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor) -BaseRetencion Doble 19 Base de retención de la factura en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor) -PorRetencion Doble 19 Porcentaje de retención de la factura en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor) -ImporteRetencion Doble 19 Importe de retención de la factura en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor) -AbonoIva Entero 2 0 -CodigoActividadF Texto 1 ('') -Intracomunitaria Entero 2 0 -CodigoTerritorio Entero 2 0 -SiglaNacion Texto 2 Sigla de la nación de la factura en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor) -RetencionInformativa Entero 2 0 -EjercicioFacturaOriginal Entero 2 0 -SerieFacturaOriginal Texto 10 ('') -NumeroFacturaOriginal Entero Largo 4 0 -EjercicioFactura Entero 2 Ejercicio de la factura en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor) -CobroPagoRetencion Texto 1 ('') -FechaOperacion Fecha 8 Normalmente Fecha Factura en el caso de que sea un asiento de facturas. (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor) -Exclusion347 Entero 2 0 -MovIdentificadorIME Guid contador 16 (newid()) -Previsiones Texto 1 ('') -MantenerAsiento Byte 1 -1 si se quiere mantener el número de asiento que se informa en la importación o "0" si se quiere que se asigne automáticamente el asiento en Sage 200c -OrdenMovIME Entero 2 0 -Metalico347 Entero 2 0 -ClaveOperacionFactura_ Texto 1 Ver con dpto. de contabilidad - Depende de la naturaleza del asiento (Nacional, Intracoumunitario, etc…) (Solamente se informa en el movimiento de la factura - cuenta cliente / proveedor) -SerieAgrupacion_ Texto 10 ('') -NumeroFacturaInicial_ Entero Largo 4 0 -NumeroFacturaFinal_ Entero Largo 4 0 -IdAsientoExterno Texto 50 ('') -IdDiarioExterno Texto 10 ('') -IdFacturaExterno Texto 50 ('') -IdMovimiento Texto 40 ('') -IdCuadre Entero 2 ((0)) -FechaCuadre Fecha 8 (getdate()) -TipoCuadre Texto 4 ('') -AgrupacionCuadre Entero Largo 4 ((0)) -StatusSaldo Entero 2 ((0)) -StatusConciliacion Entero 2 ((0)) -CodigoConciliacion Entero Largo 4 ((0)) -FechaConciliacion Fecha 8 -TipoConciliacion Entero 2 ((0)) -IndicadorContaBanco Texto 1 ('') -Descripcion3 Texto 40 ('') -Descripcion4 Texto 40 ('') -Descripcion5 Texto 40 ('') -Descripcion6 Texto 40 ('') -Descripcion7 Texto 40 ('') -Descripcion8 Texto 50 ('') -Descripcion9 Texto 50 ('') -Descripcion2 Texto 250 ('') -Descripcion1 Texto 250 ('') -Punteo1 Entero 2 ((0)) -Punteo9 Entero 2 ((0)) -Punteo8 Entero 2 ((0)) -Punteo7 Entero 2 ((0)) -Punteo6 Entero 2 ((0)) -Punteo5 Entero 2 ((0)) -Punteo4 Entero 2 ((0)) -Punteo3 Entero 2 ((0)) -Punteo2 Entero 2 ((0)) -CodigoIva1 Entero 2 ((0)) -CodigoIva2 Entero 2 ((0)) -CodigoIva3 Entero 2 ((0)) -CodigoIva4 Entero 2 ((0)) -CriterioIva Byte 1 ((0)) -FechaMaxVencimiento Fecha 8 -TipoCriterioCaja Byte 1 ((0)) -MovFacturaOrigenIME Texto 50 ('') -IdFacturaExternoFinal Texto 50 ('') -IdFacturaExternoInicial Texto 50 ('') -IdFacturaExternoOriginal Texto 50 ('') -NumFacturasExternoAgrupacion Entero Largo 4 ((0)) -CodigoMedioCobro Texto 1 ('') -MedioCobro Texto 31 ('') -IvaDeducible1 Entero 2 ((-1)) -IvaDeducible2 Entero 2 ((-1)) -IvaDeducible3 Entero 2 ((-1)) -IvaDeducible4 Entero 2 ((-1)) -TipoRectificativa Entero 2 ((0)) -FechaFacturaOriginal Fecha 8 -BaseImponibleOriginal Doble 19 ((0)) -CuotaIvaOriginal Doble 19 ((0)) -ClaseAbonoRectificativas Entero 2 ((0)) -RecargoEquivalenciaOriginal Doble 19 ((0)) -ObjetoFactura Texto 500 ('') -*/ -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 `movContaAdd___` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -22140,7 +22082,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`z-sysadmin`@`%`*/ /*!50106 EVENT `log_clean` ON SCHEDULE EVERY 1 DAY STARTS '2019-06-17 02:45:00' ON COMPLETION PRESERVE ENABLE DO CALL log_clean */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`%`*/ /*!50106 EVENT `log_clean` ON SCHEDULE EVERY 1 DAY STARTS '2019-06-17 02:45:00' ON COMPLETION PRESERVE ENABLE DO CALL log_clean */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -23250,9 +23192,10 @@ DROP TABLE IF EXISTS `version`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `version` ( `code` varchar(255) COLLATE utf8_unicode_ci NOT NULL, - `number` char(11) COLLATE utf8_unicode_ci NOT NULL, - `gitCommit` varchar(255) COLLATE utf8_unicode_ci NOT NULL, - `updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `number` char(11) COLLATE utf8_unicode_ci DEFAULT NULL, + `gitCommit` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `updated` datetime DEFAULT NULL, + `lastNumber` char(11) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -23267,9 +23210,9 @@ DROP TABLE IF EXISTS `versionUser`; CREATE TABLE `versionUser` ( `code` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `user` varchar(255) COLLATE utf8_unicode_ci NOT NULL, - `number` char(11) COLLATE utf8_unicode_ci NOT NULL, - `gitCommit` varchar(255) COLLATE utf8_unicode_ci NOT NULL, - `updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `number` char(11) COLLATE utf8_unicode_ci DEFAULT NULL, + `gitCommit` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `updated` datetime NOT NULL, PRIMARY KEY (`code`,`user`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -23277,6 +23220,27 @@ CREATE TABLE `versionUser` ( -- -- Dumping events for database 'util' -- +/*!50106 SET @save_time_zone= @@TIME_ZONE */ ; +/*!50106 DROP EVENT IF EXISTS `slowLog_prune` */; +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 @saved_sql_mode = @@sql_mode */ ;; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;; +/*!50003 SET @saved_time_zone = @@time_zone */ ;; +/*!50003 SET time_zone = 'SYSTEM' */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`%`*/ /*!50106 EVENT `slowLog_prune` ON SCHEDULE EVERY 1 DAY STARTS '2021-10-08 00:00:00' ON COMPLETION PRESERVE ENABLE DO CALL util.slowLog_prune */ ;; +/*!50003 SET time_zone = @saved_time_zone */ ;; +/*!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 */ ;; +DELIMITER ; +/*!50106 SET TIME_ZONE= @save_time_zone */ ; -- -- Dumping routines for database 'util' @@ -23488,6 +23452,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 FUNCTION IF EXISTS `hasDateOverlapped` */; +/*!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 `hasDateOverlapped`(vSarted1 DATE, vEnded1 DATE, vSarted2 DATE, vEnded2 DATE) RETURNS tinyint(1) + DETERMINISTIC +BEGIN + + RETURN GREATEST(vSarted1, vSarted2) <= LEAST(vEnded1,vEnded2); + +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 `hmacSha2` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -23532,6 +23518,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 FUNCTION IF EXISTS `isLeapYear` */; +/*!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 `isLeapYear`(vYear INT) RETURNS tinyint(1) + DETERMINISTIC +BEGIN + + RETURN (DAYOFYEAR(CONCAT(vYear, "-02-29")) IS NOT NULL); + +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 `lang` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -24072,77 +24080,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 `findObject__` */; -/*!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 `findObject__`(vChain VARCHAR(45)) - READS SQL DATA -BEGIN -/** - * Devuelve un listado de todos los procedimientos, funciones - * eventos, disparadores y vistas que inluyen una cadena dada. - * - * @param vChain Cadena a buscar - * @select Listado de objetos - */ - SET vChain = CONCAT('%', vChain, '%'); - - SELECT * FROM - ( - SELECT - `db`, - `name`, - `type`, - `body`, - `created`, - `modified` - FROM `mysql`.`proc` - WHERE `body` LIKE vChain COLLATE utf8_general_ci - UNION ALL - SELECT - `db`, - `name`, - 'EVENT', - `body_utf8`, - `created`, - `modified` - FROM `mysql`.`event` - WHERE `body_utf8` LIKE vChain COLLATE utf8_general_ci - UNION ALL - SELECT - `EVENT_OBJECT_SCHEMA`, - `TRIGGER_NAME`, - 'TRIGGER', - `ACTION_STATEMENT`, - NULL, - NULL - FROM `information_schema`.`TRIGGERS` - WHERE `ACTION_STATEMENT` LIKE vChain COLLATE utf8_general_ci - UNION ALL - SELECT - `TABLE_SCHEMA`, - `TABLE_NAME`, - 'VIEW', - `VIEW_DEFINITION`, - NULL, - NULL - FROM `information_schema`.`VIEWS` - WHERE `VIEW_DEFINITION` LIKE vChain COLLATE utf8_general_ci - ) t - ORDER BY `db`, `name`; -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 `procNoOverlap` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -24264,6 +24201,37 @@ 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 `slowLog_prune` */; +/*!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 @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `slowLog_prune`() +BEGIN +/** + * Prunes MySQL slow query log table deleting all records older than one week. + */ + DECLARE vSlowQueryLog INT DEFAULT @@slow_query_log; + + SET GLOBAL slow_query_log = 'OFF'; + RENAME TABLE `mysql`.`slow_log` TO `mysql`.`slow_log_temp`; + + DELETE FROM `mysql`.`slow_log_temp` + WHERE start_time < TIMESTAMPADD(WEEK, -1, NOW()); + + RENAME TABLE `mysql`.`slow_log_temp` TO `mysql`.`slow_log`; + SET GLOBAL slow_query_log = vSlowQueryLog; +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 `throw` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -24504,7 +24472,9 @@ SET character_set_client = utf8; `name` tinyint NOT NULL, `rgb` tinyint NOT NULL, `code` tinyint NOT NULL, - `holidayEntitlementRate` tinyint NOT NULL + `permissionRate` tinyint NOT NULL, + `holidayEntitlementRate` tinyint NOT NULL, + `discountRate` tinyint NOT NULL ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; @@ -24921,7 +24891,6 @@ DROP TABLE IF EXISTS `alertLevel`; CREATE TABLE `alertLevel` ( `code` varchar(45) CHARACTER SET utf8 NOT NULL, `id` int(11) NOT NULL, - `alertLevel` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -25195,13 +25164,11 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`awb_au` AFTER UPDATE ON `awb` FOR EACH ROW -begin +BEGIN -IF NEW.amount <> OLD.amount THEN - - CALL vn2008.buy_tarifas_awb(NEW.code); - -END IF; + IF NEW.amount <> OLD.amount THEN + CALL vn2008.buy_tarifas_awb(NEW.code); + END IF; END */;; DELIMITER ; @@ -25266,7 +25233,7 @@ CREATE TABLE `bank` ( KEY `foreignkey1_idx` (`cash`), KEY `Bancoscurrency_idx` (`currencyFk`), CONSTRAINT `Bancoscurrency` FOREIGN KEY (`currencyFk`) REFERENCES `currency` (`id`) ON UPDATE CASCADE, - CONSTRAINT `foreignkey1` FOREIGN KEY (`cash`) REFERENCES `accountingType` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION + CONSTRAINT `bank_FK` FOREIGN KEY (`cash`) REFERENCES `accountingType` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Apunta a la vista vn.Accounting\nLa columna cash es la FK de vn.AccountingType'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -26282,8 +26249,8 @@ CREATE TABLE `client` ( `email` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `cc` varchar(23) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'obsoleta (comprobar)', `dueDay` smallint(6) NOT NULL DEFAULT '5', - `receipt` int(11) DEFAULT '1' COMMENT 'obsoleta', - `isOfficial` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'obsoleta (comprobar)', + `receipt__` int(11) DEFAULT '1' COMMENT 'obsoleta', + `isOfficial__` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'obsoleta (comprobar)', `isTaxDataChecked` tinyint(1) NOT NULL DEFAULT '0', `mobile` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, `accountingAccount` varchar(10) CHARACTER SET utf8 NOT NULL, @@ -26299,7 +26266,7 @@ CREATE TABLE `client` ( `notes` text COLLATE utf8_unicode_ci COMMENT 'obsoleta (comprobar)', `administrativeNotes__` text COLLATE utf8_unicode_ci NOT NULL COMMENT 'obsoleta (comprobar)', `invoiceCopy__` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'obsoleta (comprobar)', - `hold` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'obsoleta (comprobar)', + `hold__` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'obsoleta (comprobar)', `isFreezed` tinyint(1) NOT NULL DEFAULT '0', `salesPersonFk` int(10) unsigned DEFAULT NULL, `credit` decimal(10,2) NOT NULL DEFAULT '0.00', @@ -26447,7 +26414,7 @@ BEGIN IF vText IS NOT NULL THEN - INSERT INTO mail(sender, replyTo, `subject`, body) + INSERT INTO mail(receiver, replyTo, `subject`, body) SELECT CONCAT(IF(ac.id,u.name, 'jgallego'), '@verdnatura.es'), 'administracion@verdnatura.es', @@ -26482,9 +26449,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 ;; @@ -26500,12 +26467,13 @@ BEGIN WHERE id = NEW.defaultAddressFk; END IF; - IF NOT (NEW.provinceFk <=> OLD.provinceFk) THEN + IF NOT (NEW.provinceFk <=> OLD.provinceFk) OR NOT (NEW.isVies <=> OLD.isVies) THEN INSERT IGNORE INTO ticketRecalc (ticketFk) SELECT id FROM ticket t WHERE t.clientFk = NEW.id AND t.refFk IS NULL; END IF; + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -26740,6 +26708,20 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +-- +-- Temporary table structure for view `clientPhoneBook` +-- + +DROP TABLE IF EXISTS `clientPhoneBook`; +/*!50001 DROP VIEW IF EXISTS `clientPhoneBook`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `clientPhoneBook` ( + `clientFk` tinyint NOT NULL, + `phone` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `clientProtected` -- @@ -26870,6 +26852,7 @@ CREATE TABLE `cmr` ( `packagesList` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `merchandiseDetail` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `state` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `landed` datetime DEFAULT NULL COMMENT 'Hora de llegada a destino', PRIMARY KEY (`id`), KEY `cmr_fk1_idx` (`ticketFk`), KEY `cmr_fk2_idx` (`companyFk`), @@ -27244,6 +27227,7 @@ CREATE TABLE `company` ( KEY `empresa_cliente_idx` (`clientFk`), KEY `Id_Proveedores_account` (`supplierAccountFk`), KEY `empresa_grupo_fk_idx` (`companyGroupFk`), + KEY `company_fhAdminNumber_IDX` (`fhAdminNumber`) USING BTREE, CONSTRAINT `company_ibfk_1` FOREIGN KEY (`workerManagerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `empresa_cliente` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `empresa_fk4` FOREIGN KEY (`supplierAccountFk`) REFERENCES `supplierAccount` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, @@ -27440,8 +27424,7 @@ CREATE TABLE `config` ( `fakeEmail` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `defaultersMaxAmount` int(10) DEFAULT '200' COMMENT 'maxima deuda permitida a partir de la cual se bloquea a un usuario', `ASIEN` bigint(20) DEFAULT NULL, - `deviceHuntingMode` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Habilita el modo cazador para usuarios sin device registrado', - `tractorHuntingMode` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Habilita el modo cazador para usuarios que no se han logeado un tractor para sacar', + `dayStartingHour` int(11) NOT NULL DEFAULT '3' COMMENT 'Hora a la que empieza una nueva jornada de producción', PRIMARY KEY (`id`), KEY `fechainv_idx` (`inventoried`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -27722,11 +27705,14 @@ BEGIN WHERE Nacion = NEW.country; IF ROW_COUNT() = 0 THEN - INSERT INTO vn.mail (sender, subject, body) - VALUES ('cau@verdnatura.es', - 'Actualizar tabla sage.Naciones', - CONCAT('Se ha insertado un nuevo país en la tabla vn.conuntry. Para el correcto funcionamiento del sistema de contabilidad es necesario actualizar la columna sage.Naciones.countryFk con el valor del nuevo país. - Hay que buscar el nuevo país: ', NEW.country, ' en la tabla sage.Naciones y actualizar el campo sage.Naciones.countryFk con el valor ', NEW.id)); + CALL mail_insert( + 'cau@verdnatura.es', + NULL, + 'Actualizar tabla sage.Naciones', + CONCAT('Se ha insertado un nuevo país en la tabla vn.conuntry. Para el correcto funcionamiento del sistema + de contabilidad es necesario actualizar la columna sage.Naciones.countryFk con el valor del nuevo país. + Hay que buscar el nuevo país: ', NEW.country, ' en la tabla sage.Naciones y actualizar el campo sage.Naciones.countryFk con el valor ', NEW.id) + ); END IF; END */;; @@ -28164,6 +28150,7 @@ CREATE TABLE `department` ( `isTeleworking` tinyint(1) DEFAULT '0', `notificationEmail` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, `hasToRefill` tinyint(1) DEFAULT '0' COMMENT 'Rellenar días sin fichadas presenciales', + `hasToSendMail` tinyint(1) DEFAULT '0' COMMENT 'Para el envio de mail en el procedimiento workerTimeControl_sendMail()', PRIMARY KEY (`id`), UNIQUE KEY `name_UNIQUE` (`name`), KEY `fk_department_Trabajadores1_idx` (`workerFk`), @@ -28233,13 +28220,13 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; -- --- Table structure for table `departmentItemType` +-- Table structure for table `departmentItemType__` -- -DROP TABLE IF EXISTS `departmentItemType`; +DROP TABLE IF EXISTS `departmentItemType__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `departmentItemType` ( +CREATE TABLE `departmentItemType__` ( `id` int(11) NOT NULL AUTO_INCREMENT, `departmentFk` int(11) NOT NULL, `itemTypeFk` smallint(5) unsigned NOT NULL, @@ -28312,6 +28299,8 @@ CREATE TABLE `deviceLog` ( `android_id` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `userFk` int(11) DEFAULT NULL, `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `nameApp` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `versionApp` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -28343,6 +28332,21 @@ CREATE TABLE `deviceProduction` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `deviceProductionConfig` +-- + +DROP TABLE IF EXISTS `deviceProductionConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `deviceProductionConfig` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `isAllUsersallowed` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Permite que cualquier usuario pueda loguearse', + `isTractorHuntingMode` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Habilita el modo cazador para usuarios que no se han logeado un tractor para sacar', + PRIMARY KEY (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `deviceProductionModels` -- @@ -28397,7 +28401,7 @@ DROP TABLE IF EXISTS `dms`; CREATE TABLE `dms` ( `id` int(11) NOT NULL AUTO_INCREMENT, `dmsTypeFk` int(11) NOT NULL DEFAULT '1', - `reference` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, + `reference` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `description` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL, `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', `hardCopyNumber` mediumint(8) unsigned DEFAULT NULL, @@ -28406,10 +28410,10 @@ CREATE TABLE `dms` ( `hasFile` tinyint(4) NOT NULL DEFAULT '0', `workerFk` int(10) unsigned DEFAULT NULL, `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `warehouseFk` smallint(5) unsigned NOT NULL DEFAULT '60', + `warehouseFk` smallint(5) unsigned DEFAULT '60', PRIMARY KEY (`id`), UNIQUE KEY `emp_id` (`companyFk`,`hardCopyNumber`,`warehouseFk`), - UNIQUE KEY `dms_hardCopyNumber_IDX` (`hardCopyNumber`,`warehouseFk`,`companyFk`) USING BTREE, + UNIQUE KEY `dms_hardCopyNumber_IDX` (`hardCopyNumber`,`warehouseFk`) USING BTREE, KEY `trabajador_id` (`workerFk`), KEY `warehouse_id` (`warehouseFk`), KEY `dms_dmsTypeFk_idx` (`dmsTypeFk`), @@ -29246,6 +29250,54 @@ CREATE TABLE `errorLogApp` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Guarda un registro de errores e la app de almacén'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `errorProduction` +-- + +DROP TABLE IF EXISTS `errorProduction`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `errorProduction` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `userFk` int(11) DEFAULT NULL, + `firstname` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `lastname` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `rol` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `ticketNumber` int(11) DEFAULT NULL, + `error` int(11) DEFAULT NULL, + `ratio` double DEFAULT NULL, + `volume` double DEFAULT NULL, + `hourStart` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `hourEnd` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `hourWorked` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `dated` date DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `errorProduction__` +-- + +DROP TABLE IF EXISTS `errorProduction__`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `errorProduction__` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `userFk` int(11) DEFAULT NULL, + `firstname` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `lastname` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `rol` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `ticketNumber` int(11) DEFAULT NULL, + `error` int(11) DEFAULT NULL, + `ratio` double DEFAULT NULL, + `volume` double DEFAULT NULL, + `month` int(11) DEFAULT NULL, + `year` int(11) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `erte` -- @@ -29705,7 +29757,8 @@ SET character_set_client = utf8; `beachFk` tinyint NOT NULL, `zona` tinyint NOT NULL, `province` tinyint NOT NULL, - `phone` tinyint NOT NULL + `phone` tinyint NOT NULL, + `workerCode` tinyint NOT NULL ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; @@ -29734,6 +29787,22 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `expeditionTicket_NoBoxes` +-- + +DROP TABLE IF EXISTS `expeditionTicket_NoBoxes`; +/*!50001 DROP VIEW IF EXISTS `expeditionTicket_NoBoxes`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `expeditionTicket_NoBoxes` ( + `ticketFk` tinyint NOT NULL, + `warehouseFk` tinyint NOT NULL, + `routeFk` tinyint NOT NULL, + `description` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `expeditionTimeExpended` -- @@ -29763,8 +29832,11 @@ CREATE TABLE `expeditionTruck` ( `id` int(11) NOT NULL AUTO_INCREMENT, `ETD` datetime DEFAULT NULL, `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `bufferFk` int(11) DEFAULT NULL COMMENT 'buffer destino de las cajas', PRIMARY KEY (`id`), - KEY `expeditionTruck_idx1` (`ETD`) + KEY `expeditionTruck_idx1` (`ETD`), + KEY `expeditionTruck_FK` (`bufferFk`), + CONSTRAINT `expeditionTruck_FK` FOREIGN KEY (`bufferFk`) REFERENCES `srt`.`buffer` (`id`) ON DELETE SET NULL 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 */ ; @@ -29940,6 +30012,7 @@ CREATE TABLE `floramondoConfig` ( `MaxLatestDeliveryHour` int(11) DEFAULT NULL, `MaxLatestOrderHour` int(11) DEFAULT '12' COMMENT 'Hora máxima para aceptar pedidos hoy', `LastUpdated` datetime DEFAULT NULL, + `itemMaxSize` int(11) DEFAULT NULL COMMENT 'tamaño maximo de los articulos a mostrar', PRIMARY KEY (`id`), KEY `floramondoConfigWarehouseIn_idx` (`warehouseInFk`), KEY `floramondoConfigWarehouseOut_idx` (`warehouseOutFk__`), @@ -29968,6 +30041,20 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +-- +-- Table structure for table `floramondoNotOfferDay` +-- + +DROP TABLE IF EXISTS `floramondoNotOfferDay`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `floramondoNotOfferDay` ( + `dated` date NOT NULL, + `warehouseFk` int(11) NOT NULL DEFAULT '60', + PRIMARY KEY (`dated`,`warehouseFk`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='no muestra oferta en floramondo para ese dia y almacen'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `fuelType` -- @@ -30014,6 +30101,45 @@ CREATE TABLE `genus` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `glsConfig` +-- + +DROP TABLE IF EXISTS `glsConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `glsConfig` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `service` int(1) DEFAULT NULL, + `schedule` int(1) DEFAULT NULL, + `token` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `labelType` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, + `supplierFk` int(11) DEFAULT NULL, + `package` int(1) DEFAULT NULL, + `refund` int(1) DEFAULT NULL, + `weight` int(1) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `glsExpedition` +-- + +DROP TABLE IF EXISTS `glsExpedition`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `glsExpedition` ( + `expeditionFk` int(11) NOT NULL, + `barcode` bigint(20) unsigned DEFAULT NULL, + `uid` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `codexp` int(11) DEFAULT NULL, + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`expeditionFk`), + CONSTRAINT `glsInfo_FK` FOREIGN KEY (`expeditionFk`) REFERENCES `expedition` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `greuge` -- @@ -30434,7 +30560,6 @@ DELIMITER ;; WHERE supplierRef = NEW.supplierRef AND supplierFk = NEW.supplierFk AND YEAR(issued) = YEAR(NEW.issued) - AND id <> NEW.id ) THEN CALL util.throw('reference duplicated'); END IF; @@ -30598,13 +30723,15 @@ BEGIN IF (NEW.dueDated <= CURDATE() AND vIsNotified) THEN - INSERT INTO vn.mail SET - `sender` = 'begonya@verdnatura.es', - `replyTo` = 'begonya@verdnatura.es', - `subject` = 'Añadido vencimiento en el pasado', - `body` = CONCAT(account.myUserGetName(), ' ha añadido un vencimiento de ', - NEW.amount,'€ en una fecha pasada en la recibida ', - NEW.invoiceInFk); + CALL mail_insert( + 'begonya@verdnatura.es', + 'begonya@verdnatura.es', + 'Añadido vencimiento en el pasado', + CONCAT( + account.myUserGetName(), ' ha añadido un vencimiento de ', + NEW.amount, '€ en una fecha pasada en la recibida ', NEW.invoiceInFk + ) + ); END IF; END */;; @@ -30636,13 +30763,15 @@ BEGIN IF (NEW.dueDated <= CURDATE() AND vIsNotified) THEN - INSERT INTO vn.mail SET - `sender` = 'begonya@verdnatura.es', - `replyTo` = 'begonya@verdnatura.es', - `subject` = 'Añadido vencimiento en el pasado', - `body` = CONCAT(account.myUserGetName(), ' ha añadido un vencimiento de ', - NEW.amount,'€ en una fecha pasada en la recibida ', - NEW.invoiceInFk); + CALL mail_insert( + 'begonya@verdnatura.es', + 'begonya@verdnatura.es', + 'Añadido vencimiento en el pasado', + CONCAT( + account.myUserGetName(), ' ha añadido un vencimiento de ', + NEW.amount,'€ en una fecha pasada en la recibida ',NEW.invoiceInFk + ) + ); END IF; END */;; @@ -30671,24 +30800,6 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; --- --- Temporary table structure for view `invoiceInEntry__` --- - -DROP TABLE IF EXISTS `invoiceInEntry__`; -/*!50001 DROP VIEW IF EXISTS `invoiceInEntry__`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `invoiceInEntry__` ( - `id` tinyint NOT NULL, - `invoiceInFk` tinyint NOT NULL, - `entryFk` tinyint NOT NULL, - `percentage` tinyint NOT NULL, - `invoiceInAwbFk` tinyint NOT NULL, - `isBooked` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - -- -- Table structure for table `invoiceInIntrastat` -- @@ -30994,14 +31105,26 @@ 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 ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`invoiceOut_afterInsert` AFTER INSERT ON `vn`.`invoiceOut` FOR EACH ROW BEGIN CALL clientRisk_update(NEW.clientFk, NEW.companyFk, NEW.amount); + IF (SELECT COUNT(*) + FROM client + WHERE id = NEW.clientFk + AND businessTypeFk = 'officialOrganism' + ) THEN + CALL mail_insert('administracion@verdnatura.es', + NULL, + CONCAT('Se ha emitido una factura al organismo: ', NEW.clientFk), + CONCAT('Presentar factura en FACE https://salix.verdnatura.es/#!/invoice-out/', + NEW.id, + '/summary')); + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -31178,7 +31301,7 @@ CREATE TABLE `item` ( `stars` int(11) DEFAULT NULL, `stemMultiplier` double NOT NULL DEFAULT '1' COMMENT 'este valor multiplica las unidades y divide los precios en el procedimiento edi.ekt_load', `itemPackingTypeFk` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, - `packingOut` int(11) DEFAULT NULL COMMENT 'cantidad que cabe en una caja de verdnatura', + `packingOut` decimal(10,2) DEFAULT NULL COMMENT 'cantidad que cabe en una caja de verdnatura', PRIMARY KEY (`id`), UNIQUE KEY `item_supplyResponseFk_idx` (`supplyResponseFk`), KEY `Color` (`inkFk`), @@ -31254,15 +31377,17 @@ 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 ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`item_afterInsert` - AFTER INSERT ON `item` FOR EACH ROW +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`item_afterInsert` + AFTER INSERT ON `item` + FOR EACH ROW BEGIN + CALL hedera.image_ref('catalog', NEW.image); INSERT INTO vn.itemTaxCountry(itemFk, countryFk) @@ -31273,12 +31398,6 @@ BEGIN INSERT INTO vn.itemTaxCountry(itemFk, countryFk) SELECT NEW.id, 30; - /* - IF NEW.typeFk IS NOT NULL THEN - INSERT INTO vn.itemTag (itemFk, tagFk, priority) - SELECT NEW.id, tagFk, priority FROM vn.itemTypeTag - WHERE itemTypeFk = NEW.typeFk; - END IF;*/ END */;; DELIMITER ; @@ -31298,6 +31417,8 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`item_afterUpdate` AFTER UPDATE ON `item` FOR EACH ROW BEGIN + DECLARE vStandardFlowerBox INT; + IF !(NEW.image <=> OLD.image) THEN CALL hedera.image_unref('catalog', OLD.image); CALL hedera.image_ref('catalog', NEW.image); @@ -31305,8 +31426,15 @@ BEGIN IF NEW.density = 0 THEN CALL util.throw('error densidad = 0'); END IF; - IF (SELECT NEW.compression < minCompressionRate FROM vn.volumeConfig vc) AND NEW.compression < OLD.compression THEN - CALL util.throw('compression too low'); + + IF !(NEW.packingOut <=> OLD.packingOut) THEN + SELECT standardFlowerBox * 1000 INTO vStandardFlowerBox + FROM volumeConfig; + + UPDATE itemCost ic + JOIN warehouse w ON w.id = ic.warehouseFk + SET cm3Delivery = IFNULL(vStandardFlowerBox / NEW.packingOut, cm3) + WHERE itemFk = NEW.id AND w.hasProduction; END IF; END */;; DELIMITER ; @@ -31366,7 +31494,7 @@ DROP TABLE IF EXISTS `itemBotanical`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `itemBotanical` ( `itemFk` int(11) NOT NULL, - `botanical` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `botanical__` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `genusFk` int(11) NOT NULL, `specieFk` int(11) DEFAULT NULL, PRIMARY KEY (`itemFk`), @@ -31516,6 +31644,7 @@ BEGIN IF NEW.itemFk IN (95, 98) THEN SET NEW.cm3 = 0; END IF; + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -31525,9 +31654,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 ;; @@ -31548,6 +31677,13 @@ BEGIN AND ic.itemFk = NEW.itemFk AND r.created >= CURDATE() GROUP BY r.id; + IF NEW.cm3Delivery = 0 AND NEW.warehouseFk = 60 THEN + CALL mail_insert( + 'jgallego@verdnatura.es', + NULL, + 'update cm3Delivery', + CONCAT('articulo: ', NEW.itemFk)); + END IF; END IF; END */;; DELIMITER ; @@ -31686,6 +31822,23 @@ CREATE TABLE `itemLog` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `itemMatchProperties` +-- + +DROP TABLE IF EXISTS `itemMatchProperties`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `itemMatchProperties` ( + `itemFk` int(11) NOT NULL, + `name` varchar(80) COLLATE utf8_unicode_ci NOT NULL, + `producer` varchar(80) COLLATE utf8_unicode_ci NOT NULL, + `size` int(11) NOT NULL, + PRIMARY KEY (`itemFk`,`name`,`producer`,`size`), + CONSTRAINT `itemFk___fk` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Propiedades para encontrar articulos equivalentes en verdnatura'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `itemPackingType` -- @@ -32614,7 +32767,7 @@ CREATE TABLE `itemType` ( `gramsMin` int(11) DEFAULT NULL, `gramsMax` int(11) DEFAULT NULL, `order` int(11) DEFAULT '0', - `temperature` tinyint(1) unsigned NOT NULL DEFAULT '0', + `temperature__` tinyint(1) unsigned DEFAULT NULL, `categoryFk` int(10) unsigned NOT NULL, `workerFk` int(10) unsigned NOT NULL, `isInventory` tinyint(4) NOT NULL DEFAULT '1' COMMENT 'Se utiliza tanto en el cálculo del inventario, como en el del informe del inventario valorado', @@ -32714,6 +32867,25 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `itemTypeRestriction` +-- + +DROP TABLE IF EXISTS `itemTypeRestriction`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `itemTypeRestriction` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `itemTypeFk` smallint(5) unsigned NOT NULL, + `dated` date NOT NULL, + `minAmount` decimal(10,2) NOT NULL COMMENT 'importe mínimo en la linea de venta', + PRIMARY KEY (`id`), + UNIQUE KEY `itemTypeRestriction_UN` (`itemTypeFk`,`dated`), + KEY `itemTypeRestriction_dated_IDX` (`dated`,`itemTypeFk`) USING BTREE, + CONSTRAINT `itemTypeRestriction_itemType_id_fk` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `itemTypeTag` -- @@ -32855,7 +33027,10 @@ SET character_set_client = utf8; `stickers` tinyint NOT NULL, `packing` tinyint NOT NULL, `ref` tinyint NOT NULL, - `itemFk` tinyint NOT NULL + `itemFk` tinyint NOT NULL, + `pro` tinyint NOT NULL, + `ektRef` tinyint NOT NULL, + `agj` tinyint NOT NULL ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; @@ -33028,6 +33203,20 @@ CREATE TABLE `machineWorker` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Registros horarios de vehículos de almacén por empleado'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `machineWorkerConfig` +-- + +DROP TABLE IF EXISTS `machineWorkerConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `machineWorkerConfig` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `maxHours` smallint(5) unsigned NOT NULL COMMENT 'Indicates how many hours a user record is reviewed to update or insert', + PRIMARY KEY (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `mail` -- @@ -33038,7 +33227,7 @@ DROP TABLE IF EXISTS `mail`; CREATE TABLE `mail` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `receiver` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `sender` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `sender` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `replyTo` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `subject` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `body` text COLLATE utf8_unicode_ci NOT NULL, @@ -33322,6 +33511,7 @@ CREATE TABLE `mobileAppVersionControl` ( `id` int(11) NOT NULL AUTO_INCREMENT, `appName` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `version` varchar(45) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0', + `IsVersionCritical` tinyint(1) DEFAULT '0', PRIMARY KEY (`id`) ) 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 */; @@ -33738,7 +33928,8 @@ CREATE TABLE `payMethod` ( `solution` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, `outstandingDebt` tinyint(3) unsigned zerofill NOT NULL DEFAULT '000', `graceDays` int(11) unsigned NOT NULL DEFAULT '0', - `ibanRequired` tinyint(3) DEFAULT '0', + `ibanRequiredForClients` tinyint(3) DEFAULT '0', + `ibanRequiredForSuppliers` tinyint(3) DEFAULT '0', `isNotified` tinyint(3) NOT NULL DEFAULT '1', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -33958,8 +34149,12 @@ CREATE TABLE `person` ( `isDisable` tinyint(1) NOT NULL DEFAULT '0', `isFreelance` tinyint(1) NOT NULL DEFAULT '0', `isSsDiscounted` tinyint(1) NOT NULL DEFAULT '0', + `nickname` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, + `p2` longtext COLLATE utf8_unicode_ci, + `sex` enum('M','F') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'F' COMMENT 'M Masculino F Femenino', PRIMARY KEY (`id`), UNIQUE KEY `nif` (`fi`), + UNIQUE KEY `person_UN` (`readerId`), KEY `nifIndex` (`fi`), KEY `workerFk_idx` (`workerFk`), CONSTRAINT `Person_ibfk_1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE @@ -34531,7 +34726,7 @@ CREATE TABLE `profile` ( KEY `profileTypeFk` (`profileTypeFk`), CONSTRAINT `profile_ibfk_1` FOREIGN KEY (`personFk`) REFERENCES `person` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `profile_ibfk_2` FOREIGN KEY (`profileTypeFk`) REFERENCES `profileType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -34800,7 +34995,7 @@ CREATE TABLE `receipt` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `invoiceFk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'nombre incorrecto, renombrar a description', `amountPaid` decimal(10,2) NOT NULL DEFAULT '0.00', - `amountUnpaid` decimal(10,2) NOT NULL DEFAULT '0.00', + `amountUnpaid__` decimal(10,2) NOT NULL DEFAULT '0.00', `payed` datetime DEFAULT NULL, `workerFk` int(10) unsigned DEFAULT NULL, `bankFk` int(11) DEFAULT '0', @@ -34887,19 +35082,21 @@ 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 ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`receipt_afterUpdate` AFTER UPDATE ON `receipt` FOR EACH ROW BEGIN IF NEW.isConciliate = FALSE AND NEW.payed > OLD.payed THEN - INSERT INTO vn.mail(`sender`, subject, `body`) - SELECT 'finanzas@verdnatura.es', - CONCAT(' Cambios de recibos del cliente: ', NEW.clientFk), - CONCAT('Se ha cambiado el recibo: ', NEW.Id, ' de ', OLD.payed, ' a ', NEW.payed); + CALL mail_insert( + 'finanzas@verdnatura.es', + NULL, + CONCAT('Cambios de recibos del cliente: ', NEW.clientFk), + CONCAT('Se ha cambiado el recibo: ', NEW.Id, ' de ', OLD.payed, ' a ', NEW.payed) + ); END IF; END */;; DELIMITER ; @@ -35586,9 +35783,9 @@ BEGIN UPDATE vn.collection c JOIN vn.ticketCollection tc ON tc.collectionFk = c.id AND tc.ticketFk = NEW.ticketFk - JOIN vn.item i ON i.id = NEW.itemFk + /*JOIN vn.item i ON i.id = NEW.itemFk AND (c.itemPackingTypeFk = i.itemPackingTypeFk - OR ISNULL(c.itemPackingTypeFk)) + OR ISNULL(c.itemPackingTypeFk))*/ SET c.salePickedCount = c.salePickedCount + IF(NEW.isPicked != 0, 1, -1); @@ -35598,9 +35795,9 @@ BEGIN UPDATE vn.collection c JOIN vn.ticketCollection tc ON tc.collectionFk = c.id AND tc.ticketFk = NEW.ticketFk - JOIN vn.item i ON i.id = NEW.itemFk + /*JOIN vn.item i ON i.id = NEW.itemFk AND (c.itemPackingTypeFk = i.itemPackingTypeFk - OR ISNULL(c.itemPackingTypeFk)) + OR ISNULL(c.itemPackingTypeFk))*/ SET c.saleTotalCount = c.saleTotalCount + IF(OLD.quantity = 0, 1, -1); END IF; @@ -35845,27 +36042,6 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; --- --- Temporary table structure for view `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 TABLE `saleFreight__` ( - `ticketFk` tinyint NOT NULL, - `clientFk` tinyint NOT NULL, - `routeFk` tinyint NOT NULL, - `saleFk` tinyint NOT NULL, - `zoneFk` tinyint NOT NULL, - `companyFk` tinyint NOT NULL, - `shipped` tinyint NOT NULL, - `price` tinyint NOT NULL, - `freight` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - -- -- Table structure for table `saleGoal` -- @@ -35916,7 +36092,7 @@ DROP TABLE IF EXISTS `saleMistake`; CREATE TABLE `saleMistake` ( `id` int(11) NOT NULL AUTO_INCREMENT, `saleFk` int(11) NOT NULL, - `userFk` int(10) unsigned NOT NULL, + `userFk` int(10) unsigned NOT NULL COMMENT 'Controlador', `typeFk` int(11) NOT NULL, `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), @@ -36227,11 +36403,12 @@ DROP TABLE IF EXISTS `sample`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `sample` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `code` varchar(20) CHARACTER SET utf8 NOT NULL, + `code` varchar(25) CHARACTER SET utf8 NOT NULL, `description` varchar(105) COLLATE utf8_unicode_ci NOT NULL, `isVisible` tinyint(1) unsigned NOT NULL DEFAULT '1', `hasCompany` tinyint(1) unsigned NOT NULL DEFAULT '0', `hasPreview` tinyint(1) unsigned NOT NULL DEFAULT '1', + `datepickerEnabled` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -36260,6 +36437,8 @@ CREATE TABLE `sector` ( `workerFk` int(11) DEFAULT NULL, `labelReport__` tinyint(3) DEFAULT NULL, `printerFk` tinyint(3) unsigned DEFAULT NULL, + `isHideForPickers` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'sector a ocultar a los sacadores', + `isReserve` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Sectores de reserva, como Albenfruit o Fuentes', PRIMARY KEY (`id`,`warehouseFk`), UNIQUE KEY `code_UNIQUE` (`code`), KEY `sector_fk1_idx` (`warehouseFk`), @@ -36288,7 +36467,7 @@ CREATE TABLE `sharingCart` ( KEY `Suplent` (`workerSubstitute`), CONSTRAINT `Suplent_key` FOREIGN KEY (`workerSubstitute`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `Trabajador_key` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) 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 */ ; @@ -36462,6 +36641,7 @@ CREATE TABLE `shelving` ( `priority` int(11) DEFAULT NULL, `parked` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `userFk` int(10) unsigned DEFAULT NULL, + `isSpam` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'señala las matrículas con producto que se puede llevar a la reserva', PRIMARY KEY (`code`), KEY `shelving_fk1_idx` (`parkingFk`), KEY `shelving_fk2_idx` (`userFk`), @@ -36530,6 +36710,23 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +-- +-- Table structure for table `silexACL` +-- + +DROP TABLE IF EXISTS `silexACL`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `silexACL` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `module` varchar(255) NOT NULL, + `method` varchar(255) NOT NULL, + `role` varchar(20) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `module_UNIQUE` (`module`,`method`,`role`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `sinister` -- @@ -36596,6 +36793,7 @@ CREATE TABLE `smartTag` ( `code` varchar(12) CHARACTER SET utf8 NOT NULL, `shelvingFk` varchar(10) CHARACTER SET utf8 DEFAULT NULL, `level` int(11) DEFAULT NULL, + PRIMARY KEY (`code`), KEY `smartTag_shelving_fk` (`shelvingFk`), CONSTRAINT `smartTag_shelving_fk` FOREIGN KEY (`shelvingFk`) REFERENCES `shelving` (`code`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -36984,6 +37182,7 @@ CREATE TABLE `supplier` ( `workerFk` int(10) unsigned DEFAULT NULL COMMENT 'Responsible for approving invoices', `supplierActivityFk` varchar(45) NOT NULL DEFAULT 'flowersPlants', `healthRegister` varchar(45) DEFAULT NULL, + `isPayMethodChecked` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Se ha validado la forma de pago', PRIMARY KEY (`id`), UNIQUE KEY `cuenta` (`account`), UNIQUE KEY `NIF` (`nif`), @@ -37034,33 +37233,6 @@ CREATE TABLE `supplierAccount` ( KEY `fk_banco_prov_account_idx` (`bankFk`) ) ENGINE=InnoDBDEFAULT 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 = 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 supplierAccount_AfterInsert -AFTER INSERT -ON supplierAccount FOR EACH ROW -BEGIN - - INSERT INTO vn.mail(`sender`, subject, `body`) - SELECT 'finanzas@verdnatura.es', - CONCAT('Añadida cuenta bancaria al proveedor: ', NEW.supplierFk), - CONCAT(account.myUserGetName(), ' ha añadido: ', - NEW.iban, ', entidad: ', be.name, ', bic: ', be.bic) - FROM bankEntity be - WHERE be.id = NEW.bankEntityFk; -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 */ ; -- -- Table structure for table `supplierActivity` @@ -37593,9 +37765,10 @@ BEGIN AND r.id IN (OLD.routeFk,NEW.routeFk) AND r.created >= CURDATE() GROUP BY r.id; + call util.debugAdd(NEW.id,CONCAT(OLD.routeFk,' ',NEW.routeFk)); END IF; - IF !(NEW.shipped <=> OLD.shipped) THEN + IF !(DATE(NEW.shipped) <=> DATE(OLD.shipped)) THEN IF YEAR(NEW.shipped) < 2000 THEN SIGNAL SQLSTATE '46000' SET MESSAGE_TEXT = 'Year cannot be lesser than 2000'; @@ -37604,6 +37777,9 @@ BEGIN IF YEAR(NEW.shipped) = 2000 THEN SET NEW.isDeleted = TRUE; END IF; + + SET NEW.nickname = CONCAT('<',DAY(OLD.shipped),'> ', NEW.nickname ); + END IF; IF !(NEW.isDeleted <=> OLD.isDeleted) AND NEW.isDeleted THEN @@ -37663,14 +37839,11 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `ticket_afterUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER vn.`ticket_afterUpdate` AFTER UPDATE ON `ticket` FOR EACH ROW BEGIN - /** - * Hay una versión en salix que machacará toda esta función/procedimiento avisa - * a jgallego de los cambios que quieres hacer. - */ + IF !(NEW.id <=> OLD.id) OR !(NEW.warehouseFk <=> OLD.warehouseFk) OR !(NEW.shipped <=> OLD.shipped) THEN @@ -37685,23 +37858,14 @@ BEGIN IF NEW.clientFk = 2067 AND !(NEW.clientFk <=> OLD.clientFk) THEN -- Fallo que se insertan no se sabe como tickets en este cliente - INSERT INTO vn.mail SET - `sender` = 'jgallego@verdnatura.es', - `replyTo` = 'jgallego@verdnatura.es', - `subject` = 'Modificado ticket al cliente 2067', - `body` = CONCAT(account.myUserGetName(), ' ha modificado el ticket ', - NEW.id); + CALL mail_insert( + 'jgallego@verdnatura.es', + 'jgallego@verdnatura.es', + 'Modificado ticket al cliente 2067', + CONCAT(account.myUserGetName(), ' ha modificado el ticket ',NEW.id) + ); END IF; - - IF !(NEW.addressFk <=> OLD.addressFk) THEN - DELETE FROM ticketObservation - WHERE ticketFk = NEW.id; - - INSERT INTO ticketObservation(ticketFk, observationTypeFk, description) - SELECT NEW.id, ao.observationTypeFk, ao.description - FROM addressObservation ao - WHERE ao.addressFk = NEW.addressFk; - END IF; + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -37758,6 +37922,7 @@ CREATE TABLE `ticketCollection` ( KEY `ticketCollection_fk1_idx` (`collectionFk`), KEY `ticketCollection_fk2_idx` (`ticketFk`), KEY `ticketCollection_smartTagFk_IDX` (`smartTagFk`) USING BTREE, + KEY `ticketCollection_created_IDX` (`created`) USING BTREE, CONSTRAINT `ticketCollection_fk1` FOREIGN KEY (`collectionFk`) REFERENCES `collection` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketCollection_fk2` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -37905,23 +38070,6 @@ CREATE TABLE `ticketDown_SelectionType` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Temporary table structure for view `ticketGetVolume__` --- - -DROP TABLE IF EXISTS `ticketGetVolume__`; -/*!50001 DROP VIEW IF EXISTS `ticketGetVolume__`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `ticketGetVolume__` ( - `ticketFk` tinyint NOT NULL, - `routeFk` tinyint NOT NULL, - `saleFk` tinyint NOT NULL, - `shipped` tinyint NOT NULL, - `volume` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - -- -- Temporary table structure for view `ticketLabel_Source` -- @@ -38392,7 +38540,7 @@ CREATE TABLE `ticketService` ( `id` int(11) NOT NULL AUTO_INCREMENT, `description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `quantity` int(11) NOT NULL DEFAULT '0', - `price` decimal(10,2) unsigned NOT NULL DEFAULT '0.00', + `price` decimal(10,2) NOT NULL DEFAULT '0.00', `taxClassFk` tinyint(3) unsigned NOT NULL DEFAULT '2', `ticketFk` int(11) NOT NULL, `ticketServiceTypeFk` int(11) NOT NULL, @@ -39153,10 +39301,10 @@ CREATE TABLE `travelThermograph` ( `created` date NOT NULL, `warehouseFk` smallint(6) unsigned NOT NULL, `travelFk` int(10) unsigned DEFAULT NULL, - `temperature` enum('COOL','WARM') COLLATE utf8_unicode_ci NOT NULL, + `temperature` enum('COOL','WARM','DRY') COLLATE utf8_unicode_ci DEFAULT NULL, `result` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `dmsFk` int(11) DEFAULT NULL, - `temperatureFk` varchar(10) CHARACTER SET utf8 DEFAULT NULL COMMENT 'En la versión de Agosto de Salix se empezará a usar este campo y se actualizaran los anteriores mirando temperature.', + `temperatureFk` varchar(10) CHARACTER SET utf8 DEFAULT 'cool' COMMENT 'En la versión de Agosto de Salix se empezará a usar este campo y se actualizaran los anteriores mirando temperature.', PRIMARY KEY (`id`), KEY `thermograph_fk_idx` (`thermographFk`), KEY `gestdoc_fk_idx` (`dmsFk`), @@ -39170,6 +39318,28 @@ CREATE TABLE `travelThermograph` ( CONSTRAINT `travelThermographWarehouseFgn` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Registra cada termografo que se ha introducido en cada travel'; /*!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`.`travelThermograph_beforeInsert` BEFORE INSERT ON `travelThermograph` FOR EACH ROW +BEGIN + + IF NEW.temperature IS NULL THEN + SET NEW.temperature = UCASE(NEW.temperatureFk); + 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 */ ; -- -- Table structure for table `trolley` @@ -39314,45 +39484,6 @@ CREATE TABLE `vehicle` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `vehicleWarehouse` --- - -DROP TABLE IF EXISTS `vehicleWarehouse`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `vehicleWarehouse` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `numberPlate` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `model` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - `tradeMark` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - `numberSerial` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `vehicleWarehouse_UN` (`numberPlate`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Registros de vehículos utilizados en almacén'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `vehicleWarehouseTimeControl` --- - -DROP TABLE IF EXISTS `vehicleWarehouseTimeControl`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `vehicleWarehouseTimeControl` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `workerFk` int(10) unsigned NOT NULL, - `vehicleWarehouseFk` int(10) unsigned DEFAULT NULL, - `timed` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - `direction` enum('in','out') COLLATE utf8_unicode_ci DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `vehicleWarehouseTimeControl_worker_idx` (`workerFk`), - KEY `vehicleWarehouseTimeControl_FK` (`vehicleWarehouseFk`), - CONSTRAINT `vehicleWarehouseTimeControl_FK` FOREIGN KEY (`vehicleWarehouseFk`) REFERENCES `vehicleWarehouse` (`id`) ON UPDATE CASCADE, - CONSTRAINT `vehicleWarehouseTimeControl_worker` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Registros horarios de vehículos de almacén por empleado'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `volumeConfig` -- @@ -39697,6 +39828,20 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `workerDepartmentTest` +-- + +DROP TABLE IF EXISTS `workerDepartmentTest`; +/*!50001 DROP VIEW IF EXISTS `workerDepartmentTest`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `workerDepartmentTest` ( + `workerFk` tinyint NOT NULL, + `departmentFk` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `workerDisableExcluded` -- @@ -39774,7 +39919,7 @@ DROP TABLE IF EXISTS `workerHourPrice`; CREATE TABLE `workerHourPrice` ( `id` int(11) NOT NULL AUTO_INCREMENT, `dated` date NOT NULL, - `hollidayInc` decimal(4,2) DEFAULT NULL, + `holidayInc` decimal(4,2) DEFAULT NULL, `nightInc` decimal(4,2) DEFAULT NULL, `extraInc` decimal(4,2) DEFAULT NULL, PRIMARY KEY (`id`) @@ -39823,13 +39968,13 @@ CREATE TABLE `workerJourney` ( `priceOrdinaryHour` decimal(5,2) NOT NULL DEFAULT '0.00', `nocturn` decimal(5,2) NOT NULL DEFAULT '0.00', `priceNocturnHour` decimal(5,2) NOT NULL DEFAULT '0.00', - `hollyday` decimal(5,2) NOT NULL DEFAULT '0.00', - `priceHollydayHour` decimal(5,2) NOT NULL DEFAULT '0.00', + `holiday` decimal(5,2) NOT NULL DEFAULT '0.00', + `priceHolidayHour` decimal(5,2) NOT NULL DEFAULT '0.00', `lunch` decimal(5,2) NOT NULL DEFAULT '0.00', `priceExtraHour` decimal(5,2) NOT NULL DEFAULT '0.00', `extra` decimal(5,2) NOT NULL DEFAULT '0.00', `contractJourney` decimal(5,2) NOT NULL DEFAULT '0.00', - `priceExtraHollyday` decimal(5,2) NOT NULL DEFAULT '0.00', + `priceExtraHoliday` decimal(5,2) NOT NULL DEFAULT '0.00', `businessFk` int(11) DEFAULT NULL, `isPaid` tinyint(1) NOT NULL DEFAULT '0', `isUpdated` tinyint(1) NOT NULL DEFAULT '0', @@ -40100,6 +40245,57 @@ CREATE TABLE `workerTimeControl` ( CONSTRAINT `workerTimeControl_fk1` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Fichadas'; /*!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`.`workerTimeControl_AI` AFTER INSERT ON `workerTimeControl` FOR EACH ROW +BEGIN + IF NEW.timed > DATE_ADD(NOW(), INTERVAL 1 DAY) THEN + CALL mail_insert( + 'cau@verdnatura.es', + NULL, + 'Fichada fuera de rango', + CONCAT('Se ha introducido una fichada con fecha/hora ', NEW.timed, ' del usuario ', NEW.userFk) + ); + 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 */ ; + +-- +-- Table structure for table `workerTimeControlConfig` +-- + +DROP TABLE IF EXISTS `workerTimeControlConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `workerTimeControlConfig` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `dayBreak` int(11) NOT NULL, + `dayBreakDriver` int(11) NOT NULL, + `shortWeekBreak` int(11) NOT NULL, + `longWeekBreak` int(11) NOT NULL, + `weekScope` int(11) NOT NULL, + `mailPass` varchar(45) COLLATE utf8_bin NOT NULL, + `mailHost` varchar(45) COLLATE utf8_bin NOT NULL, + `mailSuccessFolder` varchar(45) COLLATE utf8_bin NOT NULL, + `mailErrorFolder` varchar(45) COLLATE utf8_bin NOT NULL, + `mailUser` varchar(45) COLLATE utf8_bin NOT NULL, + `minHoursToBreak` decimal(5,2) unsigned NOT NULL COMMENT 'Horas mínimas que se deben trabajar para añadir descanso remunerado', + `breakHours` decimal(5,2) unsigned NOT NULL COMMENT 'Descanso remunerado', + `hoursCompleteWeek` int(10) unsigned NOT NULL COMMENT 'Horas a realizar por semana para que se considere jornada completa', + PRIMARY KEY (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='All values in seconds'; +/*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `workerTimeControlConfig_` @@ -40291,14 +40487,14 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `workerWithoutDevice` +-- Temporary table structure for view `workerWithoutDevice__` -- -DROP TABLE IF EXISTS `workerWithoutDevice`; -/*!50001 DROP VIEW IF EXISTS `workerWithoutDevice`*/; +DROP TABLE IF EXISTS `workerWithoutDevice__`; +/*!50001 DROP VIEW IF EXISTS `workerWithoutDevice__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE TABLE `workerWithoutDevice` ( +/*!50001 CREATE TABLE `workerWithoutDevice__` ( `workerFk` tinyint NOT NULL, `Trabajador` tinyint NOT NULL, `Colecciones` tinyint NOT NULL @@ -40537,6 +40733,7 @@ CREATE TABLE `zone` ( `isVolumetric` tinyint(1) NOT NULL DEFAULT '0', `inflation` decimal(5,2) NOT NULL DEFAULT '1.00', `m3Max` decimal(10,2) unsigned DEFAULT NULL, + `itemMaxSize` int(11) DEFAULT NULL COMMENT 'tamaño maximo de los articulos que esa ruta puede transportar', PRIMARY KEY (`id`), KEY `fk_zone_1_idx` (`warehouseFk__`), KEY `fk_zone_2_idx` (`agencyModeFk`), @@ -40888,14 +41085,14 @@ CREATE TABLE `zoneWarehouse` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `zone_ETD` +-- Temporary table structure for view `zone_ETD__` -- -DROP TABLE IF EXISTS `zone_ETD`; -/*!50001 DROP VIEW IF EXISTS `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 TABLE `zone_ETD` ( +/*!50001 CREATE TABLE `zone_ETD__` ( `zoneFk` tinyint NOT NULL, `HoraTeórica` tinyint NOT NULL, `volumenTotal` tinyint NOT NULL, @@ -40936,12 +41133,12 @@ DELIMITER ;; /*!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 collation_connection = utf8mb4_general_ci */ ;; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`%`*/ /*!50106 EVENT `envialiaThreHoldChecker` ON SCHEDULE EVERY 1 DAY STARTS '2019-02-07 07:00:00' ON COMPLETION NOT PRESERVE ENABLE COMMENT 'comprueba el rango de numeros para las etiquetas de envialia' DO BEGIN +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`%`*/ /*!50106 EVENT `envialiaThreHoldChecker` ON SCHEDULE EVERY 1 DAY STARTS '2019-02-07 08:00:00' ON COMPLETION NOT PRESERVE ENABLE COMMENT 'comprueba el rango de numeros para las etiquetas de envialia' DO BEGIN DECLARE vActualNumber BIGINT; DECLARE vEndRange BIGINT; DECLARE vIsAlreadyNotified BOOLEAN; @@ -40954,10 +41151,12 @@ DELIMITER ;; IF (vActualNumber+vNotificationThrehold) >= vEndRange AND vIsAlreadyNotified = FALSE THEN - INSERT INTO vn2008.mail (`to`, subject, text) - VALUES ('cau@verdnatura.es', - 'Hablar con envialia, acercandonos al numero final del rango permitido para las etiquetas', - CONCAT('Numero actual: ', vActualNumber, ' , numero final: ',vEndRange)); + CALL mail_insert( + 'cau@verdnatura.es', + NULL, + 'Hablar con envialia, acercandonos al numero final del rango permitido para las etiquetas', + CONCAT('Numero actual: ', vActualNumber, ' , numero final: ',vEndRange) + ); UPDATE envialiaConfig SET isAlreadyNotified = TRUE; END IF; @@ -40973,19 +41172,37 @@ END */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; /*!50003 SET character_set_results = @saved_cs_results */ ;; /*!50003 SET collation_connection = @saved_col_connection */ ;; +/*!50106 DROP EVENT IF EXISTS `mysqlConnectionsSorter_kill` */;; +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 @saved_sql_mode = @@sql_mode */ ;; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;; +/*!50003 SET @saved_time_zone = @@time_zone */ ;; +/*!50003 SET time_zone = 'SYSTEM' */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`%`*/ /*!50106 EVENT `mysqlConnectionsSorter_kill` ON SCHEDULE EVERY 1 MINUTE STARTS '2021-10-28 09:56:27' ON COMPLETION NOT PRESERVE ENABLE DO CALL mysqlConnectionsSorter_kill() */ ;; +/*!50003 SET time_zone = @saved_time_zone */ ;; +/*!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 */ ;; /*!50106 DROP EVENT IF EXISTS `printQueue_check` */;; 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' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`z-sysadmin`@`%`*/ /*!50106 EVENT `printQueue_check` ON SCHEDULE EVERY 10 MINUTE STARTS '2019-11-08 01:00:00' ON COMPLETION PRESERVE ENABLE COMMENT 'Notifica en caso de que el servidor de impresión este parado' DO BEGIN +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`%`*/ /*!50106 EVENT `printQueue_check` ON SCHEDULE EVERY 10 MINUTE STARTS '2019-11-08 02:00:00' ON COMPLETION PRESERVE ENABLE COMMENT 'Notifica en caso de que el servidor de impresión este parado' DO BEGIN DECLARE vCurrentCount INT; DECLARE vCheckSum INT; @@ -41051,10 +41268,12 @@ DELIMITER ;; CLOSE vCur; - INSERT INTO vn2008.mail (`to`, subject, text) - VALUES ('cau@verdnatura.es', - 'servidor de impresion parado', - CONCAT('Hay ', vCurrentCount, ' lineas bloqueadas', vTableQueue, '')); + CALL mail_insert( + 'cau@verdnatura.es', + NULL, + 'Servidor de impresion parado', + CONCAT('Hay ', vCurrentCount, ' lineas bloqueadas', vTableQueue, '') + ); UPDATE printingQueueCheck SET isAlreadyNotified = TRUE; END IF; @@ -41141,7 +41360,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`z-sysadmin`@`%`*/ /*!50106 EVENT `ticket_doRecalc` ON SCHEDULE EVERY 10 SECOND STARTS '2021-02-26 07:32:23' ON COMPLETION PRESERVE ENABLE DO CALL ticket_doRecalc */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`%`*/ /*!50106 EVENT `ticket_doRecalc` ON SCHEDULE EVERY 10 SECOND STARTS '2021-02-26 07:32:23' ON COMPLETION PRESERVE ENABLE DO CALL ticket_doRecalc */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -41355,17 +41574,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 `bionicCalcReverse` */; +/*!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 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 `bionicCalcReverse`(vWarehouse INT, +CREATE DEFINER=`root`@`%` FUNCTION `bionicCalcReverse__`(vWarehouse INT, vMargin DECIMAL(10,3), vRetailedPrice DECIMAL(10,3), vM3 DECIMAL(10,3), @@ -41556,17 +41775,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 `buy_hasNotifyPassport` */; +/*!50003 DROP FUNCTION IF EXISTS `buy_hasNotifyPassport__` */; /*!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`@`%` FUNCTION `buy_hasNotifyPassport`(vBuyFk INT, vItemFk INT) RETURNS tinyint(1) +CREATE DEFINER=`root`@`%` FUNCTION `buy_hasNotifyPassport__`(vBuyFk INT, vItemFk INT) RETURNS tinyint(1) READS SQL DATA BEGIN DECLARE vHasPassport BOOL; @@ -41777,89 +41996,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 FUNCTION IF EXISTS `clientGetDebt__` */; -/*!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 `clientGetDebt__`(vClient INT, vDate DATE) RETURNS decimal(10,2) - READS SQL DATA -BEGIN -/** - * Devuelve el saldo de un cliente. - * - * @param vClient Identificador del cliente - * @param vDate Fecha hasta la que tener en cuenta - * @return Saldo del cliente - */ - DECLARE vDateEnd DATETIME; - DECLARE vDateIni DATETIME; - DECLARE vDebt DECIMAL(10,2); - DECLARE vHasDebt BOOLEAN; - - SELECT COUNT(*) INTO vHasDebt - FROM `client` c - WHERE c.id = vClient AND c.typeFk = 'normal'; - - IF NOT vHasDebt THEN - RETURN 0; - END IF; - - SET vDate = IFNULL(vDate, CURDATE()); - - SET vDateIni = TIMESTAMPADD(MONTH, -2, CURDATE()); - SET vDateEnd = TIMESTAMP(vDate, '23:59:59'); - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket; - CREATE TEMPORARY TABLE tmp.ticket - (INDEX (ticketFk)) - ENGINE = MEMORY - SELECT id ticketFk - FROM ticket - WHERE clientFk = vClient - AND refFk IS NULL - AND shipped BETWEEN vDateIni AND vDateEnd; - - CALL vn.ticketGetTotal; - - SELECT IFNULL(SUM(t.amount), 0) INTO vDebt - FROM ( - - SELECT SUM(IFNULL(total,0)) amount - FROM tmp.ticketTotal - UNION ALL - SELECT SUM(amountPaid) amount - FROM receipt - WHERE clientFk = vClient - AND payed > vDateEnd - UNION ALL - SELECT SUM(amount) - FROM clientRisk - WHERE clientFk = vClient - UNION ALL - SELECT CAST(-SUM(amount) / 100 AS DECIMAL(10,2)) - FROM hedera.tpvTransaction - WHERE clientFk = vClient - AND receiptFk IS NULL - AND `status` = 'ok' - ) t; - - DROP TEMPORARY TABLE - tmp.ticket, - tmp.ticketTotal; - - RETURN vDebt; -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 `clientGetMana` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -42354,7 +42490,7 @@ BEGIN * * */ - DECLARE vIsGranted BOOLEAN; + /*DECLARE vIsGranted BOOLEAN; DECLARE vDeviceProductionFk INT(11) DEFAULT NULL; SELECT dp.id INTO vDeviceProductionFk @@ -42369,7 +42505,7 @@ BEGIN AND dpu.deviceProductionFk = vDeviceProductionFk; RETURN vIsGranted; - END IF; + END IF;*/ RETURN TRUE; END ;; DELIMITER ; @@ -42387,7 +42523,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`z-sysadmin`@`%` FUNCTION `duaTax_getRate`(vDua INT, vTaxClass INT) RETURNS decimal(5,2) +CREATE DEFINER=`root`@`%` FUNCTION `duaTax_getRate`(vDua INT, vTaxClass INT) RETURNS decimal(5,2) DETERMINISTIC BEGIN DECLARE vCountryFk INTEGER; @@ -42823,34 +42959,6 @@ BEGIN RETURN vHasDistinctRoutes; -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 `floramondoNewItemFk__` */; -/*!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 `floramondoNewItemFk__`() RETURNS int(11) - DETERMINISTIC -BEGIN - - DECLARE vItemFk INT; - - SELECT max(id) + 1 INTO vItemFk - FROM item - WHERE id BETWEEN 250000 AND 290000; - - RETURN vItemFk; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -42861,9 +42969,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 ;; @@ -42875,6 +42983,14 @@ BEGIN DECLARE vEntryFk INT; DECLARE previousEntryFk INT; + IF (SELECT COUNT(*) + FROM vn.floramondoNotOfferDay + WHERE dated = vLanded + AND warehouseFk = vWarehouseFk) + THEN + RETURN NULL; + END IF; + SET vTravelFk = floramondo_getTravel(vLanded, vWarehouseFk); IF vLanded THEN @@ -42971,59 +43087,6 @@ BEGIN RETURN vTravelFk; -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 `floramondo_getTravel__` */; -/*!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 `floramondo_getTravel__`(vLanded DATE) RETURNS int(11) - READS SQL DATA -BEGIN - - DECLARE vTravelFk INT; - DECLARE vWarehouseOutName VARCHAR(50) DEFAULT 'Holanda'; - DECLARE vWarehouseInName VARCHAR(50) DEFAULT 'VNH'; - - IF vLanded THEN - SELECT IFNULL(MAX(tr.id),0) INTO vTravelFk - FROM vn.travel tr - JOIN vn.warehouse wIn ON wIn.id = tr.warehouseInFk - JOIN vn.warehouse wOut ON wOut.id = tr.warehouseOutFk - WHERE wIn.name = vWarehouseInName - AND wOut.name = vWarehouseOutName - AND landed = vLanded; - - IF NOT vTravelFk THEN - - INSERT INTO vn.travel(landed, shipped, warehouseInFk, warehouseOutFk, agencyFk) - SELECT vLanded, curdate(), wIn.id, wOut.id, am.id - FROM vn.warehouse wIn - JOIN vn.warehouse wOut ON wOut.name = vWarehouseOutName - JOIN vn.agencyMode am ON am.name = 'HOLANDA DIRECTO' - WHERE wIn.name = vWarehouseInName; - - SELECT MAX(tr.id) INTO vTravelFk - FROM vn.travel tr - JOIN vn.warehouse wIn ON wIn.id = tr.warehouseInFk - JOIN vn.warehouse wOut ON wOut.id = tr.warehouseOutFk - WHERE wIn.name = vWarehouseInName - AND wOut.name = vWarehouseOutName - AND landed = vLanded; - END IF; - END IF; - RETURN vTravelFk; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -44905,34 +44968,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 FUNCTION IF EXISTS `smartTag_nextLevel` */; -/*!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 `smartTag_nextLevel`(vShelvingFk VARCHAR(10)) RETURNS int(2) - DETERMINISTIC -BEGIN - - DECLARE vLevel INT; - - SELECT count(*) + 1 INTO vLevel - FROM smartTag st - WHERE st.shelvingFk = vShelvingFk COLLATE utf8_general_ci; - - RETURN vLevel; - -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 `specie_IsForbidden` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -45345,19 +45380,10 @@ CREATE DEFINER=`root`@`%` FUNCTION `ticketTotalVolume`(vTicketId INT) RETURNS de READS SQL DATA BEGIN -- Devuelte el volumen total del ticket sumado - -- DECLARE vWarehouseId INTEGER; - -- DECLARE vShippedDate DATE; + DECLARE vVolume DECIMAL(10,3); - /* - SELECT warehouseFk, shipped INTO vWarehouseId,vShippedDate FROM vn.ticket WHERE id = vTicketId; - - SELECT IFNULL(SUM(s.quantity * i.compression * r.cm3)/1000000,0) INTO vVolume - FROM sale s - JOIN vn.item i ON i.id = s.itemFk - JOIN bi.rotacion r on r.Id_Article = s.itemFk AND r.warehouse_id = vWarehouseId - WHERE s.ticketFk = vTicketId; - */ - SELECT sum(volume) INTO vVolume + + SELECT SUM(volume) INTO vVolume FROM saleVolume WHERE ticketFk = vTicketId; RETURN vVolume; @@ -45505,6 +45531,39 @@ 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 `ticket_getWeight` */; +/*!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 `ticket_getWeight`(vTicketFk INT) RETURNS decimal(10,3) + READS SQL DATA +BEGIN +/** + * Devuelve el peso total del ticket + * + * @return Total peso + */ + + DECLARE vWeight DECIMAL(10,3); + + SELECT sum(weight) INTO vWeight + FROM saleVolume + WHERE ticketFk = vTicketFk; + + RETURN vWeight; + +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 `ticket_getWithParameters` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -45771,7 +45830,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`z-sysadmin`@`%` FUNCTION `time_getSalesYear`(vMonth INT, vYear INT) RETURNS int(11) +CREATE DEFINER=`root`@`%` FUNCTION `time_getSalesYear`(vMonth INT, vYear INT) RETURNS int(11) DETERMINISTIC BEGIN DECLARE vSalesYear INT; @@ -45868,71 +45927,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 FUNCTION IF EXISTS `vehicleWarehouseTimeControl_checkRegister` */; -/*!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 `vehicleWarehouseTimeControl_checkRegister`(vWorkerFk VARCHAR(10)) RETURNS tinyint(1) - READS SQL DATA -BEGIN -/** - * Comprueba si existen registros - * @return Devuelve TRUE en caso de que haya registros - */ - - IF (SELECT COUNT(*) - FROM vn.vehicleWarehouseTimeControl vwt - WHERE vwt.workerFk = vWorkerFk - AND vwt.timed >= TIMESTAMPADD(HOUR , -12,NOW())) - THEN - RETURN TRUE; - ELSE - RETURN FALSE; - 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 FUNCTION IF EXISTS `vehicleWarehouse_checkNumberPlate` */; -/*!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 `vehicleWarehouse_checkNumberPlate`(vNumberPlate VARCHAR(10)) RETURNS tinyint(1) - READS SQL DATA -BEGIN -/** - * Comprueba si existe matrícula - * @return Devuelve TRUE en caso de que exista - */ - - IF (SELECT COUNT(*) - FROM vn.vehicleWarehouse - WHERE numberPlate = vNumberPlate - ) THEN - RETURN TRUE; - ELSE - RETURN FALSE; - 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 FUNCTION IF EXISTS `workerIsBoss` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -45992,6 +45986,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 FUNCTION IF EXISTS `workerMachinery_isRegistered` */; +/*!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 `workerMachinery_isRegistered`(vWorkerFk VARCHAR(10)) RETURNS tinyint(1) + READS SQL DATA +BEGIN +/** + * Comprueba si existen registros en las últimas horas (maxHours de machineWorkerConfig) del trabajador vWorkerFk y si tiene a nulo la hora outTimed (indica la hora que deja el vehículo) + * + * @param vWorkerFk id del trabajador + * @return Devuelve TRUE/FALSE en caso de que haya o no registros + */ + + IF (SELECT COUNT(*) + FROM machineWorker m + WHERE m.workerFk = vWorkerFk + AND m.inTimed >= TIMESTAMPADD(HOUR , -(SELECT maxHours from machineWorkerConfig), NOW()) AND ISNULL(m.outTimed)) + THEN + RETURN TRUE; + ELSE + RETURN FALSE; + 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 FUNCTION IF EXISTS `workerTimeControl_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -46582,135 +46612,6 @@ BEGIN AND tr.agencyFk IN (0, vAgency) GROUP BY Temp; -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 `algemesi_silla__` */; -/*!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 `algemesi_silla__`(vDate DATE, vItemFk INT, vQuantity INT) -BEGIN - -DECLARE done INT DEFAULT FALSE; -DECLARE vAlgemesiFk INT DEFAULT 60; -DECLARE vSillaFk INT DEFAULT 1; -DECLARE vTicketFk INT; -DECLARE vSaleFk INT; -DECLARE vClonTicket INT DEFAULT 0; -DECLARE i INT DEFAULT 0; - -DECLARE cur1 CURSOR FOR - select distinct s.ticketFk, s.id - from vn.sale s - join vn.ticket t ON t.id = s.ticketFk - left join vn.ticketStateToday tss ON tss.ticket = t.id - where t.shipped between vDate and util.dayend(vDate) - and t.warehouseFk = vAlgemesiFk - and s.itemFk IN (vItemFk) - and s.quantity < vQuantity - and IFNULL(tss.alertLevel,0) = 0 - -- limit 1 - ; - - -DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; - -OPEN cur1; - -FETCH cur1 INTO vTicketFk, vSaleFk; - - WHILE done = 0 DO - - SELECT t.id INTO vClonTicket - FROM vn.ticket t - JOIN (SELECT t.addressFk, t.shipped - FROM vn.ticket t - left join vn.ticketStateToday tss ON tss.ticket = t.id - WHERE id = vTicketFk - and IFNULL(tss.alertLevel,0) = 0) sub USING(addressFk, shipped) - WHERE t.warehouseFk = vSillaFk - LIMIT 1; - - -- SELECT vTicketFk, vClonTicket; - - IF vClonTicket = 0 THEN - - INSERT INTO ticket ( - clientFk, - shipped, - addressFk, - agencyModeFk, - nickname, - warehouseFk, - companyFk, - landed, - zoneFk, - zonePrice, - zoneBonus, - routeFk - ) - SELECT - clientFk, - shipped, - addressFk, - agencyModeFk, - nickname, - vSillaFk, - companyFk, - landed, - zoneFk, - zonePrice, - zoneBonus, - routeFk - - FROM ticket - WHERE id = vTicketFk; - - SET vClonTicket = LAST_INSERT_ID(); - - -- SELECT 'lstID', vClonTicket; - - INSERT IGNORE INTO ticketObservation(ticketFk, observationTypeFk, description) - SELECT vClonTicket, ao.observationTypeFk, ao.description - FROM addressObservation ao - JOIN ticket t ON t.addressFk = ao.addressFk - WHERE t.id = vTicketFk; - - INSERT IGNORE INTO ticketLog - SET originFk = vClonTicket, userFk = account.myUser_getId(), `action` = 'insert', - description = CONCAT('Ha creado el ticket:', ' ', vClonTicket, ' clonando el ', vTicketFk); - - END IF; - - UPDATE vn.sale - SET ticketFk = vClonTicket - WHERE id = vSaleFk; - - - SET vClonTicket = 0; - - SET done = 0; - FETCH cur1 INTO vTicketFk, vSaleFk; - - SET i = i + 1; - - END WHILE; - - CLOSE cur1; - - SELECT i; - - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -46875,30 +46776,17 @@ BEGIN * de los leasing * */ - INSERT INTO mail (sender,replyTo,subject,body) - SELECT 'administracion@verdnatura.es' sender, + INSERT INTO mail (receiver,replyTo,subject,body) + SELECT 'administracion@verdnatura.es' receiver, 'noreply@verdnatura.es' replyTo, - CONCAT( - 'El seguro de la poliza ', - b.id, - ' ', - b.bank, - ' ha finalizado.' - ) subject, - CONCAT( - 'El seguro de la poliza ', - b.id, - ' ', - b.bank, - ' ha finalizado.' - ) body + CONCAT('El seguro de la poliza ',b.id,' ',b.bank,' ha finalizado.') subject, + CONCAT('El seguro de la poliza ',b.id,' ',b.bank,' ha finalizado.') body FROM vn.bankPolicy bp LEFT JOIN vn.supplier s ON s.id = bp.supplierFk LEFT JOIN vn.bank b ON b.id = bp.bankFk WHERE bp.insuranceExpired = CURDATE(); - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -47044,9 +46932,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 ;; @@ -47059,20 +46947,21 @@ BEGIN */ DECLARE vEntryFk INT; DECLARE vItemFk INT; - DECLARE vSize INT; - DECLARE vPackageFk VARCHAR(10); - DECLARE vStickers INT; - DECLARE vPacking INT; + DECLARE vPackingOut DECIMAL(10,2); DECLARE vWarehouse INT; + DECLARE vStandardFlowerBox INT; DECLARE vWarehouseOut INT; DECLARE vIsMerchandise BOOL; DECLARE vIsFeedStock BOOL; - SELECT b.entryFk, b.itemFk, b.stickers, b.packing, p.id, i.`size` - INTO vEntryFk, vItemFk, vStickers, vPacking, vPackageFk, vSize + SELECT b.entryFk, b.itemFk, i.packingOut, ic.merchandise, vc.standardFlowerBox + INTO vEntryFk, vItemFk, vPackingOut, vIsMerchandise, vStandardFlowerBox FROM buy b LEFT JOIN item i ON i.id = b.itemFk + LEFT JOIN itemType it ON it.id = i.typeFk + LEFT JOIN itemCategory ic ON ic.id = it.categoryFk LEFT JOIN packaging p ON p.id = b.packageFk AND NOT p.isBox + JOIN volumeConfig vc ON TRUE WHERE b.id = vSelf; SELECT t.warehouseInFk, t.warehouseOutFk @@ -47081,26 +46970,14 @@ BEGIN JOIN travel t ON t.id = e.travelFk WHERE e.id = vEntryFk; - SELECT k.merchandise - INTO vIsMerchandise - FROM itemCategory k - JOIN itemType it ON it.categoryFk = k.id - JOIN item i ON i.typeFk = it.id - WHERE i.id = vItemFk; - IF vIsMerchandise THEN - - REPLACE itemCost SET + + REPLACE itemCost SET itemFk = vItemFk, warehouseFk = vWarehouse, - cm3 = buy_getUnitVolume(vSelf); - - UPDATE vn.itemCost ic - JOIN vn.item i ON i.id = ic.itemFk - SET ic.cm3delivery = i.compression * ic.cm3 - WHERE ic.itemFk = vItemFk AND - ic.warehouseFk = vWarehouse; - + cm3 = buy_getUnitVolume(vSelf), + cm3Delivery = IFNULL((vStandardFlowerBox * 1000) / vPackingOut, buy_getUnitVolume(vSelf)); + UPDATE vn.itemCost ic JOIN cache.last_buy lb ON lb.item_id = ic.itemFk AND lb.warehouse_id = ic.warehouseFk JOIN vn.buy b ON b.id = lb.buy_id @@ -47120,98 +46997,7 @@ BEGIN JOIN edi.ekt be ON be.id = b.ektFk JOIN edi.supplier es ON es.supplier_id = be.pro WHERE b.id = vSelf; - - IF buy_hasNotifyPassport(vSelf, vItemFk) THEN - CALL vn.buy_notifyPassport(vSelf, vItemFk, vStickers, vPacking); - 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 `buy_afterUpsert__` */; -/*!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 `buy_afterUpsert__`(vSelf INT) -BEGIN -/** - * Triggered actions when a buy is updated or inserted. - * - * @param vSelf The buy reference - */ - DECLARE vEntryFk INT; - DECLARE vItemFk INT; - DECLARE vStickers INT; - DECLARE vPacking INT; - DECLARE vWarehouse INT; - DECLARE vWarehouseOut INT; - DECLARE vIsMerchandise BOOL; - DECLARE vIsFeedStock BOOL; - - - SELECT entryFk, itemFk, stickers, packing - INTO vEntryFk, vItemFk, vStickers, vPacking - FROM buy - WHERE id = vSelf; - SELECT t.warehouseInFk, t.warehouseOutFk - INTO vWarehouse, vWarehouseOut - FROM entry e - JOIN travel t ON t.id = e.travelFk - WHERE e.id = vEntryFk; - - SELECT k.merchandise - INTO vIsMerchandise - FROM itemCategory k - JOIN itemType it ON it.categoryFk = k.id - JOIN item i ON i.typeFk = it.id - WHERE i.id = vItemFk; - - IF vIsMerchandise THEN - - REPLACE itemCost SET - itemFk = vItemFk, - warehouseFk = vWarehouse, - cm3 = buy_getUnitVolume(vSelf); - - UPDATE vn.itemCost ic - JOIN vn.item i ON i.id = ic.itemFk - SET ic.cm3delivery = i.compression * ic.cm3 - WHERE ic.itemFk = vItemFk AND - ic.warehouseFk = vWarehouse; - - UPDATE vn.itemCost ic - JOIN cache.last_buy lb ON lb.item_id = ic.itemFk AND lb.warehouse_id = ic.warehouseFk - JOIN vn.buy b ON b.id = lb.buy_id - SET ic.grams = b.weight * 1000 / b.packing - WHERE ic.itemFk = vItemFk AND - ic.warehouseFk = vWarehouse; - END IF; - - SELECT isFeedStock INTO vIsFeedStock - FROM warehouse WHERE id = vWarehouseOut AND id <> 13; - - IF vIsFeedStock THEN - INSERT IGNORE INTO producer(`name`) - SELECT es.company_name - FROM buy b - JOIN edi.ekt be ON be.id = b.ektFk - JOIN edi.supplier es ON es.supplier_id = be.pro - WHERE b.id = vSelf; - - IF buy_hasNotifyPassport(vSelf, vItemFk) THEN - CALL vn.buy_notifyPassport(vSelf, vItemFk, vStickers, vPacking); - END IF; END IF; END ;; @@ -47263,7 +47049,7 @@ BEGIN * Cálculo de volumen en líneas de compra * @table tmp.buy(buyFk) */ - SELECT ELT(it.temperature + 1,'Calientes','Frios','Secos') Temp, + SELECT t.name Temp, CAST(ROUND(SUM(GREATEST(b.stickers ,b.quantity /b.packing ) * item_getVolume(b.itemFk, b.packageFk)) / vc.trolleyM3 / 1000000 ,1) AS DECIMAL(10,2)) carros , CAST(ROUND(SUM(GREATEST(b.stickers ,b.quantity /b.packing ) * @@ -47273,6 +47059,7 @@ BEGIN JOIN volumeConfig vc JOIN item i ON i.id = b.itemFk JOIN itemType it ON it.id = i.typeFk + LEFT JOIN temperature t ON t.code = it.temperatureFk GROUP BY Temp; END ;; DELIMITER ; @@ -47344,17 +47131,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 `buy_notifyPassport` */; +/*!50003 DROP PROCEDURE IF EXISTS `buy_notifyPassport__` */; /*!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 `buy_notifyPassport`( +CREATE DEFINER=`root`@`%` PROCEDURE `buy_notifyPassport__`( IN vBuyFk INT, IN vItemFk INT, IN vStickers SMALLINT, @@ -47391,9 +47178,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 ;; @@ -47438,10 +47225,10 @@ BEGIN b.price2 = @t2:= round(@t3 * (1 + ((r.rate2 - r.rate3)/100)),2), b.price2 = @t2:= IF(@t2 <= @t3,@t3 , @t2); - SELECT (b.buyingValue = b.price2), b.buyingValue , b.packageFk - INTO vFallo, vBuyingValue ,vPackageFk + SELECT (b.buyingValue = b.price2), b.buyingValue, b.packageFk + INTO vFallo, vBuyingValue, vPackageFk FROM vn.buy b - WHERE b.id = @buyId; + WHERE b.id = @buyId AND b.buyingValue <> 0.01; IF vFallo THEN @@ -47471,26 +47258,31 @@ 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 `buy_updateGrouping`(vWarehouseFk INT,vItemFk INT,vGrouping INT) +CREATE DEFINER=`root`@`%` PROCEDURE `buy_updateGrouping`(vWarehouseFk INT, vItemFk INT, vGrouping INT) BEGIN +/** + * Actualiza el grouping de las últimas compras de un artículo + * + * @param vWarehouseFk Id del almacén + * @param vItemFk Id del Artículo + * @param vGrouping Cantidad de grouping + */ + + CALL vn.buyUltimate(vWarehouseFk, CURDATE()); -DECLARE lastId INT; - -CALL vn2008.item_last_buy_(vWarehouseFk,vItemFk); - -SELECT b.buy_id INTO lastId -FROM vn2008.t_item_last_buy b -INNER JOIN vn2008.Compres c ON c.Id_Compra = b.buy_id -where b.warehouse_id = vWarehouseFk AND b.item_id =vItemFk; - -UPDATE vn.buy SET `grouping` = vGrouping WHERE id = lastId; + UPDATE vn.buy b + JOIN tmp.buyUltimate bu ON b.id = bu.buyFk + SET b.`grouping` = vGrouping + WHERE bu.warehouseFk = vWarehouseFk + AND bu.itemFk = vItemFk; + DROP TEMPORARY TABLE tmp.buyUltimate; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -47527,7 +47319,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 `camaraFutureVolume` */; +/*!50003 DROP PROCEDURE IF EXISTS `camaraFutureVolume__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -47537,7 +47329,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `camaraFutureVolume`(vWarehouseFk INT, vDateStart DATE, vDateEnd DATE) +CREATE DEFINER=`root`@`%` PROCEDURE `camaraFutureVolume__`(vWarehouseFk INT, vDateStart DATE, vDateEnd DATE) BEGIN DECLARE vDated DATE; @@ -47579,7 +47371,7 @@ BEGIN JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.itemCategory ic ON ic.id = it.categoryFk WHERE calc_id = @calc_id - AND ic.merchandise; + AND ic.display; INSERT INTO tmp.camara(dated, place, m3) SELECT vDated, 'entradas', FLOOR(SUM(iei.amount * r.cm3) / 1000000) as m3 @@ -47588,7 +47380,7 @@ BEGIN JOIN vn.item i ON i.id = iei.item_id JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.itemCategory ic ON ic.id = it.categoryFk - WHERE ic.merchandise + WHERE ic.display AND dat = vDated AND NOT received AND NOT isVirtualStock @@ -47601,7 +47393,7 @@ BEGIN JOIN vn.item i ON i.id = ieo.item_id JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.itemCategory ic ON ic.id = it.categoryFk - WHERE ic.merchandise + WHERE ic.display AND dat = vDated AND NOT delivered AND NOT isVirtualStock @@ -47616,7 +47408,7 @@ BEGIN JOIN vn.itemCategory ic ON ic.id = it.categoryFk JOIN vn.ticketStateToday tst ON tst.ticket = io.ticketFk JOIN vn.ticket t ON t.id = io.ticketFk - WHERE ic.merchandise + WHERE ic.display AND ic.id != 7 AND t.clientFk NOT IN (200,400,50,450) AND dat BETWEEN vDated AND util.dayend(vDated) @@ -47634,7 +47426,7 @@ BEGIN JOIN vn.item i ON i.id = iei.item_id JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.itemCategory ic ON ic.id = it.categoryFk - WHERE ic.merchandise + WHERE ic.display AND dat = vDated AND NOT isVirtualStock AND iei.warehouse_id = vWarehouseFk; @@ -47646,7 +47438,7 @@ BEGIN JOIN vn.item i ON i.id = ieo.item_id JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.itemCategory ic ON ic.id = it.categoryFk - WHERE ic.merchandise + WHERE ic.display AND dat = vDated AND ieo.warehouse_id = vWarehouseFk; @@ -47658,7 +47450,7 @@ BEGIN JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.itemCategory ic ON ic.id = it.categoryFk JOIN vn.ticket t ON t.id = io.ticketFk - WHERE ic.merchandise + WHERE ic.display AND dat BETWEEN vDated AND util.dayend(vDated) AND ic.id != 7 AND t.clientFk NOT IN (200,400,50,450) @@ -47685,7 +47477,7 @@ BEGIN JOIN vn.item i ON i.id = iei.item_id JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.itemCategory ic ON ic.id = it.categoryFk - WHERE ic.merchandise + WHERE ic.display AND dat = vDated AND NOT isVirtualStock AND iei.warehouse_id = vWarehouseFk; @@ -47697,7 +47489,7 @@ BEGIN JOIN vn.item i ON i.id = ieo.item_id JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.itemCategory ic ON ic.id = it.categoryFk - WHERE ic.merchandise + WHERE ic.display AND dat = vDated AND ieo.warehouse_id = vWarehouseFk; @@ -47709,7 +47501,7 @@ BEGIN JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.itemCategory ic ON ic.id = it.categoryFk JOIN vn.ticket t ON t.id = io.ticketFk - WHERE ic.merchandise + WHERE ic.display AND dat BETWEEN vDated AND util.dayend(vDated) AND ic.id != 7 AND t.clientFk NOT IN (200,400,50,450) @@ -48198,6 +47990,7 @@ proc: BEGIN DECLARE vFrenchOffer INT DEFAULT 42; DECLARE vIsFrenchVNHBuyer BOOLEAN DEFAULT FALSE; DECLARE vVNHWarehouseFk INT DEFAULT 7; + DECLARE vFloramondoWarehouseFk INT DEFAULT 40; DECLARE vIsLogifloraAllowed BOOLEAN DEFAULT 0; DECLARE vMaxLogifloraDays INT; DECLARE vRangeLogifloraDays INT DEFAULT 3; @@ -48205,6 +47998,7 @@ proc: BEGIN DECLARE vRappelComponent INT DEFAULT 44; DECLARE vIsZonePremium BOOL; DECLARE vFrenchDiscount DECIMAL(3,2) DEFAULT 0.12; + DECLARE vIsCatalonianBuyer BOOL; -- PAK 18/10/21 SELECT (COUNT(*) > 0) INTO vIsZonePremium FROM vn.zoneFilter zf @@ -48217,20 +48011,34 @@ proc: BEGIN FROM address WHERE id = vAddressFk; - SELECT (c.country = 'FRANCIA' AND vWarehouseFk = vVNHWarehouseFk) + SELECT (c.country = 'FRANCIA' AND vWarehouseFk IN (vVNHWarehouseFk, vFloramondoWarehouseFk)) INTO vIsFrenchVNHBuyer FROM vn.country c JOIN vn.province p ON p.countryFk = c.id JOIN vn.address a ON a.provinceFk = p.id WHERE a.id = vAddressFk; - + + SELECT (p.name = 'Barcelona' AND vWarehouseFk = vVNHWarehouseFk) + INTO vIsCatalonianBuyer + FROM vn.province p + JOIN vn.address a ON a.provinceFk = p.id + WHERE a.id = vAddressFk; -- PAK 18/10/21 + SELECT travellingDays INTO vMaxLogifloraDays FROM edi.warehouseFloramondo WHERE warehouseFk = vWarehouseFk; - IF (NOT vIsLogifloraAllowed AND vVNHWarehouseFk != vWarehouseFk) - OR (vn.isLogifloraDay(vShipped, vWarehouseFk) = FALSE) - + -- Esto sirve para que los franceses compren sólo por las cuentas de VNH + DELETE tl.* + FROM tmp.ticketLot tl + JOIN vn.item i ON i.id = tl.itemFk + JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk + JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID + WHERE v.isVNHSupplier != vIsFrenchVNHBuyer; + + IF (NOT vIsLogifloraAllowed AND vVNHWarehouseFk != vWarehouseFk) + OR NOT vn.isLogifloraDay(vShipped, vWarehouseFk) + -- OR NOT(vIsCatalonianBuyer OR vIsFrenchVNHBuyer) THEN CALL cache.visible_refresh(vVisibleCache, FALSE, vWarehouseFk); @@ -48240,6 +48048,7 @@ proc: BEGIN LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = vWarehouseFk LEFT JOIN vn.buy b ON b.id = lb.buy_id LEFT JOIN vn.entry e ON e.id = b.entryFk + LEFT JOIN vn.supplier s ON s.id = e.supplierFk -- PAK 13/10/21 LEFT JOIN cache.visible v ON v.calc_id = vVisibleCache AND v.item_id = i.id LEFT JOIN (SELECT DISTINCT s.itemFk FROM vn.sale s @@ -48249,7 +48058,8 @@ proc: BEGIN AND t.shipped = vShipped AND t.zoneFk = vZoneFk) sub ON sub.itemFk = i.id WHERE (i.supplyResponseFk - AND IFNULL(e.isRaid,TRUE) + AND (IFNULL(e.isRaid,TRUE) + OR s.nickname = 'INVENTARIO') -- PAK 13/10/21 AND ISNULL(sub.itemFk) AND IFNULL(v.visible,0) = 0 AND vWarehouseFk = tl.warehouseFk); @@ -48291,8 +48101,14 @@ proc: BEGIN WHERE zf.id IS NULL ; END IF; - - + + -- Eliminem productes de la oferta que la zona no pot transportar + DELETE tl.* + FROM tmp.ticketLot tl + JOIN item i ON i.id = tl.itemFk + JOIN vn.zone z ON z.id = vZoneFk + WHERE i.size > z.itemMaxSize; + SET @rate2 := 0; SET @rate3 := 0; SET @minPrice := 0; @@ -48329,7 +48145,7 @@ proc: BEGIN ) 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 + WHERE b.buyingValue + b.freightValue + b.packageValue + b.comissionValue > 0.01 AND ic.merchandise <> 0 AND tl.zoneFk = vZoneFk AND tl.warehouseFk = vWarehouseFk; -- Coste @@ -48395,8 +48211,6 @@ proc: BEGIN WHERE wm.isPricesModifierActivated HAVING manaAuto <> 0; - - -- Precios especiales INSERT INTO tmp.ticketComponent SELECT tcb.warehouseFk, @@ -48627,7 +48441,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 `clean` */; +/*!50003 DROP PROCEDURE IF EXISTS `catalog_test` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -48637,6 +48451,169 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `catalog_test`() +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 vLanded DATE DEFAULT DATE_ADD(CURDATE(),INTERVAL 2 DAY); + DECLARE vAddressFk INT DEFAULT 24526; + DECLARE vAgencyModeFk INT DEFAULT 639; + DECLARE vAvailableCalc INT; + DECLARE vShipped DATE; + 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; + + DROP TEMPORARY TABLE IF EXISTS tmp.item; + CREATE TEMPORARY TABLE tmp.item + ENGINE = MEMORY + SELECT 10 itemFk; + -- Establece los almacenes y las fechas que van a entrar al disponible +SELECT 1; + CALL vn.zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, FALSE); +SELECT 2; + 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', + `zoneFk` int(11) NOT NULL, + KEY `itemFk` (`itemFk`), + KEY `item_warehouse` (`itemFk`,`warehouseFk`) USING HASH + ) ENGINE=MEMORY DEFAULT CHARSET=utf8; + CALL catalog_componentPrepare(); + +SELECT 3; + DROP TEMPORARY TABLE IF EXISTS tmp.ticketCalculateItem; + CREATE TEMPORARY TABLE tmp.ticketCalculateItem( + itemFk INT(11) NOT NULL, + available INT(11), + producer VARCHAR(50), + item VARCHAR(50), + size INT(10) UNSIGNED, + stems INT(11), + category VARCHAR(3), + inkFk VARCHAR(3), + image VARCHAR(50), + origin VARCHAR(3), + price DECIMAL(10,2), + priceKg DECIMAL(10,2), + PRIMARY KEY `itemFk` (`itemFk`) + ) 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); +SELECT '4', vWarehouseFk, vShipped ; + CALL buyUltimate (vWarehouseFk, vShipped); +SELECT 5; + INSERT INTO tmp.ticketLot (warehouseFk, itemFk, available, buyFk, zoneFk) + SELECT vWarehouseFk, + i.item_id, + IFNULL(i.available, 0), + bu.buyFk, + vZoneFk + 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 i.available > 0; + + DROP TEMPORARY TABLE tmp.buyUltimate; + + CALL vn.catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk); +SELECT 6; + INSERT INTO tmp.ticketCalculateItem ( + itemFk, + available, + producer, + item, + size, + stems, + category, + inkFk, + image, + origin, + price, + priceKg) + SELECT + tl.itemFk, + SUM(tl.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 tl + JOIN item i ON tl.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 * + FROM (SELECT price, itemFk, priceKg + FROM tmp.ticketComponentPrice + WHERE warehouseFk = vWarehouseFk + ORDER BY (rate = 2) DESC) sub + GROUP BY itemFk + ) bl ON bl.itemFk = tl.itemFk + WHERE tl.zoneFk = vZoneFk AND tl.warehouseFk = vWarehouseFk + GROUP BY tl.itemFk + ON DUPLICATE KEY UPDATE available = available + VALUES(available); + + END LOOP; + + CLOSE cTravelTree; + DROP TEMPORARY TABLE tmp.item; +SELECT 7; + +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 `clean` */; +/*!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 `clean`() BEGIN DECLARE vDateShort DATETIME; @@ -48662,6 +48639,9 @@ BEGIN DELETE FROM itemShelving WHERE created < CURDATE() AND visible = 0; DELETE FROM ticketDown WHERE created < TIMESTAMPADD(DAY,-1,CURDATE()); DELETE FROM entryLog WHERE creationDate < vDateShort; + DELETE g FROM glsExpedition g + JOIN expedition e ON e.id = g.expeditionFk + WHERE e.created < v26Month; DELETE FROM expedition WHERE created < v26Month; DELETE FROM sms WHERE created < v18Month; DELETE FROM saleTracking WHERE created < vDateShort; @@ -48786,6 +48766,9 @@ BEGIN -- Borra los ficheros gestDoc INSERT INTO vn.printServerQueue(priorityFk, labelReportFk)VALUES(1,11); + + -- Borra los registros de collection y ticketcollection + DELETE FROM vn.collection WHERE created < vDateShort; DROP TEMPORARY TABLE IF EXISTS tmp.thermographToDelete; DROP TEMPORARY TABLE IF EXISTS tmp.entryToDelete; @@ -49230,6 +49213,10 @@ BEGIN FETCH cur INTO vCreated, vIssued, vBalance; + IF vDate IS NULL THEN + SET vDate=vIssued; + END IF; + IF vDone THEN LEAVE proc; END IF; @@ -50228,7 +50215,7 @@ BEGIN SET SESSION group_concat_max_len = 1000000; -- IF (DAY(CURDATE()) = 5) THEN INSERT INTO - vn.mail (sender, + vn.mail (receiver, replyTo, subject, body) @@ -50251,9 +50238,9 @@ BEGIN CMR Ticket - - ', GROUP_CONCAT(' ', c.id, ' ', c.ticketFk, ' ' ORDER BY c.id SEPARATOR '' ), ' - + ' + , GROUP_CONCAT(' ', c.id, ' ', c.ticketFk, ' ' ORDER BY c.id SEPARATOR '' ), + '

Saludos cordiales, Dpto administración. @@ -50284,14 +50271,19 @@ 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 `collectionPlacement_get`(vParamFk INT(11)) BEGIN + + /* Devuelve el listado de ubicaciones a las que hay que ir para preparar una colección o ticket + * + * @param vParamFk Identificador de vn.collection o Identificador de vn.ticket + */ DECLARE vCalcFk INT; DECLARE vWarehouseFk INT; @@ -50301,9 +50293,9 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.sale; CREATE TEMPORARY TABLE tmp.sale ENGINE = MEMORY - SELECT 0000000 as ticketFk, - 0000000 as saleFk, - 0000000 as itemFk, + SELECT 00000000 as ticketFk, + 00000000 as saleFk, + 00000000 as itemFk, FALSE as isStowaway, 0 as quantity; @@ -50320,29 +50312,6 @@ BEGIN FROM vn.sale s WHERE s.ticketFk = vParamFk; - - /* UNION ALL - SELECT sw.shipFk, s.id, s.itemFk, TRUE - FROM vn.sale s - JOIN vn.stowaway sw ON sw.id = s.ticketFk - JOIN vn.ticketCollection tc ON tc.ticketFk = sw.shipFk - WHERE tc.collectionFk = vParamFk; - - INSERT INTO tmp.sale(ticketFk, saleFk, itemFk, isStowaway) - SELECT s.ticketFk, s.id, s.itemFk, FALSE - FROM vn.sale s - JOIN vn.ticket t ON t.id = s.ticketFk - WHERE s.ticketFk = vParamFk - AND t.shipped > '2020-01-01' - UNION ALL - SELECT sw.shipFk, s.id, s.itemFk, TRUE - FROM vn.sale s - JOIN vn.stowaway sw ON sw.id = s.ticketFk - WHERE sw.shipFk = vParamFk; - - DELETE FROM tmp.sale - WHERE saleFk = 0; - */ SELECT t.warehouseFk, w.aliasFk INTO vWarehouseFk, vWarehouseAliasFk FROM vn.ticket t @@ -50367,7 +50336,8 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.`grouping`; CREATE TEMPORARY TABLE tmp.`grouping` - ENGINE MEMORY + (INDEX(itemFk)) + ENGINE = MEMORY SELECT b.itemFk, CASE b.groupingMode WHEN 0 THEN 1 @@ -50377,7 +50347,7 @@ BEGIN FROM buy b JOIN cache.last_buy lb ON lb.buy_id = b.id WHERE lb.warehouse_id = vWarehouseFk - ; + GROUP BY b.itemFk; DROP TEMPORARY TABLE IF EXISTS tmp.grouping2; CREATE TEMPORARY TABLE tmp.grouping2 @@ -50395,13 +50365,14 @@ BEGIN CONCAT('< ', IFNULL(wk.`code`, '---'),' > '), ''), p.`code`) COLLATE utf8_general_ci as placement , + sh.priority shelvingPriority, -- PAK 05/11/2021 sh.code COLLATE utf8_general_ci as shelving, ish.created, ish.visible, IF(ts.isStowaway, - 100000, IF(ish.visible > 0 OR iss.id, 1, 100000)) * p.pickingOrder as `order`, IFNULL(IF(sc.isPreviousPreparedByPacking, ish.packing, g.`grouping`),1) as `grouping`, IF(iss.id, TO_SECONDS(TIMESTAMPADD(YEAR,-vCurrentYear,iss.created)), TO_SECONDS(TIMESTAMPADD(YEAR,- year(ish.created),ish.created)) + TO_SECONDS(TIMESTAMPADD(YEAR,-vCurrentYear,NOW()))) as priority, - 0 as saleOrder, + CAST(0 AS DECIMAL(10,0)) as saleOrder, sc.isPreviousPrepared, iss.id as itemShelvingSaleFk, ts.ticketFk @@ -50423,7 +50394,8 @@ BEGIN LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = ts.saleFk AND iss.itemShelvingFk = ish.id LEFT JOIN vn.worker wk ON wk.id = iss.userFk WHERE w.aliasFk = vWarehouseAliasFk - HAVING (iss.id AND st.saleFk) OR salePreviousPrepared IS NULL + AND NOT sc.isHideForPickers + HAVING (iss.id AND st.saleFk) OR salePreviousPrepared IS NULL ; DROP TEMPORARY TABLE IF EXISTS tmp.salePlacementList_2; @@ -50432,7 +50404,10 @@ BEGIN SELECT saleFk, priority as olderPriority FROM (SELECT saleFk, priority FROM tmp.salePlacementList - ORDER BY IF(isPreviousPrepared,2,1), IF(visible > 0 OR itemShelvingSaleFk,1,2), priority + ORDER BY IF(isPreviousPrepared,2,1), + IF(visible > 0 OR itemShelvingSaleFk,1,2), + IFNULL(shelvingPriority,0) DESC, -- PAK 05/11/21 + priority ) sub GROUP BY saleFk; @@ -50446,14 +50421,19 @@ BEGIN UPDATE tmp.salePlacementList s1 JOIN tmp.salePlacementList_3 s3 ON s3.saleFk = s1.saleFk SET s1.saleOrder = s3.saleOrder; - - -- Nuevo campaña + /* + -- Anula el orden de antigüedad y ordena por ubicación UPDATE tmp.salePlacementList - SET saleOrder = `order`; - + SET saleOrder = `order`;*/ + SELECT * FROM tmp.salePlacementList - ORDER BY saleOrder, IF(isPreviousPrepared,2,1), IF(visible > 0 OR itemShelvingSaleFk,1,2),priority; + ORDER BY visible <> 0 DESC, + saleOrder, + IF(isPreviousPrepared,2,1), + IF(itemShelvingSaleFk,1,2), + shelvingPriority DESC, -- PAK 05/11/2021 + priority; DROP TEMPORARY TABLE tmp.sale, @@ -50473,9 +50453,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 ;; @@ -50537,7 +50517,7 @@ CALL util.debugAdd("vCollectionFk",vn.getUser()); s.itemFk, s.quantity, i.longName, - i.size, + i.size, s.reserved, MAX(IF(st.semaphore <=> 1, TRUE, FALSE)) as isPreviousPrepared, MAX(IF(st.semaphore <=> 2, TRUE, FALSE)) as isPrepared, @@ -50555,18 +50535,27 @@ CALL util.debugAdd("vCollectionFk",vn.getUser()); LPAD(s.concept,30,' '), ' ', RPAD(IFNULL(i.size,''),5,' ') ) - ) as line1, + ) as line1, + '' cel1, TRIM(CONCAT(LPAD(IFNULL(ip.productor,''),30,' '), ' ',LPAD(IFNULL(o.code,''),4,' '))) as line2, + IF(s.quantity MOD b.packing, + CONCAT(CAST(s.quantity/b.`grouping` AS decimal(10,0)),' x ',b.`grouping`), + CONCAT(CAST(s.quantity / b.packing AS DECIMAL(10,0)),' pack de ',b.packing)) cel2, TRIM(CONCAT(ic.color, IF(MAX(IF(st.semaphore <=> 1, TRUE, FALSE)) AND t.id != t.showTicketFk, CONCAT(' [ TICKET ',t.id,' ] '),''), IFNULL(LPAD(st.parkingCode,40,' '),''))) as line3, + '' cel3, s.isAdded, str.originalQuantity as startQuantity, -- eliminar cuando tengamos la nueva apk c.workerFk, IFNULL(SUM(iss.quantity),0) as pickedQuantity FROM vn.sale s JOIN tmp.ticket t ON t.id = s.ticketFk + JOIN vn.ticket tt ON tt.id = t.id + JOIN cache.last_buy lb ON lb.item_id = s.itemFk AND lb.warehouse_id = tt.warehouseFk + JOIN vn.buy b ON b.id = lb.buy_id JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.ticketCollection tc ON tc.ticketFk = t.id - JOIN vn.collection c ON c.id = tc.collectionFk + JOIN vn.collection c ON c.id = tc.collectionFk LEFT JOIN vn.saleTracking str ON str.saleFk = s.id AND str.isChecked = 1 LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id LEFT JOIN vn.state st ON st.id = str.stateFk @@ -50688,9 +50677,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 ;; @@ -50707,7 +50696,10 @@ BEGIN INTO vCollectionFk, vItemPackingTypeFk FROM vn.collection WHERE id = vParamFk; - + + -- Sergio debug insertado el 13-10-2021 +-- CALL util.debugAdd("collectionTicket_get",vn.getUser()); + IF !(vItemPackingTypeFk <=> 'V') THEN IF vCollectionFk THEN @@ -50851,6 +50843,50 @@ BEGIN CALL vn.sale_calculateComponent(vSaleFk, null); +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_checkFullyControlled` */; +/*!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_checkFullyControlled`(vWorkerFk INT, vCollectionFk INT ) +BEGIN +/** + * Comprueba que no hay ningún ticket pendiente de revisar de alguna colección del trabajador haya revisado ya + * @param vWorkerFk id del user + * @param vCollectionFk número de colección escaneada + * + */ + + SELECT tc.collectionFk + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN ticketCollection tc ON tc.ticketFk = t.id + JOIN (SELECT tc.collectionFk + FROM ticketState ts + JOIN ticketCollection tc ON tc.ticketFk = ts.ticketFk + WHERE ts.workerFk = vWorkerFk + AND tc.collectionFk <> vCollectionFk + AND tc.created >= CURDATE() + GROUP BY tc.collectionFk + )sub ON sub.collectionFk = tc.collectionFk + JOIN ticketState ts ON ts.ticketFk = t.id + WHERE t.shipped >= CURDATE() + AND ts.code IN ('ON_PREPARATION', 'PREPARED', 'PREVIOUS_PREPARATION', 'OK PREVIOUS') + AND s.quantity <>0 + + LIMIT 1; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -50941,6 +50977,73 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `collection_getTickets`(vParamFk INT) +BEGIN +/** + * Selecciona los tickets de una colección/ticket + * @param vParamFk ticketFk/collectionFk + * @return Retorna ticketFk, level, agencyName, warehouseFk, salesPersonFk, observaciones + */ + DECLARE vItemPackingTypeFk VARCHAR(1); + + -- Si los sacadores son los de pruebas, pinta los colores + SELECT itemPackingTypeFk INTO vItemPackingTypeFk + FROM vn.collection + WHERE id = vParamFk; + + SELECT t.id ticketFk, + IF (!(vItemPackingTypeFk <=> 'V'), cc.code,CONCAT(SUBSTRING('ABCDEFGH',tc.wagon, 1),'-',tc.`level` )) `level`, + am.name agencyName, + t.warehouseFk, + w.id salesPersonFk, + IFNULL(tob.description,'') observaciones + FROM vn.ticket t + LEFT JOIN vn.ticketCollection tc ON t.id = tc.ticketFk + LEFT JOIN vn.collectionColors cc ON cc.wagon = tc.wagon + AND cc.shelve = tc.`level` + 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 + LEFT JOIN vn.ticketObservation tob ON tob.ticketFk = t.id + AND tob.observationTypeFk = 1 + WHERE t.id = vParamFk + AND t.shipped >= util.yesterday() + UNION ALL + SELECT t.id ticketFk, + IF(!(vItemPackingTypeFk <=> 'V'), cc.code, CONCAT(SUBSTRING('ABCDEFGH', tc.wagon, 1), '-', tc.`level`)) `level`, + am.name agencyName, + t.warehouseFk, + w.id salesPersonFk, + IFNULL(tob.description, '') observaciones + FROM vn.ticket t + JOIN vn.ticketCollection tc ON t.id = tc.ticketFk + LEFT JOIN vn.collectionColors cc ON cc.wagon = tc.wagon + AND cc.shelve = tc.`level` + 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 + LEFT JOIN vn.ticketObservation tob ON tob.ticketFk = t.id + AND tob.observationTypeFk = 1 + WHERE tc.collectionFk = vParamFk; + +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_getTickets__` */; +/*!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_getTickets__`(vParamFk INT) BEGIN DECLARE vAlertLevel INT; @@ -51045,24 +51148,23 @@ BEGIN IF vTicketFk IS NULL THEN SELECT c.name , co.id INTO vClientName,vConsignatario - FROM vn.client c - INNER JOIN vn.address co ON c.id = co.clientFk - WHERE c.id = vClientFk - LIMIT 1; + FROM vn.client c + INNER JOIN vn.address co ON c.id = co.clientFk + WHERE c.id = vClientFk + LIMIT 1; - INSERT INTO vn.ticket (clientFk,warehouseFk,shipped,nickname,addressFk,workerFk,agencyModeFk) - VALUES (vClientFk,vWarehouseFk,NOW(),vClientName,vConsignatario,vn.getUser(),2); + CALL ticketCreateWithUser(vClientFk, NOW(), vWarehouseFk, 442, vConsignatario, NULL, NULL, NULL, account.userGetId(), vTicketFk); SELECT t.id INTO vTicketFk FROM vn.ticket t WHERE t.created > DATE_SUB(NOW(), INTERVAL 1 DAY) AND t.clientFk = vClientFk AND t.warehouseFk = vWarehouseFk LIMIT 1; END IF; INSERT INTO vn.sale (itemFk, ticketFk, concept, quantity, originalQuantity, price, discount, priceFixed, reserved, isPicked, isPriceFixed, created, isAdded) - SELECT itemFk, vTicketFk, CONCAT(concept," ",vn.getWorkerCode(), " ",LEFT(CAST(NOW() AS TIME),5)), vQuantity, originalQuantity, price, discount, priceFixed, reserved, isPicked, isPriceFixed, created, isAdded - FROM vn.sale s WHERE s.id = vSaleFk; + SELECT itemFk, vTicketFk, CONCAT(concept," ",vn.getWorkerCode(), " ",LEFT(CAST(NOW() AS TIME),5)), vQuantity, originalQuantity, price, discount, priceFixed, reserved, isPicked, isPriceFixed, created, isAdded + FROM vn.sale s WHERE s.id = vSaleFk; SELECT quantity INTO vOriginalQuantity FROM vn.sale WHERE id = vSaleFk; - UPDATE vn.sale SET originalQuantity = vOriginalQuantity ,quantity = vNewQuantity WHERE id = vSaleFk; + UPDATE vn.sale SET originalQuantity = vOriginalQuantity ,quantity = vNewQuantity WHERE id = vSaleFk; END ;; DELIMITER ; @@ -51594,7 +51696,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 `collection_newSmartTag2` */; +/*!50003 DROP PROCEDURE IF EXISTS `collection_newWithWagon` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -51604,7 +51706,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `collection_newSmartTag2`(vSectorFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `collection_newWithWagon`(vSectorFk INT, vWagons INT) proc:BEGIN DECLARE vIsPreviousPrepared BOOLEAN; @@ -51615,7 +51717,6 @@ proc:BEGIN DECLARE vFirstTicketFk INT; DECLARE vHour INT; DECLARE vMinute INT; - DECLARE vWorker INT; DECLARE vWorkerCode VARCHAR(3); DECLARE vWagon INT; DECLARE vWagonCounter INT; @@ -51630,19 +51731,39 @@ proc:BEGIN DECLARE vMaxNotReadyCollections INT DEFAULT 0; DECLARE vNotReadyCollections INT; DECLARE vSectorCode VARCHAR(20); - DECLARE vWagons INT; + + /*IF NOT vn.deviceProductionUser_Exists(vn.getUser()) THEN + + LEAVE proc; - /* SELECT w.code, w.id INTO vWorkerCode, vWorker + END IF;*/ + + CALL util.debugAdd('vn.collection_newWithWagon',CONCAT('sector: ',vSectorFk,' wagons:',vWagons)); + + + SELECT w.code INTO vWorkerCode FROM vn.worker w WHERE w.id = vn.getUser(); - */ + + -- 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, itemPackingTypeFk, code + INTO vIsPreviousPrepared, vWarehouseFk, vItemPackingTypeFk, vSectorCode + FROM vn.sector + WHERE id = vSectorFk; - SELECT 'VLC', 19263 INTO vWorkerCode, vWorker; +-- Si está habilitado el modo cazador para las motos, y el usuario no está registrado, se sale. + + IF (SELECT isTractorHuntingMode FROM vn.deviceProductionConfig dpc) AND vItemPackingTypeFk = 'H' THEN + IF (SELECT COUNT(*) FROM vn.workerWithoutTractor wwt WHERE wwt.workerFk = account.userGetId()) THEN + INSERT INTO tmp.kk(userFk) VALUES(vn.getUser()); + LEAVE proc; + END IF; + END IF; -- Si hay colecciones sin terminar, sale del proceso SELECT count(*) INTO vNotReadyCollections FROM vn.collection c - WHERE c.workerFk = 19263 + WHERE c.workerFk = vn.getUser() AND c.saleTotalCount > c.salePickedCount + 1 AND c.created > TIMESTAMPADD(HOUR , -5,NOW()); @@ -51652,23 +51773,17 @@ proc:BEGIN END IF; - -- 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, itemPackingTypeFk, code - INTO vIsPreviousPrepared, vWarehouseFk, vItemPackingTypeFk, vSectorCode - FROM vn.sector - WHERE id = vSectorFk; - - -- Cogemos el numero de wagons del trabajador - SELECT COUNT(ws.id) - FROM vn.workerShelving ws - WHERE ws.workerFk = vWorker - AND ws.collectionFk IS NULL - INTO vWagons; - - SET vMaxTicketPrinted = 6 * vWagons; - SET vMaxTickets = 3 * vWagons; - - +/* + IF LENGTH(vSectorCode) = 2 THEN + + SELECT CAST(SUBSTRING(vSectorCode,2,1) AS UNSIGNED) INTO vWagons; + + END IF; +*/ + SET vMaxTicketPrinted = 8 * vWagons; + SET vMaxTickets = 4 * vWagons; + + IF vIsPreviousPrepared THEN LEAVE proc; -- Hasta que tengamos el altillo, vamos a cancelar esta opcion @@ -51689,23 +51804,24 @@ proc:BEGIN INTO myUserIsSalesPersonRole FROM account.user u JOIN account.role r ON r.id = u.role - WHERE u.id = 19263; + WHERE u.id = vn.getUser(); -- Se obtiene nº de colección y el buffer con los pedidos preparables INSERT INTO vn.collection - SET workerFk = 19263, + SET workerFk = account.myUser_getId(), itemPackingTypeFk = vItemPackingTypeFk; SELECT LAST_INSERT_ID() INTO vCollectionFk; - - - UPDATE workerShelving - SET collectionFk = vCollectionFk - WHERE workerFk = vWorker - AND collectionFk IS NULL; CALL vn.productionControl(vWarehouseFk, 0); - + + -- 05/08/2021 PAK Jose Frau pide que los tickets de recogida en Algemesí sólo se saquen si están asignados. + DELETE pb.* + FROM tmp.productionBuffer pb + JOIN vn.state s ON s.id = pb.state + WHERE pb.agency = 'REC_ALGEMESI' + AND s.code != 'PICKER_DESIGNED'; + -- Comprobamos si hay tickets asignados. En ese caso, nos centramos exclusivamente en esos tickets -- y los sacamos independientemente de problemas o tamaños SELECT COUNT(*) INTO hasAssignedTickets @@ -51775,7 +51891,7 @@ proc:BEGIN IF vMaxTicketPrinted > 0 THEN INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) - SELECT s2.id, pb.ticketFk, 19263 + SELECT s2.id, pb.ticketFk, vn.getUser() FROM tmp.productionBuffer pb JOIN vn.agencyMode am ON am.id = pb.agencyModeFk JOIN vn.agency a ON a.id = am.agencyFk @@ -52067,19 +52183,14 @@ proc:BEGIN SET c.stateFk = st.id WHERE c.id = vCollectionFk; - -- Asigna las bandejas y las smartTags - SET @wagon := 0; - UPDATE vn.ticketCollection tc - JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk - JOIN (SELECT @wagon:=@wagon+1 as wagon, ws.shelvingFk - FROM workerShelving ws - WHERE ws.collectionFk = vCollectionFk) sub ON sub.wagon = t.wagon - JOIN smartTag s ON s.shelvingFk = sub.shelvingFk AND s.`level` = t.shelve - SET tc.`level` = t.shelve, tc.wagon = t.wagon, tc.smartTagFk = s.code; + -- Asigna las bandejas + UPDATE vn.ticketCollection tc + JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk + SET tc.level = t.shelve, tc.wagon = t.wagon; -- Actualiza el estado de los tickets INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) - SELECT vStateFk, ticketFk, 19263 + SELECT vStateFk, ticketFk, account.myUser_getId() FROM vn.ticketCollection tc WHERE tc.collectionFk = vCollectionFk; @@ -52115,24 +52226,24 @@ proc:BEGIN END IF; DROP TEMPORARY TABLE tmp.ticketToSplit; - + 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_newWithWagon` */; +/*!50003 DROP PROCEDURE IF EXISTS `collection_newWithWagon__` */; /*!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 `collection_newWithWagon`(vSectorFk INT, vWagons INT) +CREATE DEFINER=`root`@`%` PROCEDURE `collection_newWithWagon__`(vSectorFk INT, vWagons INT) proc:BEGIN DECLARE vIsPreviousPrepared BOOLEAN; @@ -52157,12 +52268,16 @@ proc:BEGIN DECLARE vMaxNotReadyCollections INT DEFAULT 0; DECLARE vNotReadyCollections INT; DECLARE vSectorCode VARCHAR(20); -/* - IF vn.getUser() = 18890 THEN - CALL collection_newSmartTag(vSectorFk); + + /*IF NOT vn.deviceProductionUser_Exists(vn.getUser()) THEN + LEAVE proc; + END IF;*/ + CALL util.debugAdd('vn.collection_newWithWagon',CONCAT('sector: ',vSectorFk,' wagons:',vWagons)); + + SELECT w.code INTO vWorkerCode FROM vn.worker w WHERE w.id = vn.getUser(); @@ -53527,7 +53642,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 `cristalBall` */; +/*!50003 DROP PROCEDURE IF EXISTS `cristalBall__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -53537,7 +53652,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `cristalBall`() +CREATE DEFINER=`root`@`%` PROCEDURE `cristalBall__`() BEGIN /* *se utiliza en campaña @@ -53577,7 +53692,7 @@ FROM JOIN bi.rotacion r ON r.Id_Article = e.item_id AND r.warehouse_id = e.warehouse_id WHERE e.dat BETWEEN CURDATE() AND vLastDate AND e.warehouse_id = vWarehouse - AND ic.merchandise + AND ic.display AND e.isVirtualStock is FALSE GROUP BY e.dat, e.item_id @@ -53597,7 +53712,7 @@ FROM JOIN bi.rotacion r ON r.Id_Article = s.item_id AND r.warehouse_id = s.warehouse_id WHERE s.dat BETWEEN CURDATE() AND vLastDate AND s.warehouse_id = vWarehouse - AND ic.merchandise + AND ic.display GROUP BY date(s.dat), s.item_id UNION ALL @@ -53615,7 +53730,7 @@ FROM JOIN vn.itemCategory ic ON ic.id = it.categoryFk JOIN bi.rotacion r ON r.Id_Article = st.item_id AND r.warehouse_id = st.warehouse_id WHERE st.warehouse_id = vWarehouse - AND ic.merchandise + AND ic.display ) sub ORDER BY itemFk, dat, entra DESC) sub2 @@ -53786,79 +53901,74 @@ DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `dayMinuteWorker`(vDateFrom DATETIME, vDateTo DATETIME) BEGIN -DECLARE vDateStart DATETIME DEFAULT DATE(vDateFrom); -DECLARE vDateEnd DATETIME DEFAULT util.dayEnd(vDateTo); + DECLARE vDateStart DATE DEFAULT vDateFrom; + DECLARE vDateEnd DATETIME DEFAULT util.dayEnd(vDateTo); -SET @ordr := 0; -SET @user := 0; - -DROP TEMPORARY TABLE IF EXISTS tmp.dayMinuteWorker; -CREATE TEMPORARY TABLE tmp.dayMinuteWorker - ENGINE = MEMORY - SELECT sub3.id, - sub3.hh as Hora, - sub3.mm as Minuto, - sub3.userFk, - sub3.code as CodigoTrabajador, - sub3.firstname as Nombre, - sub3.lastName as Apellidos, - sub3.warehouseFk as Almacen, - w.name as NombreAlmacen - FROM vn.warehouse w - JOIN - ( - SELECT id, - hh, - mm, - userFk, - code, - firstname, - lastName, - @ordr := IF(@user != userFk,0,@ordr), - IF(@ordr MOD 2, 'presente','--') as estado, - @ordr := IFNULL(sub2.`order`,@ordr), - @user := IFNULL(sub2.`userFk`,@user), - warehouseFk - FROM - ( - SELECT dm.id, - dm.hh, - dm.mm, - users.userFk, - sub.`order`, - users.code, - firstName, - lastName, - users.warehouseFk - FROM dayMinute dm - JOIN - ( - SELECT DISTINCT wtc.userFk , - code , - firstName, - lastName, - IFNULL(warehouseFk,1) warehouseFk - FROM vn.workerTimeControl wtc - JOIN vn.worker w ON w.userFk = wtc.userFk - WHERE timed BETWEEN vDateStart AND vDateEnd - ) users - - LEFT JOIN - ( - SELECT `order`, - wtc.userFk, - hour(timed) * 100 + minute(timed) as dayMinuteFk - FROM vn.workerTimeControl wtc - WHERE timed BETWEEN vDateStart AND vDateEnd - ORDER BY wtc.userFk, `order` - ) sub ON sub.dayMinuteFk = dm.id AND sub.userFk = users.userFk - ORDER BY userFk,dm.id - ) sub2 - ) sub3 ON sub3.warehouseFk = w.id - WHERE estado = 'presente' - AND sub3.id BETWEEN HOUR(vDateFrom) *100 + MINUTE(vDateFrom) AND HOUR(vDateTo) *100 + MINUTE(vDateTo); --- SELECT * FROM tmp.dayMinuteWorker; + SET @ordr := 0; + SET @user := 0; + DROP TEMPORARY TABLE IF EXISTS tmp.dayMinuteWorker; + CREATE TEMPORARY TABLE tmp.dayMinuteWorker + SELECT sub3.id, + sub3.hh AS `Hour`, + sub3.mm AS Minut, + sub3.userFk, + sub3.code AS workerCode, + sub3.firstname AS name, + sub3.lastName AS surnames, + sub3.workcenterFk AS center, + w.name AS centerName, + w2.name AS warehouseName, + w2.hasProduction AS production + FROM postgresql.workcenter w + JOIN(SELECT id, + hh, + mm, + userFk, + code, + firstname, + lastName, + @ordr := IF(@user != userFk,0,@ordr), + IF(@ordr MOD 2, 'presente','--') AS state, + @ordr := IFNULL(sub2.`order`,@ordr), + @user := IFNULL(sub2.`userFk`,@user), + workcenterFk + FROM(SELECT dm.id, + dm.hh, + dm.mm, + users.userFk, + sub.`order`, + users.code, + firstName, + lastName, + users.workcenterFk + FROM dayMinute dm + JOIN(SELECT DISTINCT wtc.userFk , + code , + firstName, + lastName, + wl.workCenterFk + FROM vn.workerTimeControl wtc + JOIN vn.worker w ON w.userFk = wtc.userFk + JOIN vn.workerLabour wl ON wl.workerFK = w.id + AND wtc.timed BETWEEN wl.started AND IFNULL(wl.ended, CURDATE()) + WHERE wtc.timed BETWEEN vDateStart AND vDateEnd + ) users + LEFT JOIN(SELECT `order`, + wtc.userFk, + hour(wtc.timed) * 100 + minute(wtc.timed) as dayMinuteFk + FROM vn.workerTimeControl wtc + WHERE wtc.timed BETWEEN vDateStart AND vDateEnd + ORDER BY wtc.userFk, `order` + ) sub ON sub.dayMinuteFk = dm.id AND sub.userFk = users.userFk + ORDER BY userFk,dm.id + ) sub2 + ) sub3 ON sub3.workcenterFk = w.workcenter_id + JOIN vn.warehouse w2 ON w2.id = w.warehouseFk + WHERE state = 'presente' + AND sub3.id BETWEEN HOUR(vDateFrom) *100 + MINUTE(vDateFrom) + AND HOUR(vDateTo) *100 + MINUTE(vDateTo); + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -54124,13 +54234,66 @@ 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 `deviceLog_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 = 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 `deviceLog_add`(vWorkerFk INT, vAppName VARCHAR(45), vAppVersion VARCHAR(45), vAndroid_id VARCHAR(100)) +BEGIN +/* + * Inserta registro en tabla devicelog el log del usuario conectado + * @param vAppName es el nombre de la app + * @param vAppVersion es la versión de la app + * @param vAndroid_id es el android_id del dispositivo que se ha logueado + */ + + INSERT INTO deviceLog (userFK, nameApp, versionApp, android_id) + VALUES(vWorkerFk, vAppName, vAppVersion, vAndroid_id); + + +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 `deviceProductionUser_exists` */; +/*!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 `deviceProductionUser_exists`(vUserFk INT) +BEGIN + +/* SELECT COUNT(*) AS UserExists + FROM vn.deviceProductionUser dpu + WHERE dpu.userFk = vUserFk;*/ + SELECT 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 `deviceProductionUser_getWorker` */; /*!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 ;; @@ -54142,11 +54305,11 @@ BEGIN * @param vAndroid_id el número android_id del dispositivo * */ - - SELECT account.user_getNameFromId(dpu.userFk) + SELECT 103; +/* SELECT account.user_getNameFromId(dpu.userFk) FROM deviceProductionUser dpu JOIN deviceProduction dp ON dpu.deviceProductionFk = dp.id - WHERE dp.android_id = vAndroid_id; + WHERE dp.android_id = vAndroid_id;*/ END ;; DELIMITER ; @@ -54177,6 +54340,117 @@ BEGIN FROM deviceProduction dp WHERE dp.android_id = vAndroid_id; +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 `device_checkLogin` */; +/*!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 `device_checkLogin`(vUserFk INT, vAndroidID VARCHAR(50)) +BEGIN + +/* + * Comprueba si está registrado el dispositivo mediante su androidId + * + * @param vUSerFk el id del user + * @param vAndroidID es el identificador android_id del dispositivo + */ + DECLARE vIsAuthorized BOOL DEFAULT TRUE; + DECLARE vIsDepartment BOOL; + DECLARE vIsAllUsersAllowed BOOL; + DECLARE vMessage VARCHAR(200); + + SELECT dpc.isAllUsersallowed INTO vIsAllUsersAllowed + FROM vn.deviceProductionConfig dpc; + + IF NOT vIsAllUsersAllowed THEN + + SELECT COUNT(*) INTO vIsDepartment + FROM vn.workerDepartment dp + JOIN department d ON d.id = dp.departmentFk + WHERE dp.workerFk = vUserFk AND d.name = "PRODUCCION"; + + IF vIsDepartment THEN + SELECT COUNT(*) INTO vIsAuthorized + FROM vn.deviceProductionUser dpu + JOIN vn.deviceProduction dp ON dp.id = dpu.deviceProductionFk + WHERE dpu.userFk = vUserFk + AND dp.android_id = vAndroidID; + + IF NOT vIsAuthorized THEN + SET vMessage = 'Usuario no autorizado'; + END IF; + END IF; + + END IF; + + SELECT vIsAuthorized,vMessage; + +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 `device_checkLogin__` */; +/*!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 `device_checkLogin__`(vUserFk INT, vAndroidID VARCHAR(50)) +BEGIN + +/* + * Comprueba si está registrado el dispositivo mediante su androidId + * + * @param vUSerFk el id del user + * @param vAndroidID es el identificador android_id del dispositivo + */ + DECLARE vIsAuthorized BOOL DEFAULT TRUE; + DECLARE vIsDepartment BOOL; + DECLARE vMessage VARCHAR(200); + + SELECT COUNT(*) INTO vIsDepartment + FROM vn.workerDepartment dp + JOIN department d ON d.id = dp.departmentFk + WHERE dp.workerFk = vUserFk AND d.name = "PRODUCCION"; + + IF vIsDepartment THEN + + SELECT COUNT(*) INTO vIsAuthorized + FROM vn.deviceProductionUser dpu + JOIN vn.deviceProduction dp ON dp.id = dpu.deviceProductionFk + WHERE dpu.userFk = vUserFk + AND dp.android_id = vAndroidID; + + + IF NOT vIsAuthorized THEN + + SET vMessage = 'Usuario no autorizado'; + + END IF; + + END IF; + + + #vIsAuthorized = TRUE; #Descomentar esta linea si se quiere quitar la comprobación de autorizacion + SELECT vIsAuthorized,vMessage; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -55413,7 +55687,7 @@ DELIMITER ; /*!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 collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -55473,7 +55747,7 @@ BEGIN NOT wIn.isFeedStock AND NOT e.isInventory AND NOT e.isRaid AND e.id = 158772 AND i.typeFk IS NOT NULL - AND ic.merchandise IS NOT FALSE; + AND ic.display IS NOT FALSE; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -55716,6 +55990,81 @@ BEGIN 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 `entry_fixMisfit` */; +/*!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 `entry_fixMisfit`(vSelf INT) +BEGIN + + /* Arregla el descuadre de una entrada, agregando registros en vn.buy para compensar la diferencia + * entre las etiquetas impresas y las etiquetas esperadas + * + */ + + INSERT INTO vn.buy(entryFk, itemFk) + SELECT vSelf, i.id + FROM vn.item i + WHERE i.description = 'MISFIT' + LIMIT 1; + + INSERT INTO vn.buy(entryFk, + itemFk, + quantity, + buyingValue, + freightValue, + isIgnored, + stickers, + packing, + `grouping`, + groupingMode, + containerFk, + comissionValue, + packageValue, + location, + packageFk, + price1, + price2, + price3, + minPrice, + producer) + SELECT vSelf, + itemFk, + (printedStickers - stickers) * packing AS quantity, + buyingValue, + freightValue, + TRUE isIgnored, + printedStickers - stickers, + packing, + `grouping`, + groupingMode, + containerFk, + comissionValue, + packageValue, + location, + packageFk, + price1, + price2, + price3, + minPrice, + producer + FROM vn.buy b + WHERE b.entryFk = vSelf + AND b.printedStickers != b.stickers; + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -55772,6 +56121,302 @@ 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 `entry_recalc` */; +/*!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 `entry_recalc`() +BEGIN +/** + * Comprueba que las ventas creadas entre un rango de fechas tienen componentes + * + * @param vCreatedFrom inicio del rango + * @param vCreatedTo fin del rango + */ + DECLARE v_done BOOL DEFAULT FALSE; + DECLARE vEntryFk INTEGER; + + DECLARE vCur CURSOR FOR + SELECT e.id FROM vn.entry e + JOIN vn.travel t ON t.id = e.travelFk + WHERE t.shipped >= '2021-10-08' AND t.warehouseInFk= 60; + + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET v_done = TRUE; + + OPEN vCur; + + l: LOOP + SET v_done = FALSE; + FETCH vCur INTO vEntryFk; + + IF v_done THEN + LEAVE l; + END IF; + + CALL vn2008.buy_tarifas_entry(vEntryFk); + END LOOP; + + CLOSE vCur; +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 `errorProduction_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 = 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 `errorProduction_add`(vAction VARCHAR(25), vDepartment VARCHAR(25), vStateCode VARCHAR(25) CHARSET utf8, vDatedFrom DATETIME, vDatedTo DATETIME) +BEGIN + /** + * Fill in the errorProduction table. + */ + DROP TEMPORARY TABLE IF EXISTS tmp.total; + + IF (vDepartment = 'Encajadores') + THEN + CREATE TEMPORARY TABLE tmp.total + ENGINE = MEMORY + SELECT e.workerFk, Count(DISTINCT t.id) AS ticketCount + FROM expedition e + JOIN ticket t ON e.ticketFk = t.id + WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo + GROUP BY e.workerFk; + ELSE + CREATE TEMPORARY TABLE tmp.total + ENGINE = MEMORY + SELECT st.workerFk, Count(DISTINCT t.id) AS ticketCount + FROM state ss + JOIN vn.saleTracking st ON st.stateFk = ss.id + JOIN vn.sale s ON s.id = st.saleFk + JOIN ticket t ON s.ticketFk = t.id + WHERE (t.shipped BETWEEN vDatedFrom AND vDatedTo) AND ss.code = vStateCode + GROUP BY st.workerFk; + END IF; + + CALL timeControl_calculateAll(vDatedFrom, vDatedTo); + + INSERT INTO errorProduction(userFk, firstname, lastname, rol, ticketNumber, error, ratio, volume, hourStart, hourEnd, hourWorked, dated) + SELECT sub1.id, sub1.firstName, sub1.lastName, + CASE + WHEN vDepartment = 'Encajadores' THEN 'Encajador' + WHEN vDepartment = 'Sacadores' THEN 'Sacador' + ELSE 'Revisador' + END AS rol, + CAST(sub1.totalTickets AS DECIMAL(10,0)) AS totalTickets, + CAST(IFNULL(sub1.errors,0) + IFNULL(sub2.errors,0) AS DECIMAL(10,0)) AS errors, + ((IFNULL(sub1.errors,0) + IFNULL(sub2.errors,0))/sub1.totalTickets)*100 AS ratio, + IF(vDepartment = 'Revisadores', NULL, volume) AS volume, + sub1.hourStart AS hourStart, + sub1.hourEnd AS hourEnd, + sub1.hourWorked AS hourWorked, + vDatedFrom AS date + FROM( + SELECT w.id, w.code, w.firstName, w.lastName, t.ticketCount AS totalTickets, sub.errors, sub2.volume, SUBSTRING(tc.timed, 1, 5) AS hourStart, SUBSTRING(tc.timed, LENGTH(tc.timed)-4, 5) AS hourEnd, IFNULL(CAST(tc.timeWorkDecimal AS DECIMAL (10,2)) , 0) AS hourWorked + FROM tmp.total AS t + JOIN worker w ON w.id = t.workerFk + JOIN tmp.timeControlCalculate tc ON tc.userFk = t.workerFk + LEFT JOIN ( + SELECT COUNT(c.ticketFk) AS errors, cd.workerFk + FROM claimDevelopment cd + JOIN claim c ON cd.claimFk = c.id + JOIN ticket t ON c.ticketFk = t.id + JOIN claimResponsible cr ON cd.claimResponsibleFk = cr.id + WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo AND cr.description = vDepartment + GROUP BY cd.workerFk + )sub ON t.workerFk = sub.workerFk + LEFT JOIN ( -- Añadir volume + SELECT SUM(w.volume) AS volume, w.workerFk + FROM bs.workerProductivity w + INNER JOIN vn.`role` r ON r.id=w.roleFk + WHERE IF(vDepartment = 'Encajadores', r.name='packager', r.name='itemPicker') AND w.dated BETWEEN vDatedFrom AND vDatedTo + GROUP BY w.workerFk) sub2 ON w.id = sub2.workerFk + GROUP BY w.code) sub1 + LEFT JOIN( + SELECT sub1.workerFk, COUNT(id) AS errors + FROM ( + SELECT st.workerFk, t.id + FROM vn.saleMistake sm + JOIN vn.saleTracking st ON sm.saleFk = st.saleFk + JOIN state ss ON ss.id = st.stateFk + JOIN vncontrol.accion a ON a.accion_id = st.actionFk + JOIN vn.sale s ON s.id = sm.saleFk + JOIN vn.ticket t on t.id = s.ticketFk + WHERE (t.shipped BETWEEN vDatedFrom AND vDatedTo) AND a.accion = vAction AND ss.code = vStateCode + GROUP BY s.ticketFk + ) sub1 + GROUP BY sub1.workerFk) sub2 ON sub2.workerFk = sub1.id; + + DROP TEMPORARY TABLE tmp.timeControlCalculate; + DROP TEMPORARY TABLE tmp.total; +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 `errorProduction_addLauncher` */; +/*!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 `errorProduction_addLauncher`() +BEGIN + DECLARE vDatedFrom DATETIME; + DECLARE vDatedTo DATETIME; + + SELECT DATE_SUB(CURDATE(),INTERVAL 1 DAY), CONCAT(DATE_SUB(CURDATE(),INTERVAL 1 DAY),' 23:59:59') INTO vDatedFrom, vDatedTo; + + CALL vn.errorProduction_add('SACAR' ,'Sacadores','PREPARED', vDatedFrom, vDatedTo); + CALL vn.errorProduction_add('ENCAJAR' ,'Encajadores','PACKED', vDatedFrom, vDatedTo); + CALL vn.errorProduction_add('CONTROLAR' ,'Revisadores','CHECKED', vDatedFrom, vDatedTo); +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 `errorProduction_addLauncher__` */; +/*!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 `errorProduction_addLauncher__`() +BEGIN + DECLARE vDatedFrom DATETIME; + DECLARE vDatedTo DATETIME; + + IF (DAY(CURDATE()) = 5) THEN + SELECT util.firstDayOfMonth(DATE_SUB(CURDATE(),INTERVAL 1 MONTH)), CONCAT(LAST_DAY(DATE_SUB(CURDATE(),INTERVAL 1 MONTH)),' 23:59:59') INTO vDatedFrom, vDatedTo; + + CALL vn.errorProduction_add('SACAR' ,'Sacadores','PREPARED', vDatedFrom, vDatedTo); + CALL vn.errorProduction_add('ENCAJAR' ,'Encajadores','PACKED', vDatedFrom, vDatedTo); + CALL vn.errorProduction_add('CONTROLAR' ,'Revisadores','CHECKED', vDatedFrom, vDatedTo); + 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 `errorProduction_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 = 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 `errorProduction_add__`(vAction VARCHAR(25), vDepartment VARCHAR(25), vStateCode VARCHAR(25) CHARSET utf8, vDatedFrom DATETIME, vDatedTo DATETIME) +BEGIN + /** + * Fill in the errorProduction table. + */ + DROP TEMPORARY TABLE IF EXISTS tmp.total; + + IF (vDepartment = 'Encajadores') + THEN + CREATE TEMPORARY TABLE tmp.total + ENGINE = MEMORY + SELECT e.workerFk, Count(DISTINCT t.id) AS ticketCount + FROM expedition e + JOIN ticket t ON e.ticketFk = t.id + WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo + GROUP BY e.workerFk; + ELSE + CREATE TEMPORARY TABLE tmp.total + ENGINE = MEMORY + SELECT st.workerFk, Count(DISTINCT t.id) AS ticketCount + FROM state ss + JOIN vn.saleTracking st ON st.stateFk = ss.id + JOIN vn.sale s ON s.id = st.saleFk + JOIN ticket t ON s.ticketFk = t.id + WHERE (t.shipped BETWEEN vDatedFrom AND vDatedTo) AND ss.code = vStateCode + GROUP BY st.workerFk; + END IF; + + + INSERT INTO errorProduction(userFk, firstname, lastname, rol, ticketNumber, error, ratio, volume, month, year) + SELECT sub1.id, sub1.firstName, sub1.lastName, + CASE + WHEN vDepartment = 'Encajadores' THEN 'Encajador' + WHEN vDepartment = 'Sacadores' THEN 'Sacador' + ELSE 'Revisador' + END AS rol, + CAST(sub1.totalTickets AS DECIMAL(10,0)) AS totalTickets, + CAST(IFNULL(sub1.errors,0) + IFNULL(sub2.errors,0) AS DECIMAL(10,0)) AS errors, + ((IFNULL(sub1.errors,0) + IFNULL(sub2.errors,0))/sub1.totalTickets)*100 AS ratio, + IF(vDepartment = 'Revisadores', NULL, volume) AS volume, + MONTH(vDatedFrom) AS month, + YEAR(vDatedFrom) AS year + FROM( + SELECT w.id, w.code, w.firstName, w.lastName, t.ticketCount AS totalTickets, sub.errors, sub2.volume + FROM tmp.total AS t + JOIN worker w ON w.id = t.workerFk + LEFT JOIN ( + SELECT COUNT(c.ticketFk) AS errors, cd.workerFk + FROM claimDevelopment cd + JOIN claim c ON cd.claimFk = c.id + JOIN ticket t ON c.ticketFk = t.id + JOIN claimResponsible cr ON cd.claimResponsibleFk = cr.id + WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo AND cr.description = vDepartment + GROUP BY cd.workerFk + )sub ON t.workerFk = sub.workerFk + LEFT JOIN ( -- Añadir volume + SELECT SUM(w.volume) AS volume, w.workerFk + FROM bs.workerProductivity w + INNER JOIN vn.`role` r ON r.id=w.roleFk + WHERE IF(vDepartment = 'Encajadores', r.name='packager', r.name='itemPicker') AND w.dated BETWEEN vDatedFrom AND vDatedTo + GROUP BY w.workerFk) sub2 ON w.id = sub2.workerFk + GROUP BY w.code) sub1 + LEFT JOIN( + SELECT sub1.workerFk, COUNT(id) AS errors + FROM ( + SELECT st.workerFk, t.id + FROM vn.saleMistake sm + JOIN vn.saleTracking st ON sm.saleFk = st.saleFk + JOIN state ss ON ss.id = st.stateFk + JOIN vncontrol.accion a ON a.accion_id = st.actionFk + JOIN vn.sale s ON s.id = sm.saleFk + JOIN vn.ticket t on t.id = s.ticketFk + WHERE (t.shipped BETWEEN vDatedFrom AND vDatedTo) AND a.accion = vAction AND ss.code = vStateCode + GROUP BY s.ticketFk + ) sub1 + GROUP BY sub1.workerFk) sub2 ON sub2.workerFk = sub1.id; + + DROP TEMPORARY TABLE tmp.total; +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 `expeditionGetFromRoute` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -56199,6 +56844,93 @@ BEGIN LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk WHERE e.id = vExpeditionFk; +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 `expedition_StateGet` */; +/*!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 `expedition_StateGet`(vExpeditionFk INT) +BEGIN + + /* Devuelve una "ficha" con todos los datos relativos a la expedición + * + * param vExpeditionFk + */ + + DECLARE vTicketsPendientes INT; + DECLARE vEtiquetasTotales INT; + DECLARE vEtiquetasEscaneadas INT; + DECLARE vEtiquetasLeidasSorter INT; + DECLARE vRouteFk INT; + + SELECT t.routeFk INTO vRouteFk + FROM vn.ticket t + JOIN vn.expedition e ON e.ticketFk = t.id + WHERE e.id = vExpeditionFk; + + SELECT COUNT(*) INTO vTicketsPendientes + FROM vn.ticket t + LEFT JOIN vn.expedition e ON e.ticketFk = t.id + WHERE t.routeFk = vRouteFk + AND ISNULL(e.id); + + SELECT COUNT(*) INTO vEtiquetasTotales + FROM vn.expedition e + JOIN vn.ticket t ON t.id = e.ticketFk + WHERE t.routeFk = vRouteFk; + + SELECT COUNT(*) INTO vEtiquetasEscaneadas + FROM vn.expeditionScan es + JOIN vn.expedition e ON e.id = es.expeditionFk + JOIN vn.ticket t ON t.id = e.ticketFk + WHERE t.routeFk = vRouteFk; + + SELECT COUNT(*) INTO vEtiquetasLeidasSorter + FROM srt.expedition e + JOIN vn.expedition ve ON ve.id = e.id + LEFT JOIN vn.expeditionScan es ON es.expeditionFk = e.id + JOIN vn.ticket t ON t.id = ve.ticketFk + WHERE t.routeFk = vRouteFk + AND e.created != e.updated + AND ISNULL(es.expeditionFk); + + + SELECT e.ticketFk ticket, + t.nickname cliente, + a.city ciudad, + p.name provincia, + z.name zonaTicket, + am.name zonaRuta, + t.routeFk ruta, + rm.beachFk ubicacion, + et.ETD , + et.description camion, + vTicketsPendientes AS ticketsPendientes, + vEtiquetasTotales AS etiquetasTotales, + vEtiquetasEscaneadas AS etiquetasEscaneadas, + vEtiquetasLeidasSorter AS etiquetasSorter + FROM vn.expedition e + JOIN vn.ticket t ON t.id = e.ticketFk + JOIN vn.address a ON a.id = t.addressFk + JOIN vn.province p ON p.id = a.provinceFk + JOIN vn.`zone`z ON z.id = t.zoneFk + LEFT JOIN vn.route r ON r.id = t.routeFk + LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk + LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id + LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk + WHERE e.id = vExpeditionFk; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -56746,23 +57478,24 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `intrastat_data_neto_Update`(IN vinvoiceInFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `intrastat_data_neto_Update`(IN vInvoiceInFk INT) BEGIN -UPDATE vn2008.intrastat_data id - JOIN ( - SELECT i.intrastatFk, - LEAST(sum(b.quantity) * IFNULL(it.gramsMax,100000) / 1000 ,sum(r.cm3 * b.quantity) * IF(i.density, i.density, it.density) / 1000000) as neto - FROM vn.entry e - JOIN vn.travel tr ON tr.id = e.travelFk - JOIN vn.buy b ON b.entryFk = e.id - JOIN vn.item i ON i.id = b.itemFk - join vn.itemType it ON it.id = i.typeFk - JOIN bi.rotacion r ON r.Id_Article = i.id AND tr.warehouseInFk = r.warehouse_id - WHERE e.invoiceInFk = vinvoiceInFk - GROUP BY i.intrastatFk) sub ON sub.intrastatFk = id.intrastat_id - SET id.neto = ROUND(sub.neto,1) - WHERE id.recibida_id = vInvoiceInFk; + UPDATE vn2008.intrastat_data id + JOIN ( + SELECT i.intrastatFk, + LEAST(SUM(b.quantity) * IFNULL(it.gramsMax,100000) / 1000, + SUM(ic.cm3 * b.quantity) * IF(i.density, i.density, it.density) / 1000000) as neto + FROM entry e + JOIN travel tr ON tr.id = e.travelFk + JOIN buy b ON b.entryFk = e.id + JOIN item i ON i.id = b.itemFk + join itemType it ON it.id = i.typeFk + JOIN itemCost ic ON ic.itemFk = i.id AND tr.warehouseInFk = ic.warehouseFk + WHERE e.invoiceInFk = vinvoiceInFk + GROUP BY i.intrastatFk) sub ON sub.intrastatFk = id.intrastat_id + SET id.neto = ROUND(sub.neto, 1) + WHERE id.recibida_id = vInvoiceInFk; END ;; @@ -57616,7 +58349,6 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; ALTER DATABASE `vn` CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci ; /*!50003 DROP PROCEDURE IF EXISTS `invoiceFromClient` */; -ALTER DATABASE `vn` CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -57626,32 +58358,26 @@ ALTER DATABASE `vn` CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `invoiceFromClient`(vMaxTicketDate DATETIME, vClient INT, vCompany INT) -BEGIN - - DECLARE vMinDateTicket DATE DEFAULT TIMESTAMPADD(YEAR, -3, CURDATE()); - - SET vMaxTicketDate = vn2008.DAYEND(vMaxTicketDate); +CREATE DEFINER=`root`@`%` PROCEDURE `invoiceFromClient`(IN vMaxTicketDate datetime, IN vClientFk INT, IN vCompanyFk INT) +BEGIN + DECLARE vMinTicketDate DATE DEFAULT TIMESTAMPADD(YEAR, -3, CURDATE()); + SET vMaxTicketDate = util.dayend(vMaxTicketDate); DROP TEMPORARY TABLE IF EXISTS `ticketToInvoice`; - CREATE TEMPORARY TABLE `ticketToInvoice` (PRIMARY KEY (`id`)) ENGINE = MEMORY - SELECT Id_Ticket id FROM vn2008.Tickets - WHERE Id_Cliente = vClient - AND Factura IS NULL - AND empresa_id = vCompany - AND (Fecha BETWEEN vMinDateTicket AND vMaxTicketDate) - ; - + SELECT id FROM ticket t + WHERE t.clientFk = vClientFk + AND t.refFk IS NULL + AND t.companyFk = vCompanyFk + AND (t.shipped BETWEEN vMinTicketDate AND vMaxTicketDate); 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 */ ; -ALTER DATABASE `vn` CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci ; /*!50003 DROP PROCEDURE IF EXISTS `invoiceFromTicket` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -58555,7 +59281,9 @@ BEGIN amount, foreignValue) SELECT vInvoiceInFk, - IF(payDay, vn2008.next_venc(created, detalle, payDay),TIMESTAMPADD(DAY, GREATEST(detalle, 2), created)), + IF(payDay, + IF(vn2008.next_venc(issued, detalle, payDay) < DATE_ADD(created, INTERVAL 2 DAY), DATE_ADD(created, INTERVAL 2 DAY), vn2008.next_venc(issued, detalle, payDay)), + TIMESTAMPADD(DAY, GREATEST(detalle, 2), created)), IF((@cont:=@cont + 1) < cont, TRUNCATE(venc / cont, 2),venc-(TRUNCATE(venc / cont, 2) * (cont - 1))), IF(@cont < cont, TRUNCATE(foreignValue / cont, 2), foreignValue - (TRUNCATE(foreignValue / cont, 2) * (cont - 1))) FROM ( SELECT SUM((1 + (IFNULL(ti.PorcentajeIva, 0) / 100)*(s.countryFk = s2.countryFk)) * iit.taxableBase)/COUNT(DISTINCT(pdd.detalle)) venc, @@ -58564,6 +59292,7 @@ BEGIN ii.companyFk, COUNT(DISTINCT(pdd.detalle)) cont, s.payDay, + ii.issued, DATE(ii.created) created FROM invoiceIn ii JOIN invoiceInTax iit ON iit.invoiceInFk = ii.id @@ -59170,25 +59899,28 @@ BEGIN LIMIT 1; SELECT IF(enlazado OR enlazadoSage, TRUE, FALSE), - CONCAT(' - - - - - - - ', - GROUP_CONCAT(CONCAT(' - - - - - - - ' - ) SEPARATOR ' ' - ), - '
FECHASUBCTACONTRACONCEPTOEURODEBEEUROHABER
', IFNULL(FECHA,''), '', IFNULL(SUBCTA,''), '', IFNULL(CONTRA,''), '', IFNULL(CONCEPTO,''), '', IFNULL(EURODEBE,''), '', IFNULL(EUROHABER,''), '
') + CONCAT( + ' + + + + + + + ', + GROUP_CONCAT( + CONCAT(' + + + + + + + ' + ) SEPARATOR ' ' + ), + '
FECHASUBCTACONTRACONCEPTOEURODEBEEUROHABER
', IFNULL(FECHA,''), '', IFNULL(SUBCTA,''), '', IFNULL(CONTRA,''), '', IFNULL(CONCEPTO,''), '', IFNULL(EURODEBE,''), '', IFNULL(EUROHABER,''), '
' + ) INTO vSendMail, vBody FROM XDiario WHERE ASIEN = vAsien; @@ -59197,14 +59929,16 @@ BEGIN WHERE ASIEN = vAsien; IF vSendMail THEN - INSERT INTO mail(sender, replyTo, `subject`, body) - SELECT 'administracion@verdnatura.es', - 'noreply@verdnatura.es', - CONCAT('Eliminada factura ' ,vRef), - CONCAT('

-

Se ha eliminado el asiento ', vAsien, ' que estaba enlazado en SAGE/CONTAPLUS, vinculado a la factura ', vRef ,'

- ', vBody, ' -
'); + CALL mail_insert( + 'administracion@verdnatura.es', + 'noreply@verdnatura.es', + CONCAT('Eliminada factura ' ,vRef), + CONCAT( + '
+

Se ha eliminado el asiento ', vAsien, ' que estaba enlazado en SAGE/CONTAPLUS, vinculado a la factura ', vRef ,'

+ ', vBody, '
' + ) + ); END IF; UPDATE ticket @@ -59624,13 +60358,15 @@ 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 `invoiceOut_newFromClient`(vClientFk INT, vSerial CHAR(2), vMaxShipped DATE, vCompanyFk INT, vTaxArea VARCHAR(25), vRef VARCHAR(25), OUT vInvoiceId INT) +CREATE DEFINER=`root`@`%` PROCEDURE `invoiceOut_newFromClient`(IN vClientFk int, IN vSerial char(2), IN vMaxShipped date, + IN vCompanyFk int, IN vTaxArea varchar(25), + IN vRef varchar(25), OUT vInvoiceId int) BEGIN /** * Factura los tickets de un cliente hasta una fecha dada @@ -59644,12 +60380,7 @@ BEGIN */ DECLARE vIsRefEditable BOOLEAN; - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; - + IF vRef IS NOT NULL THEN SELECT isRefEditable INTO vIsRefEditable FROM invoiceOutSerial @@ -59660,7 +60391,6 @@ BEGIN END IF; END IF; - START TRANSACTION; CALL invoiceFromClient(vMaxShipped, vClientFk, vCompanyFk); CALL invoiceOut_new(vSerial, CURDATE(), vTaxArea, vInvoiceId); @@ -59670,11 +60400,8 @@ BEGIN AND vRef IS NOT NULL; IF vSerial <> 'R' AND NOT ISNULL(vInvoiceId) AND vInvoiceId <> 0 THEN - CALL invoiceOutBooking(vInvoiceId); - INSERT INTO printServerQueue(priorityFk, labelReportFk, param1) VALUES(1, 3, vInvoiceId); END IF; - COMMIT; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -59716,13 +60443,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 = 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 `invoiceOut_newFromTicket`(vTicketFk INT, vSerial CHAR(2), vTaxArea VARCHAR(25), vRef VARCHAR(25), OUT vInvoiceId INT) +CREATE DEFINER=`root`@`%` PROCEDURE `invoiceOut_newFromTicket`(IN vTicketFk int, IN vSerial char(2), IN vTaxArea varchar(25), + IN vRef varchar(25), OUT vInvoiceId int) BEGIN /** * Factura un ticket @@ -59733,13 +60461,6 @@ BEGIN * @return vInvoiceId */ DECLARE vIsRefEditable BOOLEAN; - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; - - START TRANSACTION; CALL invoiceFromTicket(vTicketFk); CALL invoiceOut_new(vSerial, CURDATE(), vTaxArea, vInvoiceId); @@ -59758,12 +60479,7 @@ BEGIN IF vSerial <> 'R' AND NOT ISNULL(vInvoiceId) AND vInvoiceId <> 0 THEN CALL invoiceOutBooking(vInvoiceId); - IF account.myUser_getId() IS NOT NULL THEN - INSERT INTO printServerQueue(priorityFk, labelReportFk, param1, workerFk) VALUES(1, 3, vInvoiceId, account.myUser_getId()); - END IF; END IF; - - COMMIT; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -60069,7 +60785,97 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `itemCard`(IN `vBarcode` VARCHAR(22), IN `vWarehouseFk` INT, isBarcode BOOL) +CREATE DEFINER=`root`@`%` PROCEDURE `itemCard`(IN `vBarcode` VARCHAR(22), IN `vWarehouseFk` INT, IN isBarcode BOOL) +BEGIN + + DECLARE vCacheVisibleFk INT; + DECLARE vCacheAvailableFk INT; + DECLARE vVisibleAltillo INT; + DECLARE vItemFk INT; + + IF isBarcode THEN + SELECT vn.barcodeToItem(vBarcode) INTO vItemFk; + ELSE + SELECT i.id INTO vItemFk + FROM vn.item i + WHERE i.name LIKE CONCAT('%',vBarcode,'%') + ORDER BY i.id ASC + LIMIT 1; + END IF; + + IF vItemFk IS NULL THEN + SELECT vn.barcodeToItem(vBarcode) INTO vItemFk; + END IF; + + CALL cache.visible_refresh(vCacheVisibleFk, FALSE,vWarehouseFk); + CALL cache.available_refresh(vCacheAvailableFk, FALSE,vWarehouseFk, CURDATE()); + + SELECT SUM(visible) INTO vVisibleAltillo + FROM vn.itemShelvingStock + WHERE itemFk = vItemFk AND warehouseFk = vWarehouseFk; + + CALL vn.buyUltimate(vWarehouseFk, CURDATE()); + + SELECT i.id, + i.longName, + i.tag5, + i.value5, + i.tag6, + i.value6, + i.tag7, + i.value7, + i.image, + i.size, + i.stems, + i.category, + i.minimum as min, + i.upToDown as repo, + p.name as producer, + o.code as origin, + ip.code as nicho, + ip.reserve as reserva, + v.visible - IFNULL(vVisibleAltillo,0) as enNicho, + a.available, + vVisibleAltillo as enAltillo, + v.visible as total, + c.`grouping` as `grouping`, + c.Packing as packing, + CONCAT('https://verdnatura.es/vn-image-data/catalog/200x200/', i.image) as urlImage200, + CONCAT('https://verdnatura.es/vn-image-data/catalog/1600x900/', i.image) as urlImage, + i.itemPackingTypeFk + FROM vn.item i + LEFT JOIN vn.producer p ON p.id = i.producerFk + LEFT JOIN vn.origin o ON o.id = i.originFk + LEFT JOIN vn.itemPlacement ip ON ip.itemFk = i.id + LEFT JOIN cache.visible v ON v.calc_id = vCacheVisibleFk AND v.item_id = i.id + LEFT JOIN cache.available a ON a.calc_id = vCacheAvailableFk AND a.item_id = i.id + LEFT JOIN ( + SELECT b.itemFk, b2.`grouping`, b2.packing + FROM tmp.buyUltimate b + JOIN vn.buy b2 ON b2.id = b.buyFk + WHERE b.warehouseFk = vWarehouseFk + ) c ON i.id = c.itemFk + WHERE i.id = vItemFk; + + DROP TEMPORARY TABLE tmp.buyUltimate; + +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 `itemCard__` */; +/*!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 `itemCard__`(IN `vBarcode` VARCHAR(22), IN `vWarehouseFk` INT, isBarcode BOOL) BEGIN DECLARE vCacheVisibleFk INT; @@ -60294,8 +61100,6 @@ BEGIN SELECT cm3 Volumen_Entrada, cm3delivery Volumen_Salida, - i.compression Compresion_del_Articulo, - it.compression Compresion_del_Tipo, p.volume Volumen_del_embalaje, p.width Ancho_del_embalaje, p.`depth` Largo_del_embalaje, @@ -60309,7 +61113,6 @@ BEGIN w.name warehouseFk FROM vn.itemCost ic JOIN vn.item i ON i.id = ic.itemFk - JOIN vn.itemType it ON it.id = i.typeFk LEFT JOIN cache.last_buy lb ON lb.item_id = ic.itemFk AND lb.warehouse_id = ic.warehouseFk LEFT JOIN vn.buy b ON b.id = lb.buy_id LEFT JOIN vn.packaging p ON p.id = b.packageFk @@ -60335,50 +61138,78 @@ DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `itemFuentesBalance`(vDaysInFuture INT) BEGIN + /* Se utiliza para calcular la necesidad de mover mercancia entre el almacén de fuentes y el nuestro + * + * @param vDaysInFuture Rango de dias para calcular entradas y salidas + * + */ + + DECLARE vWarehouseFk INT; + + SELECT s.warehouseFk INTO vWarehouseFk + FROM vn.sector s + WHERE s.code = 'FUENTES_PICASSE'; + CALL cache.stock_refresh(FALSE); - SELECT alt.itemFk, + SELECT i.id itemFk, i.longName, i.size, i.subName, - v.amount as visible, - alt.reserva, + v.amount - IFNULL(fue.Fuentes,0) - IFNULL(alb.albenfruit,0) as visible, + fue.Fuentes, + alb.Albenfruit, sale.venta, IFNULL(buy.compra,0) + IFNULL(mov.traslado,0) as compra, - IFNULL(v.amount,0) + IFNULL(sale.venta,0) + IFNULL(buy.compra,0) + IFNULL(mov.traslado,0) as saldo + IFNULL(v.amount,0) + IFNULL(sale.venta,0) + IFNULL(buy.compra,0) + IFNULL(mov.traslado,0) + - IFNULL(fue.Fuentes,0) - IFNULL(alb.albenfruit,0) as saldo FROM vn.item i - JOIN ( - SELECT ish.itemFk, CAST(SUM(ish.visible) AS DECIMAL(10,0)) AS reserva + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk + LEFT JOIN ( + SELECT ish.itemFk, CAST(SUM(ish.visible) AS DECIMAL(10,0)) AS Fuentes FROM vn.itemShelving ish JOIN vn.shelving sh ON sh.code = ish.shelvingFk JOIN vn.parking p ON p.id = sh.parkingFk - WHERE p.sectorFk = 37 + JOIN vn.sector s ON s.id = p.sectorFk + WHERE s.code = 'FUENTES_PICASSE' GROUP BY ish.itemFk - ) alt ON alt.itemFk = i.id - LEFT JOIN cache.stock v ON i.id = v.item_id AND v.warehouse_id = 1 + ) fue ON fue.itemFk = i.id + LEFT JOIN ( + SELECT ish.itemFk, CAST(SUM(ish.visible) AS DECIMAL(10,0)) AS Albenfruit + FROM vn.itemShelving ish + JOIN vn.shelving sh ON sh.code = ish.shelvingFk + JOIN vn.parking p ON p.id = sh.parkingFk + JOIN vn.sector s ON s.id = p.sectorFk + WHERE s.code = 'ALBENFRUIT' + GROUP BY ish.itemFk + ) alb ON alb.itemFk = i.id + LEFT JOIN cache.stock v ON i.id = v.item_id AND v.warehouse_id = vWarehouseFk LEFT JOIN ( SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as venta FROM vn2008.item_out WHERE dat BETWEEN CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(curdate())) - AND warehouse_id = 1 + AND warehouse_id = vWarehouseFk GROUP BY item_id - ) sale ON sale.item_id = alt.itemFk + ) sale ON sale.item_id = i.id LEFT JOIN ( SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as compra FROM vn2008.item_entry_in WHERE dat BETWEEN CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(curdate())) - AND warehouse_id = 1 + AND warehouse_id = vWarehouseFk AND isVirtualStock = FALSE GROUP BY item_id - ) buy ON buy.item_id = alt.itemFk + ) buy ON buy.item_id = i.id LEFT JOIN ( SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as traslado FROM vn2008.item_entry_out WHERE dat BETWEEN CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(curdate())) - AND warehouse_id = 1 + AND warehouse_id = vWarehouseFk GROUP BY item_id - ) mov ON mov.item_id = alt.itemFk - + ) mov ON mov.item_id = i.id + WHERE (v.amount OR fue.Fuentes OR alb.Albenfruit) + AND i.itemPackingTypeFk = 'H' + AND ic.shortLife ; END ;; @@ -62449,6 +63280,94 @@ 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 `itemShelving_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 = 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 `itemShelving_add`(IN vShelvingFk VARCHAR(8), IN vBarcode VARCHAR(22), IN vShelve VARCHAR(2), IN vDeep INT, IN vQuantity INT, IN vPackagingFk VARCHAR(10), IN vGrouping INT, IN vPacking INT, IN vWarehouseFk INT, IN vLevel INT) +BEGIN + +/** + * Añade registro o lo actualiza si ya existe. + * + * @param vShelvingFk matrícula del carro + * @param vBarcode el id del registro + * @param vShelve de itemshleving + * @param vDeep indica profundidad + * @param vQuantity indica la cantidad del producto + * @param vPackagingFk el packaging del producto en itemShelving + * @param vGrouping el grouping del producto en itemShelving + * @param vPacking el packing del producto + * @param vWarehouseFk indica el sector + * @param vLevel indica el level + * + **/ + + DECLARE vItemFk INT; + + SELECT barcodeToItem(vBarcode) INTO vItemFk; + + IF (SELECT COUNT(*) FROM shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN + + INSERT IGNORE INTO parking(code) VALUES(vShelvingFk); + INSERT INTO shelving(code, parkingFk) + SELECT vShelvingFk, id + FROM parking + WHERE `code` = vShelvingFk COLLATE utf8_unicode_ci; + + END IF; + + IF (SELECT COUNT(*) FROM itemShelving + WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk + AND itemFk = vItemFk + AND packing = vPacking) = 1 THEN + + UPDATE itemShelving SET quantity = quantity+vQuantity,visible = visible+vQuantity,available = available+vQuantity + WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking; + + ELSE + CALL cache.last_buy_refresh(FALSE); + INSERT INTO itemShelving( itemFk, + shelvingFk, + shelve, + deep, + quantity, + visible, + available, + grouping, + packing, + packagingFk, + level) + + SELECT + vItemFk, + vShelvingFk, + vShelve, + vDeep, + vQuantity, + vQuantity, + vQuantity, + IF(vGrouping = 0, IFNULL(b.packing, vPacking), vGrouping) as `grouping`, + IF(vPacking = 0, b.packing, vPacking) as packing, + IF(vPackagingFk = '', b.packageFk, vPackagingFk) as packaging, + vLevel + FROM item i + LEFT JOIN cache.last_buy lb ON i.id = lb.item_id AND lb.warehouse_id = vWarehouseFk + LEFT JOIN buy b ON b.id = lb.buy_id + WHERE i.id = vItemFk; + 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 `itemShelving_BuyerGet` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -62601,6 +63520,207 @@ proc:BEGIN WHERE nicho ORDER BY producer; +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 `itemShelving_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 `itemShelving_get`(IN vShelvingFk VARCHAR(8)) +BEGIN +/** + * Lista artículos de itemshelving + * + * @param vShelvingFk matrícula del carro + * + **/ + + SELECT ish.itemFk as item, + IFNULL(i.longName, CONCAT(i.name, ' ', i.size)) as description, + ish.visible as visible, + ceil(ish.visible/ish.packing) as stickers, + ish.packing as packing, + ish.grouping, + IF (p.column IS NULL, "", p.column) as col, + IF (p.row IS NULL, "", p.row) as row, + IF (p.code IS NULL, "", p.code) as code, + ish.id, + s.priority + FROM itemShelving ish + JOIN item i ON i.id = ish.itemFk + INNER JOIN shelving s ON vShelvingFk = s.code COLLATE utf8_unicode_ci + LEFT JOIN parking p ON s.parkingFk = p.id + WHERE ish.shelvingFk COLLATE utf8_unicode_ci = vShelvingFk; + +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 `itemShelving_getSaleDate` */; +/*!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 `itemShelving_getSaleDate`(vShelvingFk VARCHAR(3)) +BEGIN + + /* Devuelve la minima fecha en que se necesita cada producto en esa matricula. + * + * @param vShelvingFk Matrícula del carro o pallet + */ + + DECLARE vWarehouseFk INT; + + SELECT warehouseFk INTO vWarehouseFk + FROM shelving s + JOIN parking p ON s.parkingFk = p.id + JOIN sector st ON st.id = p.sectorFk + WHERE s.code = vShelvingFk COLLATE utf8_unicode_ci; + + DROP TEMPORARY TABLE IF EXISTS tmp.itemShelvingDistinct; + CREATE TEMPORARY TABLE tmp.itemShelvingDistinct + (PRIMARY KEY (itemFk)) + ENGINE = MEMORY + SELECT itemFk, SUM(visible) visible + FROM vn.itemShelving + WHERE shelvingFk = vShelvingFk COLLATE utf8_unicode_ci + GROUP BY itemFk; + + DROP TEMPORARY TABLE IF EXISTS tmp.item; + CREATE TEMPORARY TABLE tmp.item + (PRIMARY KEY (itemFk)) + ENGINE = MEMORY + SELECT * FROM tmp.itemShelvingDistinct; + + DROP TEMPORARY TABLE IF EXISTS tmp.stockByDay; + CREATE TEMPORARY TABLE tmp.stockByDay + (index (itemFk, dated)) + ENGINE = MEMORY + SELECT t3.amount, dated, + @stock := IF(@itemFk = t3.itemFk, @stock + t3.amount, t3.amount) stock, + @itemFk := t3.itemFk itemFk + FROM ( + SELECT * FROM ( + SELECT t2.* FROM ( + SELECT item_id itemFk, amount, CURDATE() dated + FROM cache.stock + WHERE warehouse_id = vWarehouseFk + UNION ALL + SELECT ish.itemFk, - sum(visible), CURDATE() + FROM vn.itemShelving ish + JOIN shelving sh ON sh.code = ish.shelvingFk + JOIN parking p ON sh.parkingFk = p.id + JOIN sector s ON s.id = p.sectorFk + WHERE s.isReserve + GROUP BY ish.itemFk + UNION ALL + SELECT item_id, sum(iei.amount), dat + FROM vn2008.item_entry_in iei + WHERE dat >= CURDATE() + AND warehouse_id = vWarehouseFk + AND isVirtualStock = FALSE + GROUP BY item_id, dat + UNION ALL + SELECT item_id, sum(ieo.amount), dat + FROM vn2008.item_entry_out ieo + WHERE dat >= CURDATE() + AND warehouse_id = vWarehouseFk + GROUP BY item_id, dat + UNION ALL + SELECT i.itemFk, sum(io.amount), dat + FROM vn2008.item_out io + JOIN tmp.item i ON i.itemFk = io.item_id + WHERE io.dat >= CURDATE() + AND io.warehouse_id = vWarehouseFk + GROUP BY io.item_id, io.dat + ) t2 + JOIN tmp.itemShelvingDistinct ish ON ish.itemFk = t2.itemFk) t + order by t.itemFk, DATE(t.dated), t.amount DESC) t3; + + SELECT sbd.itemFk, i.longName, DATE(dated) dated, ish.visible amount, sbd.stock + FROM tmp.stockByDay sbd + JOIN vn.item i ON i.id = sbd.itemFk + JOIN tmp.itemShelvingDistinct ish ON ish.itemFk = sbd.itemFk + WHERE ish.visible >= sbd.stock + GROUP BY itemFk + ORDER BY dated; + + DROP TEMPORARY TABLE tmp.stockByDay, + tmp.itemShelvingDistinct, + tmp.item; +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 `itemShelving_inventory` */; +/*!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 `itemShelving_inventory`(vParkingFromFk INT, vParkingToFk INT) +BEGIN + + /* Devuelve un listado de ubicaciones a revisar + * + * @param vParkingFromFk Parking de partida, identificador de vn.parking + * @param vParkingToFk Parking de llegada, identificador de vn.parking + */ + + DECLARE vSectorFk INT; + DECLARE vPickingOrderFrom INT; + DECLARE vPickingOrderTo INT; + + SELECT p.sectorFk, p.pickingOrder INTO vSectorFk, vPickingOrderFrom + FROM vn.parking p + WHERE p.id = vParkingFromFk; + + SELECT p.pickingOrder INTO vPickingOrderTo + FROM vn.parking p + WHERE p.id = vParkingToFk; + + CALL vn.visible_getMisfit(vSectorFk); + + SELECT p.code parking , + ish.shelvingFk , + ish.itemFk, + i.longName, + ish.visible , + ish.visible / ish.packing packs, + ish.packing, + sm.visible - sm.parked faltan + FROM vn.itemShelving ish + JOIN vn.item i ON i.id = ish.itemFk + JOIN tmp.stockMisfit sm ON sm.itemFk = ish.itemFk + JOIN vn.shelving sh ON sh.code = ish.shelvingFk + JOIN vn.parking p ON p.id = sh.parkingFk + WHERE p.pickingOrder BETWEEN vPickingOrderFrom AND vPickingOrderTo + AND p.sectorFk = vSectorFk + ORDER BY p.pickingOrder ; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -62624,6 +63744,39 @@ BEGIN SET stars = vStars WHERE id = vId; +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 `itemShelving_update` */; +/*!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 `itemShelving_update`(vVisible INT, vPacking INT, vShelf INT ,vGrouping INT ) +BEGIN +/** + * Actualiza itemShelving. + * + * @param vVisible la cantidad visible del registro a actualizar + * @param vShelf el id del registro a actualizar + * @param vPacking el packing del del producto en itemShelving + * @param vGrouping el grouping del producto en itemShelving + */ + UPDATE itemShelving SET + available = vVisible, + visible = vVisible, + packing = vPacking, + grouping = vGrouping + WHERE id = vShelf; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -63576,6 +64729,103 @@ BEGIN ORDER BY shipped, alertLevel DESC, isTicket, `order` DESC, isPicked DESC, `in` DESC, `out` DESC ) AS itemDiary; +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_getSimilar` */; +/*!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 `item_getSimilar`(vItemFk INT, vWarehouseFk INT, vDate DATE, vIsShowedByType BOOL) +BEGIN + +/** + * Propone articulos similares para posible cambio, + * ordenado con la cantidad de veces usado y segun sus caracteristicas + * + * @param vItemFk item id + * @param vWarehouseFk warehouse id + * @param vDate fecha para revisar disponible + * @param vIsShowedByType para mostrar solo artículos de ese tipo + */ + + DECLARE vCalcFk INT; + DECLARE vTypeFk INT; + + DECLARE vTag1 VARCHAR(25) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci'; + DECLARE vTag5 VARCHAR(25) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci'; + DECLARE vTag6 VARCHAR(25) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci'; + DECLARE vTag7 VARCHAR(25) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci'; + DECLARE vTag8 VARCHAR(25) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci'; + + DECLARE vValue1 VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci'; + DECLARE vValue5 VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci'; + DECLARE vValue6 VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci'; + DECLARE vValue7 VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci'; + DECLARE vValue8 VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci'; + + + SELECT typeFk, tag5, value5, tag6, value6, tag7, value7, tag8, value8, t1.name, it1.value + INTO vTypeFk, vTag5, vValue5, vTag6, vValue6, vTag7, vValue7, vTag8, vValue8, vTag1, vValue1 + FROM vn.item i + LEFT JOIN vn.itemTag it1 ON it1.itemFk = i.id AND it1.priority = 1 + LEFT JOIN vn.tag t1 ON t1.id = it1.tagFk + WHERE i.id = vItemFk; + + CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vDate); + + SELECT i.id itemFk, + i.longName, + i.subName, + i.tag5, + i.value5, + (i.value5 <=> vValue5) match5, + i.tag6, + i.value6, + (i.value6 <=> vValue6) match6, + i.tag7, + i.value7, + (i.value7 <=> vValue7) match7, + i.tag8, + i.value8, + (i.value8 <=> vValue8) match8, + a.available, + IFNULL(ip.counter,0) counter, + IF(b.groupingMode = 1, b.grouping, b.packing) as minQuantity + FROM vn.item i + JOIN cache.available a ON a.item_id = i.id + LEFT JOIN vn.itemProposal ip ON ip.mateFk = i.id AND ip.itemFk = vItemFk + LEFT JOIN vn.itemTag it1 ON it1.itemFk = i.id AND it1.priority = 1 + LEFT JOIN vn.tag t1 ON t1.id = it1.tagFk + LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = vWarehouseFk + LEFT JOIN vn.buy b ON b.id = lb.buy_id + WHERE a.calc_id = vCalcFk + AND available > 0 + AND IF(vIsShowedByType, i.typeFk = vTypeFk, TRUE) + AND i.id != vItemFk + ORDER BY counter DESC, + (t1.name = vTag1) DESC, + (it1.value = vValue1) DESC, + (i.tag6 = vTag6) DESC, + (i.value6 = vValue6) DESC, + (i.tag5 = vTag5) DESC, + (i.value5 = vValue5) DESC, + (i.tag7 = vTag7) DESC, + (i.value7 = vValue7) DESC, + (i.tag8 = vTag8) DESC, + (i.value8 = vValue8) DESC + LIMIT 30; + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -64132,7 +65382,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 `item_setCompression` */; +/*!50003 DROP PROCEDURE IF EXISTS `item_setCompression__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -64142,7 +65392,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `item_setCompression`() +CREATE DEFINER=`root`@`%` PROCEDURE `item_setCompression__`() BEGIN /** * Actualiza la compression de los articulos con un packing.hasCompressionVariations = TRUE @@ -64612,70 +65862,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 `kk` */; -/*!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 `kk`(vCIF VARCHAR(9)) -BEGIN - - DECLARE vLetraInicial VARCHAR(1); - DECLARE vLetraFinal VARCHAR(1); - DECLARE vParteNumerica VARCHAR(7); - DECLARE vSuma INT DEFAULT 0; - DECLARE vNumero INT DEFAULT 0; - DECLARE i INT DEFAULT 0; - DECLARE vResult BOOL DEFAULT FALSE; - - SET vLetraInicial = SUBSTR(vCIF, 1, 1); - SET vLetraFinal = SUBSTR(vCIF, 9, 1); - SET vParteNumerica = SUBSTR(vCIF, 2, 7); - - WHILE i < 7 DO - - SET i = i + 1; - - SET vNumero = CAST(SUBSTR(vParteNumerica, i, 1) AS DECIMAL(1,0)); - - IF i MOD 2 THEN - - SET vNumero = vNumero * 2; - SET vNumero = vNumero MOD 10 + FLOOR(vNumero/10); - - END IF; - - SET vSuma = vSuma + vNumero; - - END WHILE; - - SET vSuma = vSuma MOD 10; - - IF vSuma > 0 THEN - - SET vSuma = 10 - vSuma; - - END IF; - - - -- Comprobación de dígito de control numérico - IF CAST(vLetraFinal AS DECIMAL(1,0)) = vSuma THEN - - SET vResult = TRUE; - - 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 `ledger_doCompensation` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -65038,7 +66224,7 @@ CREATE DEFINER=`root`@`%` PROCEDURE `machineWorker_update`(vPlate VARCHAR(10), v BEGIN /** - * Actualiza el registro correspondiente si el vWorkerFk ha registrado en las últimas 12 horas con vPlate, + * Actualiza el registro correspondiente si el vWorkerFk se ha registrado en las últimas horas (campo maxHours de machineWorkerConfig) con vPlate, * * @param vPlate número de matrícula * @param vWorkerFk id del trabajador @@ -65046,20 +66232,24 @@ BEGIN */ DECLARE vMachineFk INT(10); + DECLARE vMaxHours INT(10); SELECT m.id INTO vMachineFk FROM machine m WHERE m.plate = vPlate; + + SELECT maxHours INTO vMaxHours + FROM machineWorkerConfig; IF (SELECT COUNT(*) FROM machineWorker m WHERE m.workerFk = vWorkerFk - AND m.inTimed >= TIMESTAMPADD(HOUR , -12,NOW()) AND ISNULL(m.outTimed)) THEN + AND m.inTimed >= TIMESTAMPADD(HOUR , -vMaxHours, NOW()) AND ISNULL(m.outTimed)) THEN UPDATE machineWorker m SET m.outTimed = CURRENT_TIMESTAMP() WHERE m.workerFk = vWorkerFk - AND m.inTimed >= TIMESTAMPADD(HOUR , -12,NOW()) + AND m.inTimed >= TIMESTAMPADD(HOUR , -vMaxHours, NOW()) AND ISNULL(m.outTimed) AND m.machineFk = vMachineFk; @@ -65108,38 +66298,46 @@ 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 `mail_insert`( - vSender VARCHAR(50), - vReplyTo VARCHAR(50), - vSubject VARCHAR(50), - vBody VARCHAR(255)) + vReceiver VARCHAR(255), + vReplyTo VARCHAR(50), + vSubject VARCHAR(100), + vBody TEXT) BEGIN - - DECLARE vIsRepeated BOOLEAN; - - SELECT COUNT(*) INTO vIsRepeated +/** + * Inserta en la tabla vn.mail + * + * @param vReceiver Receptor del correo + * @param vReplyTo A quién contestar el correo + * @param vSubject Título del correo + * @param vBody Cuerpo del correo + */ + + DECLARE vIsRepeated BOOLEAN; + + SELECT COUNT(*) INTO vIsRepeated FROM vn.mail WHERE creationDate >= CURDATE() - AND sender = vSender + AND `receiver` = vReceiver AND `replyTo` = vReplyTo AND `subject` = vSubject; - + IF NOT vIsRepeated THEN - - INSERT INTO vn.mail SET - `sender` = vSender, + + INSERT INTO vn.mail SET + `receiver` = vReceiver, `replyTo` = vReplyTo, `subject` = vSubject, `body` = vBody; - + END IF; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -65451,6 +66649,90 @@ BEGIN DROP TEMPORARY TABLE vn2008.Tickets_to_fusion; 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 `mysqlConnectionsSorter_kill` */; +/*!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 `mysqlConnectionsSorter_kill`() +BEGIN + +/** + * Elimina conexiones del usuario sorter con tiempo >= 30seg. Asociado al evento con el mismo nombre + */ + + DECLARE vDone INT DEFAULT 0; + DECLARE vProcesId INT; + + DECLARE vCursor CURSOR FOR + SELECT p.id + FROM information_schema.processlist p + WHERE USER = 'sorter' + AND TIME >= 30; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + OPEN vCursor; + + l: LOOP + + FETCH vCursor INTO vProcesId; + + IF vDone THEN + LEAVE l; + END IF; + + KILL vProcesId; + + END LOOP; + + CLOSE vCursor; + +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 `mysqlPreparedCount_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 `mysqlPreparedCount_check`() +BEGIN + DECLARE vPreparedCount INTEGER; + + SELECT VARIABLE_VALUE INTO vPreparedCount + FROM INFORMATION_SCHEMA.GLOBAL_STATUS + WHERE VARIABLE_NAME LIKE '%prepared_stmt_count%'; + + IF(vPreparedCount >= 40000) THEN + CALL `vn`.`mail_insert`('cau@verdnatura.es', + NULL, + 'Problemas BBDD prepared_stmt_count', + CONCAT('Existen problemas con el servicio de Logiflora, prepared_stmt_count con valor: ', + vPreparedCount, + ', está próximo a exceder su límite. \r\n Hay que reiniciar el servicio LF.VMP.Service del servidor a3.') + ); + END IF; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -65697,9 +66979,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 ;; @@ -65727,6 +67009,7 @@ BEGIN PREPARE stmt FROM @qryLog; EXECUTE stmt; + DEALLOCATE PREPARE stmt; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -66355,7 +67638,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 `payRoll` */; +/*!50003 DROP PROCEDURE IF EXISTS `payRoll__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -66365,7 +67648,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `payRoll`(IN vFromDated DATE, IN vToDated DATE, IN vFromPaid DATE, IN vToPaid DATE, IN vPartTime BOOL) +CREATE DEFINER=`root`@`%` PROCEDURE `payRoll__`(IN vFromDated DATE, IN vToDated DATE, IN vFromPaid DATE, IN vToPaid DATE, IN vPartTime BOOL) BEGIN SET @userFk := 0; @@ -66430,7 +67713,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 `payRoll__` */; +/*!50003 DROP PROCEDURE IF EXISTS `placement_test` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -66440,65 +67723,181 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `payRoll__`(IN vFromDated DATE, IN vToDated DATE, IN vFromPaid DATE, IN vToPaid DATE, IN vPartTime BOOL) +CREATE DEFINER=`root`@`%` PROCEDURE `placement_test`(vParamFk INT(11)) BEGIN - SET @userFk := 0; + DECLARE vCalcFk INT; + DECLARE vWarehouseFk INT; + DECLARE vWarehouseAliasFk INT; + DECLARE vCurrentYear INT DEFAULT YEAR(NOW()); - SELECT CONCAT(w.lastName,', ',w.firstname) AS Trabajador, - CAST(Sum((wj.total + wj.permission + wj.lunch)* wj.priceOrdinaryHour + wj.hollyday * wj.priceHollydayHour - + wj.nocturn * wj.priceNocturnHour - + wj.extra * wj.priceExtraHour) AS DECIMAL(10,2)) AS salario, - CAST(Sum(wj.permission) AS DECIMAL(10,2)) AS permission, - CAST(Sum(wj.total) AS DECIMAL(10,2)) AS total, - CAST(Sum(wj.nocturn) AS DECIMAL(10,2)) AS nocturn, - CAST(Sum(wj.hollyday) AS DECIMAL(10,2)) AS hollyday, - CAST(Sum(wj.lunch) AS DECIMAL(10,2)) AS lunch, - CAST(Sum(wj.extra) AS DECIMAL(10,2)) AS extra, - CAST(Sum(wj.contractJourney) AS DECIMAL(10,2)) AS contractJourney, - d.name AS departamento, - CAST(Sum((wj.contractJourney + wj.permission) * wj.priceOrdinaryHour) AS DECIMAL(10,2)) AS teorico, - CAST(Sum((wj.lunch + wj.permission + wj.total) * wj.priceordinaryhour) AS DECIMAL(10,2)) AS practico, - CAST(Sum(wj.nocturn * wj.pricenocturnhour) AS DECIMAL(10,2)) AS nocturno, - CAST(Sum(wj.hollyday * wj.priceHollydayHour) AS DECIMAL(10,2)) AS festivos, - CAST(Sum(wj.extra * wj.priceextrahour) AS DECIMAL(10,2)) AS extras, - MAX(wj.businessFk) as businessFk, - Min(b.date_start) AS fromDated, - Max(b.date_end) AS toDated, - blp.importepactado, - bl.porhoras, - IF(wj.userFk != @userFk, CAST(IFNULL(a.Anticipos,0) AS DECIMAL(10,2)), 0) AS Anticipos, - IF(wj.userFk != @userFk, CAST(IFNULL(se.SaldoEuros,0) AS DECIMAL(10,2)), 0) AS SaldoEuros, - @userFk := wj.userFk as userFk - - FROM vn.worker w - JOIN vn.workerJourney wj ON w.userFk = wj.userFk - JOIN postgresql.business_labour bl ON bl.business_id = wj.businessFk - JOIN postgresql.calendar_labour_type cl ON cl.calendar_labour_type_id = bl.calendar_labour_type_id - JOIN vn.department d ON bl.department_id = d.id - JOIN postgresql.business_labour_payroll blp ON bl.business_id = blp.business_id - JOIN postgresql.business b ON b.business_id = wj.businessFk - LEFT JOIN - (SELECT userFk, sum(debe) as Anticipos - FROM postgresql.income_employee ie - JOIN postgresql.person pe ON ie.person_id = pe.person_id - JOIN vn.worker w ON w.id = pe.id_trabajador - WHERE odbc_date BETWEEN vFromPaid AND vToPaid - AND id_incomeType = 14 -- Salario - GROUP BY userFk - ) a ON a.userFk = wj.userFk - LEFT JOIN - (SELECT userFk, sum(debe) - sum(haber) as SaldoEuros - FROM postgresql.income_employee ie - JOIN postgresql.person pe ON ie.person_id = pe.person_id - JOIN vn.worker w ON w.id = pe.id_trabajador - GROUP BY userFk - ) se ON se.userFk = wj.userFk - WHERE wj.dated BETWEEN vFromDated AND vToDated - AND IF(vPartTime,cl.hours_week <= 40,cl.hours_week = 40) - GROUP BY wj.userFk - ORDER BY w.lastName, w.firstname; + DROP TEMPORARY TABLE IF EXISTS tmp.sale; + CREATE TEMPORARY TABLE tmp.sale + ENGINE = MEMORY + SELECT 0000000 as ticketFk, + 0000000 as saleFk, + 0000000 as itemFk, + FALSE as isStowaway, + 0 as quantity; + + INSERT INTO tmp.sale(ticketFk, saleFk, itemFk, isStowaway) + SELECT s.ticketFk, s.id, s.itemFk, FALSE + FROM vn.ticketCollection tc + JOIN vn.collection c ON c.id = tc.collectionFk + JOIN vn.sale s ON s.ticketFk = tc.ticketFk + JOIN vn.item i ON i.id = s.itemFk + WHERE tc.collectionFk = vParamFk + AND (i.itemPackingTypeFk = c.itemPackingTypeFk OR ISNULL(c.itemPackingTypeFk)) + UNION ALL + SELECT s.ticketFk, s.id, s.itemFk, FALSE + FROM vn.sale s + WHERE s.ticketFk = vParamFk; + + + /* UNION ALL + SELECT sw.shipFk, s.id, s.itemFk, TRUE + FROM vn.sale s + JOIN vn.stowaway sw ON sw.id = s.ticketFk + JOIN vn.ticketCollection tc ON tc.ticketFk = sw.shipFk + WHERE tc.collectionFk = vParamFk; + + INSERT INTO tmp.sale(ticketFk, saleFk, itemFk, isStowaway) + SELECT s.ticketFk, s.id, s.itemFk, FALSE + FROM vn.sale s + JOIN vn.ticket t ON t.id = s.ticketFk + WHERE s.ticketFk = vParamFk + AND t.shipped > '2020-01-01' + UNION ALL + SELECT sw.shipFk, s.id, s.itemFk, TRUE + FROM vn.sale s + JOIN vn.stowaway sw ON sw.id = s.ticketFk + WHERE sw.shipFk = vParamFk; + + DELETE FROM tmp.sale + WHERE saleFk = 0; + */ + SELECT t.warehouseFk, w.aliasFk + INTO vWarehouseFk, vWarehouseAliasFk + FROM vn.ticket t + JOIN tmp.sale ts ON ts.ticketFk = t.id + JOIN vn.warehouse w ON w.id = t.warehouseFk + LIMIT 1; + + CALL cache.visible_refresh(vCalcFk,FALSE,vWarehouseFk); + + UPDATE tmp.sale ts + 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 = ts.itemFk + SET ts.quantity = iss.visible; + + DROP TEMPORARY TABLE IF EXISTS tmp.sale2; + CREATE TEMPORARY TABLE tmp.sale2 + ENGINE = MEMORY + SELECT * FROM tmp.sale; + + + DROP TEMPORARY TABLE IF EXISTS tmp.`grouping`; + CREATE TEMPORARY TABLE tmp.`grouping` + (PRIMARY KEY (itemFk)) + ENGINE = MEMORY + SELECT b.itemFk, + CASE b.groupingMode + WHEN 0 THEN 1 + WHEN 2 THEN b.packing + ELSE b.`grouping` + END AS `grouping` + FROM buy b + JOIN cache.last_buy lb ON lb.buy_id = b.id + WHERE lb.warehouse_id = vWarehouseFk + ; + + DROP TEMPORARY TABLE IF EXISTS tmp.grouping2; + CREATE TEMPORARY TABLE tmp.grouping2 + ENGINE = MEMORY + SELECT * FROM tmp.`grouping`; + + DROP TEMPORARY TABLE IF EXISTS tmp.salePlacementList; + CREATE TEMPORARY TABLE tmp.salePlacementList + ENGINE = MEMORY + + SELECT ts.saleFk, + ts.itemFk, + CONCAT( + IF( iss.id, + CONCAT('< ', IFNULL(wk.`code`, '---'),' > '), + ''), + p.`code`) COLLATE utf8_general_ci as placement , + sh.code COLLATE utf8_general_ci as shelving, + ish.created, + ish.visible, + IF(ts.isStowaway, - 100000, IF(ish.visible > 0 OR iss.id, 1, 100000)) * p.pickingOrder as `order`, + IFNULL(IF(sc.isPreviousPreparedByPacking, ish.packing, g.`grouping`),1) as `grouping`, + IF(iss.id, TO_SECONDS(TIMESTAMPADD(YEAR,-vCurrentYear,iss.created)), TO_SECONDS(TIMESTAMPADD(YEAR,- year(ish.created),ish.created)) + TO_SECONDS(TIMESTAMPADD(YEAR,-vCurrentYear,NOW()))) as priority, + 0 as saleOrder, + sc.isPreviousPrepared, + iss.id as itemShelvingSaleFk, + ts.ticketFk + ,iss.id + , st.saleFk as salePreviousPrepared + , iss.userFk + FROM tmp.sale ts + LEFT JOIN (SELECT DISTINCT saleFk + FROM vn.saleTracking st + JOIN vn.state s ON s.id = st.stateFk + WHERE st.isChecked + AND s.semaphore = 1) st ON st.saleFk = ts.saleFk + JOIN vn.itemShelving ish ON ish.itemFk = ts.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 + LEFT JOIN tmp.`grouping` g ON g.itemFk = ts.itemFk + LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = ts.saleFk AND iss.itemShelvingFk = ish.id + LEFT JOIN vn.worker wk ON wk.id = iss.userFk + WHERE w.aliasFk = vWarehouseAliasFk + HAVING (iss.id AND st.saleFk) OR salePreviousPrepared IS NULL + ; + DROP TEMPORARY TABLE IF EXISTS tmp.salePlacementList_2; + CREATE TEMPORARY TABLE tmp.salePlacementList_2 + ENGINE MEMORY + SELECT saleFk, priority as olderPriority + FROM (SELECT saleFk, priority + FROM tmp.salePlacementList + ORDER BY IF(isPreviousPrepared,2,1), IF(visible > 0 OR itemShelvingSaleFk,1,2), priority + ) sub + GROUP BY saleFk; + + DROP TEMPORARY TABLE IF EXISTS tmp.salePlacementList_3; + CREATE TEMPORARY TABLE tmp.salePlacementList_3 + ENGINE MEMORY + SELECT s1.saleFk, `order`as saleOrder + FROM tmp.salePlacementList s1 + JOIN tmp.salePlacementList_2 s2 ON s2.saleFk = s1.saleFk AND s2.olderPriority = s1.priority; + + UPDATE tmp.salePlacementList s1 + JOIN tmp.salePlacementList_3 s3 ON s3.saleFk = s1.saleFk + SET s1.saleOrder = s3.saleOrder; + /* + -- Anula el orden de antigüedad y ordena por ubicación */ + UPDATE tmp.salePlacementList + SET saleOrder = `order`; + + SELECT * + FROM tmp.salePlacementList + ORDER BY visible <> 0 DESC,saleOrder, IF(isPreviousPrepared,2,1), IF(itemShelvingSaleFk,1,2),priority; + + DROP TEMPORARY TABLE + tmp.sale, + tmp.sale2, + tmp.`grouping`, + tmp.grouping2, + tmp.salePlacementList_2, + tmp.salePlacementList_3; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -66898,9 +68297,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 ;; @@ -66911,6 +68310,8 @@ proc: BEGIN DECLARE vIsTodayRelative BOOLEAN; + CALL util.debugAdd('vn.productionControl',CONCAT('warehouse: ',vWarehouseFk,' scopeDays:',vScopeDays)); + SELECT isTodayRelative INTO vIsTodayRelative FROM vn.worker WHERE userFk = vn.getUser(); @@ -68125,7 +69526,7 @@ BEGIN LEFT JOIN vn.ticketTrolley tt ON tt.ticket = t.id LEFT JOIN vn.address a ON a.id = t.addressFk LEFT JOIN vn.route r on r.id = t.routeFk - LEFT JOIN vn.zone_ETD ze ON ze.zoneFk = t.zoneFk + LEFT JOIN vn.zoneEstimatedDelivery ze ON ze.zoneFk = t.zoneFk LEFT JOIN vn.agencyMode agm on r.agencyModeFk =agm.id LEFT JOIN vn.zone zo ON t.zoneFk = zo.id WHERE tc.collectionFk = vCollectionFk @@ -68157,7 +69558,7 @@ BEGIN LEFT JOIN vn.ticketTrolley tt ON tt.ticket = t.id LEFT JOIN vn.address a ON a.id = t.addressFk LEFT JOIN vn.route r on r.id = t.routeFk - LEFT JOIN vn.zone_ETD ze ON ze.zoneFk = t.zoneFk + LEFT JOIN vn.zoneEstimatedDelivery ze ON ze.zoneFk = t.zoneFk LEFT JOIN vn.agencyMode agm on r.agencyModeFk =agm.id LEFT JOIN vn.zone zo ON t.zoneFk = zo.id WHERE tc.collectionFk = vCollectionFk @@ -69846,7 +71247,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8 */ ; /*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `sale_checkNoComponents`(vCreatedFrom DATETIME, vCreatedTo DATETIME) BEGIN @@ -69863,12 +71264,16 @@ BEGIN DECLARE vCur CURSOR FOR SELECT s.id FROM sale s + JOIN ticket t ON t.id = s.ticketFk JOIN item i ON i.id = s.itemFk JOIN itemType tp ON tp.id = i.typeFk JOIN itemCategory ic ON ic.id = tp.categoryFk LEFT JOIN tmp.coste c ON c.id = s.id WHERE s.created >= vCreatedFrom AND s.created <= vCreatedTo AND c.id IS NULL + AND t.agencyModeFk IS NOT NULL + AND t.isDeleted IS FALSE + AND t.warehouseFk = 60 AND ic.merchandise != FALSE GROUP BY s.id; @@ -69887,7 +71292,7 @@ BEGIN JOIN itemCategory ic ON ic.id = tp.categoryFk 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.id = 1 + JOIN componentType ct ON ct.id = c.typeFk AND ct.id = 6 WHERE s.created >= vCreatedFrom AND ic.merchandise != FALSE; @@ -69906,8 +71311,8 @@ BEGIN FROM sale WHERE id = vSaleFk; - CALL util.debug(vTicketFk, vConcept); - -- CALL sale_calculateComponent(vSaleFk, 1); + CALL util.debugAdd(vTicketFk, vConcept); + CALL sale_calculateComponent(vSaleFk, 1); END LOOP; CLOSE vCur; @@ -69939,8 +71344,8 @@ BEGIN */ SET SESSION group_concat_max_len = 102400; - INSERT INTO mail (sender,replyTo,subject,body) - SELECT CONCAT(sub.name, '@verdnatura.es') sender, + INSERT INTO mail (receiver,replyTo,subject,body) + SELECT CONCAT(sub.name, '@verdnatura.es') receiver, 'noreply@verdnatura.es' replyTo, CONCAT( 'El ', @@ -70037,14 +71442,23 @@ BEGIN RPAD(IFNULL(i.size,''),5,' ') ) ) as line1, + '' cel1, + IF(s.quantity MOD b.packing, + CONCAT(CAST(s.quantity/b.`grouping` AS decimal(10,0)),' x ',b.`grouping`), + CONCAT(CAST(s.quantity / b.packing AS DECIMAL(10,0)),' pack de ',b.packing)) cel2, + TRIM(CONCAT(ic.color, IF(MAX(IF(st.semaphore <=> 1, TRUE, FALSE)) AND t.id != t.showTicketFk, CONCAT(' [ TICKET ',t.id,' ] '),''), IFNULL(LPAD(st.parkingCode,40,' '),''))) as line3, + '' cel3, TRIM(CONCAT(LPAD(IFNULL(ip.productor,''),30,' '), ' ',LPAD(IFNULL(o.code,''),4,' '))) as line2, TRIM(CONCAT(ic.color, IF(MAX(IF(st.semaphore <=> 1, TRUE, FALSE)) AND t.id != t.showTicketFk, CONCAT(' [ TICKET ',t.id,' ] '),''), IFNULL(LPAD(st.parkingCode,40,' '),''))) as line3, s.isAdded, str.originalQuantity as startQuantity, -- eliminar cuando tengamos la nueva apk - IFNULL(c.workerFk,getUser()), + IFNULL(c.workerFk,getUser()) as workerFk, IFNULL(SUM(iss.quantity),0) as pickedQuantity FROM vn.sale s JOIN tmp.ticket t ON t.id = s.ticketFk + JOIN vn.ticket tt ON tt.id = t.id + JOIN cache.last_buy lb ON lb.item_id = s.itemFk AND lb.warehouse_id = tt.warehouseFk + JOIN vn.buy b ON b.id = lb.buy_id JOIN vn.item i ON i.id = s.itemFk LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = t.id LEFT JOIN vn.collection c ON c.id = tc.collectionFk @@ -70082,13 +71496,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 `sale_getProblems`(IN vIsTodayRelative TINYINT(1)) +CREATE DEFINER=`root`@`%` PROCEDURE `sale_getProblems`(IN vIsTodayRelative tinyint(1)) BEGIN /** * Calcula los problemas de cada venta @@ -70117,6 +71531,7 @@ BEGIN saleFk INT(11), isFreezed INTEGER(1) DEFAULT 0, risk DECIMAL(10,2) DEFAULT 0, + hasHighRisk TINYINT(1) DEFAULT 0, hasTicketRequest INTEGER(1) DEFAULT 0, isAvailable INTEGER(1) DEFAULT 1, itemShortage VARCHAR(250), @@ -70167,8 +71582,8 @@ BEGIN CALL clientGetDebt(CURDATE()); - INSERT INTO tmp.sale_problems(ticketFk, risk) - SELECT DISTINCT tl.ticketFk, r.risk + INSERT INTO tmp.sale_problems(ticketFk, risk, hasHighRisk) + SELECT DISTINCT tl.ticketFk, r.risk, ((r.risk - cc.riskTolerance) > c.credit + 10) FROM tmp.ticket_list tl JOIN vn.ticket t ON t.id = tl.ticketFk JOIN vn.agencyMode a ON t.agencyModeFk = a.id @@ -70178,7 +71593,7 @@ BEGIN WHERE r.risk > c.credit + 10 AND a.isRiskFree = FALSE ON DUPLICATE KEY UPDATE - risk = r.risk; + risk = r.risk, hasHighRisk = ((r.risk - cc.riskTolerance) > c.credit + 10); INSERT INTO tmp.sale_problems(ticketFk, hasTicketRequest) SELECT DISTINCT tl.ticketFk, TRUE @@ -70560,7 +71975,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 `shelvingFuture` */; +/*!50003 DROP PROCEDURE IF EXISTS `shelvingFuture__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -70570,7 +71985,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `shelvingFuture`(vSectorFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `shelvingFuture__`(vSectorFk INT) BEGIN DECLARE vDone BOOL DEFAULT FALSE; @@ -70906,6 +72321,104 @@ BEGIN sh.parked < TIMESTAMPADD(MONTH,-1,CURDATE()) ); +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 `shelving_getSpam` */; +/*!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 `shelving_getSpam`(vDated DATE, vWarehouseFk INT) +BEGIN + + /* Devuelve las matrículas con productos que no son necesarios para la venta hasta la fecha señalada + * + * @param vDated Fecha hasta la que se puede pasar sin esos productos. + * @param vWarehouse Identificador único de vn.warehouse + */ + + DROP TEMPORARY TABLE IF EXISTS tmp.stock; + + CALL cache.stock_refresh(FALSE); + + CREATE TEMPORARY TABLE tmp.stock + SELECT i.id itemFk, + v.amount - IFNULL(fue.reserva,0) as visible, + fue.reserva, + sale.venta, + IFNULL(buy.compra,0) + IFNULL(mov.traslado,0) as compra, + IFNULL(v.amount,0) + IFNULL(sale.venta,0) + IFNULL(buy.compra,0) + IFNULL(mov.traslado,0) - IFNULL(fue.reserva,0) as saldo + FROM vn.item i + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk + LEFT JOIN ( + SELECT ish.itemFk, CAST(SUM(ish.visible) AS DECIMAL(10,0)) AS reserva + FROM vn.itemShelving ish + JOIN vn.shelving sh ON sh.code = ish.shelvingFk + JOIN vn.parking p ON p.id = sh.parkingFk + JOIN vn.sector s ON s.id = p.sectorFk + WHERE s.code = 'FUENTES_PICASSE' + OR sh.isSpam + GROUP BY ish.itemFk + ) fue ON fue.itemFk = i.id + LEFT JOIN cache.stock v ON i.id = v.item_id AND v.warehouse_id = vWarehouseFk + LEFT JOIN ( + SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as venta + FROM vn2008.item_out + WHERE dat BETWEEN CURDATE() AND util.dayend(vDated) + AND warehouse_id = vWarehouseFk + GROUP BY item_id + ) sale ON sale.item_id = i.id + LEFT JOIN ( + SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as compra + FROM vn2008.item_entry_in + WHERE dat BETWEEN CURDATE() AND util.dayend(vDated) + AND warehouse_id = vWarehouseFk + AND isVirtualStock = FALSE + GROUP BY item_id + ) buy ON buy.item_id = i.id + LEFT JOIN ( + SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as traslado + FROM vn2008.item_entry_out + WHERE dat BETWEEN CURDATE() AND util.dayend(vDated) + AND warehouse_id = vWarehouseFk + GROUP BY item_id + ) mov ON mov.item_id = i.id + WHERE v.amount; + + SELECT ish.shelvingFk matricula, + i.longName articulo, + ish.visible, + count(*) lineas, + sum(ish.visible <= s.saldo) spam, + p.code parking, + s.description sector , + w.name AS almacen, + sh.isSpam + FROM vn.itemShelving ish + JOIN vn.item i ON i.id = ish.itemFk + JOIN vn.shelving sh ON sh.code = ish.shelvingFk + JOIN vn.parking p ON p.id = sh.parkingFk + JOIN vn.sector s ON s.id = p.sectorFk + JOIN vn.warehouse w ON w.id = s.warehouseFk + LEFT JOIN tmp.stock s ON s.itemFk = ish.itemFk + WHERE (w.name = 'Algemesi' + OR (w.name = 'NuncaJamas' AND ish.created < curdate())) + AND ish.visible + GROUP BY ish.shelvingFk + HAVING lineas = spam OR isSpam; + + DROP TEMPORARY TABLE tmp.stock; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -71788,7 +73301,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`z-sysadmin`@`%` PROCEDURE `test`() +CREATE DEFINER=`root`@`%` PROCEDURE `test`() BEGIN select 'procedimiento ejecutado con éxito'; END ;; @@ -72733,13 +74246,36 @@ 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 `ticketCollection_get`(vTicketFk INT) +BEGIN + + SELECT tc.collectionFk + FROM vn.ticketCollection tc + WHERE ticketFk = vTicketFk; + +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 `ticketCollection_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 `ticketCollection_get__`(vTicketFk INT) BEGIN SELECT tc.collectionFk @@ -72951,7 +74487,7 @@ BEGIN FROM saleComponent sc JOIN tmp.sale tmps ON tmps.saleFk = sc.saleFk GROUP BY sc.saleFk) sc ON sc.saleFk = s.id - SET s.price = sumValue + SET s.price = sumValue / ((100 - s.discount) / 100) WHERE it.code != 'PRT' ; REPLACE INTO saleComponent(saleFk, componentFk, value) @@ -74056,40 +75592,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 `ticketListVolume__` */; -/*!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 `ticketListVolume__`(IN vTicketId INT) -BEGIN - - DECLARE vWarehouseId INTEGER; - DECLARE vShippedDate DATE; - - SELECT warehouseFk, shipped INTO vWarehouseId,vShippedDate FROM ticket WHERE id = vTicketId; - - SELECT s.quantity, - round(ic.cm3delivery * s.quantity / 1000000,3) as m3, - s.itemFk, - s.id AS saleFk, - s.concept, - t.agencyModeFk - FROM sale s - JOIN ticket t on t.id = s.ticketFk - JOIN itemCost ic ON ic.itemFk = s.itemFk AND ic.warehouseFk = t.warehouseFk - WHERE s.ticketFk = vTicketId; -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 `ticketManaToPromo` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -74976,44 +76478,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 `ticketVolumeByDate` */; -/*!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 `ticketVolumeByDate`(vDate DATE) -BEGIN - - DECLARE vDateStart DATETIME DEFAULT DATE(vDate); - DECLARE vDateEnd DATETIME DEFAULT util.dayEnd(vDate); - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketVolumeByDate; - - CREATE TEMPORARY TABLE tmp.ticketVolumeByDate - ENGINE = MEMORY - SELECT s.ticketFk, - CAST(SUM(ic.cm3delivery * s.quantity) / 1000000 AS DECIMAL(10,2)) as m3 - FROM sale s - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.itemCategory c ON c.id = it.categoryFk - JOIN vn.ticket t on t.id = s.ticketFk - JOIN vn.itemCost ic ON ic.itemFk = s.itemFk AND ic.warehouseFk = t.warehouseFk - WHERE c.merchandise - AND t.shipped BETWEEN vDateStart AND vDateEnd - GROUP BY s.ticketFk; -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 `ticketVolumeByDate_ventas` */; +/*!50003 DROP PROCEDURE IF EXISTS `ticketVolumeByDate_ventas_Artificial__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -75023,7 +76488,45 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ticketVolumeByDate_ventas`(vDate DATE) +CREATE DEFINER=`root`@`%` PROCEDURE `ticketVolumeByDate_ventas_Artificial__`(vDate DATE) +BEGIN + + DECLARE vDateStart DATETIME DEFAULT DATE(vDate); + DECLARE vDateEnd DATETIME DEFAULT util.dayEnd(vDate); + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketVolumeByDate_Artificial; + + CREATE TEMPORARY TABLE tmp.ticketVolumeByDate_Artificial + ENGINE = MEMORY + SELECT s.ticketFk, + CAST(SUM(r.cm3 * s.quantity) / 1000000 AS DECIMAL(10,2)) as m3 + FROM sale s + JOIN bs.ventas v ON v.Id_Movimiento = s.id + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.sector sc ON sc.id = i.sectorFk + JOIN vn.ticket t on t.id = s.ticketFk + JOIN bi.rotacion r ON r.Id_Article = s.itemFk AND r.warehouse_id = t.warehouseFk + WHERE sc.description = 'Artificial' + AND t.shipped BETWEEN vDateStart AND vDateEnd + GROUP BY s.ticketFk; + +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 `ticketVolumeByDate_ventas__` */; +/*!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 `ticketVolumeByDate_ventas__`(vDate DATE) BEGIN DECLARE vDateStart DATETIME DEFAULT DATE(vDate); @@ -75052,38 +76555,37 @@ 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 `ticketVolumeByDate_ventas_Artificial` */; +/*!50003 DROP PROCEDURE IF EXISTS `ticketVolumeByDate__` */; /*!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 `ticketVolumeByDate_ventas_Artificial`(vDate DATE) +CREATE DEFINER=`root`@`%` PROCEDURE `ticketVolumeByDate__`(vDate DATE) BEGIN DECLARE vDateStart DATETIME DEFAULT DATE(vDate); DECLARE vDateEnd DATETIME DEFAULT util.dayEnd(vDate); - DROP TEMPORARY TABLE IF EXISTS tmp.ticketVolumeByDate_Artificial; - - CREATE TEMPORARY TABLE tmp.ticketVolumeByDate_Artificial + DROP TEMPORARY TABLE IF EXISTS tmp.ticketVolumeByDate; + + CREATE TEMPORARY TABLE tmp.ticketVolumeByDate ENGINE = MEMORY SELECT s.ticketFk, - CAST(SUM(r.cm3 * s.quantity) / 1000000 AS DECIMAL(10,2)) as m3 + CAST(SUM(ic.cm3delivery * s.quantity) / 1000000 AS DECIMAL(10,2)) as m3 FROM sale s - JOIN bs.ventas v ON v.Id_Movimiento = s.id JOIN vn.item i ON i.id = s.itemFk - JOIN vn.sector sc ON sc.id = i.sectorFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory c ON c.id = it.categoryFk JOIN vn.ticket t on t.id = s.ticketFk - JOIN bi.rotacion r ON r.Id_Article = s.itemFk AND r.warehouse_id = t.warehouseFk - WHERE sc.description = 'Artificial' + JOIN vn.itemCost ic ON ic.itemFk = s.itemFk AND ic.warehouseFk = t.warehouseFk + WHERE c.merchandise AND t.shipped BETWEEN vDateStart AND vDateEnd - GROUP BY s.ticketFk; - + GROUP BY s.ticketFk; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -75220,6 +76722,123 @@ BEGIN FROM vn.sale s WHERE s.ticketFk = vOriginalTicket; +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_canMerge` */; +/*!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 `ticket_canMerge`(vDated DATE, vScopeDays INT, vLitersMax INT, vLinesMax INT, vWarehouseFk INT) +BEGIN + + /* Devuelve un listado de tickets susceptibles de fusionarse con otros tickets en el futuro + * + * @param vDated Fecha en cuestión + * @param vScopeDays Dias en el futuro a sondear + * @param vLitersMax Volumen máximo de los tickets a catapultar + * @param vLinesMax Número máximo de lineas de los tickets a catapultar + * @param vWarehouseFk Identificador de vn.warehouse + */ + + SELECT sv.ticketFk , + CAST(sum(litros) AS DECIMAL(10,0)) liters, + CAST(count(*) AS DECIMAL(10,0)) `lines`, + sub2.id ticketFuture, + sub2.shipped + FROM vn.saleVolume sv + JOIN vn.ticket t ON t.id = sv.ticketFk + JOIN vn.address a ON a.id = t.addressFk + JOIN vn.province p ON p.id = a.provinceFk + JOIN vn.country c ON c.id = p.countryFk + JOIN vn.ticketState ts ON ts.ticketFk = t.id + JOIN vn.alertLevel al ON al.id = ts.alertLevel + LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id + LEFT JOIN ( + SELECT * FROM ( + SELECT t.addressFk , t.id, t.shipped + FROM vn.ticket t + WHERE t.shipped BETWEEN TIMESTAMPADD(DAY, vScopeDays,vDated) + AND util.dayend(TIMESTAMPADD(DAY, vScopeDays,vDated)) + AND t.warehouseFk = vWarehouseFk + ) sub + GROUP BY sub.addressFk + ) sub2 ON sub2.addressFk = t.addressFk AND t.id != sub2.id + WHERE t.shipped BETWEEN vDated AND util.dayend(vDated) + AND t.warehouseFk = vWarehouseFk + AND al.code = 'FREE' + AND tp.ticketFk IS NULL + GROUP BY sv.ticketFk + HAVING liters <= vLitersMax AND `lines` <= vLinesMax AND ticketFuture; +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_canMerge__` */; +/*!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_canMerge__`(vDated DATE, vScopeDays INT, vLitersMax INT, vLinesMax INT, vWarehouseFk INT) +BEGIN + + /* Devuelve un listado de tickets susceptibles de fusionarse con otros tickets en el futuro + * + * @param vDated Fecha en cuestión + * @param vScopeDays Dias en el futuro a sondear + * @param vLitersMax Volumen máximo de los tickets a catapultar + * @param vLinesMax Número máximo de lineas de los tickets a catapultar + * @param vWarehouseFk Identificador de vn.warehouse + */ + + SELECT sv.ticketFk , + CAST(sum(litros) AS DECIMAL(10,0)) liters, + CAST(count(*) AS DECIMAL(10,0)) `lines`, + sub2.id ticketFuture, + sub2.shipped + FROM vn.saleVolume sv + JOIN vn.ticket t ON t.id = sv.ticketFk + JOIN vn.address a ON a.id = t.addressFk + JOIN vn.province p ON p.id = a.provinceFk + JOIN vn.country c ON c.id = p.countryFk + JOIN vn.ticketState ts ON ts.ticketFk = t.id + JOIN vn.alertLevel al ON al.id = ts.alertLevel + LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id + LEFT JOIN tmp.routeDayMove ra ON ra.routeFk = t.routeFk + LEFT JOIN ( + SELECT * FROM ( + SELECT t.addressFk , t.id, t.shipped + FROM vn.ticket t + WHERE t.shipped BETWEEN TIMESTAMPADD(DAY, vScopeDays,vDated) + AND util.dayend(TIMESTAMPADD(DAY, vScopeDays,vDated)) + AND t.warehouseFk = vWarehouseFk + ) sub + GROUP BY sub.addressFk + ) sub2 ON sub2.addressFk = t.addressFk AND t.id != sub2.id + WHERE t.shipped BETWEEN vDated AND util.dayend(vDated) + AND t.warehouseFk = vWarehouseFk + AND al.code = 'FREE' + AND tp.ticketFk IS NULL + AND ra.routeFk IS NULL + GROUP BY sv.ticketFk + HAVING liters <= vLitersMax AND `lines` <= vLinesMax AND ticketFuture; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -75267,6 +76886,54 @@ BEGIN ON s.shipFk = tt.ticketFk SET t.clientFk = vNewClient; +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_checkFullyControlled` */; +/*!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 `ticket_checkFullyControlled`(vWorkerFk INT, vTicketFk INT ) +BEGIN +/** + * Comprueba que no hay ningún ticket pendiente de revisar de alguna colección que haya revisado el trabajador + * @param vWorkerFk id del user + * @param vTicketFk número de ticket escaneada + * + */ + + SELECT t.id + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN ticketCollection tc ON tc.ticketFk = t.id + JOIN (SELECT tc.collectionFk + FROM ticketState ts + JOIN ticketCollection tc ON tc.ticketFk = ts.ticketFk + LEFT JOIN (SELECT tc.collectionFk + FROM ticketCollection tc + WHERE ticketFk = vTicketFk + AND tc.created >= CURDATE() + )sub ON sub.collectionFk = tc.collectionFk + WHERE ts.workerFk = vWorkerFk + AND sub.collectionFk IS NULL + AND tc.created >= CURDATE() + GROUP BY tc.collectionFk + )sub ON sub.collectionFk = tc.collectionFk + JOIN ticketState ts ON ts.ticketFk = t.id + WHERE ts.code IN ('ON_PREPARATION', 'PREPARED', 'PREVIOUS_PREPARATION', 'OK PREVIOUS') + AND t.shipped >= CURDATE() + AND s.quantity <>0 + LIMIT 1; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -75436,9 +77103,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 ;; @@ -75537,12 +77204,11 @@ BEGIN SELECT COUNT(*) INTO vMailSent FROM vn.mail - WHERE sender = vSalesPersonEmail + WHERE receiver = vSalesPersonEmail AND subject = vSubject; IF NOT vMailSent THEN - INSERT INTO vn.mail (`sender`,`subject`,`body`) - VALUES (vSalesPersonEmail, vSubject, vMessage); + CALL mail_insert(vSalesPersonEmail, NULL, vSubject, vMessage); END IF; CALL vn.ticketStateUpdate (vNewTicket, 'FIXING'); END IF; @@ -75733,19 +77399,19 @@ 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 `ticket_close`(vTicketFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `ticket_close`() BEGIN /** * Realiza el cierre de todos los - * tickets de la tabla ticketClosure. + * tickets de la tabla tmp.ticket_close. * - * @param vTicketFk Id del ticket + * @table tmp.ticket_close(ticketFk) Identificadores de los tickets a cerrar */ DECLARE vDone BOOL; DECLARE vClientFk INT; @@ -75759,20 +77425,13 @@ BEGIN DECLARE vHasToInvoice BOOL; DECLARE cur CURSOR FOR - SELECT ticketFk FROM tmp.ticketClosure; + SELECT ticketFk FROM tmp.ticket_close; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN RESIGNAL; END; - DROP TEMPORARY TABLE IF EXISTS tmp.ticketClosure; - CREATE TEMPORARY TABLE tmp.ticketClosure - SELECT vTicketFk AS ticketFk; - - INSERT INTO tmp.ticketClosure - SELECT id FROM stowaway s - WHERE s.shipFk = vTicketFk; OPEN cur; proc: LOOP @@ -75784,7 +77443,7 @@ BEGIN LEAVE proc; END IF; - -- ticketClosure start + -- Fetch ticket data SELECT c.id, c.isTaxDataChecked, @@ -75848,26 +77507,23 @@ BEGIN END LOOP; CLOSE cur; - - DROP TEMPORARY TABLE IF EXISTS 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 `ticket_closeAll` */; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_closeAll__` */; /*!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 `ticket_closeAll`() +CREATE DEFINER=`root`@`%` PROCEDURE `ticket_closeAll__`() BEGIN /** * Realiza el cierre de todos los @@ -75988,13 +77644,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 `ticket_closeByTicket`(vTicketFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `ticket_closeByTicket`(IN vTicketFk int) BEGIN /** @@ -76004,23 +77660,23 @@ BEGIN * @param vTicketFk Id del ticket */ - DROP TEMPORARY TABLE IF EXISTS tmp.ticketClosure; - - CREATE TEMPORARY TABLE tmp.ticketClosure ENGINE = MEMORY ( + DROP TEMPORARY TABLE IF EXISTS tmp.ticket_close; + CREATE TEMPORARY TABLE tmp.ticket_close ENGINE = MEMORY ( SELECT t.id AS ticketFk FROM expedition e INNER JOIN ticket t ON t.id = e.ticketFk LEFT JOIN ticketState ts ON ts.ticketFk = t.id + JOIN alertLevel al ON al.id = ts.alertLevel WHERE - ts.alertLevel = 2 + al.code = 'PACKED' AND t.id = vTicketFk AND t.refFk IS NULL GROUP BY e.ticketFk); - CALL ticket_close(vTicketFk); - - DROP TEMPORARY TABLE tmp.ticketClosure; + CALL ticket_close(); + + DROP TEMPORARY TABLE tmp.ticket_close; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -76635,13 +78291,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 = 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_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ticket_getProblems`(IN vIsTodayRelative TINYINT(1)) +CREATE DEFINER=`root`@`%` PROCEDURE `ticket_getProblems`(IN vIsTodayRelative tinyint(1)) BEGIN /** * Calcula los problemas para un conjunto de tickets. @@ -76654,20 +78310,32 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticket_problems; CREATE TEMPORARY TABLE tmp.ticket_problems - (INDEX (ticketFk)) + (PRIMARY KEY (ticketFk)) ENGINE = MEMORY SELECT ticketFk, MAX(p.isFreezed) AS isFreezed, MAX(p.risk) AS risk, + MAX(p.hasHighRisk) AS hasHighRisk, MAX(p.hasTicketRequest) AS hasTicketRequest, MIN(p.isAvailable) AS isAvailable, MAX(p.itemShortage) AS itemShortage, MIN(p.isTaxDataChecked) AS isTaxDataChecked, - MAX(p.hasComponentLack) AS hasComponentLack + MAX(p.hasComponentLack) AS hasComponentLack, + 0 AS totalProblems FROM tmp.sale_problems p GROUP BY ticketFk; + UPDATE tmp.ticket_problems tp + SET tp.totalProblems = ( + (tp.isFreezed) + + IF(tp.risk, TRUE, FALSE) + + (tp.hasTicketRequest) + + (tp.isAvailable = 0) + + (tp.isTaxDataChecked = 0) + + (tp.hasComponentLack) + ); + DROP TEMPORARY TABLE tmp.sale_problems; END ;; @@ -77081,6 +78749,40 @@ 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 `ticket_merge` */; +/*!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_merge`(vSelf INT, vTicketTargetFk INT) +BEGIN + + /* Fusiona el primer ticket al segundo + * + * @param vSelf Número de ticket a fusionar + * @param vTicketTargetFk Ticket destino + * + */ + + UPDATE vn.sale s + SET s.ticketFk = vTicketTargetFk + WHERE s.ticketFk = vSelf; + + UPDATE vn.ticket t + SET t.shipped = TIMESTAMPADD(YEAR, - YEAR(NOW()) MOD 2000, t.shipped ) + WHERE t.id = vSelf; + +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_priceDifference` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -77148,7 +78850,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`z-sysadmin`@`%` PROCEDURE `ticket_recalc`(vTicketId INT) +CREATE DEFINER=`root`@`%` PROCEDURE `ticket_recalc`(vTicketId INT) BEGIN /** * Calcula y guarda el total con/sin IVA en un ticket. @@ -77181,9 +78883,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 ;; @@ -77203,7 +78905,7 @@ proc: BEGIN DECLARE vAddressFk INT; DECLARE vLanded DATE; DECLARE vZoneFk INTEGER; - + IF vIsTicketEditable IS NULL THEN SELECT IFNULL(ts.alertLevel,0) = 0 AND IFNULL(t.refFk,'') = '' INTO vIsTicketEditable @@ -77372,74 +79074,101 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ticket_recalcComponents__`(IN vTicketFk BIGINT ) +CREATE DEFINER=`root`@`%` PROCEDURE `ticket_recalcComponents__`(IN vTicketFk BIGINT, vIsTicketEditable BOOLEAN) proc: BEGIN /** - * Este procedimiento trata de "rebionizar" un ticket, + * Este procedimiento recalcula los componentes de un ticket, * eliminando los componentes existentes e insertandolos de nuevo * * @param vTicketFk Id del ticket - * @return tmp.buyUltimate + * @param vIsTicketEditable si no se quiere forzar llamar con NULL */ 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 + + -- Santos 2021, borrar a partir del dia 31 PAK + IF (SELECT COUNT(*) + FROM tmp.routeDayMove ra + JOIN vn.ticket t ON t.routeFk = ra.routeFk + WHERE t.id = vTicketFk) THEN + + LEAVE proc; + + END IF; + + IF vIsTicketEditable IS NULL THEN + SELECT IFNULL(ts.alertLevel,0) = 0 AND IFNULL(t.refFk,'') = '' + INTO vIsTicketEditable + FROM ticket t LEFT JOIN ticketState ts ON t.id = ts.ticket + WHERE id = vTicketFk; + END IF; + + SELECT t.warehouseFk, + t.shipped, + t.addressFk, + t.agencyModeFk, + t.landed, + t.zoneFk + INTO vWarehouseFk, vShipped, vAddressFk, vAgencyModeFk, vLanded, 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; + WHERE t.id = vTicketFk; + + IF vLanded IS NULL OR vZoneFk IS NULL THEN + + CALL zone_getLanded(vShipped, vAddressFk, vAgencyModeFk, vWarehouseFk, TRUE); + + IF (SELECT COUNT(*) FROM tmp.zoneGetLanded LIMIT 1) = 0 THEN + CALL util.throw('There is no zone for these parameters'); + END IF; + + UPDATE ticket t + SET t.landed = (SELECT landed FROM tmp.zoneGetLanded LIMIT 1) + WHERE t.id = vTicketFk AND t.landed IS NULL; + + IF vZoneFk IS NULL THEN + SELECT zoneFk INTO vZoneFk FROM tmp.zoneGetLanded LIMIT 1; + UPDATE ticket t + SET t.zoneFk = vZoneFk + WHERE t.id = vTicketFk AND t.zoneFk IS NULL; + END IF; + DROP TEMPORARY TABLE tmp.zoneGetLanded; - CALL vn.zone_getShipped (vlanded, vAddressFk, vAgencyModeFk, TRUE); - - CALL vn.buyUltimate (vWarehouseFk, vShipped); -- rellena la tabla buyUltimate con la ultima compra + END IF; + + -- rellena la tabla buyUltimate con la ultima compra + CALL buyUltimate (vWarehouseFk, vShipped); DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; CREATE TEMPORARY TABLE tmp.ticketLot SELECT vWarehouseFk warehouseFk, NULL available, - s.itemFk, bu.buyFk + s.itemFk, bu.buyFk, vZoneFk zoneFk 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); - + + CALL catalog_componentPrepare(); + CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk); + 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 + SELECT id saleFk, vWarehouseFk warehouseFk + FROM sale s + WHERE s.ticketFk = vTicketFk; + + -- si el ticket esta facturado, respeta los precios + CALL ticketComponentUpdateSale(IF(vIsTicketEditable, 1, 6)); - 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; + CALL catalog_componentPurge(); + DROP TEMPORARY TABLE + tmp.buyUltimate, + tmp.sale; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -77737,10 +79466,10 @@ BEGIN * @table tmp.user(userFk) * @return tmp.timeBusinessCalculate */ - + DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate; - - CREATE TEMPORARY TABLE tmp.timeBusinessCalculate + + CREATE TEMPORARY TABLE tmp.timeBusinessCalculate SELECT dated, businessFk, userFk, @@ -77757,7 +79486,8 @@ BEGIN type, permissionRate, hoursWeek, - discountRate + discountRate, + isAllowedToWork FROM(SELECT t.dated, b.business_id businessFk, w.userFk, @@ -77769,7 +79499,8 @@ BEGIN cs.type, cs.permissionRate, cs.discountRate, - cl.hours_week hoursWeek + cl.hours_week hoursWeek, + cs.isAllowedToWork FROM vn.time t LEFT JOIN postgresql.business b ON t.dated BETWEEN b.date_start AND ifnull(b.date_end, vDatedTo ) LEFT JOIN postgresql.profile AS pr ON b.client_id = pr.profile_id @@ -77787,8 +79518,7 @@ BEGIN WHERE t.dated BETWEEN vDatedFrom AND vDatedTo GROUP BY w.userFk,dated )sub; - - + UPDATE tmp.timeBusinessCalculate t LEFT JOIN postgresql.journey j ON j.business_id = t.businessFk SET t.timeWorkSeconds = t.hoursWeek / 5 * 3600, @@ -77798,21 +79528,21 @@ BEGIN 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 + + UPDATE tmp.timeBusinessCalculate t SET t.timeWorkSeconds = t.timeWorkSeconds - (t.timeWorkSeconds * permissionRate) , t.timeWorkSexagesimal = SEC_TO_TIME ((t.timeWorkDecimal - (t.timeWorkDecimal * permissionRate)) * 3600), t.timeWorkDecimal = t.timeWorkDecimal - (t.timeWorkDecimal * permissionRate) WHERE permissionRate <> 0; - + UPDATE tmp.timeBusinessCalculate t JOIN 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.type = 'Festivo' + t.permissionrate = 1, + t.type = 'Festivo' WHERE t.type IS NULL; END ;; @@ -78284,63 +80014,6 @@ BEGIN DROP TEMPORARY TABLE tmp.`user`; -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 `timeControl_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 = 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 `timeControl_calculate__`(vDatedFrom DATETIME, vDatedTo DATETIME) -BEGIN - SET @vIsOdd := TRUE; - SET @vUser := NULL; - SET @vDated := NULL; - - DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate; - - CREATE TEMPORARY TABLE tmp.timeControlCalculate - SELECT userFk, - dated, - IF( timeWork >= 18000, @timeWork:=timeWork + 1200, @timeWork:=timeWork) timeWorkSeconds, - SEC_TO_TIME(@timeWork ) timeWorkSexagesimal, - @timeWork / 3600 timeWorkDecimal, - timed - FROM (SELECT SUM(timeWork) timeWork, - userFk, - dated, - GROUP_CONCAT(DATE_FORMAT(sub.timed,"%H:%i") ORDER BY sub.timed ASC SEPARATOR ' - ') timed - FROM (SELECT IF(@vUser = wtc.userFk, @vUser :=@vUser, @vUser := wtc.userFk ), - IF(@vIsOdd, @vIsOdd := FALSE, @vIsOdd := TRUE ), - IF(direction='in', @vIsOdd := TRUE, @vIsOdd := @vIsOdd ), - IF(@vIsOdd, @vLastTimed:=UNIX_TIMESTAMP(timed),@vLastTimed:=@vLastTimed), - IF(@vIsOdd, 0, UNIX_TIMESTAMP(timed)-@vLastTimed) timeWork, - IF(direction='in', @vDated := DATE(wtc.timed), @vDated :=@vDated) dated, - wtc.userFk, - wtc.timed timed, - direction - FROM (SELECT wtc.* - FROM workerTimeControl wtc - JOIN tmp.`user` w ON w.userFk = wtc.userFk - WHERE wtc.timed BETWEEN vDatedFrom AND vDatedTo - ORDER BY userFk, timed ASC - ) wtc - WHERE wtc.timed BETWEEN vDatedFrom AND vDatedTo - ORDER BY userFk, timed ASC - ) sub - GROUP BY userFk, dated - ORDER BY userFk, dated - )sub2; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -78388,7 +80061,7 @@ BEGIN * trasladados a la ficha del cliente. * */ - INSERT INTO mail (sender,replyTo,subject,body) + INSERT INTO mail (receiver,replyTo,subject,body) SELECT 'administracion@verdnatura.es', 'noreply@verdnatura.es', CONCAT('Cobro web no trasladado a la ficha del cliente ', t.clientFk), @@ -79098,28 +80771,59 @@ 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 `vehicleWarehouseTimeControl_getHistorical` */; +/*!50003 DROP PROCEDURE IF EXISTS `visible_getMisfit` */; /*!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 `vehicleWarehouseTimeControl_getHistorical`(vNumberPLate VARCHAR(20), vWorkerFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `visible_getMisfit`(vSectorFk INT) BEGIN -/** - * Obtiene historial de la matrícula del trabajador, si es jefe de producción muestra el historial completo. -*/ - SELECT timed,workerFk,IF (direction="out","Salida","Entrada") direction - FROM vn.vehicleWarehouseTimeControl vwt - JOIN vn.vehicleWarehouse vw ON vw.numberPlate=vNumberPLate - WHERE vwt.vehicleWarehouseFk =vw.id - AND vwt.workerFk = IF(account.userHasRole(account.user_getNameFromId(vWorkerFk), 'productionAssi'), vwt.workerFk, vWorkerFk); + /* Devuelve una tabla temporal con los descuadres entre el visible teórico y lo ubicado en la práctica + * + * @param vSectorFk Identificador de vn.sector + * + * @return tmp.stockMisfit(itemFk, visible, parked) + */ + + DECLARE vCalcVisibleFk INT; + DECLARE vWarehouseFk INT; + + SELECT warehouseFk INTO vWarehouseFk + FROM vn.sector s + WHERE s.id = vSectorFk; + + CALL cache.visible_refresh(vCalcVisibleFk, FALSE, vWarehouseFk); + + DROP TEMPORARY TABLE IF EXISTS tmp.stockMisfit; + + CREATE TEMPORARY TABLE tmp.stockMisfit( + itemFk INT PRIMARY KEY, + visible INT NOT NULL DEFAULT 0, + parked INT NOT NULL DEFAULT 0) + ENGINE = MEMORY; + + INSERT INTO tmp.stockMisfit(itemFk, parked) + SELECT iss.itemFk , sum(iss.visible ) + FROM vn.itemShelvingStock iss + JOIN vn.sector s ON s.id = iss.sectorFk + WHERE vSectorFk IN (s.id, s.sonFk) + GROUP BY iss.itemFk; + + INSERT INTO tmp.stockMisfit(itemFk, visible) + SELECT v.item_id , v.visible + FROM cache.visible v + WHERE v.calc_id = vCalcVisibleFk + ON DUPLICATE KEY UPDATE visible = v.visible; + DELETE FROM tmp.stockMisfit + WHERE visible = parked; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -79186,66 +80890,6 @@ BEGIN CALL vn.warehouseFitting(vWhOrigin, vWhDestiny); -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 `weight_Put__` */; -/*!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 `weight_Put__`() -BEGIN - - SET @isModeInventory := TRUE; - - CALL cache.last_buy_refresh(FALSE); -- jgf 2020/09/14 cuelga la BBDD al actualizar varios - - DROP TEMPORARY TABLE IF EXISTS tmp.peso; - - CREATE TEMPORARY TABLE tmp.peso - SELECT lb.item_id, - i.longName, - lb.warehouse_id, - b.weight, - it.gramsMin * b.packing / 1000 as pesMin, - it.gramsMax * b.packing / 1000 as pesMax, - b.entryFk, - CAST(GREATEST(it.gramsMin * b.packing / 1000 , LEAST(IFNULL(b.weight, (it.gramsMax - it.gramsMin) * b.packing / 1000 / 2) , it.gramsMax * b.packing / 1000)) as decimal(10,2)) pesocorrecto - FROM cache.last_buy lb - JOIN vn.buy b ON b.id = lb.buy_id - JOIN vn.item i ON i.id = b.itemFk - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.intrastat itr ON itr.id = i.intrastatFk - HAVING pesocorrecto > 0; - - DROP TEMPORARY TABLE IF EXISTS tmp.buyTochange; - - CREATE TEMPORARY TABLE tmp.buyTochange - SELECT DISTINCT b.id, b.itemFk, b.entryFk - FROM cache.last_buy lb - JOIN vn.buy b ON b.id = lb.buy_id - JOIN (SELECT DISTINCT item_id itemFk FROM tmp.peso) sub using(itemFk) - WHERE b.weight is null; - - UPDATE tmp.buyTochange btc - JOIN vn.buy b ON b.id = btc.id - JOIN (SELECT item_id , pesocorrecto FROM tmp.peso GROUP BY item_id) p ON p.item_id = b.itemFk - SET b.weight = p.pesocorrecto; - - UPDATE vn.itemCost ic - JOIN cache.last_buy lb ON lb.item_id = ic.itemFk AND lb.warehouse_id = ic.warehouseFk - JOIN vn.buy b ON b.id = lb.buy_id - SET ic.grams = b.weight * 1000 / b.packing; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -79293,6 +80937,154 @@ 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 `workerCalendar_calculateBusiness` */; +/*!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 `workerCalendar_calculateBusiness`(vYear INT, vBusinessFk INT) +BEGIN + +/** + * Calcula los días y horas de vacaciones en función de un contrato y año + * + * @param vYear + * @param vBusinessFk + * @return tmp.workerCalendarCalculateBusiness (days, hours, daysEnjoyed, hoursEnjoyed) + */ + + DECLARE vStarted DATE; + DECLARE vEnded DATE; + DECLARE vDaysHoliday DECIMAL(5,2); + DECLARE vHoursWeek DECIMAL(5,2); + DECLARE vDaysToSubtract DECIMAL(5,2); + DECLARE vDaysHolidayEnjoyed DECIMAL(5,2); + DECLARE vDifDays INT; + + SELECT IF(b.date_start < CONCAT(vYear,"-01-01"), CONCAT(vYear,"-01-01"),b.date_start), + IF(b.date_end IS NULL OR YEAR(b.date_end)>vYear , CONCAT(vYear,"-12-31"), b.date_end), + IF(hasHolidayEntilement, w.days, 0), + c.hours_week + INTO vStarted, + vEnded, + vDaysHoliday, + vHoursWeek + FROM postgresql.business b + JOIN postgresql.business_labour_payroll blp ON blp.business_id = b.business_id + JOIN vn2008.payroll_contratos p ON p.CodContrato = cod_contrato + JOIN postgresql.business_labour bl ON bl.business_id = b.business_id + JOIN workCenterHoliday w ON w.workcenterFk = bl.workcenter_id + LEFT JOIN postgresql.calendar_labour_type c ON c.calendar_labour_type_id=bl.calendar_labour_type_id + WHERE b.business_id= vBusinessFk + AND w.year = vYear; + + DROP TEMPORARY TABLE IF EXISTS tmp.workerCalendarCalculateBusiness; + + IF vStarted < vEnded THEN + SET vDifDays = DAYOFYEAR(vEnded) - DAYOFYEAR(vStarted) + 1; + + SELECT IFNULL(SUM(holidayEntitlementRate), 0) , + SUM(-(discountRate - 1)) + INTO vDaysToSubtract, + vDaysHolidayEnjoyed + FROM workerCalendar w + JOIN absenceType a ON a.id = w.absenceTypeFk + WHERE w.businessFk = vBusinessFk + AND YEAR(dated) = vYear; + END IF; + + CREATE TEMPORARY TABLE tmp.workerCalendarCalculateBusiness + ENGINE = MEMORY + SELECT @days := IFNULL(ROUND((vDaysHoliday * (vDifDays - vDaysToSubtract) / IF(util.isLeapYear(vYear) , 366, 365)), 1), 0) days, + @days * (vHoursWeek / 5) hours, + @daysEnjoyed := IFNULL(ROUND(vDaysHolidayEnjoyed, 1), 0) daysEnjoyed, + @daysEnjoyed * (vHoursWeek / 5) hoursEnjoyed; +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 `workerCalendar_calculateYear` */; +/*!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 `workerCalendar_calculateYear`(vYear INT, vWorkerFk INT) +BEGIN + +/** + * Calcula los días y horas de vacaciones en función de un trabajador y año + * + * @param vYear + * @param vWorkerFk + * @return tmp.workerCalendarCalculateYear (days, hours, daysEnjoyed, hoursEnjoyed) + */ + + DECLARE vDone BOOL; + DECLARE vBusinessFk INT; + + DECLARE cur CURSOR FOR + SELECT b.business_id + FROM postgresql.business b + LEFT JOIN postgresql.profile AS pr ON pr.profile_id = b.client_id + LEFT JOIN postgresql.person AS p ON p.person_id = pr.person_id + WHERE vYear BETWEEN YEAR(b.date_start) AND IFNULL(YEAR(b.date_end), vYear ) + AND p.id_trabajador = vWorkerFk; + + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET vDone = TRUE; + + DROP TEMPORARY TABLE IF EXISTS tmp.workerCalendarCalculateYear; + + CREATE TEMPORARY TABLE tmp.workerCalendarCalculateYear + (days DEC(5,2), + hours DEC(5,2), + daysEnjoyed DEC(5,2), + hoursEnjoyed DEC(5,2)) + ENGINE = MEMORY; + INSERT INTO tmp.workerCalendarCalculateYear VALUES(0, 0, 0, 0); + + OPEN cur; + + l: LOOP + SET vDone = FALSE; + FETCH cur INTO vBusinessFk; + + IF vDone THEN + LEAVE l; + END IF; + + CALL workerCalendar_calculateBusiness(vYear, vBusinessFk); + UPDATE tmp.workerCalendarCalculateYear w + JOIN tmp.workerCalendarCalculateBusiness wc + SET w.days = w.days + wc.days, + w.hours = w.hours + wc.hours, + w.daysEnjoyed = w.daysEnjoyed + wc.daysEnjoyed, + w.hoursEnjoyed = w.hoursEnjoyed + wc.hoursEnjoyed; + + DROP TEMPORARY TABLE tmp.workerCalendarCalculateBusiness; + + END LOOP; + + CLOSE cur; + +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 `workerCreate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -79617,17 +81409,44 @@ 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 `workerJourneyReplace` */; +/*!50003 DROP PROCEDURE IF EXISTS `workerJourneyReplaceLauncher__` */; /*!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 `workerJourneyReplace`(vFromDate DATE, vToDate DATE, vUserFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `workerJourneyReplaceLauncher__`() +BEGIN + + DECLARE vDateStart DATE; + DECLARE vDateEnd DATE; + + SET vDateStart = TIMESTAMPADD(MONTH,-1,CURDATE()); + SET vDateEnd = util.yesterday(); + + CALL vn.workerJourneyReplace(vDateStart,vDateEnd,0); + +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 `workerJourneyReplace__` */; +/*!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 `workerJourneyReplace__`(vFromDate DATE, vToDate DATE, vUserFk INT) BEGIN /* Actualiza la tabla workerJourney para que actue como caché permanente revisable de las jornadas laborales. @@ -79906,185 +81725,212 @@ 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 `workerJourneyReplaceLauncher` */; +/*!50003 DROP PROCEDURE IF EXISTS `workerJourney_replace` */; /*!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 `workerJourneyReplaceLauncher`() +CREATE DEFINER=`root`@`%` PROCEDURE `workerJourney_replace`(vDatedFrom DATE, vDatedTo DATE, vWorkerFk INT) BEGIN +/** + * Actualiza la tabla workerJourney para que actue como caché permanente revisable de las jornadas laborales. + * @param vDatedFrom workerTimeControl + * @param vDatedTo workerTimeControl + * @param vWorkerFk, en caso de pasar 0 ó NULL se aplica a todos + */ + + DECLARE vDatedTimeTo DATETIME; + DECLARE vMinHoursToBreak DECIMAL(10,2); + DECLARE vBreakHours DECIMAL(10,2); + DECLARE vMonthByYear INT; + DECLARE vWeeksByYear INT DEFAULT 52; + DECLARE vMonthsByYear INT DEFAULT 12; + DECLARE vDaysByWeek INT DEFAULT 5; - DECLARE vDateStart DATE; - DECLARE vDateEnd DATE; - - SET vDateStart = TIMESTAMPADD(MONTH,-1,CURDATE()); - SET vDateEnd = util.yesterday(); - - CALL vn.workerJourneyReplace(vDateStart,vDateEnd,0); - -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 `workerJourney_Replace` */; -/*!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 `workerJourney_Replace`(vFromDate DATE, vToDate DATE, vUserFk INT) -BEGIN - /* Actualiza la tabla workerJourney para que actue como caché permanente revisable de las jornadas laborales. - * vUserFk es opcional. El valor 0 indica que se tenga en cuenta a todos los usuarios.8 - */ + SET vDatedTimeTo = util.dayEnd(vDatedTo); + SELECT minHoursToBreak, breakHours + INTO vMinHoursToBreak, vBreakHours + FROM workerTimeControlConfig; + DELETE FROM workerJourney - WHERE dated BETWEEN vFromDate AND vToDate - AND IFNULL(vUserFk, userFk) = userFk; - - IF vUserFk IS NULL THEN - CALL vn.timeControl_calculateAll( vFromDate , CONCAT(REPLACE(vToDate, '00:00:00', ''), ' 23:59:59')); - CALL vn.timeBusiness_calculateAll( vFromDate , CONCAT(REPLACE(vToDate, '00:00:00', ''), ' 23:59:59')); + WHERE dated BETWEEN vDatedFrom AND vDatedTo + AND NOT isPaid + AND NOT isUpdated + AND (vWorkerFk IS NULL OR userFK = vWorkerFk); + + -- Se inserta todos los días del periodo por worker y business en el rango de fechas. + INSERT IGNORE INTO workerJourney(userFk, dated, businessFk) + SELECT w.workerFk, t.dated, w.businessFk + FROM workerLabour w + JOIN time t ON t.dated BETWEEN w.started AND IFNULL(w.ended,CURDATE()) + WHERE t.dated BETWEEN vDatedFrom AND vDatedTo + AND (vWorkerFk IS NULL OR w.workerFk = vWorkerFk) + ORDER BY w.workerFk, t.dated, w.businessFk; + + IF vWorkerFk THEN + CALL timeControl_calculateByUser(vWorkerFk, vDatedFrom , vDatedTimeTo); ELSE - CALL vn.timeControl_calculateByUser( vUserFk, vFromDate , CONCAT(REPLACE(vToDate, '00:00:00', ''), ' 23:59:59')); - CALL vn.timeBusiness_calculateByUser( vUserFk, vFromDate , CONCAT(REPLACE(vToDate, '00:00:00', ''), ' 23:59:59')); + CALL timeControl_calculateAll(vDatedFrom, vDatedTimeTo); END IF; - -- Se inicia la tabla con todas las fechas posibles para cada uno de los trabajadores que han fichado en el rango de fechas. - INSERT IGNORE INTO workerJourney(userFk, dated, businessFk) - SELECT tbc.userFk, tbc.dated, tbc.businessFk - FROM tmp.timeBusinessCalculate tbc; - - -- Se actualiza la cantidad total de horas prácticas, así como el tiempo de almuerzo remunerado, si corresponde UPDATE workerJourney wj JOIN tmp.timeControlCalculate t ON wj.dated = t.dated AND wj.userFk = t.userFk - SET wj.total = CAST(IF(t.timeWorkDecimal >= 5.33,t.timeWorkDecimal-0.33,t.timeWorkDecimal) AS DECIMAL (10,2)), - wj.lunch = IF(t.timeWorkDecimal >= 5.33,0.33,0) - WHERE wj.dated BETWEEN vFromDate AND vToDate - AND wj.isPaid = FALSE - AND wj.isUpdated = FALSE - AND IFNULL(vUserFk, wj.userFk) = wj.userFk; - - DROP TEMPORARY TABLE tmp.timeControlCalculate; - - /********** NOCTURNIDAD ************/ - DROP TEMPORARY TABLE IF EXISTS tmp.workerTimeControl; - + SET wj.total = CAST(IF(t.timeWorkDecimal >= vMinHoursToBreak, t.timeWorkDecimal - vBreakHours, t.timeWorkDecimal) AS DECIMAL (10,2)), + wj.lunch = IF(t.timeWorkDecimal >= vMinHoursToBreak , vBreakHours , 0) + WHERE wj.dated BETWEEN vDatedFrom AND vDatedTo + AND NOT wj.isPaid + AND NOT wj.isUpdated + AND (vWorkerFk IS NULL OR wj.userFk = vWorkerFk); + + -- NOCTURNIDAD + DROP TEMPORARY TABLE IF EXISTS tmp.workerTimeControl; CREATE TEMPORARY TABLE tmp.workerTimeControl - SELECT w.*, 0 as Non - FROM vn.workerTimeControl w - WHERE timed BETWEEN vFromDate AND vToDate - AND IFNULL(vUserFk, userFk) = userFk - ORDER BY userFk, timed; - - -- Regalamos un segundo para evitar que hayan fichadas en las horas claves de inicio y fin de la nocturnidad. - UPDATE tmp.workerTimeControl - SET timed = TIMESTAMPADD(SECOND,-1,timed) - WHERE TIME(timed) IN ('06:00:00','22:00:00'); - - -- Fichada virtual a las 6:00 h, hora en que empieza la jornada diurna - INSERT INTO tmp.workerTimeControl(userFk, timed) - SELECT userFk, TIMESTAMPADD(HOUR, 6, DATE(timed)) - FROM vn.workerTimeControl - WHERE IFNULL(vUserFk, userFk) = userFk - GROUP BY userFk, DATE(timed); - - -- Fichada virtual a las 22:00 h, momento en que empieza la jornada nocturna. - INSERT INTO tmp.workerTimeControl(userFk, timed) - SELECT userFk, TIMESTAMPADD(HOUR, 22, DATE(timed)) - FROM vn.workerTimeControl - WHERE IFNULL(vUserFk, userFk) = userFk - GROUP BY userFk, DATE(timed); - + SELECT sub.userFk, sub.timed, sub.order, 0 Non, FALSE manual + FROM (SELECT w.userFk, + IF(TIME(w.timed) IN ('06:00:00','22:00:00'), TIMESTAMPADD(SECOND, -1, w.timed), w.timed) timed, -- Regalamos un segundo para evitar que hayan fichadas en las horas claves de inicio y fin de la nocturnidad. + w.`order` + FROM workerTimeControl w + WHERE w.timed BETWEEN vDatedFrom AND vDatedTo + AND w.userFk = IFNULL(vWorkerFk, w.userFk) + UNION ALL + SELECT w.userFk, + TIMESTAMPADD(HOUR, 6, DATE(w.timed)), + w.`order` + FROM workerTimeControl w + WHERE w.timed BETWEEN vDatedFrom AND vDatedTo + AND w.userFk = IFNULL(vWorkerFk, w.userFk) + GROUP BY w.userFk, DATE(w.timed) + UNION ALL + SELECT w.userFk, + TIMESTAMPADD(HOUR, 22, DATE(w.timed)), + w.order + FROM workerTimeControl w + WHERE w.timed BETWEEN vDatedFrom AND vDatedTo + AND w.userFk = IFNULL(vWorkerFk, w.userFk) + GROUP BY w.userFk, DATE(w.timed) + ) sub + ORDER BY sub.userFk, sub.timed; + -- Establece el orden en que se han de leer las fichadas - CALL vn.workerTimeControlSetOrder; + CALL workerTimeControlSetOrder(); -- Marca los impares para facilitar la consulta siguiente UPDATE tmp.workerTimeControl SET Non = 1 WHERE `order` mod 2; - + -- Actualizamos la nocturnidad UPDATE workerJourney wj - JOIN - (SELECT userFk, Dia, sum(Nocturnidad) as Nocturnidad FROM - (SELECT userFk, - date(timed) as Dia, - ((IF( TIME(timed) < '06:00:00' OR (TIME(timed) = '06:00:00' AND Non = FALSE ) , IF(Non,-1,1),0) - +IF(TIME(timed) > '22:00:00' OR (TIME(timed) = '22:00:00' AND Non = TRUE), If(Non,-1,1),0) - )* (HOUR(`timed`) + MINUTE(`timed`) / 60) - ) as Nocturnidad - FROM tmp.workerTimeControl - ) sub - GROUP BY Dia, userFk - HAVING Nocturnidad - ) night ON night.userFk = wj.userFk AND night.Dia = wj.dated + JOIN(SELECT userFk, Dia, sum(Nocturnidad) Nocturnidad FROM + (SELECT userFk, + date(timed) Dia, + ((IF( TIME(timed) < '06:00:00' OR (TIME(timed) = '06:00:00' AND Non = FALSE ) , IF(Non,-1,1),0) + + + IF(TIME(timed) > '22:00:00' OR (TIME(timed) = '22:00:00' AND Non = TRUE), If(Non,-1,1),0)) + * (HOUR(`timed`) + MINUTE(`timed`) / 60) + ) Nocturnidad + FROM tmp.workerTimeControl + ) sub + GROUP BY Dia, userFk + HAVING Nocturnidad + ) night ON night.userFk = wj.userFk AND night.Dia = wj.dated SET wj.nocturn = night.Nocturnidad - WHERE wj.isPaid = FALSE AND isUpdated = FALSE; + WHERE NOT wj.isPaid + AND NOT isUpdated; + + + -- Horas téoricas y precio de la hora ordinaria + UPDATE workerJourney wj + JOIN postgresql.business_labour_payroll blp ON blp.business_id = wj.businessFk + JOIN postgresql.business_labour bl ON bl.business_id = wj.businessFk + JOIN postgresql.calendar_labour_type cl ON cl.calendar_labour_type_id = bl.calendar_labour_type_id + SET wj.priceOrdinaryHour = (vMonthsByYear * blp.importepactado) / (vWeeksByYear * cl.hours_week), + wj.contractJourney = cl.hours_week / vDaysByWeek + WHERE wj.dated BETWEEN vDatedFrom AND vDatedTo + AND (vWorkerFk IS NULL OR wj.userFk = vWorkerFk) + AND NOT wj.isPaid + AND NOT isUpdated; + -- Precio Extras, Vacaciones y Nocturnas + UPDATE workerJourney wj + JOIN(SELECT MAX(w.dated), t.dated, w.holidayInc, w.nightInc, w.extraInc + FROM time t + JOIN workerHourPrice w ON w.dated <= t.dated + WHERE t.dated BETWEEN vDatedFrom AND vDatedTo + GROUP BY t.dated + ) sub ON sub.dated = wj.dated + SET wj.priceHolidayHour = wj.priceOrdinaryHour * sub.holidayInc, + wj.priceNocturnHour = wj.priceOrdinaryHour * sub.nightInc, + wj.priceExtraHour = wj.priceOrdinaryHour * sub.extraInc + WHERE wj.dated BETWEEN vDatedFrom AND vDatedTo + AND (vWorkerFk IS NULL OR wj.userFk = vWorkerFk) + AND NOT wj.isPaid + AND NOT wj.isUpdated; - -- Precios de hora ordinaria, Extras, Vacaciones y Nocturnas - -- Falta importe pactado en el procedimiento ¿? - UPDATE vn.workerJourney wj - JOIN postgresql.business_labour_payroll blp ON blp.business_id = wj.businessFk - JOIN postgresql.business_labour bl ON bl.business_id = wj.businessFk - JOIN postgresql.calendar_labour_type pclt ON pclt.calendar_labour_type_id = bl.calendar_labour_type_id - JOIN (SELECT dated, hollidayInc, nightInc, extraInc - FROM ( SELECT tm.dated , hollidayInc, nightInc, extraInc - FROM vn.time tm - JOIN vn.workerHourPrice whp ON tm.dated >= whp.dated - ORDER BY tm.dated, whp.dated DESC - ) sub - GROUP BY dated - ) conv ON conv.dated = wj.dated - SET - wj.priceOrdinaryHour = @priceOrdinaryHour := FORMAT((12 * blp.importepactado) / (52 * pclt.hours_week),2), - wj.priceHollydayHour = @priceOrdinaryHour * conv.hollidayInc, - wj.priceNocturnHour = @priceOrdinaryHour * conv.nightInc, - wj.priceExtraHour = @priceOrdinaryHour * conv.extraInc - WHERE wj.dated BETWEEN vFromDate AND vToDate - AND IFNULL(vUserFk, userFk) = userFk - AND wj.isPaid = FALSE - AND isUpdated = FALSE; + -- Elimina el precio de las horas extras para los contratos parciales. + UPDATE workerJourney wj + JOIN postgresql.business_labour bl ON bl.business_id = wj.businessFk + JOIN postgresql.calendar_labour_type cl ON cl.calendar_labour_type_id = bl.calendar_labour_type_id + SET wj.priceExtraHour = 0 + WHERE cl.isPartial + AND wj.dated BETWEEN vDatedFrom AND vDatedTo + AND (vWorkerFk IS NULL OR wj.userFk = vWorkerFk) + AND NOT wj.isPaid + AND NOT wj.isUpdated; - -- Horas téoricas bajas, vacaciones y festivos personales - UPDATE vn.workerJourney wj - JOIN tmp.timeBusinessCalculate b ON b.dated = wj.dated AND b.userFk = wj.userFk - SET wj.permission = b.timeBusinessDecimal * b.permissionRate, - wj.contractJourney = b.timeWorkDecimal - WHERE wj.dated BETWEEN vFromDate AND vToDate - AND IFNULL(vUserFk, wj.userFk) = wj.userFk - AND wj.isPaid = FALSE - AND wj.isUpdated = FALSE; + -- Bajas, vacaciones y festivos personales + UPDATE workerJourney wj + JOIN businessCalendar bc ON bc.businessFk = wj.businessFk AND bc.dated = wj.dated + JOIN absenceType ab ON ab.id = bc.absenceTypeFk + JOIN postgresql.business_labour bl ON bl.business_id = wj.businessFk + SET wj.permission = ab.permissionRate * wj.contractJourney, + wj.contractJourney = IF(ab.permissionRate = 1, 0, ab.permissionRate) * wj.contractJourney, + wj.holiday = wj.total - IF(ab.permissionRate = 1, 0, ab.permissionRate) * wj.contractJourney + WHERE ab.permissionRate > 0 + AND wj.dated BETWEEN vDatedFrom AND vDatedTo + AND (vWorkerFk IS NULL OR wj.userFk = vWorkerFk) + AND NOT wj.isPaid + AND NOT wj.isUpdated; + + -- Festivos por centro de trabajo + UPDATE workerJourney wj + JOIN calendarHolidays ch ON ch.dated = wj.dated + JOIN postgresql.business_labour bl ON bl.business_id = wj.businessFk + AND bl.workcenter_id = ch.workcenterFk + SET wj.holiday = wj.total, + wj.permission = wj.contractJourney, + wj.contractJourney = 0 + WHERE wj.dated BETWEEN vDatedFrom AND vDatedTo + AND (vWorkerFk IS NULL OR wj.userFk = vWorkerFk) + AND NOT wj.isPaid + AND NOT wj.isUpdated; + + -- Sábados / Domingos + UPDATE workerJourney + SET holiday = total, + contractJourney = 0 + WHERE DAYNAME(dated) IN ('sábado', 'domingo') + AND dated BETWEEN vDatedFrom AND vDatedTo + AND (vWorkerFk IS NULL OR userFk = vWorkerFk) + AND NOT isPaid + AND NOT isUpdated; - UPDATE vn.workerJourney wj - JOIN tmp.timeBusinessCalculate b ON b.dated = wj.dated AND b.userFk = wj.userFk - SET wj.hollyday = wj.total - b.timeWorkDecimal - WHERE wj.dated BETWEEN vFromDate AND vToDate - AND IFNULL(vUserFk, wj.userFk) = wj.userFk - AND wj.isPaid = FALSE - AND wj.isUpdated = FALSE - AND b.permissionRate > 0 ; - -- Horas extras - UPDATE workerJourney - SET extra = lunch + total - contractJourney - WHERE dated BETWEEN vFromDate AND vToDate - AND IFNULL(vUserFk, userFk) = userFk - AND isPaid = FALSE - AND isUpdated = FALSE; - + UPDATE workerJourney + SET extra = lunch + total - contractJourney + WHERE dated BETWEEN vDatedFrom AND vDatedTo + AND (vWorkerFk IS NULL OR userFk = vWorkerFk) + AND NOT isPaid + AND NOT isUpdated; + + DROP TEMPORARY TABLE tmp.timeControlCalculate; + DROP TEMPORARY TABLE tmp.workerTimeControl; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -80130,6 +81976,49 @@ 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 `workerShelving_delete` */; +/*!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 `workerShelving_delete`(vWorkerFk INT, vBarcode VARCHAR(12)) +BEGIN +/* + * Borra de workerShelving el carro o etiqueta insertado por el trabajador + * @param vWorkerFk es id del trabajador + * @param vBarcode se puede pasar tanto el smarttag como el shelving + */ + DECLARE vIsShelvingFk BOOL; + + + SELECT COUNT(*) > 0 INTO vIsShelvingFk + FROM vn.shelving s + WHERE s.code = vBarcode COLLATE utf8_general_ci; + + + IF NOT vIsShelvingFk THEN + + SELECT st.shelvingFk INTO vBarcode + FROM vn.smartTag st + WHERE st.code = vBarcode COLLATE utf8_general_ci; + + END IF; + + DELETE FROM vn.workerShelving + WHERE shelvingFk = vBarcode COLLATE utf8_general_ci + AND workerFk = vWorkerFk ; + +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 `workerTimeControlAdd` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -80169,17 +82058,27 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControlNonDays`() BEGIN - - SELECT wtc.userFk, date(wtc.timed) as Fecha , COUNT(wtc.`order`) as maxOrder, c.name as worker, wb.code as Boss, CONCAT (au.name, "@verdnatura.es") AS bossMail - FROM workerTimeControl wtc - JOIN worker w ON w.userFk = wtc.userFk - LEFT JOIN worker wb ON wb.id = w.bossFk - JOIN client c ON c.id = wtc.userFk - LEFT JOIN account.user au ON au.id = wb.userFK - WHERE timed BETWEEN TIMESTAMPADD(YEAR,-5,CURDATE()) AND CURDATE() - GROUP BY userFk, date(timed) - HAVING maxOrder mod 2 = 1 - ORDER BY Boss; + SET @cont := 0; + SELECT sub2.userFk, sub2.dated as Fecha ,CONCAT (w.firstName," ", w.lastName) AS worker,au.name as Boss,d.name + FROM (SELECT userFk, + dated, + COUNT(*) cont2 + FROM (SELECT DATE(wtc.timed) dated, + userFk, + IFNULL(@cont, @cont := 0 ), + IF(direction = 'in', @cont:=@cont+1, true), + @cont cont + FROM vn.workerTimeControl wtc + WHERE wtc.timed BETWEEN TIMESTAMPADD(YEAR,-1,CURDATE()) AND CURDATE() + ORDER BY userFk, timed)sub + GROUP BY cont + HAVING cont2 mod 2 = 1)sub2 + JOIN worker w ON w.userFk = sub2.userFk + LEFT JOIN worker wb ON wb.id = w.bossFk + LEFT JOIN account.user au ON au.id = wb.userFK + LEFT JOIN vn.workerDepartment wd on wd.workerFk = w.id + LEFT JOIN vn.department d ON d.id = wd.departmentFk + ORDER BY Boss asc; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -80948,6 +82847,544 @@ 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_clockIn` */; +/*!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_clockIn`(vWorker INT, vTimed DATETIME, vDirection VARCHAR(10)) +BEGIN +/** + * Verifica si el empleado puede fichar + * @param vWorker Identificador del trabajador + * @param vTimed valor de la fichada, IF vTimed IS NULL vTimed = NOW() + * @param vDirection solo se pueden pasa los valores del campo workerTimeControl.direction ENUM('in', 'out', 'middle') + * @return Si todo es correcto, retorna el número de id la tabla workerTimeControl. Si hay algún problema, devuelve el mesaje a que se debe mostrar al usuario + * Solo retorna el primer problema, en caso de no ocurrir ningún error se añadirá fichada a la tabla vn.workerTimeControl + */ + DECLARE vLastIn DATETIME; + DECLARE vLastOut DATETIME; + DECLARE vNextIn DATETIME; + DECLARE vLastDirection VARCHAR(6); + DECLARE vNextDirection VARCHAR(6); + DECLARE vDayBreak INT; + DECLARE vShortWeekBreak INT; + DECLARE vLongWeekBreak INT; + DECLARE vWeekScope INT; + DECLARE vGap INT; + DECLARE vMailTo VARCHAR(50) DEFAULT NULL; + DECLARE vUserName VARCHAR(50) DEFAULT NULL; + DECLARE vIsError BOOLEAN DEFAULT FALSE; + DECLARE vErrorMessage VARCHAR(255) DEFAULT NULL; + DECLARE vErrorCode VARCHAR(50); + DECLARE vDated DATE; + DECLARE vIsAllowedToWork VARCHAR(50); + DECLARE vDepartmentFk INT; + DECLARE vTimedLoop INT; + DECLARE vTimedLoopPrevious INT; + DECLARE vHasBreakWeek BOOLEAN DEFAULT FALSE; + DECLARE vManual BOOLEAN DEFAULT TRUE; + DECLARE vDone INT DEFAULT FALSE; + + DECLARE vCursor CURSOR FOR + SELECT UNIX_TIMESTAMP(NOW() - INTERVAL vGap SECOND) + UNION + SELECT UNIX_TIMESTAMP(NOW()) + UNION + (SELECT UNIX_TIMESTAMP(timed) + FROM workerTimeControl + WHERE timed BETWEEN (vTimed - INTERVAL vGap SECOND) AND vTimed AND + userFk = vWorker AND + direction IN ('in', 'out') + ORDER BY timed ASC); + + DECLARE vCursor2 CURSOR FOR + SELECT UNIX_TIMESTAMP(NOW() - INTERVAL vGap SECOND) + UNION + SELECT UNIX_TIMESTAMP(NOW()) + UNION + SELECT UNIX_TIMESTAMP(timed) + FROM workerTimeControl + WHERE timed BETWEEN vTimed AND (vTimed - INTERVAL vGap SECOND) AND + userFk = vWorker AND + direction IN ('in', 'out') + ORDER BY timed ASC; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + DECLARE EXIT HANDLER FOR SQLSTATE '45000' + BEGIN + + SELECT email, CONCAT(w.firstName, ' ', w.lastName) + INTO vMailTo, vUserName + FROM account.user u + JOIN worker w ON w.bossFk = u.id + WHERE w.id = vWorker; + + CASE vErrorCode + WHEN 'IS_NOT_ALLOWED_FUTURE' THEN + SELECT 'No se permite fichar a futuro' INTO vErrorMessage; + WHEN 'INACTIVE_BUSINESS' THEN + SELECT 'No hay un contrato en vigor' INTO vErrorMessage; + WHEN 'IS_NOT_ALLOWED_WORK' THEN + SELECT 'No está permitido trabajar' INTO vErrorMessage; + WHEN 'ODD_WORKERTIMECONTROL' THEN + SELECT 'Fichadas impares' INTO vErrorMessage; + WHEN 'BREAK_DAY' THEN + SELECT CONCAT('Descanso diario ', FORMAT(vDayBreak/3600, 0) , 'h.') INTO vErrorMessage; + WHEN 'BREAK_WEEK' THEN + SELECT CONCAT('Descanso semanal ', + FORMAT(vShortWeekBreak / 3600,0) ,'h. / ', + FORMAT(vLongWeekBreak / 3600, 0) ,'h.') INTO vErrorMessage; + WHEN 'WRONG_DIRECTION' THEN + SELECT 'Dirección incorrecta' INTO vErrorMessage; + ELSE + SELECT 'Error sin definir'INTO vErrorMessage; + END CASE; + + SELECT vErrorMessage `error`; + SELECT CONCAT(vUserName, ' no ha podido fichar por el siguiente problema: ', vErrorMessage) INTO vErrorMessage; + CALL mail_insert( vMailTo, vMailTo, 'Error al fichar', vErrorMessage); + + END; + + IF (vTimed IS NULL) THEN + SET vTimed = NOW(); + SET vManual = FALSE; + END IF; + + SET vDated = DATE(vTimed); + + SELECT IF(pc.category_name = 'Conductor +3500kg', wc.dayBreakDriver, wc.dayBreak), + wc.shortWeekBreak, + wc.longWeekBreak, + wc.weekScope + INTO vDayBreak, + vShortWeekBreak, + vLongWeekBreak, + vWeekScope + FROM workerLabour w + JOIN postgresql.business_labour bl ON bl.business_id = w.businessFk + JOIN postgresql.professional_category pc ON pc.professional_category_id = bl.professional_category_id + JOIN workerTimeControlConfig wc ON TRUE + WHERE w.workerFk = vWorker + AND vDated BETWEEN w.started AND IFNULL(w.ended, vDated); + + SELECT timed INTO vLastIn + FROM workerTimeControl + WHERE userFk = vWorker + AND direction = 'in' + AND timed < vTimed + ORDER BY timed DESC + LIMIT 1; + + SELECT timed INTO vLastOut + FROM workerTimeControl + WHERE userFk = vWorker + AND direction = 'out' + AND timed < vTimed + ORDER BY timed DESC + LIMIT 1; + + SELECT timed INTO vNextIn + FROM workerTimeControl + WHERE userFk = vWorker + AND direction = 'in' + AND timed > vTimed + ORDER BY timed ASC + LIMIT 1; + + SELECT direction INTO vNextDirection + FROM workerTimeControl + WHERE userFk = vWorker + AND timed > vTimed + ORDER BY timed ASC + LIMIT 1; + + SELECT direction INTO vLastDirection + FROM workerTimeControl + WHERE userFk = vWorker + AND timed < vTimed + ORDER BY timed DESC + LIMIT 1; + + -- FICHADAS A FUTURO + IF vTimed > DATE_ADD(NOW(), INTERVAL 60 SECOND) THEN + SET vErrorCode = 'IS_NOT_ALLOWED_FUTURE'; + CALL util.throw(vErrorCode); + END IF; + + -- CONTRATO EN VIGOR + IF vDayBreak IS NULL THEN + SET vErrorCode = 'INACTIVE_BUSINESS'; + CALL util.throw(vErrorCode); + END IF; + + -- VERIFICAR SI ESTÁ PERMITIDO TRABAJAR + CALL timeBusiness_calculateByWorker(vWorker, vDated, vDated); + SELECT isAllowedToWork INTO vIsAllowedToWork + FROM tmp.timeBusinessCalculate; + DROP TEMPORARY TABLE tmp.timeBusinessCalculate; + + IF NOT vIsAllowedToWork THEN + SET vErrorCode = 'IS_NOT_ALLOWED_WORK'; + CALL util.throw(vErrorCode); + END IF; + + -- DIRECCION CORRECTA + CALL vn.workerTimeControl_direction(vWorker, vTimed); + IF (SELECT IF(IF(option1 IN ('inMiddle', 'outMiddle'), 'middle', option1) <> vDirection + AND IF(option2 IN ('inMiddle', 'outMiddle'), 'middle', IFNULL(option2, '')) <> vDirection, TRUE , FALSE) + FROM tmp.workerTimeControlDirection) THEN + SET vIsError = TRUE; + END IF; + + DROP TEMPORARY TABLE tmp.workerTimeControlDirection; + IF vIsError = TRUE THEN + SET vErrorCode = 'WRONG_DIRECTION'; + CALL util.throw(vErrorCode); + END IF; + + -- FICHADAS IMPARES + IF (SELECT IF(vDirection = 'in', MOD(COUNT(*), 2) , IF (vDirection = 'out', NOT MOD(COUNT(*), 2), FALSE)) + FROM workerTimeControl + WHERE userFk = vWorker + AND timed BETWEEN vLastIn AND vTimed + ) THEN + SET vErrorCode = 'ODD_WORKERTIMECONTROL'; + CALL util.throw(vErrorCode); + END IF; + + -- DESCANSO DIARIO + CASE vDirection + WHEN 'in' THEN + IF UNIX_TIMESTAMP(vTimed) - UNIX_TIMESTAMP(vLastOut) <= vDayBreak THEN + SET vIsError = TRUE; + END IF; + WHEN 'out' THEN + IF UNIX_TIMESTAMP(vNextIn) - UNIX_TIMESTAMP(vTimed) <= vDayBreak THEN + SET vIsError = TRUE; + END IF; + ELSE BEGIN END; + END CASE; + + IF vIsError THEN + SET vErrorCode = 'BREAK_DAY'; + CALL util.throw(vErrorCode); + END IF; + + -- VERIFICAR DESCANSO SEMANAL + IF (vDirection IN('in', 'out')) THEN + -- VERIFICA DESCANSO CORTO EN LA ÚLTIMA SEMANA + SET vGap = vWeekScope; + SET vTimedLoopPrevious = UNIX_TIMESTAMP((vTimed - INTERVAL vGap SECOND)); + SET vDone = FALSE; + OPEN vCursor; + l:LOOP + FETCH vCursor INTO vTimedLoop; + IF vDone THEN + LEAVE l; + END IF; + IF vShortWeekBreak - (vTimedLoop - vTimedLoopPrevious) < 0 THEN + SET vHasBreakWeek = TRUE; + LEAVE l; + END IF; + SET vTimedLoopPrevious = vTimedLoop; + END LOOP l; + CLOSE vCursor; + -- VERIFICA DESCANSO LARGO EN LA ÚLTIMAS 2 SEMANAS + IF NOT vHasBreakWeek THEN + SET vGap = vWeekScope * 2; + SET vTimedLoopPrevious = UNIX_TIMESTAMP((vTimed - INTERVAL vGap SECOND)); + SET vDone = FALSE; + OPEN vCursor; + l:LOOP + FETCH vCursor INTO vTimedLoop; + IF vDone THEN + LEAVE l; + END IF; + IF vLongWeekBreak - (vTimedLoop - vTimedLoopPrevious) < 0 THEN + SET vHasBreakWeek = TRUE; + LEAVE l; + END IF; + SET vTimedLoopPrevious = vTimedLoop; + END LOOP l; + CLOSE vCursor; + END IF; + + IF vManual THEN + -- VERIFICA DESCANSO CORTO EN LA PRÓXIMA SEMANA + SET vGap = vWeekScope; + SET vTimedLoopPrevious = vTimed; + SET vDone = FALSE; + OPEN vCursor; + l:LOOP + FETCH vCursor INTO vTimedLoop; + IF vDone THEN + LEAVE l; + END IF; + IF vShortWeekBreak - (vTimedLoop - vTimedLoopPrevious) < 0 THEN + SET vHasBreakWeek = TRUE; + LEAVE l; + END IF; + SET vTimedLoopPrevious = vTimedLoop; + END LOOP l; + CLOSE vCursor; + -- VERIFICA DESCANSO LARGO EN LAS PRÓXIMAS 2 SEMANAS + IF NOT vHasBreakWeek THEN + SET vGap = vWeekScope * 2; + SET vTimedLoopPrevious = vTimed; + SET vDone = FALSE; + OPEN vCursor; + l:LOOP + FETCH vCursor INTO vTimedLoop; + IF vDone THEN + LEAVE l; + END IF; + IF vShortWeekBreak - (vTimedLoop - vTimedLoopPrevious) < 0 THEN + SET vHasBreakWeek = TRUE; + LEAVE l; + END IF; + SET vTimedLoopPrevious = vTimedLoop; + END LOOP l; + CLOSE vCursor; + END IF; + END IF; + IF NOT vHasBreakWeek THEN + SET vErrorCode = 'BREAK_WEEK'; + CALL util.throw(vErrorCode); + END IF; + END IF; + + -- SE PERMITE FICHAR + INSERT INTO workerTimeControl(userFk, timed, direction, manual) + VALUES(vWorker, vTimed, vDirection, vManual); + + SELECT LAST_INSERT_ID() id; +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_direction` */; +/*!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_direction`(vWorkerFk VARCHAR(10), vTimed DATETIME) +BEGIN +/** + * Devuelve que direcciones de fichadas son lógicas a partir de la anterior fichada + * @param vWorkerFk Identificador del trabajador + * @return (option1, option2) + * Los valores posibles de retorno son ('in', 'inMiddle', 'outMiddle', 'out') + */ + DECLARE vLastIn DATETIME ; + DECLARE vIsMiddleOdd BOOLEAN ; + + IF (vTimed IS NULL) THEN + SET vTimed = NOW(); + END IF; + + SELECT timed INTO vLastIn + FROM workerTimeControl + WHERE userFk = vWorkerFk + AND direction = 'in' + AND timed < vTimed + ORDER BY timed DESC + LIMIT 1; + + SELECT (COUNT(*)mod 2 = 1) INTO vIsMiddleOdd + FROM workerTimeControl + WHERE userFk = vWorkerFk + AND direction = 'middle' + AND timed BETWEEN vLastIn AND NOW(); + + DROP TEMPORARY TABLE IF EXISTS tmp.workerTimeControlDirection; + + CREATE TEMPORARY TABLE tmp.workerTimeControlDirection + SELECT CASE WHEN w.direction ='in' THEN 'inMiddle' + WHEN w.direction = 'out' THEN 'in' + WHEN w.direction = 'middle' AND vIsMiddleOdd THEN 'outMiddle' + WHEN w.direction IS NULL THEN 'in' + ELSE 'inMiddle' + END option1, + CASE WHEN w.direction ='in' THEN 'out' + WHEN w.direction = 'out' THEN NULL + WHEN w.direction = 'middle' AND vIsMiddleOdd THEN NULL + WHEN w.direction IS NULL THEN NULL + ELSE 'out' + END option2 + FROM workerTimeControl w + WHERE w.timed <= vTimed + AND w.userFk = vWorkerFk + ORDER BY w.timed DESC + LIMIT 1; + + IF (SELECT IF(COUNT(*)=0, TRUE, FALSE) FROM tmp.workerTimeControlDirection ) THEN + INSERT INTO tmp.workerTimeControlDirection (option1, option2) + VALUES('in', NULL); + 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_getClockIn` */; +/*!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_getClockIn`(vUserFk INT, vDated DATE) +BEGIN + +/** + * Muestra una tabla con los 7 días inmediatamente anteriores a la fecha proporcionada + * y las fichadas de cada dia, en columnas por día + * + */ + + CALL workerTimeControl_setOrder(vUserFk,TIMESTAMPADD(DAY,-8,vDated),vDated); + + DROP TEMPORARY TABLE IF EXISTS tmp.workerWeekTiming; + CREATE TEMPORARY TABLE tmp.workerWeekTiming + SELECT orden `orden`, + max(hace7dias) 7_dias_antes, + max(hace6dias) 6_dias_antes, + max(hace5dias) 5_dias_antes, + max(hace4dias) 4_dias_antes, + max(hace3dias) 3_dias_antes, + max(antesdeayer) 2_dias_antes, + max(ayer) 1_dia_antes, + max(hoy) mismo_dia + FROM + ( + SELECT IF(dias = 7, fichada, '') as hace7dias, + IF(dias = 6, fichada, '') as hace6dias, + IF(dias = 5, fichada, '') as hace5dias, + IF(dias = 4, fichada, '') as hace4dias, + IF(dias = 3, fichada, '') as hace3dias, + IF(dias = 2, fichada, '') as antesdeayer, + IF(dias = 1, fichada, '') as ayer, + IF(dias = 0, fichada, '') as hoy, + orden + + FROM + ( + SELECT `order` as orden, datediff(vDated, timed) as dias, date(timed) as fecha, TIME_FORMAT(timed,'%H:%i') as fichada + FROM vn.workerTimeControl wtc + WHERE userFk = vUserFk + AND timed >= TIMESTAMPADD(DAY, -7, vDated) + ) sub + )sub2 + GROUP BY orden; + + DROP TEMPORARY TABLE IF EXISTS tmp.workerWeekTiming_Aux; + CREATE TEMPORARY TABLE tmp.workerWeekTiming_Aux + SELECT * FROM tmp.workerWeekTiming; + + INSERT INTO tmp.workerWeekTiming( 7_dias_antes, 6_dias_antes, 5_dias_antes, 4_dias_antes, 3_dias_antes, 2_dias_antes, 1_dia_antes, mismo_dia) + VALUES('total','','','','','','',''); + + INSERT INTO tmp.workerWeekTiming( orden, 7_dias_antes, 6_dias_antes, 5_dias_antes, 4_dias_antes, 3_dias_antes, 2_dias_antes, 1_dia_antes, mismo_dia) + SELECT 0, + IFNULL(DATE_FORMAT(SEC_TO_TIME(SUM(IF(orden MOD 2, - TIME_TO_SEC(7_dias_antes), TIME_TO_SEC(7_dias_antes)))),'%H:%i'),''), + IFNULL(DATE_FORMAT(SEC_TO_TIME(SUM(IF(orden MOD 2, - TIME_TO_SEC(6_dias_antes), TIME_TO_SEC(6_dias_antes)))),'%H:%i'),''), + IFNULL(DATE_FORMAT(SEC_TO_TIME(SUM(IF(orden MOD 2, - TIME_TO_SEC(5_dias_antes), TIME_TO_SEC(5_dias_antes)))),'%H:%i'),''), + IFNULL(DATE_FORMAT(SEC_TO_TIME(SUM(IF(orden MOD 2, - TIME_TO_SEC(4_dias_antes), TIME_TO_SEC(4_dias_antes)))),'%H:%i'),''), + IFNULL(DATE_FORMAT(SEC_TO_TIME(SUM(IF(orden MOD 2, - TIME_TO_SEC(3_dias_antes), TIME_TO_SEC(3_dias_antes)))),'%H:%i'),''), + IFNULL(DATE_FORMAT(SEC_TO_TIME(SUM(IF(orden MOD 2, - TIME_TO_SEC(2_dias_antes), TIME_TO_SEC(2_dias_antes)))),'%H:%i'),''), + IFNULL(DATE_FORMAT(SEC_TO_TIME(SUM(IF(orden MOD 2, - TIME_TO_SEC(1_dia_antes), TIME_TO_SEC(1_dia_antes)))),'%H:%i'),''), + '' + FROM tmp.workerWeekTiming_Aux; + + INSERT INTO tmp.workerWeekTiming_Aux( orden, 1_dia_antes) + SELECT 0, ROUND(( + IFNULL(TIME_TO_SEC(7_dias_antes),0) + + IFNULL(TIME_TO_SEC(6_dias_antes),0) + + IFNULL(TIME_TO_SEC(5_dias_antes),0) + + IFNULL(TIME_TO_SEC(4_dias_antes),0) + + IFNULL(TIME_TO_SEC(3_dias_antes),0) + + IFNULL(TIME_TO_SEC(2_dias_antes),0) + + IFNULL(TIME_TO_SEC(1_dia_antes),0) + ) / 3600,1) + FROM tmp.workerWeekTiming + WHERE orden = 0; + + + INSERT INTO tmp.workerWeekTiming( 7_dias_antes,6_dias_antes,5_dias_antes,4_dias_antes,3_dias_antes,2_dias_antes,1_dia_antes,mismo_dia) + SELECT '','','','','','',1_dia_antes,'' + FROM tmp.workerWeekTiming_Aux + WHERE orden = 0; + + SELECT 7_dias_antes, 6_dias_antes, 5_dias_antes, 4_dias_antes, 3_dias_antes, 2_dias_antes, 1_dia_antes, mismo_dia FROM tmp.workerWeekTiming; + + DROP TEMPORARY TABLE tmp.workerWeekTiming; + DROP TEMPORARY TABLE tmp.workerWeekTiming_Aux; + +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_login` */; +/*!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_login`(vWorkerFk VARCHAR(10)) +BEGIN +/** + * Consulta la información del usuario y los botones que tiene que activar en la tablet tras hacer login + * Solo retornará 1 ó 2 opciones de las 4 posibles + * @param vWorkerFk Identificador del trabajador + * @return (name, surname, userFk, departmentFk, button1, button2) + * Los valores posibles para button son ('in', 'inMiddle', 'outMiddle', 'out') + */ + CALL vn.workerTimeControl_direction(vWorkerFk, NOW()); + + SELECT wi.name, + wi.surname, + wi.userFk, + wi.departmentFk, + w.option1 button1, + w.option2 button2 + FROM workerTimeControlUserInfo wi + JOIN tmp.workerTimeControlDirection w + WHERE wi.userFk = vWorkerFk + LIMIT 1; + + DROP TEMPORARY TABLE tmp.workerTimeControlDirection; +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 */ ; @@ -81085,8 +83522,8 @@ BEGIN DECLARE vStarted VARCHAR(25); DECLARE vEnded VARCHAR(25); DECLARE vDone BOOL; - DECLARE vSender VARCHAR(255); - DECLARE vSenderOld VARCHAR(255); + DECLARE vReceiver VARCHAR(255); + DECLARE vReceiverOld VARCHAR(255); DECLARE vDated DATE; DECLARE vTimeWorkDecimal DECIMAL(5,2); DECLARE vTimeWorkSexagesimal VARCHAR(5); @@ -81171,9 +83608,9 @@ BEGIN SET vTimeWorkDecimalTotal = 0; SET vBody= ''; OPEN vCursor; - FETCH vCursor INTO vSender, vWorkerFk, vDated, vTimeWorkDecimal, vTimeWorkSexagesimal, vTimeTable, vTimeWorkedDecimal, vTimeWorkedSexagesimal, vAbsenceType, vBusinessFk, vPermissionRate, vIsTeleworking ; + FETCH vCursor INTO vReceiver, vWorkerFk, vDated, vTimeWorkDecimal, vTimeWorkSexagesimal, vTimeTable, vTimeWorkedDecimal, vTimeWorkedSexagesimal, vAbsenceType, vBusinessFk, vPermissionRate, vIsTeleworking ; SET vWorkerFkOld = vWorkerFk ; - SET vSenderOld = vSender; + SET vReceiverOld = vReceiver; SET vIsTeleworkingOld = vIsTeleworking; proc: LOOP IF vDone THEN @@ -81274,7 +83711,7 @@ proc: LOOP timed BETWEEN vDated AND CONCAT(vDated," 23:59:59"); SET vTimeWorkDecimalTotal = vTimeWorkDecimalTotal + IFNULL(vTimeWorkedDecimal, IF( IFNULL(vPermissionRate, TRUE), vTimeWorkDecimal, 0)); SET vDone = FALSE; - FETCH vCursor INTO vSender, vWorkerFk, vDated, vTimeWorkDecimal, vTimeWorkSexagesimal, vTimeTable, vTimeWorkedDecimal, vTimeWorkedSexagesimal, vAbsenceType, vBusinessFk, vPermissionRate, vIsTeleworking; + FETCH vCursor INTO vReceiver, vWorkerFk, vDated, vTimeWorkDecimal, vTimeWorkSexagesimal, vTimeTable, vTimeWorkedDecimal, vTimeWorkedSexagesimal, vAbsenceType, vBusinessFk, vPermissionRate, vIsTeleworking; IF vWorkerFk <> vWorkerFkOld OR vDone THEN SELECT CONCAT( IFNULL(nif, ''), ' - ', firstName, ' ', name ) INTO vWorkerInfo @@ -81310,11 +83747,12 @@ proc: LOOP "); IF vIsTeleworkingOld THEN - INSERT INTO mail(sender, replyto, subject, body) - VALUES (vSenderOld, - 'timecontrol@verdnatura.es', - CONCAT('Registro de horas semana ', vWeek, ' año ', vYear) , - CONCAT(vHeader, ' ' , vBody, ' ', vFooter)); + CALL mail_insert( + vReceiverOld, + 'timecontrol@verdnatura.es', + CONCAT('Registro de horas semana ', vWeek, ' año ', vYear) , + CONCAT(vHeader, ' ' , vBody, ' ', vFooter) + ); INSERT IGNORE INTO workerTimeControlMail (workerFk, year, week) VALUES(vWorkerFkOld, vYear, vWeek); @@ -81324,7 +83762,7 @@ proc: LOOP SET vTimeWorkDecimalTotal = 0; SET vWorkerFkOld = vWorkerFk; SET vIsTeleworkingOld = vIsTeleworking; - SET vSenderOld = vSender; + SET vReceiverOld = vReceiver; END IF; END LOOP; CLOSE vCursor; @@ -81339,7 +83777,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 `workerTimeControl_sendMail__` */; +/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_sendMailByDepartment` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -81347,265 +83785,184 @@ DELIMITER ; /*!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' */ ; +/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControl_sendMail__`(vWeek INT, vYear INT, vWorkerFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControl_sendMailByDepartment`(IN vWeek int, IN vYear int, IN vWorkerFk int) BEGIN -/** - * Inserta en la tabla vn.mail para notificar a los empleados que teletrabajan de las jornadas que se han registrado. - * Inserta fichadas en el casos que se determina que el empleado está realizando teletrabajo - * - * @param vWeek - * @param vYear - * @param vWorkerFk -> En el caso de querer generarlo para todos los empleados deberá de informarse como NULL - */ - DECLARE vStarted VARCHAR(25); - DECLARE vEnded VARCHAR(25); - DECLARE vDone BOOL; - DECLARE vSender VARCHAR(255); - DECLARE vSenderOld VARCHAR(255); - DECLARE vDated DATE; - DECLARE vTimeWorkDecimal DECIMAL(5,2); - DECLARE vTimeWorkSexagesimal VARCHAR(5); - DECLARE vTimeWorkedDecimal DECIMAL(5,2); - DECLARE vTimeWorkedSexagesimal VARCHAR(5); - DECLARE vTimeWorkDecimalTotal DECIMAL(5,2); - DECLARE vTimeTable VARCHAR(100); - DECLARE vTimeTableDecimal DECIMAL(5,2); - DECLARE vWorkerFkOld INTEGER; - DECLARE vBusinessFk INTEGER; - DECLARE vHeader TEXT; - DECLARE vBody TEXT; - DECLARE vFooter TEXT; - DECLARE vReturn INTEGER; - DECLARE vAbsenceType VARCHAR(50); - DECLARE vWorkerInfo VARCHAR(90); - - DECLARE vCursor CURSOR FOR - SELECT CONCAT(u.name, '@verdnatura.es'), u.id, tb.dated, tb.timeWorkDecimal, LEFT(tb.timeWorkSexagesimal,5) timeWorkSexagesimal, - tb.timeTable, tc.timeWorkDecimal timeWorkedDecimal, LEFT(tc.timeWorkSexagesimal,5) timeWorkedSexagesimal, tb.type, tb.businessFk - FROM tmp.timeBusinessCalculate tb - JOIN user u ON u.id = tb.userFk - JOIN department d ON d.id = tb.departmentFk - JOIN postgresql.business b ON b.business_id = tb.businessFk - JOIN company c ON c.id = b.provider_id - LEFT JOIN tmp.timeControlCalculate tc ON tc.userFk = tb.userFk AND tc.dated = tb.dated - JOIN (SELECT tb.userFk, - SUM(IF(tb.type IS NULL, - IF(tc.timeWorkDecimal > 0, FALSE, IF(tb.timeWorkDecimal > 0, TRUE, FALSE)), - TRUE))isTeleworkingWeek - FROM tmp.timeBusinessCalculate1 tb - LEFT JOIN tmp.timeControlCalculate1 tc ON tc.userFk = tb.userFk AND tc.dated = tb.dated - GROUP BY tb.userFk - HAVING isTeleworkingWeek > 0 - )sub ON sub.userFk = u.id - WHERE d.isTeleworking AND - IFNULL(vWorkerFk,u.id) = u.id AND - c.code = 'VNL' - ORDER BY u.id, tb.dated; - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - - DROP TABLE IF EXISTS tmp.timeControlCalculate; - DROP TABLE IF EXISTS tmp.timeBusinessCalculate; - DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate; - DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate; - DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate1; - DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate1; - - SELECT CONCAT (MIN(dated), ' 00:00:00'), CONCAT (MAX(dated), ' 23:59:59') INTO vStarted, vEnded - FROM time - WHERE year = vYear AND - week = vWeek; - - DELETE FROM workerTimeControl - WHERE IFNULL(vWorkerFk, userFk) = userFk AND - timed BETWEEN vStarted AND vEnded AND - isSendMail; - - UPDATE workerTimeControlMail - SET updated = NOW(), state = 'SENDED' - WHERE year = vYear AND - week = vWeek AND - IFNULL(vWorkerFk, workerFk) = workerFk ; - - IF vWorkerFk IS NULL THEN - CALL timeControl_calculateAll(vStarted,vEnded); - CALL timeBusiness_calculateAll(vStarted,vEnded); + /** + * Inserta el registro de horario semanalmente de PRODUCCION, CAMARA, TALLER NATURAL y TALLER ARTIFICIAL en vn.mail. + * + * @param vWeek + * @param vYear + * @param vWorkerFk -> En el caso de querer generarlo para todos los empleados deberá de informarse como NULL + */ + + /* + DECLARE vDateStart DATETIME; + DECLARE vDateEnd DATETIME; + + SELECT CONCAT (MIN(dated), ' 00:00:00'), CONCAT (MAX(dated), ' 23:59:59') INTO vDateStart, vDateEnd + FROM time + WHERE year = vYear AND + week = vWeek; + + SET session group_concat_max_len = 15000; + + DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate; + DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate; + DROP TEMPORARY TABLE IF EXISTS tmp.reportHours; + + IF vWorkerFk IS NULL THEN + CALL timeControl_calculateAll(vDateStart,vDateEnd); + CALL timeBusiness_calculateAll(vDateStart,vDateEnd); ELSE - CALL timeControl_calculateByUser(vWorkerFk,vStarted,vEnded); - CALL timeBusiness_calculateByUser(vWorkerFk,vStarted,vEnded); - END IF; - - CREATE TEMPORARY TABLE tmp.timeControlCalculate1 - SELECT * FROM tmp.timeControlCalculate; - CREATE TEMPORARY TABLE tmp.timeBusinessCalculate1 - SELECT * FROM tmp.timeBusinessCalculate; - - SET vTimeWorkDecimalTotal = 0; - SET vBody= ''; - OPEN vCursor; - FETCH vCursor INTO vSender, vWorkerFk, vDated, vTimeWorkDecimal, vTimeWorkSexagesimal, vTimeTable, vTimeWorkedDecimal, vTimeWorkedSexagesimal, vAbsenceType, vBusinessFk ; - SET vWorkerFkOld = vWorkerFk ; - SET vSenderOld = vSender; - proc: LOOP - IF vDone THEN - LEAVE proc; - END IF; + CALL timeControl_calculateByUser(vWorkerFk,vDateStart,vDateEnd); + CALL timeBusiness_calculateByUser(vWorkerFk,vDateStart,vDateEnd); + END IF; - IF vTimeTable IS NULL AND vTimeWorkDecimal>0 AND vTimeWorkedDecimal IS NULL THEN - INSERT INTO workerTimeControl (userFk, timed, manual, direction, isSendMail) - SELECT vWorkerFk, CONCAT(vDated,' 08:00'), TRUE, 'in', TRUE; - IF vTimeWorkDecimal >= 5 THEN - INSERT INTO workerTimeControl (userFk, timed, manual, direction, isSendMail) - SELECT vWorkerFk, CONCAT(vDated,' 09:00'), TRUE, 'middle', TRUE; - INSERT INTO workerTimeControl (userFk, timed, manual, direction, isSendMail) - SELECT vWorkerFk, CONCAT(vDated,' 09:20'), TRUE, 'middle', TRUE; - END IF; - INSERT INTO workerTimeControl (userFk, timed, manual, direction, isSendMail) - SELECT vWorkerFk,CONCAT(vDated,' ', LEFT (SEC_TO_TIME(28800 + (vTimeWorkDecimal * 3600)), 5)), TRUE, 'out', TRUE; - ELSEIF vTimeWorkDecimal>0 AND vTimeWorkedDecimal IS NULL THEN - SELECT SUM(TIME_TO_SEC(j.end)-TIME_TO_SEC(j.start))/3600 INTO vTimeTableDecimal - FROM postgresql.journey j - WHERE j.business_id = vBusinessFk AND - j.day_id = WEEKDAY(vDated)+1; - IF vTimeWorkDecimal = vTimeTableDecimal THEN - INSERT INTO workerTimeControl (userFk, timed, manual, isSendMail) - SELECT vWorkerFk, CONCAT(vDated, ' ', j.start), TRUE, TRUE - FROM postgresql.journey j - WHERE j.business_id = vBusinessFk AND - j.day_id = WEEKDAY(vDated)+1; - - INSERT INTO workerTimeControl (userFk, timed, manual, isSendMail) - SELECT vWorkerFk, CONCAT(vDated, ' ', j.end), TRUE, TRUE - FROM postgresql.journey j - WHERE j.business_id = vBusinessFk AND - j.day_id = WEEKDAY(vDated)+1; - ELSE - INSERT INTO workerTimeControl (userFk, timed, manual, isSendMail) - SELECT vWorkerFk, CONCAT(vDated, ' ', MIN(j.start)), TRUE, TRUE - FROM postgresql.journey j - WHERE j.business_id = vBusinessFk AND - j.day_id = WEEKDAY(vDated)+1; - INSERT INTO workerTimeControl (userFk, timed, manual, isSendMail) - SELECT vWorkerFk, CONCAT(vDated, ' ', SEC_TO_TIME(TIME_TO_SEC(MIN(j.start)) + (vTimeWorkDecimal * 3600))), TRUE, TRUE - FROM postgresql.journey j - WHERE j.business_id = vBusinessFk AND - j.day_id = WEEKDAY(vDated)+1; - END IF; - - IF vTimeWorkDecimal >= 5 THEN - INSERT INTO workerTimeControl (userFk, timed, manual, isSendMail) - SELECT vWorkerFk, CONCAT(vDated, ' ', SEC_TO_TIME(TIME_TO_SEC(MIN(j.start)) + 3600)), TRUE, TRUE - FROM postgresql.journey j - WHERE j.business_id = vBusinessFk AND - j.day_id = WEEKDAY(vDated)+1; - INSERT INTO workerTimeControl (userFk, timed, manual, isSendMail) - SELECT vWorkerFk, CONCAT(vDated, ' ', SEC_TO_TIME(TIME_TO_SEC(MIN(j.start)) + 4800)), TRUE, TRUE - FROM postgresql.journey j - WHERE j.business_id = vBusinessFk AND - j.day_id = WEEKDAY(vDated)+1; - END IF; - - UPDATE workerTimeControl wtc - JOIN (SELECT id FROM workerTimeControl - WHERE userFk = vWorkerFk AND - timed BETWEEN vDated AND CONCAT(vDated, ' 23:59:59') - ORDER BY timed ASC - LIMIT 1)sub on sub.id= wtc.id - SET direction = 'in' ; - - UPDATE workerTimeControl wtc - JOIN (SELECT id FROM workerTimeControl - WHERE userFk = vWorkerFk AND - timed BETWEEN vDated AND CONCAT(vDated, ' 23:59:59') - ORDER BY timed DESC - LIMIT 1)sub on sub.id= wtc.id - SET direction = 'out' ; - - END IF; + CREATE TEMPORARY TABLE tmp.reportHours + SELECT t.dated, + IF (tm.hoursWeek IS NULL,'', GROUP_CONCAT(DATE_FORMAT(wtc.timed,'%H:%i') ORDER BY wtc.timed ASC SEPARATOR ' ') ) timeWorkDay, + IFNULL(tm.timeWorkDecimal,0) tm, + IFNULL(CAST(tc.timeWorkDecimal AS DECIMAL (10,2)) , 0) tc, + IFNULL(CAST(IFNULL(tc.timeWorkDecimal, 0) - IFNULL(tm.timeWorkDecimal, 0) AS DECIMAL (10,2)), 0) balance, + w.lastName, + w.firstname, + c.fi, + w.id, + MONTHNAME(t.dated) mes, + YEAR(t.dated) año, + w.userFk, + tm.hoursWeek, + tm.type, + wl.started, + wl.ended, + d.name, + tm.businessFk + FROM time t + LEFT JOIN tmp.timeBusinessCalculate tm ON tm.dated = t.dated + LEFT JOIN tmp.timeControlCalculate tc ON tc.dated = tm.dated AND tc.userFk = tm.userFk + LEFT JOIN vn.workerTimeControl wtc ON wtc.userFk = tm.userFk AND DATE(wtc.timed) = t.dated + LEFT JOIN workerLabour wl ON wl.workerFk = tm.userFk AND wl.businessFk = tm.businessFk + LEFT JOIN workCenter wc ON wc.id = wl.workCenterFk + LEFT JOIN department d ON d.id = wl.departmentFk + LEFT JOIN worker w ON w.id = tm.userFk + LEFT JOIN client c ON c.id = w.id + WHERE wc.name NOT IN ('VNH') + AND d.hasToSendMail + AND wl.ended >= CURDATE() + GROUP BY tm.userFk,t.dated + ORDER BY tm.userFk,t.dated; - SELECT CONCAT(IFNULL(vBody,""), " - ", DATE_FORMAT(vDated, "%d/%m/%Y"), " - ", CASE WEEKDAY(vDated)+1 - WHEN 1 THEN 'Lunes' - WHEN 2 THEN 'Martes' - WHEN 3 THEN 'Miércoles' - WHEN 4 THEN 'Jueves' - WHEN 5 THEN 'Viernes' - WHEN 6 THEN 'Sábado' - WHEN 7 THEN 'Domingo' - END , " - ", IFNULL(GROUP_CONCAT(MID(timed, 12, 5) ORDER BY timed ASC SEPARATOR ' - '), " - ")," - ", IFNULL(vAbsenceType, IF (vTimeWorkedDecimal>0, "Presencial", IF(vTimeWorkDecimal>0, "Teletrabajo", " - "))), " - ", IFNULL(vTimeWorkedSexagesimal, vTimeWorkSexagesimal), " - ") INTO vBody - FROM workerTimeControl - WHERE userFk = vWorkerFk AND - timed BETWEEN vDated AND CONCAT(vDated," 23:59:59"); - SET vTimeWorkDecimalTotal = vTimeWorkDecimalTotal + IFNULL(vTimeWorkedDecimal, vTimeWorkDecimal); - SET vDone = FALSE; - FETCH vCursor INTO vSender, vWorkerFk, vDated, vTimeWorkDecimal, vTimeWorkSexagesimal, vTimeTable, vTimeWorkedDecimal, vTimeWorkedSexagesimal, vAbsenceType, vBusinessFk; + INSERT INTO vn.mail (receiver, replyTo, subject, body) + SELECT eu.email, 'laboral@verdnatura.es', CONCAT('Registro de horas semana ', WEEK(CURDATE())-1, ' año ', YEAR(CURDATE())) , + CONCAT(' + + - IF vWorkerFk <> vWorkerFkOld OR vDone THEN - SELECT CONCAT( IFNULL(nif, ''), ' - ', firstName, ' ', name ) INTO vWorkerInfo - FROM postgresql.person - WHERE id_trabajador = vWorkerFkOld; - SET vHeader = CONCAT("


-
-

", vWorkerInfo , "

- - - - - - - - - - - - "); + + + +
+

REGISTRO DE LA JORNADA DE LOS TRABAJADORES

+
- Según la información recogida en el sistema adjuntamos la tabla con los registros de las horas trabajadas en el período indicado. - Si está conforme tiene que contestar indicando únicamente la palabra OK, en caso contrario puede contestar detallando la causa de la disconformidad. - Rogamos nos conteste lo antes posible. -

-
FechaDíaFichadasDescripciónHoras
+ + + + + + + + + + + + + + + +
+ Según la información recogida en el sistema, adjuntamos tabla con los registros. Cualquier incidencia rogamos la comunique a laboral@verdnatura.es. +

+
Empresa: Verdnatura Levante SL
Trabajador: ',IFNULL(rh.firstname,' '),' ',IFNULL(rh.lastName,' '), ' NIF: ',IFNULL(rh.fi,' '), '
AÑO: ',IFNULL(rh.año,' '), ' MES: ',IFNULL(UPPER(rh.mes),' '), ' Calendario Laboral: ',IFNULL(rh.hoursWeek,' '),' horas semanales
+
+ + + + + + + + + ', + GROUP_CONCAT(DISTINCT '' ORDER BY rh.dated SEPARATOR ''), + ' + + + + + + +
Fecha:Día:Fichadas:Horas a trabajar:Horas trabajadas:Balance:
', DATE_FORMAT( rh.dated, '%d-%m-%y'), + ' ', CONCAT(UCASE(LEFT(DAYNAME(rh.dated), 1)), SUBSTRING(DAYNAME(rh.dated), 2)), + ' ', IFNULL(rh.timeWorkDay,' '),' ', IFNULL(rh.type,' '), + ' ', IF(rh.tm = 0,' ',rh.tm), + ' ', IF(rh.tc = 0,' ',rh.tc), + ' ', IF(rh.balance = 0,' ',rh.balance), '
Total horas trabajadas: ', SUM(rh.tc),'', SUM(rh.balance),'
+ ') + FROM tmp.reportHours rh + JOIN account.emailUser eu ON rh.id = eu.userFk + GROUP BY rh.id; + + DROP TEMPORARY TABLE tmp.timeControlCalculate; + DROP TEMPORARY TABLE tmp.timeBusinessCalculate; + DROP TEMPORARY TABLE tmp.reportHours; + */ 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_sendMail____` */; +/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_sendMailByDepartmentLauncher` */; +/*!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 = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControl_sendMailByDepartmentLauncher`() +BEGIN + /* No se ejecutará hasta nuevo aviso de Sandra. + DECLARE vWeek,vYear INT; + + IF (DAYNAME(CURDATE()) = 'miércoles') THEN + SELECT week,year INTO vWeek,vYear + FROM vn.time + WHERE dated IN (DATE_ADD(CURDATE(), INTERVAL -10 DAY), DATE_ADD(CURDATE(), INTERVAL -4 DAY)) + GROUP BY year,week + LIMIT 1; + + CALL vn.workerTimeControl_sendMailByDepartment(vWeek, vYear, NULL); + 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_setOrder` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -81615,247 +83972,18 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControl_sendMail____`(vWeek INT, vYear INT, vWorkerFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControl_setOrder`(vUserFk INT, vStarted DATE, vFinished DATE) BEGIN -/** - * Inserta en la tabla vn.mail para notificar a los empleados que teletrabajan de las jornadas que se han registrado. - * Inserta fichadas en el casos que se determina que el empleado está realizando teletrabajo - * - * @param vWeek - * @param vYear - * @param vWorkerFk -> En el caso de querer generarlo para todos los empleados deberá de informarse como NULL - */ - DECLARE vStarted VARCHAR(25); - DECLARE vEnded VARCHAR(25); - DECLARE vDone BOOL; - DECLARE vSender VARCHAR(255); - DECLARE vSenderOld VARCHAR(255); - DECLARE vDated DATE; - DECLARE vTimeWorkDecimal DECIMAL(5,2); - DECLARE vTimeWorkSexagesimal VARCHAR(5); - DECLARE vTimeWorkedDecimal DECIMAL(5,2); - DECLARE vTimeWorkedSexagesimal VARCHAR(5); - DECLARE vTimeWorkDecimalTotal DECIMAL(5,2); - DECLARE vTimeTable VARCHAR(100); - DECLARE vTimeTableDecimal DECIMAL(5,2); - DECLARE vWorkerFkOld INTEGER; - DECLARE vBusinessFk INTEGER; - DECLARE vHeader TEXT; - DECLARE vBody TEXT; - DECLARE vFooter TEXT; - DECLARE vReturn INTEGER; - DECLARE vAbsenceType VARCHAR(50); - DECLARE vWorkerInfo VARCHAR(90); - - DECLARE vCursor CURSOR FOR - SELECT CONCAT(u.name, '@verdnatura.es'), u.id, tb.dated, tb.timeWorkDecimal, LEFT(tb.timeWorkSexagesimal,5) timeWorkSexagesimal, - tb.timeTable, tc.timeWorkDecimal timeWorkedDecimal, LEFT(tc.timeWorkSexagesimal,5) timeWorkedSexagesimal, tb.type, tb.businessFk - FROM tmp.timeBusinessCalculate tb - JOIN user u ON u.id = tb.userFk - JOIN department d ON d.id = tb.departmentFk - JOIN postgresql.business b ON b.business_id = tb.businessFk - JOIN company c ON c.id = b.provider_id - LEFT JOIN tmp.timeControlCalculate tc ON tc.userFk = tb.userFk AND tc.dated = tb.dated - JOIN (SELECT tb.userFk, - SUM(IF(tb.type IS NULL, - IF(tc.timeWorkDecimal > 0, FALSE, IF(tb.timeWorkDecimal > 0, TRUE, FALSE)), - TRUE))isTeleworkingWeek - FROM tmp.timeBusinessCalculate tb - LEFT JOIN tmp.timeControlCalculate tc ON tc.userFk = tb.userFk AND tc.dated = tb.dated - GROUP BY tb.userFk - HAVING isTeleworkingWeek > 0 - )sub ON sub.userFk = u.id - WHERE d.isTeleworking AND - IFNULL(vWorkerFk,u.id) = u.id AND - c.code = 'VNL' - ORDER BY u.id, tb.dated; - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - - DROP TABLE IF EXISTS tmp.timeControlCalculate; - DROP TABLE IF EXISTS tmp.timeBusinessCalculate; - DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate; - DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate; - - SELECT CONCAT (MIN(dated), ' 00:00:00'), CONCAT (MAX(dated), ' 23:59:59') INTO vStarted, vEnded - FROM time - WHERE year = vYear AND - week = vWeek; - - DELETE FROM workerTimeControl - WHERE IFNULL(vWorkerFk, userFk) = userFk AND - timed BETWEEN vStarted AND vEnded AND - isSendMail; - - UPDATE workerTimeControlMail - SET updated = NOW(), state = 'SENDED' - WHERE year = vYear AND - week = vWeek AND - IFNULL(vWorkerFk, workerFk) = workerFk ; - - IF vWorkerFk IS NULL THEN - CALL timeControl_calculateAll(vStarted,vEnded); - CALL timeBusiness_calculateAll(vStarted,vEnded); - ELSE - CALL timeControl_calculateByUser(vWorkerFk,vStarted,vEnded); - CALL timeBusiness_calculateByUser(vWorkerFk,vStarted,vEnded); - END IF; - - SET vTimeWorkDecimalTotal = 0; - SET vBody= ''; - OPEN vCursor; - FETCH vCursor INTO vSender, vWorkerFk, vDated, vTimeWorkDecimal, vTimeWorkSexagesimal, vTimeTable, vTimeWorkedDecimal, vTimeWorkedSexagesimal, vAbsenceType, vBusinessFk ; - SET vWorkerFkOld = vWorkerFk ; - SET vSenderOld = vSender; - proc: LOOP - IF vDone THEN - LEAVE proc; - END IF; + SET @order := 0; + SET @day := '2000-01-01'; - IF vTimeTable IS NULL AND vTimeWorkDecimal>0 AND vTimeWorkedDecimal IS NULL THEN - INSERT INTO workerTimeControl (userFk, timed, manual, direction, isSendMail) - SELECT vWorkerFk, CONCAT(vDated,' 08:00'), TRUE, 'in', TRUE; - IF vTimeWorkDecimal >= 5 THEN - INSERT INTO workerTimeControl (userFk, timed, manual, direction, isSendMail) - SELECT vWorkerFk, CONCAT(vDated,' 09:00'), TRUE, 'middle', TRUE; - INSERT INTO workerTimeControl (userFk, timed, manual, direction, isSendMail) - SELECT vWorkerFk, CONCAT(vDated,' 09:20'), TRUE, 'middle', TRUE; - END IF; - INSERT INTO workerTimeControl (userFk, timed, manual, direction, isSendMail) - SELECT vWorkerFk,CONCAT(vDated,' ', LEFT (SEC_TO_TIME(28800 + (vTimeWorkDecimal * 3600)), 5)), TRUE, 'out', TRUE; - ELSEIF vTimeWorkDecimal>0 AND vTimeWorkedDecimal IS NULL THEN - SELECT SUM(TIME_TO_SEC(j.end)-TIME_TO_SEC(j.start))/3600 INTO vTimeTableDecimal - FROM postgresql.journey j - WHERE j.business_id = vBusinessFk AND - j.day_id = WEEKDAY(vDated)+1; - IF vTimeWorkDecimal = vTimeTableDecimal THEN - INSERT INTO workerTimeControl (userFk, timed, manual, isSendMail) - SELECT vWorkerFk, CONCAT(vDated, ' ', j.start), TRUE, TRUE - FROM postgresql.journey j - WHERE j.business_id = vBusinessFk AND - j.day_id = WEEKDAY(vDated)+1; - - INSERT INTO workerTimeControl (userFk, timed, manual, isSendMail) - SELECT vWorkerFk, CONCAT(vDated, ' ', j.end), TRUE, TRUE - FROM postgresql.journey j - WHERE j.business_id = vBusinessFk AND - j.day_id = WEEKDAY(vDated)+1; - ELSE - INSERT INTO workerTimeControl (userFk, timed, manual, isSendMail) - SELECT vWorkerFk, CONCAT(vDated, ' ', MIN(j.start)), TRUE, TRUE - FROM postgresql.journey j - WHERE j.business_id = vBusinessFk AND - j.day_id = WEEKDAY(vDated)+1; - INSERT INTO workerTimeControl (userFk, timed, manual, isSendMail) - SELECT vWorkerFk, CONCAT(vDated, ' ', SEC_TO_TIME(TIME_TO_SEC(MIN(j.start)) + (vTimeWorkDecimal * 3600))), TRUE, TRUE - FROM postgresql.journey j - WHERE j.business_id = vBusinessFk AND - j.day_id = WEEKDAY(vDated)+1; - END IF; - - IF vTimeWorkDecimal >= 5 THEN - INSERT INTO workerTimeControl (userFk, timed, manual, isSendMail) - SELECT vWorkerFk, CONCAT(vDated, ' ', SEC_TO_TIME(TIME_TO_SEC(MIN(j.start)) + 3600)), TRUE, TRUE - FROM postgresql.journey j - WHERE j.business_id = vBusinessFk AND - j.day_id = WEEKDAY(vDated)+1; - INSERT INTO workerTimeControl (userFk, timed, manual, isSendMail) - SELECT vWorkerFk, CONCAT(vDated, ' ', SEC_TO_TIME(TIME_TO_SEC(MIN(j.start)) + 4800)), TRUE, TRUE - FROM postgresql.journey j - WHERE j.business_id = vBusinessFk AND - j.day_id = WEEKDAY(vDated)+1; - END IF; - - UPDATE workerTimeControl wtc - JOIN (SELECT id FROM workerTimeControl - WHERE userFk = vWorkerFk AND - timed BETWEEN vDated AND CONCAT(vDated, ' 23:59:59') - ORDER BY timed ASC - LIMIT 1)sub on sub.id= wtc.id - SET direction = 'in' ; - - UPDATE workerTimeControl wtc - JOIN (SELECT id FROM workerTimeControl - WHERE userFk = vWorkerFk AND - timed BETWEEN vDated AND CONCAT(vDated, ' 23:59:59') - ORDER BY timed DESC - LIMIT 1)sub on sub.id= wtc.id - SET direction = 'out' ; - - END IF; + UPDATE vn.workerTimeControl w + SET w.`order` = @order := IF(@day = @day := date(timed), @order, 0) + 1 + WHERE w.userFk = vUserFk + AND w.timed BETWEEN vStarted AND util.dayend(vFinished) + ORDER BY w.timed; - SELECT CONCAT(IFNULL(vBody,""), " - ", DATE_FORMAT(vDated, "%d/%m/%Y"), " - ", CASE WEEKDAY(vDated)+1 - WHEN 1 THEN 'Lunes' - WHEN 2 THEN 'Martes' - WHEN 3 THEN 'Miércoles' - WHEN 4 THEN 'Jueves' - WHEN 5 THEN 'Viernes' - WHEN 6 THEN 'Sábado' - WHEN 7 THEN 'Domingo' - END , " - ", IFNULL(GROUP_CONCAT(MID(timed, 12, 5) ORDER BY timed ASC SEPARATOR ' - '), " - ")," - ", IFNULL(vAbsenceType, IF (vTimeWorkedDecimal>0, "Presencial", IF(vTimeWorkDecimal>0, "Teletrabajo", " - "))), " - ", IFNULL(vTimeWorkedSexagesimal, vTimeWorkSexagesimal), " - ") INTO vBody - FROM workerTimeControl - WHERE userFk = vWorkerFk AND - timed BETWEEN vDated AND CONCAT(vDated," 23:59:59"); - SET vTimeWorkDecimalTotal = vTimeWorkDecimalTotal + IFNULL(vTimeWorkedDecimal, vTimeWorkDecimal); - SET vDone = FALSE; - FETCH vCursor INTO vSender, vWorkerFk, vDated, vTimeWorkDecimal, vTimeWorkSexagesimal, vTimeTable, vTimeWorkedDecimal, vTimeWorkedSexagesimal, vAbsenceType, vBusinessFk; - - IF vWorkerFk <> vWorkerFkOld OR vDone THEN - SELECT CONCAT( IFNULL(nif, ''), ' - ', firstName, ' ', name ) INTO vWorkerInfo - FROM postgresql.person - WHERE id_trabajador = vWorkerFkOld; - SET vHeader = CONCAT("


-
-

", vWorkerInfo , "

- - - - - - - - - - - - "); - - SET vFooter = CONCAT(" - - - - -
- Según la información recogida en el sistema adjuntamos la tabla con los registros de las horas trabajadas en el período indicado. - Si está conforme tiene que contestar indicando únicamente la palabra OK, en caso contrario puede contestar detallando la causa de la disconformidad. - Rogamos nos conteste lo antes posible. -

-
FechaDíaFichadasDescripciónHoras
TOTAL", IFNULL(LEFT (SEC_TO_TIME(vTimeWorkDecimalTotal * 3600), 5), 0), "
-
"); - INSERT INTO mail(sender, replyto, subject, body) - VALUES (vSenderOld, - 'timecontrol@verdnatura.es', - CONCAT('Registro de horas semana ', vWeek, ' año ', vYear) , - CONCAT(vHeader, ' ' , vBody, ' ', vFooter)); - - INSERT IGNORE INTO workerTimeControlMail (workerFk, year, week) - VALUES(vWorkerFkOld, vYear, vWeek); - SET vBody = ''; - SET vTimeWorkDecimalTotal = 0; - SET vWorkerFkOld = vWorkerFk ; - SET vSenderOld = vSender; - END IF; - END LOOP; - CLOSE vCursor; - - DROP TABLE IF EXISTS tmp.timeControlCalculate; - DROP TABLE IF EXISTS tmp.timeBusinessCalculate; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -82613,7 +84741,7 @@ BEGIN FROM tmp.workerSalaryRoleDelivery tb WHERE (tb.description IN ('Festivo') OR dayofweek(tb.dated)=1) AND tb.extra = 0 ; - INSERT INTO tmp.workerSalaryRoleDelivery (workerFk,dated,id,packages,hours,km,m3Delivery,m3Load,amountDelivery,amountLoad,AmountKm,description, extra) +/* INSERT INTO tmp.workerSalaryRoleDelivery (workerFk,dated,id,packages,hours,km,m3Delivery,m3Load,amountDelivery,amountLoad,AmountKm,description, extra) SELECT workerFk, dated, d.id, @@ -82628,7 +84756,7 @@ BEGIN CONCAT('Plus festivo: ',description), extra FROM tmp.daysToRateHoliday d - LEFT JOIN routeConfig r ON TRUE; + LEFT JOIN routeConfig r ON TRUE;*/ DROP TEMPORARY TABLE IF EXISTS tmp.daysToDelete; CREATE TEMPORARY TABLE tmp.daysToDelete @@ -82640,23 +84768,6 @@ BEGIN FROM tmp.workerSalaryRoleDelivery d JOIN tmp.daysToDelete dd on dd.dated = d.dated WHERE d.description NOT IN ('Baja enfermedad común', 'Maternidad/Paternidad'); - - INSERT INTO tmp.workerSalaryRoleDelivery (workerFk,dated,id,packages,hours,km,m3Delivery,m3Load,amountDelivery,amountLoad,AmountKm,description, extra) - SELECT workerFk, - dated, - d.id, - packages, - hours, - km, - m3Delivery, - m3Load, - amountDelivery * r.rateHoliday, - amountLoad * r.rateHoliday, - AmountKm * r.rateHoliday, - CONCAT('Plus festivo: ', description), - extra - FROM tmp.daysToRateHoliday d - LEFT JOIN routeConfig r ON TRUE; INSERT INTO tmp.workerSalaryRoleDelivery (workerFk, dated, @@ -82947,280 +85058,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 `worker_calculateSalaryRoleDelivery___` */; -/*!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 `worker_calculateSalaryRoleDelivery___`(vWorkerFk INTEGER,vDateFrom DATE,vDateTo DATE) -BEGIN -/** - * Calcula el salario de trabajadores para los departamentos de reparto, paletizado - * - * @param vDateFrom - * @param vDateTo - * @param vWorkerFk - * @return tmp.workerSalaryRoleDelivery - */ - DROP TEMPORARY TABLE IF EXISTS tmp.workerSalaryRoleDelivery; - - CREATE TEMPORARY TABLE tmp.workerSalaryRoleDelivery - SELECT w.id workerFk, - r.created dated, - r.id, - SUM(t.packages) packages, - CAST(time_to_sec(TIMEDIFF( DATE_FORMAT(r.finished, '%H:%i:%s'),DATE_FORMAT(r.time, '%H:%i:%s'))) / (60 * 60) AS DECIMAL(10, 1)) hours , - r.kmEnd-r.kmStart km, - r.m3 m3Delivery, - CAST(r.m3/loadWorker AS DECIMAL(10,2)) m3Load, - CAST(rc.m3Distribution*m3 AS DECIMAL(10,2)) amountDelivery, - CASE loadWorker - WHEN 1 THEN CAST(r.m3/ loadWorker*rc.load1m3 AS DECIMAL(10,2)) - WHEN 2 THEN CAST(r.m3/ loadWorker*rc.load2m3 AS DECIMAL(10,2)) - WHEN 3 THEN CAST(r.m3/ loadWorker*rc.load3m3 AS DECIMAL(10,2)) - WHEN 4 THEN CAST(r.m3/ loadWorker*rc.load4m3 AS DECIMAL(10,2)) - WHEN 5 THEN CAST(r.m3/ loadWorker*rc.load5m3 AS DECIMAL(10,2)) - ELSE CAST(r.m3/ loadWorker*rc.load6m3 AS DECIMAL(10,2)) - END amountLoad, - rc.kmRate*(r.kmEnd-r.kmStart) amountKm, - CAST('' AS CHAR(45)) description, - CAST( 0 AS DECIMAL(10,2)) extra, - CAST( 0 AS DECIMAL(10,2)) maxSalary - FROM ticket t - LEFT JOIN route r ON t.routeFk = r.id - LEFT JOIN worker w ON w.id = r.workerFk - LEFT JOIN routeConfig rc ON TRUE - LEFT JOIN (SELECT rw.routeFk, COUNT(rw.workerFk) loadWorker - FROM routeLoadWorker rw - JOIN routeLoadWorker rw2 ON rw.routeFk = rw2.routeFk AND rw2.workerFk = vWorkerFk - GROUP BY rw2.routeFk - ) sub ON sub.routeFk=r.id - WHERE r.created BETWEEN vDateFrom AND vDateTo AND w.id = vWorkerFk - GROUP BY r.id; - - INSERT INTO tmp.workerSalaryRoleDelivery (workerFk, - dated, - id, - packages, - km, - m3Load, - amountLoad) - SELECT w.id , - r.created , - r.id, - SUM(t.packages) , - r.kmEnd-r.kmStart , - CAST(r.m3/loadWorker AS DECIMAL(10,2)) , - CASE loadWorker - WHEN 1 THEN CAST(r.m3/ loadWorker*rc.load1m3 AS DECIMAL(10,2)) - WHEN 2 THEN CAST(r.m3/ loadWorker*rc.load2m3 AS DECIMAL(10,2)) - WHEN 3 THEN CAST(r.m3/ loadWorker*rc.load3m3 AS DECIMAL(10,2)) - WHEN 4 THEN CAST(r.m3/ loadWorker*rc.load4m3 AS DECIMAL(10,2)) - WHEN 5 THEN CAST(r.m3/ loadWorker*rc.load5m3 AS DECIMAL(10,2)) - ELSE CAST(r.m3/ loadWorker*rc.load6m3 AS DECIMAL(10,2)) - END - FROM (SELECT rw.routeFk, COUNT(rw.workerFk) loadWorker - FROM routeLoadWorker rw - JOIN routeLoadWorker rw2 ON rw.routeFk = rw2.routeFk AND rw2.workerFk = vWorkerFk - GROUP BY rw2.routeFk) sub - LEFT JOIN route r ON sub.routeFk = r.id - LEFT JOIN ticket t ON t.routeFk = r.id - LEFT JOIN worker w ON w.id = r.workerFk - LEFT JOIN routeConfig rc ON TRUE - WHERE r.created BETWEEN vDateFrom AND vDateTo AND w.id <> vWorkerFk - GROUP BY r.id; - - INSERT INTO tmp.workerSalaryRoleDelivery(workerFk, - dated, - description, - extra) - SELECT workerFk, - dated, - GROUP_CONCAT(ra.name) , - CAST(SUM(rc.price) AS DECIMAL(9,2)) - FROM routeComplement rc - JOIN routeAction ra ON rc.routeActionFk=ra.id - WHERE dated BETWEEN vDateFrom AND vDateTo AND workerFk=vWorkerFk - GROUP BY dated; - - CALL timeBusiness_calculateByWorker(vWorkerFk, vDateFrom, vDateTo); - - INSERT INTO tmp.workerSalaryRoleDelivery (workerFk, - dated, - description, - extra) - SELECT w.id, - tb.dated, - tb.type COLLATE utf8_general_ci, - CASE - WHEN tb.type = 'Vacaciones 1/2 día' OR tb.type = 'Permiso retribuido 1/2 día' - THEN CAST(((12 * blp.importepactado) / (52 * tb.hoursWeek)) * 4 AS DECIMAL(10,2)) - WHEN tb.type = 'Vacaciones' OR tb.type = 'Baja enfermedad común' OR tb.type = 'Permiso retribuido' OR tb.type = 'Festivo' - THEN CAST(((12 * blp.importepactado) / (52 * tb.hoursWeek)) * 8 AS DECIMAL(10,2)) - WHEN tb.type = 'Maternidad/Paternidad' - THEN 0 - END - FROM worker w - JOIN tmp.timeBusinessCalculate tb ON tb.userFk = w.id - JOIN postgresql.business_labour_payroll blp ON blp.business_id = tb.businessFk - JOIN time tm ON tm.dated = tb.dated - WHERE tb.dated BETWEEN vDateFrom AND vDateTo AND - w.id = vWorkerFk AND - tb.type IN ('Vacaciones 1/2 día', 'Vacaciones', 'Baja enfermedad común','Festivo','Permiso retribuido 1/2 día','Permiso retribuido', 'Maternidad/Paternidad') - GROUP BY tb.dated; - - INSERT INTO tmp.workerSalaryRoleDelivery (workerFk, - dated, - m3Delivery, - amountLoad, - description) - SELECT wdc.workerFk , - r.created, - SUM(r.m3) , - CASE - WHEN wdc.category = 1 - THEN CAST(SUM(r.m3) * rc.distributionM3Category1 AS DECIMAL (10,2)) - WHEN wdc.category = 2 - THEN CAST(SUM(r.m3) * rc.distributionM3Category2 AS DECIMAL (10,2)) - END amountLoad, - 'Gestión de la distribución' description - FROM route r - JOIN agencyMode am ON am.id= r.agencyModeFk - JOIN agency a ON a.id = am.agencyFk - JOIN workerDistributionCategory wdc ON wdc.workerFk = vWorkerFk - JOIN workerLabour wl ON r.created BETWEEN wl.started AND IFNULL(wl.ended, CURDATE()) AND wl.workerFk = wdc.workerFk AND a.workCenterFk = wl.workCenterFk - JOIN department v ON v.id = departmentFk - JOIN routeConfig rc - WHERE r.m3>0 AND created BETWEEN vDateFrom AND vDateTo AND - am.name NOT LIKE "REC_%" AND - v.name= "REPARTO" - GROUP BY r.created; - - INSERT INTO tmp.workerSalaryRoleDelivery (workerFk, - dated, - m3Delivery, - amountLoad, - description) - SELECT sub.workerFk, - r.created, - SUM(r.m3), - CAST( (SUM(r.m3)*sub.percentage /100) * rc.m3Palletization AS DECIMAL (10,2) ), - 'Gestión de paletizado' - FROM route r - JOIN agencyMode am ON am.id= r.agencyModeFk - JOIN agency a ON a.id = am.agencyFk - JOIN (SELECT percentage,workerFk ,dated - FROM routeUserPercentage ru - WHERE workerFk = vWorkerFk AND ru.dated <= vDateTo - ORDER BY dated DESC LIMIT 1 - ) sub - JOIN routeConfig rc - JOIN workerLabour wl ON r.created BETWEEN wl.started AND IFNULL(wl.ended, CURDATE()) AND - wl.workerFk = sub.workerFk - JOIN department v ON v.id = departmentFk - WHERE r.m3>0 AND - r.created BETWEEN vDateFrom AND vDateTo AND - am.name NOT LIKE "REC_%" AND - v.name= "PALETIZADO" - GROUP BY r.created; - - DROP TEMPORARY TABLE IF EXISTS tmp.daysToRateHoliday; - CREATE TEMPORARY TABLE tmp.daysToRateHoliday - SELECT * - FROM tmp.workerSalaryRoleDelivery tb - WHERE (tb.description IN ('Festivo') OR dayofweek(tb.dated)=1) AND tb.extra = 0 ; - - INSERT INTO tmp.workerSalaryRoleDelivery (workerFk,dated,id,packages,hours,km,m3Delivery,m3Load,amountDelivery,amountLoad,AmountKm,description, extra) - SELECT workerFk, - dated, - d.id, - packages, - hours, - km, - m3Delivery, - m3Load, - amountDelivery * r.rateHoliday, - amountLoad * r.rateHoliday, - AmountKm * r.rateHoliday, - CONCAT('Plus festivo: ',description), - extra - FROM tmp.daysToRateHoliday d - LEFT JOIN routeConfig r ON TRUE; - - DROP TEMPORARY TABLE IF EXISTS tmp.daysToDelete; - CREATE TEMPORARY TABLE tmp.daysToDelete - SELECT dated - FROM tmp.workerSalaryRoleDelivery d - WHERE d.description IN ('Baja enfermedad común', 'Maternidad/Paternidad'); - - DELETE d - FROM tmp.workerSalaryRoleDelivery d - JOIN tmp.daysToDelete dd on dd.dated = d.dated - WHERE d.description NOT IN ('Baja enfermedad común', 'Maternidad/Paternidad'); - - INSERT INTO tmp.workerSalaryRoleDelivery (workerFk,dated,id,packages,hours,km,m3Delivery,m3Load,amountDelivery,amountLoad,AmountKm,description, extra) - SELECT workerFk, - dated, - d.id, - packages, - hours, - km, - m3Delivery, - m3Load, - amountDelivery * r.rateHoliday, - amountLoad * r.rateHoliday, - AmountKm * r.rateHoliday, - CONCAT('Plus festivo: ', description), - extra - FROM tmp.daysToRateHoliday d - LEFT JOIN routeConfig r ON TRUE; - - INSERT INTO tmp.workerSalaryRoleDelivery (workerFk, - dated, - description, - extra, - maxSalary) - SELECT wdc.workerFk , - CONCAT(YEAR(t.dated),'-', MONTH(t.dated),'-01') , - CASE - WHEN wdc.category = 1 - THEN rc.plusCategory1Concept - WHEN wdc.category = 2 - THEN rc.plusCategory2Concept - END, - CASE - WHEN wdc.category = 1 - THEN CAST(rc.plusCategory1 AS DECIMAL (10,2)) - WHEN wdc.category = 2 - THEN CAST(rc.plusCategory2 AS DECIMAL (10,2)) - END, - CASE - WHEN wdc.category = 1 - THEN CAST(rc.maxSalaryCategory1 AS DECIMAL (10,2)) - WHEN wdc.category = 2 - THEN CAST(rc.maxSalaryCategory2 AS DECIMAL (10,2)) - END - FROM worker w - JOIN workerDistributionCategory wdc ON wdc.workerFk = w.id - JOIN routeConfig rc - JOIN time t on t.dated BETWEEN vDateFrom AND vDateTo - WHERE w.id = vWorkerFk - GROUP BY MONTH(t.dated), YEAR(t.dated); - - DROP TEMPORARY TABLE tmp.daysToRateHoliday; - DROP TEMPORARY TABLE tmp.daysToDelete; - DROP TEMPORARY TABLE tmp.timeBusinessCalculate; -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 `worker_getHierarchy` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -83335,7 +85172,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 `worker_getProductionerrors` */; +/*!50003 DROP PROCEDURE IF EXISTS `worker_getProductionErrors` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -83345,7 +85182,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `worker_getProductionerrors`(vAction VARCHAR(25), vDepartment VARCHAR(25), vStateCode VARCHAR(25) CHARSET utf8, vDatedFrom DATETIME, vDatedTo DATETIME) +CREATE DEFINER=`root`@`%` PROCEDURE `worker_getProductionErrors`(vAction VARCHAR(25), vDepartment VARCHAR(25), vStateCode VARCHAR(25) CHARSET utf8, vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.total; @@ -83371,9 +85208,9 @@ BEGIN GROUP BY st.workerFk; END IF; - SELECT sub1.id, sub1.firstName, sub1.lastName, CAST(sub1.totalTickets AS DECIMAL(10,0)) AS totalTickets, CAST(IFNULL(sub1.errors,0) + IFNULL(sub2.errors,0) AS DECIMAL(10,0)) AS errors + SELECT sub1.id, sub1.firstName, sub1.lastName, CAST(sub1.totalTickets AS DECIMAL(10,0)) AS totalTickets, CAST(IFNULL(sub1.errors,0) + IFNULL(sub2.errors,0) AS DECIMAL(10,0)) AS errors, (IFNULL(sub1.errors,0) + IFNULL(sub2.errors,0))/sub1.totalTickets AS ratio, IF(vDepartment = 'Revisadores', NULL, volume) AS volume FROM( - SELECT w.id, w.code, w.firstName, w.lastName, t.ticketCount AS totalTickets, sub.errors + SELECT w.id, w.code, w.firstName, w.lastName, t.ticketCount AS totalTickets, sub.errors, sub2.volume FROM tmp.total AS t JOIN worker w ON w.id = t.workerFk LEFT JOIN ( @@ -83385,6 +85222,12 @@ BEGIN WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo AND cr.description = vDepartment GROUP BY cd.workerFk )sub ON t.workerFk = sub.workerFk + LEFT JOIN ( -- Añadir volume + SELECT SUM(w.volume) AS volume, w.workerFk + FROM bs.workerProductivity w + INNER JOIN vn.`role` r ON r.id=w.roleFk + WHERE IF(vDepartment = 'Encajadores', r.name='packager', r.name='itemPicker') AND w.dated BETWEEN vDatedFrom AND vDatedTo + GROUP BY w.workerFk) sub2 ON w.id = sub2.workerFk GROUP BY w.code) sub1 LEFT JOIN( SELECT sub1.workerFk, COUNT(id) AS errors @@ -84219,9 +86062,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 ;; @@ -84229,12 +86072,13 @@ CREATE DEFINER=`root`@`%` PROCEDURE `zone_getCollisions`() BEGIN /** * Calcula si para un mismo codigo postal y dia - * hay mas de una zona configurada + * hay mas de una zona configurada y manda correo * */ DECLARE vGeoFk INT DEFAULT NULL; DECLARE vZoneFk INT; DECLARE vIsDone INT DEFAULT FALSE; + DECLARE vTableCollisions TEXT; DECLARE cur1 CURSOR FOR SELECT zoneFk from tmp.zoneOption; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE; @@ -84257,7 +86101,8 @@ BEGIN sons INT, isChecked BOOL DEFAULT 0, zoneFk INT, - PRIMARY KEY zoneFkk (zoneFk, geoFk)) + PRIMARY KEY zoneFkk (zoneFk, geoFk), + INDEX(geoFk)) ENGINE = MEMORY; OPEN cur1; @@ -84294,25 +86139,53 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS geoCollision; CREATE TEMPORARY TABLE geoCollision - SELECT z.agencyModeFk, zn.geoFk + SELECT z.agencyModeFk, zn.geoFk, zw.warehouseFk FROM tmp.zoneNodes zn JOIN zone z ON z.id = zn.zoneFk - GROUP BY z.agencyModeFk, zn.geoFk + JOIN zoneWarehouse zw ON z.id = zw.zoneFk + GROUP BY z.agencyModeFk, zn.geoFk, zw.warehouseFk HAVING count(*) > 1; - SELECT zn.name postalCode, - zoneFk, - z.price, - z.name, - CONCAT('https://salix.verdnatura.es/#!/zone/', - zoneFk, - '/location?q=%7B%22search%22:%22', - zn.name, - '%22%7D') salix - FROM tmp.zoneNodes zn - JOIN zone z ON z.id = zn.zoneFk - JOIN geoCollision gc ON gc.agencyModeFk = z.agencyModeFk AND zn.geoFk = gc.geoFk; - + SELECT ' + + + + + + + + ' INTO vTableCollisions; + + INSERT INTO mail (receiver,replyTo,subject,body) + SELECT 'pepe@verdnatura.es' receiver, + 'noreply@verdnatura.es' replyTo, + CONCAT('Colisiones en zonas ', CURDATE()) subject, + CONCAT(vTableCollisions, + GROUP_CONCAT(sub.td SEPARATOR ''), + '
C.PostalNúmero de zonaPrecioZonaAlmacénSalix
') body + FROM(SELECT + CONCAT(' + ', zn.name, ' + ', zoneFk,' + ', z.price,' + ', z.name,' + ', w.name, ' + ', CONCAT('' + 'https://salix.verdnatura.es/#!/zone/', + zoneFk, + '/location?q=%7B%22search%22:%22', + zn.name, + '%22%7D'),' + ') td + FROM tmp.zoneNodes zn + JOIN zone z ON z.id = zn.zoneFk + JOIN geoCollision gc ON gc.agencyModeFk = z.agencyModeFk AND zn.geoFk = gc.geoFk + JOIN warehouse w ON w.id = gc.warehouseFk) sub; + DROP TEMPORARY TABLE geoCollision, tmp.zone, @@ -84515,18 +86388,20 @@ 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 `zone_getLeaves`( - vSelf INT, - vParentFk INT, - vSearch VARCHAR(255) -) +CREATE DEFINER=`root`@`%` PROCEDURE `zone_getLeaves`(vSelf INT, vParentFk INT, vSearch VARCHAR(255)) BEGIN +/** + * Devuelve las ubicaciones incluidas en la ruta y que sean hijos de parentFk. + * @param vSelf Id de la zona + * @param vParentFk Id del geo a calcular + * @param vSearch cadena a buscar + */ DECLARE vIsNumber BOOL; DECLARE vIsSearch BOOL DEFAULT vSearch IS NOT NULL AND vSearch != ''; @@ -84534,19 +86409,24 @@ BEGIN CREATE TEMPORARY TABLE tNodes (UNIQUE (id)) ENGINE = MEMORY - SELECT id FROM zoneGeo LIMIT 0; + SELECT id + FROM zoneGeo + LIMIT 0; IF vIsSearch THEN SET vIsNumber = vSearch REGEXP '^[0-9]+$'; - + INSERT INTO tNodes - SELECT id FROM zoneGeo + SELECT id + FROM zoneGeo WHERE (vIsNumber AND `name` = vSearch) OR (!vIsNumber AND `name` LIKE CONCAT('%', vSearch, '%')) LIMIT 1000; + ELSEIF vParentFk IS NULL THEN INSERT INTO tNodes - SELECT geoFk FROM zoneIncluded + SELECT geoFk + FROM zoneIncluded WHERE zoneFk = vSelf; END IF; @@ -84554,12 +86434,15 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tChilds; CREATE TEMPORARY TABLE tChilds ENGINE = MEMORY - SELECT id FROM tNodes; + SELECT id + FROM tNodes; DROP TEMPORARY TABLE IF EXISTS tParents; CREATE TEMPORARY TABLE tParents ENGINE = MEMORY - SELECT id FROM zoneGeo LIMIT 0; + SELECT id + FROM zoneGeo + LIMIT 0; myLoop: LOOP DELETE FROM tParents; @@ -84570,7 +86453,8 @@ BEGIN WHERE g.parentFk IS NOT NULL; INSERT IGNORE INTO tNodes - SELECT id FROM tParents; + SELECT id + FROM tParents; IF ROW_COUNT() = 0 THEN LEAVE myLoop; @@ -84578,30 +86462,29 @@ BEGIN DELETE FROM tChilds; INSERT INTO tChilds - SELECT id FROM tParents; + SELECT id + FROM tParents; END LOOP; - DROP TEMPORARY TABLE - tChilds, - tParents; + DROP TEMPORARY TABLE tChilds, tParents; END IF; IF !vIsSearch THEN INSERT IGNORE INTO tNodes - SELECT id FROM zoneGeo + SELECT id + FROM zoneGeo WHERE parentFk <=> vParentFk; END IF; - SELECT g.id, - g.`name`, + SELECT g.id, + g.name, g.parentFk, g.sons, isIncluded selected FROM zoneGeo g JOIN tNodes n ON n.id = g.id - LEFT JOIN zoneIncluded i - ON i.geoFk = g.id AND i.zoneFk = vSelf - ORDER BY depth, selected DESC, `name`; + LEFT JOIN zoneIncluded i ON i.geoFk = g.id AND i.zoneFk = vSelf + ORDER BY `depth`, selected DESC, name; DROP TEMPORARY TABLE tNodes; END ;; @@ -84614,21 +86497,15 @@ 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 `zone_getLeaves2`( - vSelf INT, - vParentFk INT, - vSearch VARCHAR(255) -) +CREATE DEFINER=`root`@`%` PROCEDURE `zone_getLeaves2`(vSelf INT, vParentFk INT, vSearch VARCHAR(255)) BEGIN /** - * HAY QUE REFACTORIZAR ESTE Y zone_getLeaves - * https://redmine.verdnatura.es/issues/3073 * Devuelve los geoFk incluidos en la ruta y que sean hijos de parentFk * @param vSelf Id de la zona * @param vParentFk Id del geo a calcular @@ -84644,32 +86521,42 @@ BEGIN CREATE TEMPORARY TABLE tNodes (UNIQUE (id)) ENGINE = MEMORY - SELECT id FROM zoneGeo LIMIT 0; + SELECT id + FROM zoneGeo + LIMIT 0; IF vIsSearch THEN SET vIsNumber = vSearch REGEXP '^[0-9]+$'; INSERT INTO tNodes - SELECT id FROM zoneGeo + SELECT id + FROM zoneGeo WHERE (vIsNumber AND `name` = vSearch) OR (!vIsNumber AND `name` LIKE CONCAT('%', vSearch, '%')) LIMIT 1000; + ELSEIF vParentFk IS NULL THEN INSERT INTO tNodes - SELECT geoFk FROM zoneIncluded + SELECT geoFk + FROM zoneIncluded WHERE zoneFk = vSelf; END IF; IF vParentFk IS NULL THEN DROP TEMPORARY TABLE IF EXISTS tChilds; CREATE TEMPORARY TABLE tChilds + (INDEX(id)) ENGINE = MEMORY - SELECT id FROM tNodes; + SELECT id + FROM tNodes; DROP TEMPORARY TABLE IF EXISTS tParents; CREATE TEMPORARY TABLE tParents + (INDEX(id)) ENGINE = MEMORY - SELECT id FROM zoneGeo LIMIT 0; + SELECT id + FROM zoneGeo + LIMIT 0; myLoop: LOOP DELETE FROM tParents; @@ -84680,7 +86567,8 @@ BEGIN WHERE g.parentFk IS NOT NULL; INSERT IGNORE INTO tNodes - SELECT id FROM tParents; + SELECT id + FROM tParents; IF ROW_COUNT() = 0 THEN LEAVE myLoop; @@ -84688,22 +86576,22 @@ BEGIN DELETE FROM tChilds; INSERT INTO tChilds - SELECT id FROM tParents; + SELECT id + FROM tParents; END LOOP; - DROP TEMPORARY TABLE - tChilds, - tParents; + DROP TEMPORARY TABLE tChilds, tParents; END IF; IF !vIsSearch THEN INSERT IGNORE INTO tNodes - SELECT id FROM zoneGeo + SELECT id + FROM zoneGeo WHERE parentFk <=> vParentFk; END IF; INSERT IGNORE INTO tmp.zoneNodes(geoFk, name, parentFk, sons, isChecked, zoneFk) - SELECT g.id, + SELECT g.id, g.`name`, g.parentFk, g.sons, @@ -84711,10 +86599,10 @@ BEGIN vSelf FROM zoneGeo g JOIN tNodes n ON n.id = g.id - LEFT JOIN zoneIncluded i - ON i.geoFk = g.id AND i.zoneFk = vSelf - WHERE (i.isIncluded = TRUE - OR (i.isIncluded IS NULL AND vParentFk IS NOT NULL)); + LEFT JOIN zoneIncluded i ON i.geoFk = g.id AND i.zoneFk = vSelf + WHERE i.isIncluded = TRUE + OR (i.isIncluded IS NULL AND vParentFk IS NOT NULL); + DROP TEMPORARY TABLE tNodes; END ;; DELIMITER ; @@ -84841,7 +86729,7 @@ BEGIN /** * Gets computed options for the passed zones and delivery date. * - * @table tmp.zones(id) The zones ids + * @table tmp.zone(id) The zones ids * @param vLanded The delivery date * @return tmp.zoneOption The computed options */ @@ -85115,7 +87003,7 @@ 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 + * Devuelve la mínima fecha de envío para cada warehouse * * @param vLanded La fecha de recepcion * @param vAddressFk Id del consignatario @@ -85152,17 +87040,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 `zone_getShippedWarehouse` */; +/*!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 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 `zone_getShippedWarehouse`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `zone_getShippedWarehouse__`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT) BEGIN /** * Devuelve la mínima fecha de envío para cada warehouse @@ -85696,22 +87584,22 @@ USE `bs`; /*!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 `lastIndicators` AS select `i`.`updated` AS `updated`,`i`.`lastYearSales` AS `lastYearSales`,(`i`.`lastYearSales` - `yi`.`lastYearSales`) AS `incLastYearSales`,`i`.`totalGreuge` AS `totalGreuge`,(`i`.`totalGreuge` - `yi`.`totalGreuge`) AS `incTotalGreuge`,`i`.`latePaymentRate` AS `latePaymentRate`,(`i`.`latePaymentRate` - `yi`.`latePaymentRate`) AS `incLatePaymentRate`,`i`.`countEmployee` AS `countEmployee`,(`i`.`countEmployee` - `yi`.`countEmployee`) AS `incCountEmployee`,`i`.`averageMana` AS `averageMana`,(`i`.`averageMana` - `yi`.`averageMana`) AS `incAverageMana`,`i`.`bankingPool` AS `bankingPool`,(`i`.`bankingPool` - `yi`.`bankingPool`) AS `incbankingPool`,`i`.`lastMonthActiveClients` AS `lastMonthActiveClients`,(`i`.`lastMonthActiveClients` - `yi`.`lastMonthActiveClients`) AS `incLastMonthActiveClients`,`i`.`lastMonthLostClients` AS `lastMonthLostClients`,(`i`.`lastMonthLostClients` - `yi`.`lastMonthLostClients`) AS `incLastMonthLostClients`,`i`.`lastMonthNewClients` AS `lastMonthNewClients`,(`i`.`lastMonthNewClients` - `yi`.`lastMonthNewClients`) AS `incLastMonthNewClients`,`i`.`lastMonthWebBuyingRate` AS `lastMonthWebBuyingRate`,(`i`.`lastMonthWebBuyingRate` - `yi`.`lastMonthWebBuyingRate`) AS `incLastMonthWebBuyingRate`,`i`.`productionHours` AS `productionHours`,`i`.`dailyWorkersCost` AS `dailyWorkersCost`,`i`.`volumeM3` AS `volumeM3`,`i`.`salesValue` AS `salesValue`,`i`.`valueM3` AS `valueM3`,`i`.`hoursM3` AS `hoursM3`,`i`.`workerCostM3` AS `workerCostM3`,`i`.`salesWorkersCostRate` AS `salesWorkersCostRate`,`i`.`thisWeekSales` AS `thisWeekSales`,`i`.`lastYearWeekSales` AS `lastYearWeekSales` from (`indicators` `i` join `indicators` `yi` on((`yi`.`updated` = (select (max(`indicators`.`updated`) + interval -(1) day) from `indicators`)))) where (`i`.`updated` = (select max(`indicators`.`updated`) from `indicators`)) */; +/*!50001 VIEW `lastIndicators` AS select `i`.`updated` AS `updated`,`i`.`lastYearSales` AS `lastYearSales`,(`i`.`lastYearSales` - `yi`.`lastYearSales`) AS `incLastYearSales`,`i`.`totalGreuge` AS `totalGreuge`,(`i`.`totalGreuge` - `yi`.`totalGreuge`) AS `incTotalGreuge`,`i`.`latePaymentRate` AS `latePaymentRate`,(`i`.`latePaymentRate` - `yi`.`latePaymentRate`) AS `incLatePaymentRate`,`i`.`countEmployee` AS `countEmployee`,(`i`.`countEmployee` - `yi`.`countEmployee`) AS `incCountEmployee`,`i`.`averageMana` AS `averageMana`,(`i`.`averageMana` - `yi`.`averageMana`) AS `incAverageMana`,`i`.`bankingPool` AS `bankingPool`,(`i`.`bankingPool` - `yi`.`bankingPool`) AS `incbankingPool`,`i`.`lastMonthActiveClients` AS `lastMonthActiveClients`,(`i`.`lastMonthActiveClients` - `yi`.`lastMonthActiveClients`) AS `incLastMonthActiveClients`,`i`.`lastMonthLostClients` AS `lastMonthLostClients`,(`i`.`lastMonthLostClients` - `yi`.`lastMonthLostClients`) AS `incLastMonthLostClients`,`i`.`lastMonthNewClients` AS `lastMonthNewClients`,(`i`.`lastMonthNewClients` - `yi`.`lastMonthNewClients`) AS `incLastMonthNewClients`,`i`.`lastMonthWebBuyingRate` AS `lastMonthWebBuyingRate`,(`i`.`lastMonthWebBuyingRate` - `yi`.`lastMonthWebBuyingRate`) AS `incLastMonthWebBuyingRate`,`i`.`productionHours__` AS `productionHours__`,`i`.`dailyWorkersCost__` AS `dailyWorkersCost__`,`i`.`volumeM3__` AS `volumeM3__`,`i`.`salesValue__` AS `salesValue__`,`i`.`valueM3__` AS `valueM3__`,`i`.`hoursM3__` AS `hoursM3__`,`i`.`workerCostM3__` AS `workerCostM3__`,`i`.`salesWorkersCostRate__` AS `salesWorkersCostRate__`,`i`.`thisWeekSales` AS `thisWeekSales`,`i`.`lastYearWeekSales` AS `lastYearWeekSales` from (`indicators` `i` join `indicators` `yi` on((`yi`.`updated` = (select (max(`indicators`.`updated`) + interval -(1) day) from `indicators`)))) where (`i`.`updated` = (select max(`indicators`.`updated`) from `indicators`)) */; /*!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 `m3Silla` +-- Final view structure for view `m3Silla__` -- -/*!50001 DROP TABLE IF EXISTS `m3Silla`*/; -/*!50001 DROP VIEW IF EXISTS `m3Silla`*/; +/*!50001 DROP TABLE IF EXISTS `m3Silla__`*/; +/*!50001 DROP VIEW IF EXISTS `m3Silla__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -85720,26 +87608,7 @@ USE `bs`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `m3Silla` AS select `m3`.`fecha` AS `fecha`,`m3`.`year` AS `year`,`m3`.`month` AS `month`,`m3`.`week` AS `week`,`m3`.`day` AS `day`,`m3`.`dayName` AS `dayName`,cast(sum(`m3`.`m3`) as decimal(10,0)) AS `Volumen`,cast(sum(`m3`.`euros`) as decimal(10,0)) AS `Euros` from `m3` where (`m3`.`warehouseFk` in (1,44)) group by `m3`.`fecha` */; -/*!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 `m3analisis` --- - -/*!50001 DROP TABLE IF EXISTS `m3analisis`*/; -/*!50001 DROP VIEW IF EXISTS `m3analisis`*/; -/*!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 `m3analisis` AS select `m`.`fecha` AS `fecha`,`m`.`year` AS `year`,`m`.`month` AS `month`,`m`.`week` AS `week`,`m`.`day` AS `day`,`m`.`dayName` AS `dayName`,`m`.`Volumen` AS `Volumen`,`m`.`Euros` AS `Euros`,`h`.`Departamento` AS `Departamento`,`h`.`Horas` AS `Horas`,`h`.`Salarios` AS `Salarios`,(`h`.`Horas` / `m`.`Volumen`) AS `tiempoM3`,(`m`.`Euros` / `m`.`Volumen`) AS `valorM3`,(`h`.`Salarios` / `m`.`Volumen`) AS `costeLaboralM3`,(`h`.`Salarios` / `m`.`Euros`) AS `costeEuros`,(`h`.`Salarios` / `h`.`Horas`) AS `precioHora` from (`bs`.`m3Silla` `m` join `bs`.`horasSilla` `h` on((`h`.`Fecha` = `m`.`fecha`))) */; +/*!50001 VIEW `m3Silla__` AS select `m3`.`fecha` AS `fecha`,`m3`.`year` AS `year`,`m3`.`month` AS `month`,`m3`.`week` AS `week`,`m3`.`day` AS `day`,`m3`.`dayName` AS `dayName`,cast(sum(`m3`.`m3`) as decimal(10,0)) AS `Volumen`,cast(sum(`m3`.`euros`) as decimal(10,0)) AS `Euros` from `m3` where (`m3`.`warehouseFk` in (1,44)) group by `m3`.`fecha` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -85820,25 +87689,6 @@ USE `bs`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `mermas__` --- - -/*!50001 DROP TABLE IF EXISTS `mermas__`*/; -/*!50001 DROP VIEW IF EXISTS `mermas__`*/; -/*!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 `mermas__` AS select `w`.`code` AS `Comprador`,`it`.`name` AS `Familia`,`i`.`id` AS `Referencia`,`i`.`name` AS `Item`,`s`.`quantity` AS `Cantidad`,(((`b`.`buyingValue` + `b`.`freightValue`) + `b`.`comissionValue`) + `b`.`packageValue`) AS `Coste_Unitario`,(`s`.`quantity` * (((`b`.`buyingValue` + `b`.`freightValue`) + `b`.`comissionValue`) + `b`.`packageValue`)) AS `Importe`,`c`.`name` AS `Cliente`,`s`.`ticketFk` AS `ticketFk`,`t`.`shipped` AS `Fecha` from (((((((`vn`.`worker` `w` join `vn`.`itemType` `it` on((`it`.`workerFk` = `w`.`id`))) join `vn`.`item` `i` on((`i`.`typeFk` = `it`.`id`))) join `vn`.`sale` `s` on((`s`.`itemFk` = `i`.`id`))) join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`client` `c` on((`c`.`id` = `t`.`clientFk`))) left join `bi`.`Last_buy_id__` `lb` on(((`lb`.`Id_Article` = `s`.`itemFk`) and (`lb`.`warehouse_id` = `t`.`warehouseFk`)))) left join `vn`.`buy` `b` on((`b`.`id` = `lb`.`Id_Compra`))) where ((`t`.`shipped` > '2018-01-01') and (`c`.`isRelevant` or (`c`.`id` in (200,400)))) */; -/*!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 `packingSpeed` -- @@ -85858,6 +87708,44 @@ USE `bs`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `s1_ticketDetail` +-- + +/*!50001 DROP TABLE IF EXISTS `s1_ticketDetail`*/; +/*!50001 DROP VIEW IF EXISTS `s1_ticketDetail`*/; +/*!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 `s1_ticketDetail` AS select `s`.`ticketFk` AS `ticketFk`,cast(sum((`s`.`price` * `s`.`quantity`)) as decimal(10,2)) AS `ticketAmount`,count(`s`.`id`) AS `ticketLines`,cast(sum(`sv`.`volume`) as decimal(10,2)) AS `ticketM3`,cast(`t`.`shipped` as date) AS `shipped` from ((`vn`.`ticket` `t` join `vn`.`sale` `s` on((`s`.`ticketFk` = `t`.`id`))) join `vn`.`saleVolume` `sv` on((`sv`.`saleFk` = `s`.`id`))) where (`t`.`shipped` between '2021-09-01' and '2021-10-31 23:59') group by `s`.`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 `s21_saleDetail` +-- + +/*!50001 DROP TABLE IF EXISTS `s21_saleDetail`*/; +/*!50001 DROP VIEW IF EXISTS `s21_saleDetail`*/; +/*!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 `s21_saleDetail` AS select dayofmonth(`t`.`shipped`) AS `dia`,year(`t`.`shipped`) AS `año`,month(`t`.`shipped`) AS `mes`,`s`.`concept` AS `concepto`,`s`.`quantity` AS `unidades`,`s`.`price` AS `precio`,(`s`.`quantity` * `s`.`price`) AS `venta`,`it`.`name` AS `familia`,`w`.`code` AS `comprador`,`s`.`itemFk` AS `itemFk`,`s`.`ticketFk` AS `ticketFk`,`sv`.`volume` AS `volume` from ((((((`vn`.`sale` `s` join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`itemType` `it` on((`it`.`id` = `i`.`typeFk`))) join `vn`.`worker` `w` on((`w`.`id` = `it`.`workerFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`client` `c` on((`c`.`id` = `t`.`clientFk`))) join `vn`.`saleVolume` `sv` on((`sv`.`saleFk` = `s`.`id`))) where (((`t`.`shipped` between '2020-10-21' and '2020-10-28') or (`t`.`shipped` between '2019-10-21' and '2019-10-28') or (`t`.`shipped` between '2021-09-1' and '2021-10-28')) and (`t`.`warehouseFk` in (1,60)) and `c`.`isRelevant` and (`s`.`quantity` > 0)) */; +/*!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 `v_ventas__` -- @@ -86452,6 +88340,25 @@ USE `postgresql`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `person` +-- + +/*!50001 DROP TABLE IF EXISTS `person`*/; +/*!50001 DROP VIEW IF EXISTS `person`*/; +/*!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 `person` AS select `p`.`id` AS `person_id`,`p`.`surnames` AS `name`,`p`.`nickname` AS `nickname`,`p`.`fi` AS `nif`,`p`.`birth` AS `birth`,`p`.`firstname` AS `firstname`,`p`.`p2` AS `p2`,`p`.`readerId` AS `nis`,`p`.`workerFk` AS `id_trabajador`,`p`.`isDisable` AS `isDisable`,`p`.`isFreelance` AS `isFreelance`,`p`.`isSsDiscounted` AS `isSsDiscounted`,`p`.`sex` AS `sex` from `vn`.`person` `p` */; +/*!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: `sage` -- @@ -86610,7 +88517,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `absenceType` AS select `cs`.`calendar_state_id` AS `id`,`cs`.`type` AS `name`,`cs`.`rgb` AS `rgb`,`cs`.`code` AS `code`,`cs`.`holidayEntitlementRate` AS `holidayEntitlementRate` from `postgresql`.`calendar_state` `cs` */; +/*!50001 VIEW `absenceType` AS select `cs`.`calendar_state_id` AS `id`,`cs`.`type` AS `name`,`cs`.`rgb` AS `rgb`,`cs`.`code` AS `code`,`cs`.`permissionRate` AS `permissionRate`,`cs`.`holidayEntitlementRate` AS `holidayEntitlementRate`,`cs`.`discountRate` AS `discountRate` from `postgresql`.`calendar_state` `cs` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -86824,6 +88731,25 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `clientPhoneBook` +-- + +/*!50001 DROP TABLE IF EXISTS `clientPhoneBook`*/; +/*!50001 DROP VIEW IF EXISTS `clientPhoneBook`*/; +/*!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 `clientPhoneBook` AS select `c`.`id` AS `clientFk`,trim(`c`.`phone`) AS `phone` from `client` `c` where (`c`.`phone` and `c`.`isActive`) union select `c`.`id` AS `clientFk`,trim(`c`.`mobile`) AS `phone` from `client` `c` where (`c`.`mobile` and `c`.`isActive`) union select `a`.`clientFk` AS `clientFk`,trim(`a`.`phone`) AS `phone` from (`address` `a` join `client` `c` on((`c`.`id` = `a`.`clientFk`))) where (`a`.`phone` and `c`.`isActive`) union select `a`.`clientFk` AS `clientFk`,trim(`a`.`mobile`) AS `phone` from (`address` `a` join `client` `c` on((`c`.`id` = `a`.`clientFk`))) where (`a`.`mobile` and `c`.`isActive`) union select `cc`.`clientFk` AS `clientFk`,trim(`cc`.`phone`) AS `phone` from (`clientContact` `cc` left join `client` `c` on((`c`.`id` = `cc`.`clientFk`))) where (`c`.`phone` and `c`.`isActive`) */; +/*!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 `clientRisk__` -- @@ -87085,7 +89011,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `entryList` AS select `e`.`id` AS `entryFk`,if(`tr`.`isReceived`,' x','') AS `isHere`,`tr`.`landed` AS `landed`,ifnull(`s`.`nickname`,`s`.`name`) AS `supplier`,`e`.`ref` AS `entryRef`,`a`.`name` AS `agency`,`tr`.`ref` AS `travelRef`,`tr`.`appointment` AS `appointment`,`e`.`supplierFk` AS `supplierFk`,`tr`.`warehouseInFk` AS `warehouseInFk` from (((`entry` `e` join `travel` `tr` on((`tr`.`id` = `e`.`travelFk`))) join `supplier` `s` on((`s`.`id` = `e`.`supplierFk`))) left join `agency` `a` on((`tr`.`agencyFk` = `a`.`id`))) where (`tr`.`landed` between (curdate() + interval -(1) week) and (curdate() + interval 3 month)) order by (`tr`.`landed` < (curdate() + interval 3 day)),`tr`.`landed` desc,`s`.`name`,`e`.`id` desc */; +/*!50001 VIEW `entryList` AS select `e`.`id` AS `entryFk`,if(`tr`.`isReceived`,' x','') AS `isHere`,`tr`.`landed` AS `landed`,ifnull(`s`.`nickname`,`s`.`name`) AS `supplier`,`e`.`ref` AS `entryRef`,`a`.`name` AS `agency`,`tr`.`ref` AS `travelRef`,`tr`.`appointment` AS `appointment`,`e`.`supplierFk` AS `supplierFk`,`tr`.`warehouseInFk` AS `warehouseInFk` from (((`entry` `e` join `travel` `tr` on((`tr`.`id` = `e`.`travelFk`))) join `supplier` `s` on((`s`.`id` = `e`.`supplierFk`))) left join `agency` `a` on((`tr`.`agencyFk` = `a`.`id`))) where (`tr`.`landed` between (curdate() + interval -(1) week) and (curdate() + interval 3 month)) order by (`tr`.`landed` < (curdate() + interval 2 day)) desc,`tr`.`landed` desc,ifnull(`s`.`nickname`,`s`.`name`),`e`.`id` desc */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -87275,7 +89201,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionSticker` AS select `e`.`id` AS `expeditionFk`,`e`.`ticketFk` AS `ticketFk`,`t`.`addressFk` AS `addressFk`,`t`.`clientFk` AS `clientFk`,`a`.`street` AS `street`,`a`.`postalCode` AS `postalCode`,`a`.`city` AS `city`,`a`.`nickname` AS `nickname`,concat('R(',convert(right(`t`.`routeFk`,4) using utf8mb4),')') AS `routeFk`,`rm`.`beachFk` AS `beachFk`,if(`t`.`routeFk`,replace(`am`.`name`,'ZONA ','Z'),`z`.`name`) AS `zona`,`p`.`name` AS `province`,ifnull(`c`.`mobile`,ifnull(`a`.`mobile`,ifnull(`c`.`phone`,`a`.`phone`))) AS `phone` from (((((((((`expedition` `e` join `ticket` `t` on((`t`.`id` = `e`.`ticketFk`))) join `address` `a` on((`a`.`id` = `t`.`addressFk`))) join `province` `p` on((`p`.`id` = `a`.`provinceFk`))) left join `routesMonitor` `rm` on((`rm`.`routeFk` = `t`.`routeFk`))) left join `beach` `b` on((`b`.`id` = `rm`.`beachFk`))) left join `zone` `z` on((`z`.`id` = `t`.`zoneFk`))) left join `route` `r` on((`r`.`id` = `t`.`routeFk`))) left join `agencyMode` `am` on((`am`.`id` = `r`.`agencyModeFk`))) join `client` `c` on((`c`.`id` = `a`.`clientFk`))) */; +/*!50001 VIEW `expeditionSticker` AS select `e`.`id` AS `expeditionFk`,`e`.`ticketFk` AS `ticketFk`,`t`.`addressFk` AS `addressFk`,`t`.`clientFk` AS `clientFk`,`a`.`street` AS `street`,`a`.`postalCode` AS `postalCode`,`a`.`city` AS `city`,`a`.`nickname` AS `nickname`,concat('R(',convert(right(`t`.`routeFk`,3) using utf8mb4),')') AS `routeFk`,`rm`.`beachFk` AS `beachFk`,if(`t`.`routeFk`,replace(`am`.`name`,'ZONA ','Z'),`z`.`name`) AS `zona`,`p`.`name` AS `province`,ifnull(`c`.`mobile`,ifnull(`a`.`mobile`,ifnull(`c`.`phone`,`a`.`phone`))) AS `phone`,`w`.`code` AS `workerCode` from ((((((((((`expedition` `e` join `ticket` `t` on((`t`.`id` = `e`.`ticketFk`))) join `address` `a` on((`a`.`id` = `t`.`addressFk`))) join `province` `p` on((`p`.`id` = `a`.`provinceFk`))) left join `routesMonitor` `rm` on((`rm`.`routeFk` = `t`.`routeFk`))) left join `beach` `b` on((`b`.`id` = `rm`.`beachFk`))) left join `zone` `z` on((`z`.`id` = `t`.`zoneFk`))) left join `route` `r` on((`r`.`id` = `t`.`routeFk`))) left join `agencyMode` `am` on((`am`.`id` = `r`.`agencyModeFk`))) join `client` `c` on((`c`.`id` = `a`.`clientFk`))) join `worker` `w` on((`w`.`id` = `e`.`workerFk`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -87299,6 +89225,25 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `expeditionTicket_NoBoxes` +-- + +/*!50001 DROP TABLE IF EXISTS `expeditionTicket_NoBoxes`*/; +/*!50001 DROP VIEW IF EXISTS `expeditionTicket_NoBoxes`*/; +/*!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 `expeditionTicket_NoBoxes` AS select `t`.`id` AS `ticketFk`,`t`.`warehouseFk` AS `warehouseFk`,`t`.`routeFk` AS `routeFk`,`et`.`description` AS `description` from (((`ticket` `t` left join `expedition` `e` on((`e`.`ticketFk` = `t`.`id`))) join `routesMonitor` `rm` on((`rm`.`routeFk` = `t`.`routeFk`))) join `expeditionTruck` `et` on((`et`.`id` = `rm`.`expeditionTruckFk`))) where (isnull(`e`.`id`) and (`et`.`ETD` > curdate())) */; +/*!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 `expeditionTimeExpended` -- @@ -87522,7 +89467,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `invoiceCorrectionDataSource` AS select `s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`s`.`price` AS `price`,`s`.`discount` AS `discount`,`t`.`refFk` AS `refFk`,`s`.`id` AS `saleFk`,`t`.`shipped` AS `shipped` from (`sale` `s` join `ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) */; +/*!50001 VIEW `invoiceCorrectionDataSource` AS select `s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`s`.`price` AS `price`,`s`.`discount` AS `discount`,`t`.`refFk` AS `refFk`,`s`.`id` AS `saleFk`,`t`.`shipped` AS `shipped` from (`sale` `s` join `ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) where (`t`.`shipped` > (curdate() + interval -(1) year)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -87565,25 +89510,6 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `invoiceInEntry__` --- - -/*!50001 DROP TABLE IF EXISTS `invoiceInEntry__`*/; -/*!50001 DROP VIEW IF EXISTS `invoiceInEntry__`*/; -/*!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 `invoiceInEntry__` AS select `i`.`recibida_entrada_id` AS `id`,`i`.`recibida_id` AS `invoiceInFk`,`i`.`Id_Entrada` AS `entryFk`,`i`.`percentage` AS `percentage`,`i`.`awb_recibida` AS `invoiceInAwbFk`,`i`.`Contabilizado` AS `isBooked` from `vn2008`.`recibida_entrada__` `i` */; -/*!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 `invoiceInIntrastat__` -- @@ -87636,7 +89562,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemBotanicalWithGenus` AS select `ib`.`itemFk` AS `itemFk`,ifnull(`ib`.`botanical`,concat(`g`.`latinGenusName`,' ',ifnull(`s`.`latinSpeciesName`,''))) AS `ediBotanic` from ((`vn`.`itemBotanical` `ib` left join `vn`.`ediGenus` `g` on((`g`.`id` = `ib`.`genusFk`))) left join `vn`.`ediSpecie` `s` on((`s`.`id` = `ib`.`specieFk`))) */; +/*!50001 VIEW `itemBotanicalWithGenus` AS select `ib`.`itemFk` AS `itemFk`,concat(`g`.`name`,' ',ifnull(`s`.`name`,'')) AS `ediBotanic` from ((`itemBotanical` `ib` left join `specie` `s` on((`s`.`id` = `ib`.`specieFk`))) left join `genus` `g` on((`g`.`id` = `ib`.`genusFk`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -87897,12 +89823,12 @@ USE `vn`; /*!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 `itemShelvingStock` AS select `ish`.`itemFk` AS `itemFk`,sum(`ish`.`visible`) AS `visible`,min(`ish`.`packing`) AS `packing`,min(`ish`.`grouping`) AS `grouping`,`s`.`description` AS `sector`,sum(`ish`.`visible`) AS `visibleOriginal`,sum(`issr`.`removed`) AS `removed`,`p`.`sectorFk` AS `sectorFk`,`s`.`warehouseFk` AS `warehouseFk`,`ish`.`shelvingFk` AS `shelvingFk`,`p`.`code` AS `parkingCode`,`sh`.`parkingFk` AS `parkingFk`,`ish`.`id` AS `itemShelvingFk`,`ish`.`created` AS `created` from ((((`itemShelving` `ish` left join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) left join `parking` `p` on((`p`.`id` = `sh`.`parkingFk`))) left join `sector` `s` on((`s`.`id` = `p`.`sectorFk`))) left join `itemShelvingStockRemoved` `issr` on((`issr`.`itemShelvingFk` = `ish`.`id`))) where ((`ish`.`visible` <> 0) and `p`.`sectorFk`) group by `ish`.`itemFk`,`p`.`sectorFk` */; +/*!50001 VIEW `itemShelvingStock` AS select `ish`.`itemFk` AS `itemFk`,sum(`ish`.`visible`) AS `visible`,min(`ish`.`packing`) AS `packing`,min(`ish`.`grouping`) AS `grouping`,`s`.`description` AS `sector`,sum(`ish`.`visible`) AS `visibleOriginal`,0 AS `removed`,`p`.`sectorFk` AS `sectorFk`,`s`.`warehouseFk` AS `warehouseFk`,`ish`.`shelvingFk` AS `shelvingFk`,`p`.`code` AS `parkingCode`,`sh`.`parkingFk` AS `parkingFk`,`ish`.`id` AS `itemShelvingFk`,`ish`.`created` AS `created` from (((`itemShelving` `ish` left join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) left join `parking` `p` on((`p`.`id` = `sh`.`parkingFk`))) left join `sector` `s` on((`s`.`id` = `p`.`sectorFk`))) where ((`ish`.`visible` <> 0) and `p`.`sectorFk`) group by `ish`.`itemFk`,`p`.`sectorFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -87935,12 +89861,12 @@ USE `vn`; /*!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 `itemShelvingStockRemoved` AS select `ish`.`id` AS `itemShelvingFk`,`ish`.`itemFk` AS `itemFk`,(sum(ifnull(`iss`.`quantity`,0)) + sum(ifnull(`isps`.`quantity`,0))) AS `removed` from ((`itemShelving` `ish` left join `itemShelvingSale` `iss` on((`iss`.`itemShelvingFk` = `ish`.`id`))) left join `itemShelvingPlacementSupply` `isps` on((`isps`.`itemShelvingFk` = `ish`.`id`))) group by `ish`.`id` */; +/*!50001 VIEW `itemShelvingStockRemoved` AS select `ish`.`id` AS `itemShelvingFk`,`ish`.`itemFk` AS `itemFk`,0 AS `removed` from ((`itemShelving` `ish` left join `itemShelvingSale` `iss` on((`iss`.`itemShelvingFk` = `ish`.`id`))) left join `itemShelvingPlacementSupply` `isps` on((`isps`.`itemShelvingFk` = `ish`.`id`))) group by `ish`.`id` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -88087,12 +90013,12 @@ USE `vn`; /*!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 `lastPurchases` AS select `tr`.`landed` AS `landed`,`w`.`id` AS `warehouseFk`,`w`.`name` AS `warehouse`,`i`.`longName` AS `longName`,`i`.`subName` AS `subName`,`e`.`id` AS `entryFk`,`b`.`stickers` AS `stickers`,`b`.`packing` AS `packing`,`e`.`ref` AS `ref`,`b`.`itemFk` AS `itemFk` from ((((`buy` `b` join `entry` `e` on((`e`.`id` = `b`.`entryFk`))) join `item` `i` on((`i`.`id` = `b`.`itemFk`))) join `travel` `tr` on((`tr`.`id` = `e`.`travelFk`))) join `warehouse` `w` on((`w`.`id` = `tr`.`warehouseInFk`))) where ((`tr`.`landed` between `util`.`yesterday`() and `util`.`tomorrow`()) and (`e`.`isRaid` = 0) and (`b`.`stickers` > 0)) */; +/*!50001 VIEW `lastPurchases` AS select `tr`.`landed` AS `landed`,`w`.`id` AS `warehouseFk`,`w`.`name` AS `warehouse`,`i`.`longName` AS `longName`,`i`.`subName` AS `subName`,`e`.`id` AS `entryFk`,`b`.`stickers` AS `stickers`,`b`.`packing` AS `packing`,`e`.`ref` AS `ref`,`b`.`itemFk` AS `itemFk`,`ek`.`pro` AS `pro`,`ek`.`ref` AS `ektRef`,`ek`.`agj` AS `agj` from (((((`vn`.`buy` `b` join `vn`.`entry` `e` on((`e`.`id` = `b`.`entryFk`))) join `vn`.`item` `i` on((`i`.`id` = `b`.`itemFk`))) join `vn`.`travel` `tr` on((`tr`.`id` = `e`.`travelFk`))) join `vn`.`warehouse` `w` on((`w`.`id` = `tr`.`warehouseInFk`))) left join `edi`.`ekt` `ek` on((`ek`.`id` = `b`.`ektFk`))) where ((`tr`.`landed` between `util`.`yesterday`() and `util`.`tomorrow`()) and (`e`.`isRaid` = 0) and (`b`.`stickers` > 0)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -88401,25 +90327,6 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `saleFreight__` --- - -/*!50001 DROP TABLE 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 = 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`,`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 */; - -- -- Final view structure for view `saleMistakeList` -- @@ -88648,25 +90555,6 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `ticketGetVolume__` --- - -/*!50001 DROP TABLE IF EXISTS `ticketGetVolume__`*/; -/*!50001 DROP VIEW IF EXISTS `ticketGetVolume__`*/; -/*!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 `ticketGetVolume__` AS select `s`.`ticketFk` AS `ticketFk`,`t`.`routeFk` AS `routeFk`,`s`.`id` AS `saleFk`,`t`.`shipped` AS `shipped`,(((`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 `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 */; - -- -- Final view structure for view `ticketLabel_Source` -- @@ -88681,7 +90569,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketLabel_Source` AS select concat(`tc`.`collectionFk`,' ',`tc`.`wagon`,'-',`tc`.`level`) AS `level`,`t`.`id` AS `Id_Ticket`,(case when (`t`.`routeFk` is not null) then if(`agr`.`showAgencyName`,concat(right(left(`agr`.`name`,(locate(' ',`agr`.`name`) - 1)),2),'- R',right(`t`.`routeFk`,3)),`agr`.`name`) else if((`am`.`deliveryMethodFk` = 2),`zo`.`name`,`am`.`name`) end) AS `Agencia`,`t`.`clientFk` AS `Id_Cliente`,`t`.`notes` AS `Notas`,'CDT' AS `Sacador`,1 AS `ncarro`,if(hour(`t`.`shipped`),date_format(`t`.`shipped`,'%H:%i'),date_format(`zo`.`hour`,'%H:%i')) AS `horaagencia`,`t`.`shipped` AS `fecha`,if(((now() + interval 1 hour) > `ze`.`etc`),'!!!','') AS `urgente` from (((((((`vn`.`ticket` `t` join `vn`.`agencyMode` `am` on((`t`.`agencyModeFk` = `am`.`id`))) left join `vn`.`address` `a` on((`a`.`id` = `t`.`addressFk`))) left join `vn`.`route` `r` on((`t`.`routeFk` = `r`.`id`))) left join `vn`.`zone_ETD` `ze` on((`ze`.`zoneFk` = `t`.`zoneFk`))) left join `vn`.`ticketCollection` `tc` on((`tc`.`ticketFk` = `t`.`id`))) left join `vn`.`agencyMode` `agr` on((`r`.`agencyModeFk` = `agr`.`id`))) left join `vn`.`zone` `zo` on((`t`.`zoneFk` = `zo`.`id`))) where (`t`.`shipped` between `util`.`yesterday`() and `util`.`dayend`(curdate())) */; +/*!50001 VIEW `ticketLabel_Source` AS select concat(`tc`.`collectionFk`,' ',`tc`.`wagon`,'-',`tc`.`level`) AS `level`,`t`.`id` AS `Id_Ticket`,(case when (`t`.`routeFk` is not null) then if(`agr`.`showAgencyName`,concat(right(left(`agr`.`name`,(locate(' ',`agr`.`name`) - 1)),2),'- R',right(`t`.`routeFk`,3)),`agr`.`name`) else if((`am`.`deliveryMethodFk` = 2),`zo`.`name`,`am`.`name`) end) AS `Agencia`,`t`.`clientFk` AS `Id_Cliente`,`t`.`notes` AS `Notas`,'CDT' AS `Sacador`,1 AS `ncarro`,if(hour(`t`.`shipped`),date_format(`t`.`shipped`,'%H:%i'),date_format(`zo`.`hour`,'%H:%i')) AS `horaagencia`,`t`.`shipped` AS `fecha`,if(((now() + interval 1 hour) > `ze`.`etc`),'!!!','') AS `urgente` from (((((((`vn`.`ticket` `t` join `vn`.`agencyMode` `am` on((`t`.`agencyModeFk` = `am`.`id`))) left join `vn`.`address` `a` on((`a`.`id` = `t`.`addressFk`))) left join `vn`.`route` `r` on((`t`.`routeFk` = `r`.`id`))) left join `vn`.`zoneEstimatedDelivery` `ze` on((`ze`.`zoneFk` = `t`.`zoneFk`))) left join `vn`.`ticketCollection` `tc` on((`tc`.`ticketFk` = `t`.`id`))) left join `vn`.`agencyMode` `agr` on((`r`.`agencyModeFk` = `agr`.`id`))) left join `vn`.`zone` `zo` on((`t`.`zoneFk` = `zo`.`id`))) where (`t`.`shipped` between `util`.`yesterday`() and `util`.`dayend`(curdate())) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -88757,7 +90645,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketMRW` AS select `Tickets`.`Id_Agencia` AS `id_Agencia`,`Tickets`.`empresa_id` AS `empresa_id`,`Consignatarios`.`consignatario` AS `Consignatario`,`Consignatarios`.`domicilio` AS `DOMICILIO`,`Consignatarios`.`poblacion` AS `POBLACION`,`Consignatarios`.`codPostal` AS `CODPOSTAL`,`Consignatarios`.`telefono` AS `telefono`,`Consignatarios`.`movil` AS `movil`,`Clientes`.`if` AS `IF`,`Tickets`.`Id_Ticket` AS `Id_Ticket`,`Tickets`.`warehouse_id` AS `warehouse_id`,`Consignatarios`.`id_consigna` AS `Id_Consigna`,`Paises`.`Codigo` AS `CodigoPais`,`Tickets`.`Fecha` AS `Fecha`,`province`.`province_id` AS `province_id`,`Tickets`.`landing` AS `landing` from ((((`vn2008`.`Clientes` join `vn2008`.`Consignatarios` on((`Clientes`.`id_cliente` = `Consignatarios`.`Id_cliente`))) join `vn2008`.`Tickets` on((`Consignatarios`.`id_consigna` = `Tickets`.`Id_Consigna`))) join `vn2008`.`province` on((`Consignatarios`.`province_id` = `province`.`province_id`))) join `vn2008`.`Paises` on((`province`.`Paises_Id` = `Paises`.`Id`))) */; +/*!50001 VIEW `ticketMRW` AS select `Tickets`.`Id_Agencia` AS `id_Agencia`,`Tickets`.`empresa_id` AS `empresa_id`,`Consignatarios`.`consignatario` AS `Consignatario`,`Consignatarios`.`domicilio` AS `DOMICILIO`,`Consignatarios`.`poblacion` AS `POBLACION`,`Consignatarios`.`codPostal` AS `CODPOSTAL`,`Consignatarios`.`telefono` AS `telefono`,ifnull(ifnull(ifnull(ifnull(`Consignatarios`.`movil`,`Clientes`.`movil`),`Consignatarios`.`telefono`),`Clientes`.`telefono`),0) AS `movil`,`Clientes`.`if` AS `IF`,`Tickets`.`Id_Ticket` AS `Id_Ticket`,`Tickets`.`warehouse_id` AS `warehouse_id`,`Consignatarios`.`id_consigna` AS `Id_Consigna`,`Paises`.`Codigo` AS `CodigoPais`,`Tickets`.`Fecha` AS `Fecha`,`province`.`province_id` AS `province_id`,`Tickets`.`landing` AS `landing` from ((((`vn2008`.`Clientes` join `vn2008`.`Consignatarios` on((`Clientes`.`id_cliente` = `Consignatarios`.`Id_cliente`))) join `vn2008`.`Tickets` on((`Consignatarios`.`id_consigna` = `Tickets`.`Id_Consigna`))) join `vn2008`.`province` on((`Consignatarios`.`province_id` = `province`.`province_id`))) join `vn2008`.`Paises` on((`province`.`Paises_Id` = `Paises`.`Id`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -89028,6 +90916,25 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `workerDepartmentTest` +-- + +/*!50001 DROP TABLE IF EXISTS `workerDepartmentTest`*/; +/*!50001 DROP VIEW IF EXISTS `workerDepartmentTest`*/; +/*!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 `workerDepartmentTest` AS select `p`.`workerFk` AS `workerFk`,`d`.`id` AS `departmentFk` from ((((`vn`.`person` `p` join `postgresql`.`profile` `pr` on((`pr`.`person_id` = `p`.`id`))) join `postgresql`.`business` `b` on((`b`.`client_id` = `pr`.`profile_id`))) join `postgresql`.`business_labour` `bl` on((`b`.`business_id` = `bl`.`business_id`))) join `vn`.`department` `d` on((`d`.`id` = `bl`.`department_id`))) where (curdate() between `b`.`date_start` and ifnull(`b`.`date_end`,curdate())) */; +/*!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 `workerLabour` -- @@ -89219,20 +91126,20 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `workerWithoutDevice` +-- Final view structure for view `workerWithoutDevice__` -- -/*!50001 DROP TABLE IF EXISTS `workerWithoutDevice`*/; -/*!50001 DROP VIEW IF EXISTS `workerWithoutDevice`*/; +/*!50001 DROP TABLE IF EXISTS `workerWithoutDevice__`*/; +/*!50001 DROP VIEW IF EXISTS `workerWithoutDevice__`*/; /*!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 `workerWithoutDevice` AS select `c`.`workerFk` AS `workerFk`,`cl`.`name` AS `Trabajador`,count(distinct `c`.`id`) AS `Colecciones` from ((`collection` `c` join `client` `cl` on((`cl`.`id` = `c`.`workerFk`))) left join `deviceProductionUser` `dpu` on((`dpu`.`userFk` = `c`.`workerFk`))) where ((`c`.`created` > curdate()) and isnull(`dpu`.`userFk`)) group by `c`.`workerFk` */; +/*!50001 VIEW `workerWithoutDevice__` AS select `c`.`workerFk` AS `workerFk`,`cl`.`name` AS `Trabajador`,count(distinct `c`.`id`) AS `Colecciones` from ((`collection` `c` join `client` `cl` on((`cl`.`id` = `c`.`workerFk`))) left join `deviceProductionUser` `dpu` on((`dpu`.`userFk` = `c`.`workerFk`))) where ((`c`.`created` > curdate()) and isnull(`dpu`.`userFk`)) group by `c`.`workerFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -89276,11 +91183,11 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `zone_ETD` +-- Final view structure for view `zone_ETD__` -- -/*!50001 DROP TABLE IF EXISTS `zone_ETD`*/; -/*!50001 DROP VIEW IF EXISTS `zone_ETD`*/; +/*!50001 DROP TABLE IF EXISTS `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 */; @@ -89289,7 +91196,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `zone_ETD` AS select `zed`.`zoneFk` AS `zoneFk`,`zed`.`hourTheoretical` AS `HoraTeórica`,`zed`.`totalVolume` AS `volumenTotal`,`zed`.`remainingVolume` AS `volumenPendiente`,`zed`.`speed` AS `velocidad`,`zed`.`hourEffective` AS `HoraPráctica`,`zed`.`minutesLess` AS `minutesLess`,`zed`.`etc` AS `etc` from `vn`.`zoneEstimatedDelivery` `zed` */; +/*!50001 VIEW `zone_ETD__` AS select `zed`.`zoneFk` AS `zoneFk`,`zed`.`hourTheoretical` AS `HoraTeórica`,`zed`.`totalVolume` AS `volumenTotal`,`zed`.`remainingVolume` AS `volumenPendiente`,`zed`.`speed` AS `velocidad`,`zed`.`hourEffective` AS `HoraPráctica`,`zed`.`minutesLess` AS `minutesLess`,`zed`.`etc` AS `etc` from `vn`.`zoneEstimatedDelivery` `zed` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -89309,4 +91216,4 @@ USE `vncontrol`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-08-31 14:41:28 +-- Dump completed on 2021-11-08 8:19:44 diff --git a/docker-compose.yml b/docker-compose.yml index f8d1c808b..1d80a4b62 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,9 +29,9 @@ services: - source: print_local target: /etc/salix/print.local.json volumes: - - /mnt/storage/pdfs:/var/lib/salix/pdfs - - /mnt/storage/dms:/var/lib/salix/dms - - /mnt/storage/image:/var/lib/salix/image + - /mnt/appdata/pdfs:/var/lib/salix/pdfs + - /mnt/appdata/dms:/var/lib/salix/dms + - /mnt/appdata/image:/var/lib/salix/image deploy: replicas: ${BACK_REPLICAS:?} placement: diff --git a/e2e/helpers/extensions.js b/e2e/helpers/extensions.js index 71f834476..789c800b5 100644 --- a/e2e/helpers/extensions.js +++ b/e2e/helpers/extensions.js @@ -94,6 +94,19 @@ let actions = { login: async function(userName) { await this.doLogin(userName); await this.waitForState('home'); + await this.addStyleTag({ + content: ` + *, + *::after, + *::before { + transition-delay: 0s !important; + transition-duration: 0s !important; + animation-delay: -0.0001s !important; + animation-duration: 0s !important; + animation-play-state: paused !important; + caret-color: transparent !important; + }` + }); }, selectModule: async function(moduleName) { @@ -108,7 +121,7 @@ let actions = { }, getState: async function() { - return await this.evaluate(() => { + return this.evaluate(() => { let $state = angular.element(document.body).injector().get('$state'); return $state.current.name; }); @@ -194,7 +207,7 @@ let actions = { }, getProperty: async function(selector, property) { - return await this.evaluate((selector, property) => { + return this.evaluate((selector, property) => { return document.querySelector(selector)[property].replace(/\s+/g, ' ').trim(); }, selector, property); }, @@ -202,15 +215,16 @@ let actions = { getClassName: async function(selector) { const element = await this.$(selector); const handle = await element.getProperty('className'); - return await handle.jsonValue(); + return handle.jsonValue(); }, waitPropertyLength: async function(selector, property, minLength) { await this.waitForFunction((selector, property, minLength) => { const element = document.querySelector(selector); - return element && element[property] != null && element[property] !== '' && element[property].length >= minLength; + const isValidElement = element && element[property] != null && element[property] !== ''; + return isValidElement && element[property].length >= minLength; }, {}, selector, property, minLength); - return await this.getProperty(selector, property); + return this.getProperty(selector, property); }, expectPropertyValue: async function(selector, property, value) { @@ -219,7 +233,7 @@ let actions = { builtSelector = await this.selectorFormater(selector); try { - return await this.waitForFunction((selector, property, value) => { + return this.waitForFunction((selector, property, value) => { const element = document.querySelector(selector); return element[property] == value; }, {}, builtSelector, property, value); @@ -239,7 +253,7 @@ let actions = { return element && element[property] != null && element[property] !== ''; }, {}, builtSelector, property); - return await this.getProperty(builtSelector, property); + return this.getProperty(builtSelector, property); } catch (error) { throw new Error(`couldn't get property: ${property} of ${builtSelector}, ${error}`); } @@ -261,7 +275,7 @@ let actions = { await this.waitForSelector(selector); await this.waitForFunction(checkVisibility, {}, selector); - return await this.click(selector); + return this.click(selector); }, writeOnEditableTD: async function(selector, text) { @@ -274,7 +288,7 @@ let actions = { focusElement: async function(selector) { await this.waitForSelector(selector); - return await this.evaluate(selector => { + return this.evaluate(selector => { let element = document.querySelector(selector); element.focus(); }, selector); @@ -282,19 +296,19 @@ let actions = { isVisible: async function(selector) { await this.waitForSelector(selector); - return await this.evaluate(checkVisibility, selector); + return this.evaluate(checkVisibility, selector); }, waitImgLoad: async function(selector) { await this.waitForSelector(selector); - return await this.waitForFunction(selector => { + return this.waitForFunction(selector => { const imageReady = document.querySelector(selector).complete; return imageReady; }, {}, selector); }, countElement: async function(selector) { - return await this.evaluate(selector => { + return this.evaluate(selector => { return document.querySelectorAll(selector).length; }, selector); }, @@ -312,7 +326,7 @@ let actions = { waitForClassNotPresent: async function(selector, className) { await this.waitForSelector(selector); - return await this.waitForFunction((selector, className) => { + return this.waitForFunction((selector, className) => { if (!document.querySelector(selector).classList.contains(className)) return true; }, {}, selector, className); @@ -320,55 +334,39 @@ let actions = { waitForClassPresent: async function(selector, className) { await this.waitForSelector(selector); - return await this.waitForFunction((elementSelector, targetClass) => { + return this.waitForFunction((elementSelector, targetClass) => { if (document.querySelector(elementSelector).classList.contains(targetClass)) return true; }, {}, selector, className); }, waitForTextInElement: async function(selector, text) { - const expectedText = text.toLowerCase(); - return new Promise((resolve, reject) => { - let attempts = 0; - const interval = setInterval(async() => { - const currentText = await this.evaluate(selector => { - return document.querySelector(selector).innerText.toLowerCase(); - }, selector); - - if (currentText === expectedText || attempts === 40) { - clearInterval(interval); - resolve(currentText); - } - attempts += 1; - }, 100); - }).then(result => { - return expect(result).toContain(expectedText); - }); + await this.waitForFunction((selector, text) => { + if (document.querySelector(selector)) { + const innerText = document.querySelector(selector).innerText.toLowerCase(); + const expectedText = text.toLowerCase(); + if (innerText.includes(expectedText)) + return innerText; + } + }, {}, selector, text); }, waitForTextInField: async function(selector, text) { - let builtSelector = await this.selectorFormater(selector); - await this.waitForSelector(builtSelector); - const expectedText = text.toLowerCase(); - return new Promise((resolve, reject) => { - let attempts = 0; - const interval = setInterval(async() => { - const currentText = await this.evaluate(selector => { - return document.querySelector(selector).value.toLowerCase(); - }, builtSelector); + const builtSelector = await this.selectorFormater(selector); + const expectedValue = text.toLowerCase(); - if (currentText === expectedText || attempts === 40) { - clearInterval(interval); - resolve(currentText); + try { + await this.waitForFunction((selector, text) => { + const element = document.querySelector(selector); + if (element) { + const value = element.value.toLowerCase(); + if (value.includes(text)) + return true; } - attempts += 1; - }, 100); - }).then(result => { - if (result === '') - return expect(result).toEqual(expectedText); - - return expect(result).toContain(expectedText); - }); + }, {}, builtSelector, expectedValue); + } catch (error) { + throw new Error(`${text} wasn't the value of ${builtSelector}, ${error}`); + } }, selectorFormater: function(selector) { @@ -387,13 +385,13 @@ let actions = { const innerText = document.querySelector(selector).innerText; return innerText != null && innerText != ''; }, {}, selector); - return await this.evaluate(selector => { + return this.evaluate(selector => { return document.querySelector(selector).innerText; }, selector); }, waitForEmptyInnerText: async function(selector) { - return await this.waitFunction(selector => { + return this.waitFunction(selector => { return document.querySelector(selector).innerText == ''; }, selector); }, @@ -521,7 +519,7 @@ let actions = { checkboxState: async function(selector) { await this.waitForSelector(selector); - return await this.evaluate(selector => { + return this.evaluate(selector => { let checkbox = document.querySelector(selector); switch (checkbox.$ctrl.field) { case null: @@ -536,14 +534,14 @@ let actions = { isDisabled: async function(selector) { await this.waitForSelector(selector); - return await this.evaluate(selector => { + return this.evaluate(selector => { let element = document.querySelector(selector); return element.$ctrl.disabled; }, selector); }, waitForStylePresent: async function(selector, property, value) { - return await this.waitForFunction((selector, property, value) => { + return this.waitForFunction((selector, property, value) => { const element = document.querySelector(selector); return element.style[property] == value; }, {}, selector, property, value); @@ -631,7 +629,7 @@ export function extendPage(page) { for (let name in actions) { page[name] = async(...args) => { try { - return await actions[name].apply(page, args); + return actions[name].apply(page, args); } catch (err) { let stringArgs = args .map(i => typeof i == 'function' ? 'Function' : i) diff --git a/e2e/helpers/puppeteer.js b/e2e/helpers/puppeteer.js index 02ef82b1b..dace276be 100644 --- a/e2e/helpers/puppeteer.js +++ b/e2e/helpers/puppeteer.js @@ -5,11 +5,17 @@ import {url as defaultURL} from './config'; export async function getBrowser() { const args = [ - `--no-sandbox`, - `--window-size=${ 1920 },${ 1080 }` + `--window-size=${ 1920 },${ 1080 }`, + // '--disable-gpu' + // '--no-sandbox', + // '--single-process', + // '--no-zygote', + // '--disable-dev-shm-usage' + // '--full-memory-crash-report', + // '--unlimited-storage' ]; - let env = process.env; + const env = process.env; if (env.E2E_DEBUG) { args.push('--auto-open-devtools-for-tabs'); @@ -21,7 +27,10 @@ export async function getBrowser() { args, defaultViewport: null, headless: headless, - slowMo: 0, // slow down by ms + slowMo: 5, // slow down by ms + // ignoreDefaultArgs: ['--disable-extensions'], + // executablePath: '/usr/bin/google-chrome-stable', + // executablePath: '/usr/bin/firefox-developer-edition', }); let page = (await browser.pages())[0]; @@ -38,7 +47,8 @@ export async function getBrowser() { }); }); page = extendPage(page); - page.setDefaultTimeout(4000); + page.setDefaultTimeout(5000); + await page.goto(defaultURL, {waitUntil: 'load'}); return {page, close: browser.close.bind(browser)}; } diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index f63d67f8b..d8ebaa069 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -1,3 +1,4 @@ +/* eslint max-len: ["error", { "ignoreStrings": true }]*/ export default { globalItems: { @@ -118,6 +119,7 @@ export default { name: 'vn-client-create vn-textfield[ng-model="$ctrl.client.name"]', taxNumber: 'vn-client-create vn-textfield[ng-model="$ctrl.client.fi"]', socialName: 'vn-client-create vn-textfield[ng-model="$ctrl.client.socialName"]', + businessType: 'vn-client-create vn-autocomplete[ng-model="$ctrl.client.businessTypeFk"]', street: 'vn-client-create vn-textfield[ng-model="$ctrl.client.street"]', addPostCode: 'vn-client-create vn-datalist[ng-model="$ctrl.client.postcode"] vn-icon-button[icon="add_circle"]', addProvince: 'vn-autocomplete[ng-model="$ctrl.location.provinceFk"] vn-icon-button[icon="add_circle"]', @@ -273,6 +275,7 @@ export default { deliveredAmount: '.vn-dialog vn-input-number[ng-model="$ctrl.deliveredAmount"]', refundAmount: '.vn-dialog vn-input-number[ng-model="$ctrl.amountToReturn"]', saveButton: '.vn-dialog.shown [response="accept"]', + anyBalanceLine: 'vn-client-balance-index vn-tbody > vn-tr', firstLineBalance: 'vn-client-balance-index vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(8)', firstLineReference: 'vn-client-balance-index vn-tbody > vn-tr:nth-child(1) > vn-td-editable', firstLineReferenceInput: 'vn-client-balance-index vn-tbody > vn-tr:nth-child(1) > vn-td-editable > div > field > vn-textfield' @@ -310,27 +313,26 @@ export default { }, itemsIndex: { createItemButton: `vn-float-button`, - firstSearchResult: 'vn-item-index a:nth-child(1)', - searchResult: 'vn-item-index a.vn-tr', - firstResultPreviewButton: 'vn-item-index vn-tbody > :nth-child(1) .buttons > [icon="preview"]', + firstSearchResult: 'vn-item-index tbody tr:nth-child(1)', + searchResult: 'vn-item-index tbody tr:not(.empty-rows)', + firstResultPreviewButton: 'vn-item-index tbody > :nth-child(1) .buttons > [icon="preview"]', searchResultCloneButton: 'vn-item-index .buttons > [icon="icon-clone"]', acceptClonationAlertButton: '.vn-confirm.shown [response="accept"]', closeItemSummaryPreview: '.vn-popup.shown', - fieldsToShowButton: 'vn-item-index vn-table > div > div > vn-icon-button[icon="more_vert"]', - fieldsToShowForm: '.vn-popover.shown .content', - firstItemImage: 'vn-item-index vn-tbody > a:nth-child(1) > vn-td:nth-child(1) > img', - firstItemImageTd: 'vn-item-index vn-table a:nth-child(1) vn-td:nth-child(1)', - firstItemId: 'vn-item-index vn-tbody > a:nth-child(1) > vn-td:nth-child(2)', - idCheckbox: '.vn-popover.shown vn-horizontal:nth-child(1) > vn-check', - stemsCheckbox: '.vn-popover.shown vn-horizontal:nth-child(2) > vn-check', - sizeCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check', - typeCheckbox: '.vn-popover.shown vn-horizontal:nth-child(5) > vn-check', - categoryCheckbox: '.vn-popover.shown vn-horizontal:nth-child(6) > vn-check', - intrastadCheckbox: '.vn-popover.shown vn-horizontal:nth-child(7) > vn-check', - originCheckbox: '.vn-popover.shown vn-horizontal:nth-child(8) > vn-check', - buyerCheckbox: '.vn-popover.shown vn-horizontal:nth-child(9) > vn-check', - destinyCheckbox: '.vn-popover.shown vn-horizontal:nth-child(10) > vn-check', - taxClassCheckbox: '.vn-popover.shown vn-horizontal:nth-child(11) > vn-check', + shownColumns: 'vn-item-index vn-button[id="shownColumns"]', + shownColumnsList: '.vn-popover.shown .content', + firstItemImage: 'vn-item-index tbody > tr:nth-child(1) > td:nth-child(1) > img', + firstItemImageTd: 'vn-item-index smart-table tr:nth-child(1) td:nth-child(1)', + firstItemId: 'vn-item-index tbody > tr:nth-child(1) > td:nth-child(2)', + idCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Identifier"]', + stemsCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Stems"]', + sizeCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Size"]', + typeCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Type"]', + categoryCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Category"]', + intrastadCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Intrastat"]', + originCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Origin"]', + buyerCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Buyer"]', + densityCheckbox: '.vn-popover.shown vn-horizontal:nth-child(3) > vn-check[label="Density"]', saveFieldsButton: '.vn-popover.shown vn-button[label="Save"] > button' }, itemFixedPrice: { @@ -470,6 +472,7 @@ export default { firstTicketCheckbox: 'vn-ticket-index vn-tbody > a:nth-child(1) > vn-td:nth-child(1) > vn-check', secondTicketCheckbox: 'vn-ticket-index vn-tbody > a:nth-child(2) > vn-td:nth-child(1) > vn-check', thirdTicketCheckbox: 'vn-ticket-index vn-tbody > a:nth-child(3) > vn-td:nth-child(1) > vn-check', + fifthTicketCheckbox: 'vn-ticket-index vn-tbody > a:nth-child(5) > vn-td:nth-child(1) > vn-check', sixthTicketCheckbox: 'vn-ticket-index vn-tbody > a:nth-child(6) > vn-td:nth-child(1) > vn-check', payoutButton: 'vn-ticket-index vn-button[icon="icon-recovery"]', payoutCompany: '.vn-dialog vn-autocomplete[ng-model="$ctrl.companyFk"]', @@ -544,7 +547,7 @@ export default { }, ticketSales: { setOk: 'vn-ticket-sale vn-tool-bar > vn-button[label="Ok"] > button', - saleLine: 'vn-table div > vn-tbody > vn-tr', + saleLine: 'vn-table div > vn-tbody > vn-tr vn-check', saleDescriptorPopover: '.vn-popover.shown vn-item-descriptor', saleDescriptorPopoverSummaryButton: '.vn-popover.shown vn-item-descriptor a[ui-sref="item.card.summary({id: $ctrl.descriptor.id})"]', newItemButton: 'vn-ticket-sale vn-card vn-icon-button[icon="add_circle"]', @@ -1039,7 +1042,7 @@ export default { zoneBasicData: { name: 'vn-zone-basic-data vn-textfield[ng-model="$ctrl.zone.name"]', agency: 'vn-zone-basic-data vn-autocomplete[ng-model="$ctrl.zone.agencyModeFk"]', - maxVolume: 'vn-zone-basic-data vn-input-number[ng-model="$ctrl.zone.m3Max"]', + maxVolume: 'vn-zone-basic-data vn-input-number[ng-model="$ctrl.zone.itemMaxSize"]', travelingDays: 'vn-zone-basic-data vn-input-number[ng-model="$ctrl.zone.travelingDays"]', closing: 'vn-zone-basic-data vn-input-time[ng-model="$ctrl.zone.hour"]', price: 'vn-zone-basic-data vn-input-number[ng-model="$ctrl.zone.price"]', @@ -1083,7 +1086,7 @@ export default { allBuyCheckbox: 'vn-entry-buy-index thead vn-check', firstBuyCheckbox: 'vn-entry-buy-index tbody:nth-child(2) vn-check', deleteBuysButton: 'vn-entry-buy-index vn-button[icon="delete"]', - addBuyButton: 'vn-entry-buy-index vn-icon[icon="add_circle"]', + addBuyButton: 'vn-entry-buy-index vn-icon[icon="add"]', secondBuyPackingPrice: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.price3"]', secondBuyGroupingPrice: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.price2"]', secondBuyPrice: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.buyingValue"]', @@ -1105,9 +1108,9 @@ export default { importBuysButton: 'vn-entry-buy-import button[type="submit"]' }, entryLatestBuys: { - firstBuy: 'vn-entry-latest-buys vn-tbody > a:nth-child(1)', - allBuysCheckBox: 'vn-entry-latest-buys vn-thead vn-check', - secondBuyCheckBox: 'vn-entry-latest-buys a:nth-child(2) vn-check[ng-model="buy.checked"]', + firstBuy: 'vn-entry-latest-buys tbody > tr:nth-child(1)', + allBuysCheckBox: 'vn-entry-latest-buys thead vn-check', + secondBuyCheckBox: 'vn-entry-latest-buys tbody tr:nth-child(2) vn-check[ng-model="buy.$checked"]', editBuysButton: 'vn-entry-latest-buys vn-button[icon="edit"]', fieldAutocomplete: 'vn-autocomplete[ng-model="$ctrl.editedColumn.field"]', newValueInput: 'vn-textfield[ng-model="$ctrl.editedColumn.newValue"]', @@ -1144,6 +1147,7 @@ export default { alias: 'vn-supplier-basic-data vn-textfield[ng-model="$ctrl.supplier.nickname"]', isSerious: 'vn-supplier-basic-data vn-check[ng-model="$ctrl.supplier.isSerious"]', isActive: 'vn-supplier-basic-data vn-check[ng-model="$ctrl.supplier.isActive"]', + isPayMethodChecked: 'vn-supplier-basic-data vn-check[ng-model="$ctrl.supplier.isPayMethodChecked"]', notes: 'vn-supplier-basic-data vn-textarea[ng-model="$ctrl.supplier.note"]', saveButton: 'vn-supplier-basic-data button[type="submit"]', }, diff --git a/e2e/paths/01-salix/01_login.spec.js b/e2e/paths/01-salix/01_login.spec.js index 7414856da..9dba61379 100644 --- a/e2e/paths/01-salix/01_login.spec.js +++ b/e2e/paths/01-salix/01_login.spec.js @@ -19,7 +19,9 @@ describe('Login path', async() => { const message = await page.waitForSnackbar(); const state = await page.getState(); - expect(message.text).toContain('Invalid login, remember that distinction is made between uppercase and lowercase'); + const errorMessage = 'Invalid login, remember that distinction is made between uppercase and lowercase'; + + expect(message.text).toContain(errorMessage); expect(state).toBe('login'); }); @@ -28,7 +30,9 @@ describe('Login path', async() => { const message = await page.waitForSnackbar(); const state = await page.getState(); - expect(message.text).toContain('Invalid login, remember that distinction is made between uppercase and lowercase'); + const errorMessage = 'Invalid login, remember that distinction is made between uppercase and lowercase'; + + expect(message.text).toContain(errorMessage); expect(state).toBe('login'); }); diff --git a/e2e/paths/02-client/01_create_client.spec.js b/e2e/paths/02-client/01_create_client.spec.js index 5860eca49..bde4203b4 100644 --- a/e2e/paths/02-client/01_create_client.spec.js +++ b/e2e/paths/02-client/01_create_client.spec.js @@ -27,16 +27,19 @@ describe('Client create path', () => { await page.waitForState('client.create'); }); - it('should receive an error when clicking the create button having name and Business name fields empty', async() => { - await page.write(selectors.createClientView.taxNumber, '74451390E'); - await page.write(selectors.createClientView.userName, 'CaptainMarvel'); - await page.write(selectors.createClientView.email, 'CarolDanvers@verdnatura.es'); - await page.autocompleteSearch(selectors.createClientView.salesPerson, 'salesPerson'); - await page.waitToClick(selectors.createClientView.createButton); - const message = await page.waitForSnackbar(); + it('should receive an error when clicking the create button having name and Business name fields empty', + async() => { + await page.write(selectors.createClientView.taxNumber, '74451390E'); + await page.write(selectors.createClientView.userName, 'CaptainMarvel'); + await page.write(selectors.createClientView.email, 'CarolDanvers@verdnatura.es'); + await page.autocompleteSearch(selectors.createClientView.salesPerson, 'salesPerson'); + await page.autocompleteSearch(selectors.createClientView.businessType, 'florist'); + await page.waitToClick(selectors.createClientView.createButton); + const message = await page.waitForSnackbar(); - expect(message.text).toContain('Some fields are invalid'); - }); + expect(message.text).toContain('Some fields are invalid'); + } + ); it(`should create a new province`, async() => { await page.waitToClick(selectors.createClientView.addPostCode); @@ -80,9 +83,22 @@ describe('Client create path', () => { expect(message.text).toContain('Some fields are invalid'); }); + /* Tarea #3370 + it(`should attempt to create a new user with all it's data but wrong business type`, async() => { + await page.clearInput(selectors.createClientView.email); + await page.write(selectors.createClientView.email, 'CarolDanvers@verdnatura.es'); + await page.clearInput(selectors.createClientView.businessType); + await page.waitToClick(selectors.createClientView.createButton); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Some fields are invalid'); + });*/ + it(`should attempt to create a new user with all it's data but wrong postal code`, async() => { await page.clearInput(selectors.createClientView.email); await page.write(selectors.createClientView.email, 'CarolDanvers@verdnatura.es'); + + await page.autocompleteSearch(selectors.createClientView.businessType, 'florist'); await page.clearInput(selectors.createClientView.postcode); await page.write(selectors.createClientView.postcode, '479999'); await page.waitToClick(selectors.createClientView.createButton); 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 ab0a61ddc..4ae1d4eca 100644 --- a/e2e/paths/02-client/03_edit_fiscal_data.spec.js +++ b/e2e/paths/02-client/03_edit_fiscal_data.spec.js @@ -112,7 +112,7 @@ describe('Client Edit fiscalData path', () => { expect(message.text).toContain('Cannot check Equalization Tax in this NIF/CIF'); }); - it('should finally edit the fixcal data correctly as VIES isnt checked and fiscal id is valid for EQtax', async() => { + it('should edit the fiscal data correctly as VIES isnt checked and fiscal id is valid for EQtax', async() => { await page.clearInput(selectors.clientFiscalData.fiscalId); await page.write(selectors.clientFiscalData.fiscalId, '94980061C'); await page.waitToClick(selectors.clientFiscalData.saveButton); diff --git a/e2e/paths/02-client/04_edit_billing_data.spec.js b/e2e/paths/02-client/04_edit_billing_data.spec.js index 6bc48093e..de3270f93 100644 --- a/e2e/paths/02-client/04_edit_billing_data.spec.js +++ b/e2e/paths/02-client/04_edit_billing_data.spec.js @@ -38,10 +38,13 @@ describe('Client Edit billing data path', () => { await page.autocompleteSearch(selectors.clientBillingData.newBankEntityCountry, 'España'); await page.write(selectors.clientBillingData.newBankEntityCode, '9999'); await page.waitToClick(selectors.clientBillingData.acceptBankEntityButton); + const message = await page.waitForSnackbar(); await page.waitForTextInField(selectors.clientBillingData.swiftBic, 'Gotham City Bank'); const newcode = await page.waitToGetProperty(selectors.clientBillingData.swiftBic, 'value'); expect(newcode).toEqual('GTHMCT Gotham City Bank'); + + expect(message.text).toContain('Data saved!'); }); it(`should confirm the IBAN pay method was sucessfully saved`, async() => { diff --git a/e2e/paths/02-client/14_balance.spec.js b/e2e/paths/02-client/14_balance.spec.js index d408215ff..d3de842e3 100644 --- a/e2e/paths/02-client/14_balance.spec.js +++ b/e2e/paths/02-client/14_balance.spec.js @@ -105,7 +105,23 @@ describe('Client balance path', () => { expect(result).toContain('-€100.00'); }); + it('should create a new payment and check the cash exceeded the maximum', async() => { + const amountPaid = '1001'; + + await page.closePopup(); + await page.waitToClick(selectors.clientBalance.newPaymentButton); + await page.autocompleteSearch(selectors.clientBalance.newPaymentBank, 'Cash'); + await page.write(selectors.clientBalance.newPaymentAmount, amountPaid); + await page.clearInput(selectors.clientBalance.newDescription); + await page.write(selectors.clientBalance.newDescription, 'Payment'); + await page.waitToClick(selectors.clientBalance.saveButton); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Amount exceeded'); + }); + it('should create a new payment that sets the balance back to the original negative value', async() => { + await page.closePopup(); await page.waitToClick(selectors.clientBalance.newPaymentButton); await page.autocompleteSearch(selectors.clientBalance.newPaymentBank, 'Pay on receipt'); await page.overwrite(selectors.clientBalance.newPaymentAmount, '-150'); diff --git a/e2e/paths/04-item/01_summary.spec.js b/e2e/paths/04-item/01_summary.spec.js index a7526accb..e24fa6a9f 100644 --- a/e2e/paths/04-item/01_summary.spec.js +++ b/e2e/paths/04-item/01_summary.spec.js @@ -16,13 +16,13 @@ describe('Item summary path', () => { it('should search for an item', async() => { await page.doSearch('Ranged weapon'); - const nResults = await page.countElement(selectors.itemsIndex.searchResult); + const resultsCount = await page.countElement(selectors.itemsIndex.searchResult); await page.waitForTextInElement(selectors.itemsIndex.searchResult, 'Ranged weapon'); await page.waitToClick(selectors.itemsIndex.firstResultPreviewButton); const isVisible = await page.isVisible(selectors.itemSummary.basicData); - expect(nResults).toBe(3); + expect(resultsCount).toBe(3); expect(isVisible).toBeTruthy(); }); @@ -61,12 +61,12 @@ describe('Item summary path', () => { it('should search for other item', async() => { await page.doSearch('Melee Reinforced'); - const nResults = await page.countElement(selectors.itemsIndex.searchResult); + const resultsCount = await page.countElement(selectors.itemsIndex.searchResult); await page.waitToClick(selectors.itemsIndex.firstResultPreviewButton); await page.waitForSelector(selectors.itemSummary.basicData, {visible: true}); - expect(nResults).toBe(2); + expect(resultsCount).toBe(2); }); it(`should now check the item summary preview shows fields from basic data`, async() => { diff --git a/e2e/paths/04-item/07_create.spec.js b/e2e/paths/04-item/07_create.spec.js new file mode 100644 index 000000000..0820f2db7 --- /dev/null +++ b/e2e/paths/04-item/07_create.spec.js @@ -0,0 +1,71 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Item Create', () => { + let browser; + let page; + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('buyer', 'item'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it(`should search for the item Infinity Gauntlet to confirm it isn't created yet`, async() => { + await page.doSearch('Infinity Gauntlet'); + const resultsCount = await page.countElement(selectors.itemsIndex.searchResult); + + expect(resultsCount).toEqual(0); + }); + + it('should access to the create item view by clicking the create floating button', async() => { + await page.waitToClick(selectors.itemsIndex.createItemButton); + await page.waitForState('item.create'); + }); + + it('should return to the item index by clickig the cancel button', async() => { + await page.waitToClick(selectors.itemCreateView.cancelButton); + await page.waitForState('item.index'); + }); + + it('should now access to the create item view by clicking the create floating button', async() => { + await page.waitToClick(selectors.itemsIndex.createItemButton); + await page.waitForState('item.create'); + }); + + it('should create the Infinity Gauntlet item', async() => { + await page.write(selectors.itemCreateView.temporalName, 'Infinity Gauntlet'); + await page.autocompleteSearch(selectors.itemCreateView.type, 'Crisantemo'); + await page.autocompleteSearch(selectors.itemCreateView.intrastat, 'Coral y materiales similares'); + await page.autocompleteSearch(selectors.itemCreateView.origin, 'Holand'); + await page.waitToClick(selectors.itemCreateView.createButton); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Data saved!'); + }); + + it('should confirm Infinity Gauntlet item was created', async() => { + let result = await page + .waitToGetProperty(selectors.itemBasicData.name, 'value'); + + expect(result).toEqual('Infinity Gauntlet'); + + result = await page + .waitToGetProperty(selectors.itemBasicData.type, 'value'); + + expect(result).toEqual('Crisantemo'); + + result = await page + .waitToGetProperty(selectors.itemBasicData.intrastat, 'value'); + + expect(result).toEqual('5080000 Coral y materiales similares'); + + result = await page + .waitToGetProperty(selectors.itemBasicData.origin, 'value'); + + expect(result).toEqual('Holand'); + }); +}); diff --git a/e2e/paths/04-item/07_create_and_clone.spec.js b/e2e/paths/04-item/07_create_and_clone.spec.js deleted file mode 100644 index 938f15e3f..000000000 --- a/e2e/paths/04-item/07_create_and_clone.spec.js +++ /dev/null @@ -1,105 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Item Create/Clone path', () => { - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('buyer', 'item'); - }); - - afterAll(async() => { - await browser.close(); - }); - - describe('create', () => { - it(`should search for the item Infinity Gauntlet to confirm it isn't created yet`, async() => { - await page.doSearch('Infinity Gauntlet'); - const nResults = await page.countElement(selectors.itemsIndex.searchResult); - - expect(nResults).toEqual(0); - }); - - it('should access to the create item view by clicking the create floating button', async() => { - await page.waitToClick(selectors.itemsIndex.createItemButton); - await page.waitForState('item.create'); - }); - - it('should return to the item index by clickig the cancel button', async() => { - await page.waitToClick(selectors.itemCreateView.cancelButton); - await page.waitForState('item.index'); - }); - - it('should now access to the create item view by clicking the create floating button', async() => { - await page.waitToClick(selectors.itemsIndex.createItemButton); - await page.waitForState('item.create'); - }); - - it('should create the Infinity Gauntlet item', async() => { - await page.write(selectors.itemCreateView.temporalName, 'Infinity Gauntlet'); - await page.autocompleteSearch(selectors.itemCreateView.type, 'Crisantemo'); - await page.autocompleteSearch(selectors.itemCreateView.intrastat, 'Coral y materiales similares'); - await page.autocompleteSearch(selectors.itemCreateView.origin, 'Holand'); - await page.waitToClick(selectors.itemCreateView.createButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should confirm Infinity Gauntlet item was created', async() => { - let result = await page - .waitToGetProperty(selectors.itemBasicData.name, 'value'); - - expect(result).toEqual('Infinity Gauntlet'); - - result = await page - .waitToGetProperty(selectors.itemBasicData.type, 'value'); - - expect(result).toEqual('Crisantemo'); - - result = await page - .waitToGetProperty(selectors.itemBasicData.intrastat, 'value'); - - expect(result).toEqual('5080000 Coral y materiales similares'); - - result = await page - .waitToGetProperty(selectors.itemBasicData.origin, 'value'); - - expect(result).toEqual('Holand'); - }); - }); - - // Issue #2201 - // When there is just one result you're redirected automatically to it, so - // it's not possible to use the clone option. - xdescribe('clone', () => { - it('should return to the items index by clicking the return to items button', async() => { - await page.waitToClick(selectors.itemBasicData.goToItemIndexButton); - await page.waitForSelector(selectors.itemsIndex.createItemButton); - await page.waitForState('item.index'); - }); - - it(`should search for the item Infinity Gauntlet`, async() => { - await page.doSearch('Infinity Gauntlet'); - const nResults = await page.countElement(selectors.itemsIndex.searchResult); - - expect(nResults).toEqual(1); - }); - - it(`should clone the Infinity Gauntlet`, async() => { - await page.waitForTextInElement(selectors.itemsIndex.searchResult, 'Infinity Gauntlet'); - await page.waitToClick(selectors.itemsIndex.searchResultCloneButton); - await page.waitToClick(selectors.itemsIndex.acceptClonationAlertButton); - await page.waitForState('item.tags'); - }); - - it('should search for the item Infinity Gauntlet and find two', async() => { - await page.doSearch('Infinity Gauntlet'); - const nResults = await page.countElement(selectors.itemsIndex.searchResult); - - expect(nResults).toEqual(2); - }); - }); -}); diff --git a/e2e/paths/04-item/09_index.spec.js b/e2e/paths/04-item/09_index.spec.js index 262627e99..f9262863d 100644 --- a/e2e/paths/04-item/09_index.spec.js +++ b/e2e/paths/04-item/09_index.spec.js @@ -16,8 +16,8 @@ describe('Item index path', () => { }); it('should click on the fields to show button to open the list of columns to show', async() => { - await page.waitToClick(selectors.itemsIndex.fieldsToShowButton); - const visible = await page.isVisible(selectors.itemsIndex.fieldsToShowForm); + await page.waitToClick(selectors.itemsIndex.shownColumns); + const visible = await page.isVisible(selectors.itemsIndex.shownColumnsList); expect(visible).toBeTruthy(); }); @@ -31,7 +31,7 @@ describe('Item index path', () => { await page.waitToClick(selectors.itemsIndex.intrastadCheckbox); await page.waitToClick(selectors.itemsIndex.originCheckbox); await page.waitToClick(selectors.itemsIndex.buyerCheckbox); - await page.waitToClick(selectors.itemsIndex.destinyCheckbox); + await page.waitToClick(selectors.itemsIndex.densityCheckbox); await page.waitToClick(selectors.itemsIndex.saveFieldsButton); const message = await page.waitForSnackbar(); @@ -39,6 +39,7 @@ describe('Item index path', () => { }); it('should navigate forth and back to see the images column is still visible', async() => { + await page.closePopup(); await page.waitToClick(selectors.itemsIndex.firstSearchResult); await page.waitToClick(selectors.itemDescriptor.goBackToModuleIndexButton); await page.waitToClick(selectors.globalItems.searchButton); @@ -54,7 +55,7 @@ describe('Item index path', () => { }); it('should mark all unchecked boxes to leave the index as it was', async() => { - await page.waitToClick(selectors.itemsIndex.fieldsToShowButton); + await page.waitToClick(selectors.itemsIndex.shownColumns); await page.waitToClick(selectors.itemsIndex.idCheckbox); await page.waitToClick(selectors.itemsIndex.stemsCheckbox); await page.waitToClick(selectors.itemsIndex.sizeCheckbox); @@ -63,7 +64,7 @@ describe('Item index path', () => { await page.waitToClick(selectors.itemsIndex.intrastadCheckbox); await page.waitToClick(selectors.itemsIndex.originCheckbox); await page.waitToClick(selectors.itemsIndex.buyerCheckbox); - await page.waitToClick(selectors.itemsIndex.destinyCheckbox); + await page.waitToClick(selectors.itemsIndex.densityCheckbox); await page.waitToClick(selectors.itemsIndex.saveFieldsButton); const message = await page.waitForSnackbar(); @@ -71,6 +72,7 @@ describe('Item index path', () => { }); it('should now navigate forth and back to see the ids column is now visible', async() => { + await page.closePopup(); await page.waitToClick(selectors.itemsIndex.firstSearchResult); await page.waitToClick(selectors.itemDescriptor.goBackToModuleIndexButton); await page.waitToClick(selectors.globalItems.searchButton); diff --git a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js index 6c82e31a7..55bbdf9ff 100644 --- a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js +++ b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js @@ -340,9 +340,10 @@ describe('Ticket Edit sale path', () => { }); it('should confirm the new ticket received the line', async() => { + const expectedLines = 1; const result = await page.countElement(selectors.ticketSales.saleLine); - expect(result).toEqual(1); + expect(result).toEqual(expectedLines); }); it('should check the first sale reserved icon isnt visible', async() => { @@ -353,6 +354,7 @@ describe('Ticket Edit sale path', () => { it('should mark the first sale as reserved', async() => { await page.waitToClick(selectors.ticketSales.firstSaleCheckbox); + await page.waitToClick(selectors.ticketSales.moreMenu); await page.waitToClick(selectors.ticketSales.moreMenuReserve); await page.closePopup(); diff --git a/e2e/paths/05-ticket/04_packages.spec.js b/e2e/paths/05-ticket/04_packages.spec.js index 06720ed7a..f874307a8 100644 --- a/e2e/paths/05-ticket/04_packages.spec.js +++ b/e2e/paths/05-ticket/04_packages.spec.js @@ -62,7 +62,7 @@ describe('Ticket Create packages path', () => { expect(result).toEqual('7 : Container medical box 1m'); }); - it(`should confirm the first quantity is just a number and the string part was ignored by the imput number`, async() => { + it(`should confirm quantity is just a number and the string part was ignored by the imput number`, async() => { await page.waitForTextInField(selectors.ticketPackages.firstQuantity, '-99'); const result = await page.waitToGetProperty(selectors.ticketPackages.firstQuantity, 'value'); diff --git a/e2e/paths/05-ticket/12_descriptor.spec.js b/e2e/paths/05-ticket/12_descriptor.spec.js index 08534f8e4..3429acc89 100644 --- a/e2e/paths/05-ticket/12_descriptor.spec.js +++ b/e2e/paths/05-ticket/12_descriptor.spec.js @@ -177,7 +177,6 @@ describe('Ticket descriptor path', () => { describe('SMS', () => { it('should send the payment SMS using the descriptor menu', async() => { await page.waitToClick(selectors.ticketDescriptor.moreMenu); - await page.waitForContentLoaded(); await page.waitToClick(selectors.ticketDescriptor.moreMenuPaymentSMS); await page.waitForSelector(selectors.ticketDescriptor.SMStext); await page.waitPropertyLength(selectors.ticketDescriptor.SMStext, 'value', 128); diff --git a/e2e/paths/05-ticket/18_index_payout.spec.js b/e2e/paths/05-ticket/18_index_payout.spec.js index 343ec1f43..c3325360a 100644 --- a/e2e/paths/05-ticket/18_index_payout.spec.js +++ b/e2e/paths/05-ticket/18_index_payout.spec.js @@ -21,8 +21,8 @@ describe('Ticket index payout path', () => { it('should check the second ticket from a client and 1 of another', async() => { await page.waitToClick(selectors.globalItems.searchButton); - await page.waitToClick(selectors.ticketsIndex.secondTicketCheckbox); await page.waitToClick(selectors.ticketsIndex.thirdTicketCheckbox); + await page.waitToClick(selectors.ticketsIndex.fifthTicketCheckbox); await page.waitToClick(selectors.ticketsIndex.payoutButton); const message = await page.waitForSnackbar(); @@ -58,9 +58,11 @@ describe('Ticket index payout path', () => { await page.selectModule('client'); await page.accessToSearchResult('1101'); await page.accessToSection('client.card.balance.index'); - await page.waitForSelector('vn-client-balance-index vn-tbody > vn-tr'); - let result = await page.countElement('vn-client-balance-index vn-tbody > vn-tr'); + await page.waitForSelector(selectors.clientBalance.anyBalanceLine); + const count = await page.countElement(selectors.clientBalance.anyBalanceLine); + const reference = await page.waitToGetProperty(selectors.clientBalance.firstLineReference, 'innerText'); - expect(result).toEqual(4); + expect(count).toEqual(4); + expect(reference).toContain('Cash, Albaran: 7, 8Payment'); }); }); diff --git a/e2e/paths/11-zone/01_basic-data.spec.js b/e2e/paths/11-zone/01_basic-data.spec.js index fe3a1ea9c..ded40579d 100644 --- a/e2e/paths/11-zone/01_basic-data.spec.js +++ b/e2e/paths/11-zone/01_basic-data.spec.js @@ -25,6 +25,7 @@ describe('Zone basic data path', () => { await page.clearInput(selectors.zoneBasicData.name); await page.write(selectors.zoneBasicData.name, 'Brimstone teleportation'); await page.autocompleteSearch(selectors.zoneBasicData.agency, 'Quantum break device'); + await page.clearInput(selectors.zoneBasicData.maxVolume); await page.write(selectors.zoneBasicData.maxVolume, '10'); await page.clearInput(selectors.zoneBasicData.travelingDays); await page.write(selectors.zoneBasicData.travelingDays, '1'); diff --git a/e2e/paths/12-entry/03_latestBuys.spec.js b/e2e/paths/12-entry/03_latestBuys.spec.js index f7dc07ca9..553d41b95 100644 --- a/e2e/paths/12-entry/03_latestBuys.spec.js +++ b/e2e/paths/12-entry/03_latestBuys.spec.js @@ -31,7 +31,7 @@ describe('Entry lastest buys path', () => { await page.waitForSelector(selectors.entryLatestBuys.fieldAutocomplete, {visible: true}); }); - it('should search for the "Description" field and type a new description for the items in each selected buy', async() => { + it('should search for the "Description" and type a new one for the items in each selected buy', async() => { await page.autocompleteSearch(selectors.entryLatestBuys.fieldAutocomplete, 'Description'); await page.write(selectors.entryLatestBuys.newValueInput, 'Crafted item'); await page.waitToClick(selectors.entryLatestBuys.acceptEditBuysDialog); diff --git a/e2e/paths/12-entry/07_buys.spec.js b/e2e/paths/12-entry/07_buys.spec.js index 4042c99b6..a39e88ce6 100644 --- a/e2e/paths/12-entry/07_buys.spec.js +++ b/e2e/paths/12-entry/07_buys.spec.js @@ -28,7 +28,7 @@ describe('Entry import, create and edit buys path', () => { await page.waitForState('entry.card.buy.import'); }); - it('should fill the form, import the designated JSON file and select items for each import and confirm import', async() => { + it('should fill the form, import the a JSON file and select items for each import and confirm import', async() => { let currentDir = process.cwd(); let filePath = `${currentDir}/e2e/assets/07_import_buys.json`; @@ -42,7 +42,8 @@ describe('Entry import, create and edit buys path', () => { await page.waitForTextInField(selectors.entryBuys.observation, '729-6340 2846'); await page.autocompleteSearch(selectors.entryBuys.firstImportedItem, 'Ranged Reinforced weapon pistol 9mm'); - await page.autocompleteSearch(selectors.entryBuys.secondImportedItem, 'Melee Reinforced weapon heavy shield 1x0.5m'); + const itemName = 'Melee Reinforced weapon heavy shield 1x0.5m'; + await page.autocompleteSearch(selectors.entryBuys.secondImportedItem, itemName); await page.autocompleteSearch(selectors.entryBuys.thirdImportedItem, 'Container medical box 1m'); await page.autocompleteSearch(selectors.entryBuys.fourthImportedItem, 'Container ammo box 1m'); @@ -88,37 +89,37 @@ describe('Entry import, create and edit buys path', () => { it('should edit the newest buy', async() => { await page.clearInput(selectors.entryBuys.secondBuyPackingPrice); - await page.waitForTextInField(selectors.entryBuys.secondBuyPackingPrice, ''); + await page.waitForTimeout(250); await page.write(selectors.entryBuys.secondBuyPackingPrice, '100'); await page.waitForSnackbar(); await page.clearInput(selectors.entryBuys.secondBuyGroupingPrice); - await page.waitForTextInField(selectors.entryBuys.secondBuyGroupingPrice, ''); + await page.waitForTimeout(250); await page.write(selectors.entryBuys.secondBuyGroupingPrice, '200'); await page.waitForSnackbar(); await page.clearInput(selectors.entryBuys.secondBuyPrice); - await page.waitForTextInField(selectors.entryBuys.secondBuyPrice, ''); + await page.waitForTimeout(250); await page.write(selectors.entryBuys.secondBuyPrice, '300'); await page.waitForSnackbar(); await page.clearInput(selectors.entryBuys.secondBuyGrouping); - await page.waitForTextInField(selectors.entryBuys.secondBuyGrouping, ''); + await page.waitForTimeout(250); await page.write(selectors.entryBuys.secondBuyGrouping, '400'); await page.waitForSnackbar(); await page.clearInput(selectors.entryBuys.secondBuyPacking); - await page.waitForTextInField(selectors.entryBuys.secondBuyPacking, ''); + await page.waitForTimeout(250); await page.write(selectors.entryBuys.secondBuyPacking, '500'); await page.waitForSnackbar(); await page.clearInput(selectors.entryBuys.secondBuyWeight); - await page.waitForTextInField(selectors.entryBuys.secondBuyWeight, ''); + await page.waitForTimeout(250); await page.write(selectors.entryBuys.secondBuyWeight, '600'); await page.waitForSnackbar(); await page.clearInput(selectors.entryBuys.secondBuyStickers); - await page.waitForTextInField(selectors.entryBuys.secondBuyStickers, ''); + await page.waitForTimeout(250); await page.write(selectors.entryBuys.secondBuyStickers, '700'); await page.waitForSnackbar(); @@ -126,7 +127,7 @@ describe('Entry import, create and edit buys path', () => { await page.waitForSnackbar(); await page.clearInput(selectors.entryBuys.secondBuyQuantity); - await page.waitForTextInField(selectors.entryBuys.secondBuyQuantity, ''); + await page.waitForTimeout(250); await page.write(selectors.entryBuys.secondBuyQuantity, '800'); }); diff --git a/e2e/paths/13-supplier/02_basic_data.spec.js b/e2e/paths/13-supplier/02_basic_data.spec.js index 2bc94402b..f98fa779e 100644 --- a/e2e/paths/13-supplier/02_basic_data.spec.js +++ b/e2e/paths/13-supplier/02_basic_data.spec.js @@ -22,6 +22,7 @@ describe('Supplier basic data path', () => { await page.write(selectors.supplierBasicData.alias, 'Plants Nick SL'); await page.waitToClick(selectors.supplierBasicData.isSerious); await page.waitToClick(selectors.supplierBasicData.isActive); + await page.waitToClick(selectors.supplierBasicData.isPayMethodChecked); await page.write(selectors.supplierBasicData.notes, 'Some notes'); await page.waitToClick(selectors.supplierBasicData.saveButton); @@ -52,6 +53,12 @@ describe('Supplier basic data path', () => { expect(result).toBe('unchecked'); }); + it('should check the isPayMethodChecked checkbox is now unchecked', async() => { + const result = await page.checkboxState(selectors.supplierBasicData.isPayMethodChecked); + + expect(result).toBe('unchecked'); + }); + it('should check the notes were edited', async() => { const result = await page.waitToGetProperty(selectors.supplierBasicData.notes, 'value'); diff --git a/front/core/components/contextmenu/index.js b/front/core/components/contextmenu/index.js index 646df1a0a..fa1db6887 100755 --- a/front/core/components/contextmenu/index.js +++ b/front/core/components/contextmenu/index.js @@ -49,7 +49,7 @@ export default class Contextmenu { get rowIndex() { if (!this.row) return null; - const table = this.row.closest('vn-table, .vn-table'); + const table = this.row.closest('table, vn-table, .vn-table'); const rows = table.querySelectorAll('[ng-repeat]'); return Array.from(rows).findIndex( @@ -67,13 +67,13 @@ export default class Contextmenu { get cell() { if (!this.target) return null; - return this.target.closest('vn-td, .vn-td, vn-td-editable'); + return this.target.closest('td, vn-td, .vn-td, vn-td-editable'); } get cellIndex() { if (!this.row) return null; - const cells = this.row.querySelectorAll('vn-td, .vn-td, vn-td-editable'); + const cells = this.row.querySelectorAll('td, vn-td, .vn-td, vn-td-editable'); return Array.from(cells).findIndex( cellItem => cellItem == this.cell ); @@ -82,8 +82,8 @@ export default class Contextmenu { get rowHeader() { if (!this.row) return null; - const table = this.row.closest('vn-table, .vn-table'); - const headerCells = table && table.querySelectorAll('vn-thead vn-th'); + const table = this.row.closest('table, vn-table, .vn-table'); + const headerCells = table && table.querySelectorAll('thead th, vn-thead vn-th'); const headerCell = headerCells && headerCells[this.cellIndex]; return headerCell; @@ -147,7 +147,7 @@ export default class Contextmenu { */ isActionAllowed() { if (!this.target) return false; - const isTableCell = this.target.closest('vn-td, .vn-td'); + const isTableCell = this.target.closest('td, vn-td, .vn-td'); return isTableCell && this.fieldName; } @@ -172,9 +172,28 @@ export default class Contextmenu { excludeSelection() { let where = {[this.fieldName]: {neq: this.fieldValue}}; if (this.exprBuilder) { - where = buildFilter(where, (param, value) => - this.exprBuilder({param, value}) - ); + where = {[this.fieldName]: this.fieldValue}; + where = buildFilter(where, (param, value) => { + const expr = this.exprBuilder({param, value}); + const props = Object.keys(expr); + let newExpr = {}; + for (let prop of props) { + if (expr[prop].like) { + const operator = expr[prop].like; + newExpr[prop] = {nlike: operator}; + } else if (expr[prop].between) { + const operator = expr[prop].between; + newExpr = { + or: [ + {[prop]: {lt: operator[0]}}, + {[prop]: {gt: operator[1]}}, + ] + }; + } else + newExpr[prop] = {neq: this.fieldValue}; + } + return newExpr; + }); } this.model.addFilter({where}); @@ -208,15 +227,22 @@ export default class Contextmenu { if (prop == findProp) delete instance[prop]; - if (prop === 'and') { - for (let [index, param] of instance[prop].entries()) { + if (prop === 'and' || prop === 'or') { + const instanceCopy = instance[prop].slice(); + for (let param of instanceCopy) { const [key] = Object.keys(param); + const index = instance[prop].findIndex(param => { + return Object.keys(param)[0] == key; + }); if (key == findProp) instance[prop].splice(index, 1); if (param[key] instanceof Array) removeProp(param, filterKey, key); } + + if (instance[prop].length == 0) + delete instance[prop]; } } diff --git a/front/core/components/index.js b/front/core/components/index.js index 3ccc64b89..86ab89212 100644 --- a/front/core/components/index.js +++ b/front/core/components/index.js @@ -52,3 +52,4 @@ import './wday-picker'; import './datalist'; import './contextmenu'; import './rating'; +import './smart-table'; diff --git a/front/core/components/menu/menu.js b/front/core/components/menu/menu.js index d0c649004..e0d968e2f 100755 --- a/front/core/components/menu/menu.js +++ b/front/core/components/menu/menu.js @@ -3,8 +3,8 @@ import Popover from '../popover'; import './style.scss'; export default class Menu extends Popover { - show(parent) { - super.show(parent); + show(parent, direction) { + super.show(parent, direction); this.windowEl.addEventListener('click', () => this.hide()); } } diff --git a/front/core/components/menu/style.scss b/front/core/components/menu/style.scss index 92f437243..6125c0e5b 100644 --- a/front/core/components/menu/style.scss +++ b/front/core/components/menu/style.scss @@ -1,7 +1,18 @@ @import "./effects"; +@import "variables"; .vn-menu { vn-item, .vn-item { @extend %clickable; } + + vn-item.dropdown:after, + .vn-item.dropdown:after { + font-family: 'Material Icons'; + content: 'keyboard_arrow_right'; + position: absolute; + color: $color-spacer; + font-size: 1.5em; + right: 0 + } } diff --git a/front/core/components/multi-check/multi-check.js b/front/core/components/multi-check/multi-check.js index d8fda6404..afa1bc3c4 100644 --- a/front/core/components/multi-check/multi-check.js +++ b/front/core/components/multi-check/multi-check.js @@ -145,9 +145,8 @@ export default class MultiCheck extends FormInput { toggle() { const data = this.model.data; if (!data) return; - data.forEach(el => { + for (let el of data) el[this.checkField] = this.checkAll; - }); } } @@ -156,8 +155,9 @@ ngModule.vnComponent('vnMultiCheck', { controller: MultiCheck, bindings: { model: '<', - checkField: ' - +
- + + +
diff --git a/front/core/components/pagination/style.scss b/front/core/components/pagination/style.scss index 413a6fb5f..02dcb43e4 100644 --- a/front/core/components/pagination/style.scss +++ b/front/core/components/pagination/style.scss @@ -1,7 +1,13 @@ +@import "variables"; vn-pagination { display: block; text-align: center; + color: $color-primary; + + vn-button, vn-icon { + display: block + } & > div > vn-icon-button { font-size: 2rem; diff --git a/front/core/components/popover/index.js b/front/core/components/popover/index.js index d78179ab9..446c0697b 100644 --- a/front/core/components/popover/index.js +++ b/front/core/components/popover/index.js @@ -23,12 +23,15 @@ export default class Popover extends Popup { * it is shown in a visible relative position to it. * * @param {HTMLElement|Event} parent Overrides the parent property + * @param {String} direction - Direction [left] */ - show(parent) { + show(parent, direction) { if (parent instanceof Event) parent = event.target; if (parent) this.parent = parent; + if (direction) this.direction = direction; + super.show(); this.content = this.popup.querySelector('.content'); this.$timeout(() => this.relocate(), 10); @@ -89,21 +92,40 @@ export default class Popover extends Popup { let width = clamp(popoverRect.width, parentRect.width, maxWith); let height = popoverRect.height; - let left = parentRect.left + parentRect.width / 2 - width / 2; - left = clamp(left, margin, maxRight - width); + let left; + if (this.direction == 'left') { + left = parentRect.left + parentRect.width; + left = clamp(left, margin, maxRight - width); + } else { + left = parentRect.left + parentRect.width / 2 - width / 2; + left = clamp(left, margin, maxRight - width); + } - let top = parentRect.top + parentRect.height + arrowOffset; + let top; + if (this.direction == 'left') + top = parentRect.top; + else + top = parentRect.top + parentRect.height + arrowOffset; let showTop = top + height > maxBottom; if (showTop) top = parentRect.top - height - arrowOffset; top = Math.max(top, margin); - if (showTop) + if (this.direction == 'left') + arrowStyle.left = `0`; + else if (showTop) arrowStyle.bottom = `0`; else arrowStyle.top = `0`; - let arrowLeft = (parentRect.left - left) + parentRect.width / 2; - arrowLeft = clamp(arrowLeft, arrowHeight, width - arrowHeight); + let arrowLeft; + if (this.direction == 'left') { + arrowLeft = 0; + let arrowTop = arrowOffset; + arrowStyle.top = `${arrowTop}px`; + } else { + arrowLeft = (parentRect.left - left) + parentRect.width / 2; + arrowLeft = clamp(arrowLeft, arrowHeight, width - arrowHeight); + } arrowStyle.left = `${arrowLeft}px`; style.top = `${top}px`; diff --git a/front/core/components/smart-table/index.html b/front/core/components/smart-table/index.html new file mode 100644 index 000000000..c2af9b41e --- /dev/null +++ b/front/core/components/smart-table/index.html @@ -0,0 +1,102 @@ +
+ +
+ + +
+
+
+
+ {{model.data.length}} + results +
+ + +
+ + + + + + + + +
+ + +
+
+
+ + +
+ + + + + + + + +
+ +
Shown columns
+ +
+
+ + +
+ + + + + + + + + +
+
+
\ No newline at end of file diff --git a/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js new file mode 100644 index 000000000..f32d8aa4f --- /dev/null +++ b/front/core/components/smart-table/index.js @@ -0,0 +1,454 @@ +import ngModule from '../../module'; +import Component from '../../lib/component'; +import {buildFilter} from 'vn-loopback/util/filter'; +import angular from 'angular'; +import {camelToKebab} from '../../lib/string'; +import './style.scss'; +import './table.scss'; + +export default class SmartTable extends Component { + constructor($element, $, $transclude) { + super($element, $); + this.currentUserId = window.localStorage.currentUserWorkerId; + this.$transclude = $transclude; + this.sortCriteria = []; + this.$inputsScope; + this.columns = []; + this.autoSave = false; + this.transclude(); + } + + $onDestroy() { + const styleElement = document.querySelector('style[id="smart-table"]'); + if (this.$.css && styleElement) + styleElement.parentNode.removeChild(styleElement); + } + + get options() { + return this._options; + } + + set options(options) { + this._options = options; + if (!options) return; + + const activeButtons = options.activeButtons; + const missingId = activeButtons && activeButtons.shownColumns && !this.viewConfigId; + if (missingId) + throw new Error('vnSmartTable: View identifier not defined'); + } + + get model() { + return this._model; + } + + set model(value) { + this._model = value; + if (value) + this.$.model = value; + } + + get viewConfigId() { + return this._viewConfigId; + } + + set viewConfigId(value) { + this._viewConfigId = value; + + /* if (value) { + this.defaultViewConfig = {}; + + const url = 'DefaultViewConfigs'; + const filter = {where: {tableCode: value}}; + this.$http.get(url, {filter}) + .then(res => { + if (res && res.data.length) { + const columns = res.data[0].columns; + this.defaultViewConfig = columns; + } + }); + } */ + } + + getDefaultViewConfig() { + const url = 'DefaultViewConfigs'; + const filter = {where: {tableCode: this.viewConfigId}}; + return this.$http.get(url, {filter}) + .then(res => { + if (res && res.data.length) + return res.data[0].columns; + }); + } + + get viewConfig() { + return this._viewConfig; + } + + set viewConfig(value) { + this._viewConfig = value; + + if (!value) return; + + if (!value.length) { + this.getDefaultViewConfig().then(columns => { + const defaultViewConfig = columns ? columns : {}; + + const userViewModel = this.$.userViewModel; + for (const column of this.columns) { + if (defaultViewConfig[column.field] == undefined) + defaultViewConfig[column.field] = true; + } + + userViewModel.insert({ + userFk: this.currentUserId, + tableConfig: this.viewConfigId, + configuration: defaultViewConfig + }); + }).finally(() => this.applyViewConfig()); + } else + this.applyViewConfig(); + } + + get checkedRows() { + const model = this.model; + if (model && model.data) + return model.data.filter(row => row.$checked); + + return null; + } + + get checkAll() { + return this._checkAll; + } + + set checkAll(value) { + this._checkAll = value; + if (value !== undefined) { + const shownColumns = this.viewConfig[0].configuration; + for (let param in shownColumns) + shownColumns[param] = value; + } + } + + transclude() { + const slotTable = this.element.querySelector('#table'); + this.$transclude($clone => { + const table = $clone[0]; + slotTable.appendChild(table); + this.registerColumns(); + this.emptyDataRows(); + }, null, 'table'); + } + + saveViewConfig() { + const userViewModel = this.$.userViewModel; + const [viewConfig] = userViewModel.data; + viewConfig.configuration = Object.assign({}, viewConfig.configuration); + userViewModel.save() + .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))) + .then(() => this.applyViewConfig()) + .then(() => this.$.smartTableColumns.hide()); + } + + applyViewConfig() { + const userViewModel = this.$.userViewModel; + const [viewConfig] = userViewModel.data; + + const selectors = []; + for (const column of this.columns) { + if (viewConfig.configuration[column.field] == false) { + const baseSelector = `smart-table[view-config-id="${this.viewConfigId}"] table`; + selectors.push(`${baseSelector} thead > tr > th:nth-child(${column.index + 1})`); + selectors.push(`${baseSelector} tbody > tr > td:nth-child(${column.index + 1})`); + } + } + + let styleElement = document.querySelector('style[id="smart-table"]'); + + if (styleElement) + styleElement.parentNode.removeChild(styleElement); + + if (selectors.length) { + const rule = selectors.join(', ') + '{display: none}'; + this.$.css = document.createElement('style'); + this.$.css.setAttribute('id', 'smart-table'); + document.head.appendChild(this.$.css); + this.$.css.appendChild(document.createTextNode(rule)); + } + } + + registerColumns() { + const header = this.element.querySelector('thead > tr'); + if (!header) return; + const columns = header.querySelectorAll('th'); + + // Click handler + for (const [index, column] of columns.entries()) { + const field = column.getAttribute('field'); + if (field) { + const columnElement = angular.element(column); + const caption = columnElement.text().trim(); + + this.columns.push({field, caption, index}); + + column.addEventListener('click', () => this.orderHandler(column)); + } + } + } + + emptyDataRows() { + const header = this.element.querySelector('thead > tr'); + const columns = header.querySelectorAll('th'); + const tbody = this.element.querySelector('tbody'); + if (tbody) { + const noSearch = this.$compile(` + + Enter a new search + + `)(this.$); + tbody.appendChild(noSearch[0]); + + const noRows = this.$compile(` + + No data + + `)(this.$); + tbody.appendChild(noRows[0]); + } + } + + orderHandler(element) { + const field = element.getAttribute('field'); + const existingCriteria = this.sortCriteria.find(criteria => { + return criteria.field == field; + }); + + const isASC = existingCriteria && existingCriteria.sortType == 'ASC'; + const isDESC = existingCriteria && existingCriteria.sortType == 'DESC'; + + if (!existingCriteria) { + this.sortCriteria.push({field: field, sortType: 'ASC'}); + element.classList.remove('desc'); + element.classList.add('asc'); + } + + if (isDESC) { + this.sortCriteria.splice(this.sortCriteria.findIndex(criteria => { + return criteria.field == field; + }), 1); + element.classList.remove('desc'); + element.classList.remove('asc'); + } + + if (isASC) { + existingCriteria.sortType = 'DESC'; + element.classList.remove('asc'); + element.classList.add('desc'); + } + + this.applySort(); + } + + displaySearch() { + const header = this.element.querySelector('thead > tr'); + if (!header) return; + + const tbody = this.element.querySelector('tbody'); + const columns = header.querySelectorAll('th'); + + const hasSearchRow = tbody.querySelector('tr#searchRow'); + if (hasSearchRow) { + if (this.$inputsScope) + this.$inputsScope.$destroy(); + + return hasSearchRow.remove(); + } + + const searchRow = document.createElement('tr'); + searchRow.setAttribute('id', 'searchRow'); + + this.$inputsScope = this.$.$new(); + + for (let column of columns) { + const field = column.getAttribute('field'); + const cell = document.createElement('td'); + if (field) { + let input; + let options; + const columnOptions = this.options && this.options.columns; + + if (columnOptions) + options = columnOptions.find(column => column.field == field); + + if (options && options.searchable == false) { + searchRow.appendChild(cell); + continue; + } + + if (options && options.autocomplete) { + let props = ``; + + const autocomplete = options.autocomplete; + for (const prop in autocomplete) + props += `${camelToKebab(prop)}="${autocomplete[prop]}"\n`; + input = this.$compile(` + `)(this.$inputsScope); + } else { + input = this.$compile(` + `)(this.$inputsScope); + } + cell.appendChild(input[0]); + } + searchRow.appendChild(cell); + } + + tbody.prepend(searchRow); + } + + searchWithEvent($event, field) { + if ($event.key != 'Enter') return; + + this.searchByColumn(field); + } + + searchByColumn(field) { + const searchCriteria = this.$inputsScope.searchProps[field]; + const emptySearch = searchCriteria == '' || null; + + const filters = this.filterSanitizer(field); + + if (filters && filters.userFilter) + this.model.userFilter = filters.userFilter; + + if (!emptySearch) + this.addFilter(field, this.$inputsScope.searchProps[field]); + else this.model.refresh(); + } + + addFilter(field, value) { + let where = {[field]: value}; + + if (this.exprBuilder) { + where = buildFilter(where, (param, value) => + this.exprBuilder({param, value}) + ); + } + + this.model.addFilter({where}); + } + + applySort() { + let order = this.sortCriteria.map(criteria => `${criteria.field} ${criteria.sortType}`); + order = order.join(', '); + + if (order) + this.model.order = order; + + this.model.refresh(); + } + + filterSanitizer(field) { + const userFilter = this.model.userFilter; + const userParams = this.model.userParams; + const where = userFilter && userFilter.where; + + if (this.exprBuilder) { + const param = this.exprBuilder({ + param: field, + value: null + }); + if (param) [field] = Object.keys(param); + } + + if (!where) return; + + const whereKeys = Object.keys(where); + for (let key of whereKeys) { + removeProp(where, field, key); + + if (!Object.keys(where)) + delete userFilter.where; + } + + function removeProp(instance, findProp, prop) { + if (prop == findProp) + delete instance[prop]; + + if (prop === 'and') { + for (let [index, param] of instance[prop].entries()) { + const [key] = Object.keys(param); + if (key == findProp) + instance[prop].splice(index, 1); + + if (param[key] instanceof Array) + removeProp(param, field, key); + } + } + } + + return {userFilter, userParams}; + } + + removeFilter() { + this.model.applyFilter(userFilter, userParams); + } + + createRow() { + let data = {}; + + if (this.defaultNewData) + data = this.defaultNewData(); + + this.model.insert(data); + } + + deleteAll() { + for (let row of this.checkedRows) + this.model.removeRow(row); + + if (this.autoSave) + this.saveAll(); + } + + saveAll() { + const model = this.model; + + if (!model.isChanged) + return this.vnApp.showError(this.$t('No changes to save')); + + this.model.save() + .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))); + } +} + +SmartTable.$inject = ['$element', '$scope', '$transclude']; + +ngModule.vnComponent('smartTable', { + template: require('./index.html'), + controller: SmartTable, + transclude: { + table: '?slotTable', + actions: '?slotActions' + }, + bindings: { + model: ' :before { + vertical-align: middle; + font-family: 'Material Icons'; + content: 'arrow_downward'; + color: $color-spacer; + margin-right: 2px; + opacity: 0 + + } + + &.asc > :before, &.desc > :before { + color: $color-font; + opacity: 1; + } + + &.asc > :before { + content: 'arrow_upward'; + } + + &.desc > :before { + content: 'arrow_downward'; + } + + &:hover > :before { + opacity: 1; + } + } + + th[field]:not([number]) { + & > :after { + vertical-align: middle; + font-family: 'Material Icons'; + content: 'arrow_downward'; + color: $color-spacer; + margin-left: 2px; + opacity: 0 + + } + + &.asc > :after, &.desc > :after { + color: $color-font; + opacity: 1; + } + + &.asc > :after { + content: 'arrow_upward'; + } + + &.desc > :after { + content: 'arrow_downward'; + } + + &:hover > :after { + opacity: 1; + } + } + + tr[vn-anchor] { + @extend %clickable; + } + + .totalRows { + color: $color-font-secondary; + } + + .actions-left, + .actions-right { + display: flex; + align-items: center; + + .button-group { + display: flex; + box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .3); + + & > vn-button { + box-shadow: 0 0 0 0 + } + } + } + + .actions-left { + justify-content: flex-start; + + slot-actions > vn-button, + & > vn-button, + .button-group { + margin-right: 10px + } + + slot-actions { + display: flex + } + } + + .actions-right { + justify-content: flex-end; + & > vn-button, + .button-group { + margin-left: 10px + } + } + + #table { + overflow-x: auto; + margin-top: 15px + } + + vn-tbody a[ng-repeat].vn-tr:focus { + background-color: $color-primary-light + } + + .new-row { + background-color: $color-success-light + } + + .changed-row { + background-color: $color-primary-light + } +} + +.smart-table-columns { + h6 { + color: $color-font-secondary + } + + & > vn-horizontal { + align-items: flex-start; + flex-wrap: wrap; + } + + vn-check { + flex: initial; + width: 33% + } +} \ No newline at end of file diff --git a/front/core/components/smart-table/table.scss b/front/core/components/smart-table/table.scss new file mode 100644 index 000000000..e0464465a --- /dev/null +++ b/front/core/components/smart-table/table.scss @@ -0,0 +1,108 @@ +@import "effects"; +@import "variables"; + +smart-table table { + width: 100%; + border-collapse: collapse; + + & > thead { + border-bottom: 2px solid $color-spacer; + + & > * > th { + font-weight: normal; + } + } + & > tfoot { + border-top: 2px solid $color-spacer; + } + thead, tbody, tfoot { + & > * { + & > th { + color: $color-font-light; + } + & > th, + & > td { + overflow: hidden; + } + & > th, + & > td { + text-align: left; + padding: 9px 5px; + white-space: nowrap; + text-overflow: ellipsis; + + &[number] { + text-align: right; + } + &[centered] { + text-align: center; + } + &[shrink] { + width: 1px; + text-align: center; + } + &[shrink-date] { + width: 100px; + max-width: 100px; + } + &[shrink-datetime] { + width: 150px; + max-width: 150px; + } + &[expand] { + max-width: 400px; + min-width: 0; + } + &[actions] { + width: 1px; + + & > * { + vertical-align: middle; + } + } + vn-icon.bright, i.bright { + color: #f7931e; + } + } + } + } + tbody > * { + border-bottom: 1px solid $color-spacer-light; + + &:last-child { + border-bottom: none; + } + & > td { + .chip { + padding: 4px; + border-radius: 4px; + color: $color-font-bg; + + &.notice { + background-color: $color-notice-medium + } + &.success { + background-color: $color-success-medium; + } + &.warning { + background-color: $color-main-medium; + } + &.alert { + background-color: $color-alert-medium; + } + &.message { + color: $color-font-dark; + background-color: $color-bg-dark + } + } + } + } + .vn-check { + margin: 0; + } + .empty-rows > td { + color: $color-font-secondary; + font-size: 1.375rem; + text-align: center; + } +} \ No newline at end of file diff --git a/front/core/components/table/style.scss b/front/core/components/table/style.scss index c3aaca1b1..2864ea8a1 100644 --- a/front/core/components/table/style.scss +++ b/front/core/components/table/style.scss @@ -96,24 +96,6 @@ vn-table { max-width: 400px; min-width: 0; } - &[vn-fetched-tags] { - min-width: 155px; - & > vn-one { - overflow: hidden; - text-overflow: ellipsis; - font-size: 1rem; - } - - & > vn-one:nth-child(2) h3 { - color: $color-font-secondary; - text-transform: uppercase; - line-height: initial; - font-size: 0.75rem - } - } - &[vn-fetched-tags][wide] { - width: 430px; - } vn-icon.bright, i.bright { color: #f7931e; } diff --git a/front/core/directives/index.js b/front/core/directives/index.js index e0f42aef5..e77917285 100644 --- a/front/core/directives/index.js +++ b/front/core/directives/index.js @@ -16,3 +16,4 @@ import './droppable'; import './http-click'; import './http-submit'; import './anchor'; + diff --git a/front/core/services/email.js b/front/core/services/email.js index 4385eed5f..633b13a26 100644 --- a/front/core/services/email.js +++ b/front/core/services/email.js @@ -18,6 +18,18 @@ class Email { return this.$http.get(`email/${template}`, {params}) .then(() => this.vnApp.showMessage(this.$t('Notification sent!'))); } + + /** + * Sends an email displaying a notification when it's sent. + * + * @param {String} template The email report name + * @param {Object} params The email parameters + * @return {Promise} Promise resolved when it's sent + */ + sendCsv(template, params) { + return this.$http.get(`csv/${template}/send`, {params}) + .then(() => this.vnApp.showMessage(this.$t('Notification sent!'))); + } } Email.$inject = ['$http', '$translate', 'vnApp']; diff --git a/front/core/services/report.js b/front/core/services/report.js index 32ccb52a3..c58a0ee0e 100644 --- a/front/core/services/report.js +++ b/front/core/services/report.js @@ -20,6 +20,21 @@ class Report { const serializedParams = this.$httpParamSerializer(params); window.open(`api/report/${report}?${serializedParams}`); } + + /** + * Shows a report in another window, automatically adds the authorization + * token to params. + * + * @param {String} report The report name + * @param {Object} params The report parameters + */ + showCsv(report, params) { + params = Object.assign({ + authorization: this.vnToken.token + }, params); + const serializedParams = this.$httpParamSerializer(params); + window.open(`api/csv/${report}/download?${serializedParams}`); + } } Report.$inject = ['$httpParamSerializer', 'vnToken']; diff --git a/front/package-lock.json b/front/package-lock.json deleted file mode 100644 index a62548096..000000000 --- a/front/package-lock.json +++ /dev/null @@ -1,133 +0,0 @@ -{ - "name": "salix-front", - "version": "1.0.0", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "@uirouter/angularjs": { - "version": "1.0.29", - "resolved": "https://registry.npmjs.org/@uirouter/angularjs/-/angularjs-1.0.29.tgz", - "integrity": "sha512-RImWnBarNixkMto0o8stEaGwZmvhv5cnuOLXyMU2pY8MP2rgEF74ZNJTLeJCW14LR7XDUxVH8Mk8bPI6lxedmQ==", - "requires": { - "@uirouter/core": "6.0.7" - } - }, - "@uirouter/core": { - "version": "6.0.7", - "resolved": "https://registry.npmjs.org/@uirouter/core/-/core-6.0.7.tgz", - "integrity": "sha512-KUTJxL+6q0PiBnFx4/Z+Hsyg0pSGiaW5yZQeJmUxknecjpTbnXkLU8H2EqRn9N2B+qDRa7Jg8RcgeNDPY72O1w==" - }, - "angular": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/angular/-/angular-1.8.2.tgz", - "integrity": "sha512-IauMOej2xEe7/7Ennahkbb5qd/HFADiNuLSESz9Q27inmi32zB0lnAsFeLEWcox3Gd1F6YhNd1CP7/9IukJ0Gw==" - }, - "angular-animate": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/angular-animate/-/angular-animate-1.8.2.tgz", - "integrity": "sha512-Jbr9+grNMs9Kj57xuBU3Ju3NOPAjS1+g2UAwwDv7su1lt0/PLDy+9zEwDiu8C8xJceoTbmBNKiWGPJGBdCQLlA==" - }, - "angular-moment": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/angular-moment/-/angular-moment-1.3.0.tgz", - "integrity": "sha512-KG8rvO9MoaBLwtGnxTeUveSyNtrL+RNgGl1zqWN36+HDCCVGk2DGWOzqKWB6o+eTTbO3Opn4hupWKIElc8XETA==", - "requires": { - "moment": ">=2.8.0 <3.0.0" - } - }, - "angular-translate": { - "version": "2.18.4", - "resolved": "https://registry.npmjs.org/angular-translate/-/angular-translate-2.18.4.tgz", - "integrity": "sha512-KohNrkH6J9PK+VW0L/nsRTcg5Fw70Ajwwe3Jbfm54Pf9u9Fd+wuingoKv+h45mKf38eT+Ouu51FPua8VmZNoCw==", - "requires": { - "angular": "^1.8.0" - } - }, - "angular-translate-loader-partial": { - "version": "2.18.4", - "resolved": "https://registry.npmjs.org/angular-translate-loader-partial/-/angular-translate-loader-partial-2.18.4.tgz", - "integrity": "sha512-bsjR+FbB0sdA2528E/ugwKdlPPQhA1looxLxI3otayBTFXBpED33besfSZhYAISLgNMSL038vSssfRUen9qD8w==", - "requires": { - "angular-translate": "~2.18.4" - } - }, - "argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "requires": { - "sprintf-js": "~1.0.2" - } - }, - "croppie": { - "version": "2.6.5", - "resolved": "https://registry.npmjs.org/croppie/-/croppie-2.6.5.tgz", - "integrity": "sha512-IlChnVUGG5T3w2gRZIaQgBtlvyuYnlUWs2YZIXXR3H9KrlO1PtBT3j+ykxvy9eZIWhk+V5SpBmhCQz5UXKrEKQ==" - }, - "esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" - }, - "js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", - "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - } - }, - "mg-crud": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/mg-crud/-/mg-crud-1.1.2.tgz", - "integrity": "sha1-p6AWGzWSPK7/8ZpIBpS2V1vDggw=", - "requires": { - "angular": "^1.6.1" - } - }, - "moment": { - "version": "2.29.1", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz", - "integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==" - }, - "oclazyload": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/oclazyload/-/oclazyload-0.6.3.tgz", - "integrity": "sha1-Kjirv/QJDAihEBZxkZRbWfLoJ5w=" - }, - "require-yaml": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/require-yaml/-/require-yaml-0.0.1.tgz", - "integrity": "sha1-LhsY2RPDuqcqWk03O28Tjd0sMr0=", - "requires": { - "js-yaml": "^4.0.0" - }, - "dependencies": { - "argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" - }, - "js-yaml": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.0.0.tgz", - "integrity": "sha512-pqon0s+4ScYUvX30wxQi3PogGFAlUyH0awepWvwkj4jD4v+ova3RiYw8bmA6x2rDrEaj8i/oWKoRxpVNW+Re8Q==", - "requires": { - "argparse": "^2.0.1" - } - } - } - }, - "sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" - }, - "validator": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/validator/-/validator-6.3.0.tgz", - "integrity": "sha1-R84j7Y1Ord+p1LjvAHG2zxB418g=" - } - } -} diff --git a/front/salix/components/home/home.js b/front/salix/components/home/home.js index 74b43a12f..7a36e1d42 100644 --- a/front/salix/components/home/home.js +++ b/front/salix/components/home/home.js @@ -34,8 +34,10 @@ export default class Controller extends Component { for (let starredModule of res.data) { const module = this.modules.find(mod => mod.name === starredModule.moduleFk); - module.starred = true; - module.position = starredModule.position; + if (module) { + module.starred = true; + module.position = starredModule.position; + } } this.countModules(); }); diff --git a/front/salix/components/layout/index.html b/front/salix/components/layout/index.html index cb0fb93b4..cd13c565e 100644 --- a/front/salix/components/layout/index.html +++ b/front/salix/components/layout/index.html @@ -3,7 +3,7 @@ icon="menu" class="show-menu" ng-if="$ctrl.leftMenu" - ng-click="$ctrl.leftMenu.show()"> + ng-click="$ctrl.leftMenu.toggle()">
+ +
diff --git a/print/templates/email/osticket-report/sql/tickets.sql b/print/templates/email/osticket-report/sql/tickets.sql index 4056298e1..50b15473d 100644 --- a/print/templates/email/osticket-report/sql/tickets.sql +++ b/print/templates/email/osticket-report/sql/tickets.sql @@ -9,6 +9,7 @@ SELECT * FROM ( ote.body AS description, oter.body AS resolution FROM ost_ticket ot + JOIN ost_department od ON od.id = ot.dept_id JOIN ost_ticket__cdata otc ON ot.ticket_id = otc.ticket_id JOIN ost_ticket_status ots ON ot.status_id = ots.id JOIN ost_user otu ON ot.user_id = otu.id @@ -19,9 +20,10 @@ SELECT * FROM ( AND ote.type = 'M' LEFT JOIN ost_thread_entry oter ON oth.id = oter.thread_id AND oter.type = 'R' - WHERE ot.ticket_pid = NULL + WHERE ot.ticket_pid IS NULL + AND ot.closed BETWEEN ? AND ? AND ots.state = 'closed' - AND otc.closed BETWEEN ? AND ? + AND od.code = 'IT' ORDER BY oter.created DESC ) ot GROUP BY ot.ticket_id ORDER BY ot.assigned \ No newline at end of file diff --git a/print/templates/reports/claim-pickup-order/locale/es.yml b/print/templates/reports/claim-pickup-order/locale/es.yml index 28bfa73a9..385a54917 100644 --- a/print/templates/reports/claim-pickup-order/locale/es.yml +++ b/print/templates/reports/claim-pickup-order/locale/es.yml @@ -11,5 +11,5 @@ clientSignature: Firma del cliente claim: Reclamación {0} sections: agency: - description: 'Para agilizar su recogida, por favor, póngase en contacto con la oficina - de integrados.
Tlf: 96 166 77 88 - Ana Gómez (Ext. 2113) (agomezf@integra2.com)' + description: 'Para agilizar su recogida, por favor, póngase en contacto con la oficina + de Logista Parcel.
Tlf: 96 166 77 88 - Ana Gómez (Ext. 2113) (atcsalidas.i2valencia@integra2.es)' diff --git a/print/templates/reports/claim-pickup-order/sql/client.sql b/print/templates/reports/claim-pickup-order/sql/client.sql index 249857433..30a42d5c8 100644 --- a/print/templates/reports/claim-pickup-order/sql/client.sql +++ b/print/templates/reports/claim-pickup-order/sql/client.sql @@ -12,8 +12,9 @@ SELECT FROM claim cl JOIN client c ON c.id = cl.clientFk JOIN account.user u ON u.id = c.id - JOIN country ct ON ct.id = c.countryFk JOIN ticket t ON t.id = cl.ticketFk JOIN address a ON a.id = t.addressFk - LEFT JOIN province p ON p.id = c.provinceFk + LEFT JOIN province p ON p.id = a.provinceFk + LEFT JOIN autonomy amy ON amy.id = p.autonomyFk + LEFT JOIN country ct ON ct.id = amy.countryFk WHERE cl.id = ? \ No newline at end of file diff --git a/print/templates/reports/delivery-note/delivery-note.js b/print/templates/reports/delivery-note/delivery-note.js index 549759651..9b3328d05 100755 --- a/print/templates/reports/delivery-note/delivery-note.js +++ b/print/templates/reports/delivery-note/delivery-note.js @@ -29,6 +29,9 @@ module.exports = { const hash = md5(this.signature.id.toString()).substring(0, 3); const file = `${config.storage.root}/${hash}/${this.signature.id}.png`; + + if (!fs.existsSync(file)) return null; + const src = fs.readFileSync(file); const base64 = Buffer.from(src, 'utf8').toString('base64'); diff --git a/print/templates/reports/exportation/assets/css/import.js b/print/templates/reports/exportation/assets/css/import.js new file mode 100644 index 000000000..a2a9334cb --- /dev/null +++ b/print/templates/reports/exportation/assets/css/import.js @@ -0,0 +1,8 @@ +const Stylesheet = require(`${appPath}/core/stylesheet`); + +module.exports = new Stylesheet([ + `${appPath}/common/css/layout.css`, + `${appPath}/common/css/report.css`, + `${appPath}/common/css/misc.css`, + `${__dirname}/style.css`]) + .mergeStyles(); diff --git a/print/templates/reports/exportation/assets/css/style.css b/print/templates/reports/exportation/assets/css/style.css new file mode 100644 index 000000000..174559424 --- /dev/null +++ b/print/templates/reports/exportation/assets/css/style.css @@ -0,0 +1,12 @@ +.grid-block { + font-size: 1.2em +} + +ul li { + margin-bottom: 20px; + text-align: justify; +} + +.signature img { + width: 400px +} \ No newline at end of file diff --git a/print/templates/reports/exportation/assets/images/signature.png b/print/templates/reports/exportation/assets/images/signature.png new file mode 100644 index 000000000..c69cc4798 Binary files /dev/null and b/print/templates/reports/exportation/assets/images/signature.png differ diff --git a/print/templates/reports/exportation/exportation.html b/print/templates/reports/exportation/exportation.html new file mode 100644 index 000000000..f08af2cdb --- /dev/null +++ b/print/templates/reports/exportation/exportation.html @@ -0,0 +1,51 @@ + + + + + + + + + +
+ + + +
+
+

{{$t('title')}}

+

{{$t('toAttention')}}

+

+

+

    +
  • + {{responsibility}} +
  • +
+

+
+

{{$t('issued', [ + 'Algemesí', + invoice.issued.getDate(), + $t('months')[invoice.issued.getMonth()], + invoice.issued.getFullYear()]) + }} +

+

({{$t('signature')}})

+ +

+

{{$t('signer.name')}}: JUAN VICENTE FERRER ROIG
+
{{$t('signer.ID')}}: 73943586N
+
{{$t('signer.position')}}: ADMINISTRADOR
+

+
+
+
+ + + +
+ + \ No newline at end of file diff --git a/print/templates/reports/exportation/exportation.js b/print/templates/reports/exportation/exportation.js new file mode 100755 index 000000000..f63d17930 --- /dev/null +++ b/print/templates/reports/exportation/exportation.js @@ -0,0 +1,34 @@ +const Component = require(`${appPath}/core/component`); +const reportHeader = new Component('report-header'); +const reportFooter = new Component('report-footer'); + +module.exports = { + name: 'exportation', + async serverPrefetch() { + this.invoice = await this.fetchInvoice(this.invoiceId); + + if (!this.invoice) + throw new Error('Something went wrong'); + }, + methods: { + fetchInvoice(invoiceId) { + return this.findOneFromDef('invoice', [invoiceId]); + } + }, + computed: { + issued: function() { + const filters = this.$options.filters; + + return filters.date(this.invoice.issued, '%d-%m-%Y'); + } + }, + components: { + 'report-header': reportHeader.build(), + 'report-footer': reportFooter.build() + }, + props: { + invoiceId: { + required: true + } + } +}; diff --git a/print/templates/reports/exportation/locale/es.yml b/print/templates/reports/exportation/locale/es.yml new file mode 100644 index 000000000..d5fb78b4c --- /dev/null +++ b/print/templates/reports/exportation/locale/es.yml @@ -0,0 +1,50 @@ +title: 'Carta CITES' +toAttention: 'A la atención del Sr. Administrador de la Aduana de la Farga de Moles.' +declaration: 'Por la presente DECLARO, bajo mi responsabilidad, que las mercancías detalladas en la factura +n° {0} de fecha {1} +asi como ninguno de sus componentes,' +issued: 'En {0}, a {1} de {2} de {3}' +invoice: 'Factura {0}' +responsibilities: + - 'NO están comprendidas en la Convención de Washington (CITES). Reglamento (CE) n° 338/1997 +DO L61 de 3.3.1997 y sus últimas modificaciones, relativo a la protección de especies de fauna y +flora silvestres.' + - 'NO están incluidas en las listas del Anexo I del R/CE 428/2009 y sus posteriores modificaciones, +por lo que NO puede considerarse productos ni tecnologias de Doble Uso ni de uso militar. +No estando incluidas en la Relación de Material de Defensa del Anexo I del Real Decreto +679/2014, estando exentas a todos los efectos de autorizaciones administrativas para su comercio +exterior.' + - 'NO están incluidas los Anexos II, III y IV del R/UE 2019/125 L-30 de 31/01/2019 +y sus modificaciones, sobre el comercio de determinados productos que pueden utilizarse para +aplicar la pena de muerte o infligir tortura u otros tratos o penas crueles, inhumanos o +degradantes.' + - 'NO están incluidas en el ANEXO ni en el ANEXO V del Reglamento (UE) N° 649/2012 y +sus modificaciones, relativo a la exportación e importación de productos químicos +peligrosos. ni tampoco contienen mercurio.' + - 'NO están sujetas al Reglamento/CE 1005/2009 L-286 de 30-10-2009 y sus +modificaciones, relativo a las mercancías que agotan la capa de ozono.' + - 'NO están afectadas por la prohibición a las importaciones de gases fluorados de +efecto invernadero, de acuerdo con el R/UE 517/2014.' + - 'NO están sujetas al Reglamento (CE) 116/2009 relativo a la exportación de bienes +culturales; y NO están sujetas a la Ley 16/1985, de 25 de junio, del Patrimonio +Histórico Español, estando exentas de Autorización Administrativa de Exportación.' + - 'NO están sujetos a las disposiciones del Reglamento (CE) Nº 1013/2006, relativo +a los traslados de residuos, y que en ningún modo pueden considerarse afectados por este control.' +signature: Firma y sello de la empresa +signer: + name: Nombre del firmante + ID: DNI del firmante + position: Cargo del firmante +months: + - 'Enero' + - 'Febrero' + - 'Marzo' + - 'Abril' + - 'Mayo' + - 'Junio' + - 'Julio' + - 'Agosto' + - 'Septiembre' + - 'Octubre' + - 'Noviembre' + - 'Diciembre' \ No newline at end of file diff --git a/print/templates/reports/exportation/sql/invoice.sql b/print/templates/reports/exportation/sql/invoice.sql new file mode 100644 index 000000000..8e92333dd --- /dev/null +++ b/print/templates/reports/exportation/sql/invoice.sql @@ -0,0 +1,6 @@ +SELECT + io.id, + io.ref, + io.issued +FROM invoiceOut io +WHERE io.id = ? \ No newline at end of file diff --git a/print/templates/reports/invoice-incoterms/invoice-incoterms.html b/print/templates/reports/invoice-incoterms/invoice-incoterms.html index 2cceccc93..f30667042 100644 --- a/print/templates/reports/invoice-incoterms/invoice-incoterms.html +++ b/print/templates/reports/invoice-incoterms/invoice-incoterms.html @@ -62,7 +62,6 @@ {{$t('incoterms')}} -
asd
{{incoterms.incotermsFk}} - {{incoterms.incotermsName}} diff --git a/print/templates/reports/invoice-incoterms/invoice-incoterms.js b/print/templates/reports/invoice-incoterms/invoice-incoterms.js index cfe0a21cb..95bf1f397 100755 --- a/print/templates/reports/invoice-incoterms/invoice-incoterms.js +++ b/print/templates/reports/invoice-incoterms/invoice-incoterms.js @@ -23,7 +23,7 @@ module.exports = { return this.findOneFromDef('client', [invoiceId]); }, fetchIncoterms(invoiceId) { - return this.findOneFromDef('incoterms', {invoiceId}); + return this.findOneFromDef('incoterms', [invoiceId, invoiceId, invoiceId]); } }, components: { diff --git a/print/templates/reports/invoice-incoterms/sql/incoterms.sql b/print/templates/reports/invoice-incoterms/sql/incoterms.sql index e3d3f19c1..5d894a4b2 100644 --- a/print/templates/reports/invoice-incoterms/sql/incoterms.sql +++ b/print/templates/reports/invoice-incoterms/sql/incoterms.sql @@ -51,8 +51,8 @@ SELECT io.issued, FROM vn.invoiceOut io JOIN vn.ticket t ON t.refFk = io.ref JOIN vn.saleVolume sv ON sv.ticketFk = t.id - WHERE io.id = :invoiceId - )sub2 ON TRUE + WHERE io.id = ? + ) sub2 ON TRUE JOIN vn.itemTaxCountry itc ON itc.countryFk = su.countryFk AND itc.itemFk = s.itemFk JOIN vn.taxClass tc ON tc.id = itc.taxClassFk LEFT JOIN vn.invoiceOutSerial ios ON ios.code = io.serial AND ios.taxAreaFk = 'CEE' @@ -66,6 +66,6 @@ SELECT io.issued, JOIN vn.sale s ON t.id = s.ticketFk JOIN vn.item i ON i.id = s.itemFk JOIN vn.intrastat ir ON ir.id = i.intrastatFk - WHERE io.id = :invoiceId + WHERE io.id = ? )sub3 ON TRUE - WHERE io.id = :invoiceId + WHERE io.id = ? diff --git a/print/templates/reports/invoice/invoice.html b/print/templates/reports/invoice/invoice.html index 671bb8c7f..8b13f2a15 100644 --- a/print/templates/reports/invoice/invoice.html +++ b/print/templates/reports/invoice/invoice.html @@ -96,7 +96,7 @@
-

Shipped

+

{{$t('shipped')}}

diff --git a/print/templates/reports/invoice/invoice.js b/print/templates/reports/invoice/invoice.js index a6e37d591..b56a5533c 100755 --- a/print/templates/reports/invoice/invoice.js +++ b/print/templates/reports/invoice/invoice.js @@ -19,12 +19,14 @@ module.exports = { const map = new Map(); - for (let ticket of tickets) + for (let ticket of tickets) { + ticket.sales = []; + map.set(ticket.id, ticket); + } for (let sale of sales) { const ticket = map.get(sale.ticketFk); - if (!ticket.sales) ticket.sales = []; ticket.sales.push(sale); } diff --git a/print/templates/reports/invoice/sql/tickets.sql b/print/templates/reports/invoice/sql/tickets.sql index feca81ead..7d135bd03 100644 --- a/print/templates/reports/invoice/sql/tickets.sql +++ b/print/templates/reports/invoice/sql/tickets.sql @@ -4,4 +4,5 @@ SELECT t.nickname FROM invoiceOut io JOIN ticket t ON t.refFk = io.ref -WHERE io.id = ? \ No newline at end of file +WHERE io.id = ? +ORDER BY t.shipped \ No newline at end of file