diff --git a/db/changes/10280-valentineDay/00-department.sql b/db/changes/10280-valentineDay/00-department.sql deleted file mode 100644 index bb3062825..000000000 --- a/db/changes/10280-valentineDay/00-department.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE `vn`.`department` - ADD code VARCHAR(45) NULL AFTER id; - -UPDATE `vn`.`department` t SET t.code = 'IT', t.chatName = 'informatica-cau' WHERE t.id = 31; diff --git a/db/changes/10280-valentineDay/00-itemImageQueue.sql b/db/changes/10280-valentineDay/00-itemImageQueue.sql deleted file mode 100644 index 41c55552d..000000000 --- a/db/changes/10280-valentineDay/00-itemImageQueue.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE `vn`.`itemImageQueue` - ADD attempts INT default 0 NULL AFTER error; diff --git a/db/changes/10281-valentineDay/00-ACL.sql b/db/changes/10281-valentineDay/00-ACL.sql deleted file mode 100644 index 861db5777..000000000 --- a/db/changes/10281-valentineDay/00-ACL.sql +++ /dev/null @@ -1,5 +0,0 @@ -INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) - VALUES - ('SupplierAccount', '*', '*', 'ALLOW', 'ROLE', 'administrative'), - ('Entry', '*', '*', 'ALLOW', 'ROLE', 'administrative'), - ('InvoiceIn', '*', '*', 'ALLOW', 'ROLE', 'administrative'); diff --git a/db/changes/10281-valentineDay/00-item_getBalance.sql b/db/changes/10281-valentineDay/00-item_getBalance.sql deleted file mode 100644 index 96c82cc01..000000000 --- a/db/changes/10281-valentineDay/00-item_getBalance.sql +++ /dev/null @@ -1,137 +0,0 @@ -DROP PROCEDURE `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`, - `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 - FROM - ( SELECT tr.landed AS shipped, - b.quantity AS `in`, - NULL AS `out`, - al.alertLevel AS alertLevel, - st.name AS stateName, - s.name AS name, - e.ref AS reference, - e.id AS origin, - s.id AS clientFk, - IF(al.alertLevel = 3, TRUE, FALSE) isPicked, - FALSE AS isTicket, - b.id lineFk, - NULL `order`, - NULL AS clientType - 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.alertLevel = - 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 as `in`, - b.quantity AS `out`, - al.alertLevel AS alertLevel, - st.name AS stateName, - s.name AS name, - e.ref AS reference, - e.id AS origin, - s.id AS clientFk, - IF(al.alertLevel = 3, TRUE, FALSE) isPicked, - FALSE AS isTicket, - b.id, - NULL `order`, - NULL AS clientType - 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.alertLevel = - 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 as `in`, - s.quantity AS `out`, - al.alertLevel AS alertLevel, - st.name AS stateName, - t.nickname AS name, - t.refFk AS reference, - t.id AS origin, - t.clientFk, - stk.id AS isPicked, - TRUE AS isTicket, - s.id, - st.`order`, - ct.code AS clientType - 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.alertLevel = - 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 - 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/10281-valentineDay/00-supplier.sql b/db/changes/10281-valentineDay/00-supplier.sql deleted file mode 100644 index c35a86a23..000000000 --- a/db/changes/10281-valentineDay/00-supplier.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE `vn`.`supplier` ADD COLUMN `workerFk` INT(11) NULL DEFAULT NULL COMMENT 'Responsible for approving invoices' AFTER `isTrucker`; -ALTER TABLE `vn`.`supplier` ADD CONSTRAINT `supplier_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE; \ No newline at end of file diff --git a/db/changes/10290-invoiceIn/00-ACL.sql b/db/changes/10290-invoiceIn/00-ACL.sql deleted file mode 100644 index e3551c667..000000000 --- a/db/changes/10290-invoiceIn/00-ACL.sql +++ /dev/null @@ -1,4 +0,0 @@ -INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) - VALUES - ('StarredModule', '*', '*', 'ALLOW', 'ROLE', 'employee'), - ('ItemBotanical', '*', 'WRITE', 'ALLOW', 'ROLE', 'logisticBoss'); \ No newline at end of file diff --git a/db/changes/10290-invoiceIn/00-module.sql b/db/changes/10290-invoiceIn/00-module.sql deleted file mode 100644 index 780a0e7fe..000000000 --- a/db/changes/10290-invoiceIn/00-module.sql +++ /dev/null @@ -1,20 +0,0 @@ -CREATE TABLE `salix`.`module` ( - `code` VARCHAR(45) COLLATE utf8_unicode_ci NOT NULL, - PRIMARY KEY (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; - -INSERT INTO `salix`.`module`(`code`) - VALUES - ('Items'), - ('Orders'), - ('Clients'), - ('Entries'), - ('Travels'), - ('Invoices out'), - ('Suppliers'), - ('Claims'), - ('Routes'), - ('Tickets'), - ('Workers'), - ('Users'), - ('Zones'); \ No newline at end of file diff --git a/db/changes/10290-invoiceIn/01-starredModule.sql b/db/changes/10290-invoiceIn/01-starredModule.sql deleted file mode 100644 index e36777030..000000000 --- a/db/changes/10290-invoiceIn/01-starredModule.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE `vn`.`starredModule` ( - `id` INT(11) unsigned NOT NULL AUTO_INCREMENT, - `workerFk` INT(10) NOT NULL, - `moduleFk` VARCHAR(45) COLLATE utf8_unicode_ci NOT NULL, - PRIMARY KEY (`id`), - KEY `starred_workerFk` (`workerFk`), - KEY `starred_moduleFk` (`moduleFk`), - CONSTRAINT `starred_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE, - CONSTRAINT `starred_moduleFk` FOREIGN KEY (`moduleFk`) REFERENCES `salix`.`module` (`code`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; \ No newline at end of file diff --git a/db/changes/10291-invoiceIn/00-ACL.sql b/db/changes/10291-invoiceIn/00-ACL.sql deleted file mode 100644 index 5a1cf6843..000000000 --- a/db/changes/10291-invoiceIn/00-ACL.sql +++ /dev/null @@ -1,5 +0,0 @@ -INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) - VALUES - ('Genus', '*', 'WRITE', 'ALLOW', 'ROLE', 'logisticBoss'), - ('Specie', '*', 'WRITE', 'ALLOW', 'ROLE', 'logisticBoss'), - ('InvoiceOut', 'createPdf', 'WRITE', 'ALLOW', 'ROLE', 'invoicing'); diff --git a/db/dump/dumpedFixtures.sql b/db/dump/dumpedFixtures.sql index 627d7cdc1..67f547c6d 100644 --- a/db/dump/dumpedFixtures.sql +++ b/db/dump/dumpedFixtures.sql @@ -1,10 +1,10 @@ USE `util`; --- MariaDB dump 10.18 Distrib 10.5.8-MariaDB, for Linux (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for Linux (x86_64) -- --- Host: test-db.verdnatura.es Database: util +-- Host: db.verdnatura.es Database: util -- ------------------------------------------------------ --- Server version 10.4.17-MariaDB-1:10.4.17+maria~buster-log +-- Server version 5.6.25-4-log /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -22,7 +22,7 @@ USE `util`; LOCK TABLES `config` WRITE; /*!40000 ALTER TABLE `config` DISABLE KEYS */; -INSERT INTO `config` VALUES (1,'10280',0,'test','2021-02-09 04:05:43'); +INSERT INTO `config` VALUES (1,'10291',0,'production',NULL); /*!40000 ALTER TABLE `config` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -34,13 +34,13 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-02-09 12:15:11 +-- Dump completed on 2021-03-30 11:16:49 USE `account`; --- MariaDB dump 10.18 Distrib 10.5.8-MariaDB, for Linux (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for Linux (x86_64) -- --- Host: test-db.verdnatura.es Database: account +-- Host: db.verdnatura.es Database: account -- ------------------------------------------------------ --- Server version 10.4.17-MariaDB-1:10.4.17+maria~buster-log +-- Server version 5.6.25-4-log /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -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 departamento',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(15,'logistic','Departamento de compras, responsables de la logistica',1,'2017-05-19 07:04:58','2018-02-12 10:50:10'),(16,'logisticBoss','Jefe del departamento de logística',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(17,'adminBoss','Jefe del departamento de administración',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(18,'salesPerson','Departamento de ventas',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(19,'salesBoss','Jefe del departamento de ventas',1,'2017-05-19 07:04:58','2017-08-16 12:38:27'),(20,'manager','Departamento de gerencia',1,'2017-06-01 14:57:02','2017-06-01 14:57:51'),(21,'salesAssistant','Jefe auxiliar de ventas',1,'2017-08-16 12:40:52','2017-08-16 12:40:52'),(22,'teamManager','Jefe de departamento con privilegios de auxiliar de venta.',1,'2017-09-07 09:08:12','2017-09-07 09:08:12'),(30,'financialBoss','Director finaciero',1,'2017-09-21 11:05:36','2017-09-21 11:05:36'),(31,'freelancer','Trabajadores por cuenta ajena',1,'2017-10-10 12:57:26','2017-10-10 12:59:27'),(32,'ett','Trabajadores de empresa temporal',1,'2017-10-10 12:58:58','2017-10-10 12:59:20'),(33,'invoicing','Personal con acceso a facturación',0,'2018-01-29 16:43:34','2018-01-29 16:43:34'),(34,'agencyBoss','Jefe/a del departamento de agencias',1,'2018-01-29 16:44:39','2018-02-23 07:58:53'),(35,'buyer','Departamento de compras',1,'2018-02-12 10:35:42','2018-02-12 10:35:42'),(36,'replenisher','Trabajadores de camara',1,'2018-02-16 14:07:10','2019-04-12 05:38:08'),(37,'hr','Gestor/a de recursos humanos',1,'2018-02-22 17:34:53','2018-02-22 17:34:53'),(38,'hrBoss','Jefe/a de recursos humanos',1,'2018-02-22 17:35:09','2018-02-22 17:35:09'),(39,'adminAssistant','Jefe auxiliar administrativo',1,'2018-02-23 10:37:36','2018-02-23 10:38:41'),(40,'handmade','Departamento de confección',1,'2018-02-23 11:14:53','2018-02-23 11:39:12'),(41,'handmadeBoss','Jefe de departamento de confección',1,'2018-02-23 11:15:09','2018-02-23 11:39:26'),(42,'artificial','Departamento de artificial',1,'2018-02-23 11:39:59','2018-02-23 11:39:59'),(43,'artificialBoss','Jefe del departamento de artificial',1,'2018-02-23 11:40:16','2018-02-23 11:40:16'),(44,'accessory','Departamento de complementos',1,'2018-02-23 11:41:12','2018-02-23 11:41:12'),(45,'accessoryBoss','Jefe del departamento de complementos',1,'2018-02-23 11:41:23','2018-02-23 11:41:23'),(47,'cooler','Empleados de cámara',1,'2018-02-23 13:08:18','2018-02-23 13:08:18'),(48,'coolerBoss','Jefe del departamento de cámara',1,'2018-02-23 13:12:01','2018-02-23 13:12:01'),(49,'production','Empleado de producción',0,'2018-02-26 15:28:23','2019-01-21 12:57:21'),(50,'productionBoss','Jefe de producción',1,'2018-02-26 15:34:12','2018-02-26 15:34:12'),(51,'marketing','Departamento de marketing',1,'2018-03-01 07:28:39','2018-03-01 07:28:39'),(52,'marketingBoss','Jefe del departamento de marketing',1,'2018-03-01 07:28:57','2018-03-01 07:28:57'),(53,'insurance','Gestor de seguros de cambio',0,'2018-03-05 07:44:35','2019-02-01 13:47:57'),(54,'itemPicker','Sacador en cámara',1,'2018-03-05 12:08:17','2018-03-05 12:08:17'),(55,'itemPickerBoss','Jefe de sacadores',1,'2018-03-05 12:08:31','2018-03-05 12:08:31'),(56,'delivery','Personal de reparto',1,'2018-05-30 06:07:02','2018-05-30 06:07:02'),(57,'deliveryBoss','Jefe de personal de reparto',1,'2018-05-30 06:07:19','2018-05-30 06:07:19'),(58,'packager','Departamento encajadores',1,'2019-01-21 12:43:45','2019-01-21 12:43:45'),(59,'packagerBoss','Jefe departamento encajadores',1,'2019-01-21 12:44:10','2019-01-21 12:44:10'),(60,'productionAssi','Tareas relacionadas con producción y administración',1,'2019-01-29 13:29:01','2019-01-29 13:29:01'),(61,'replenisherBos','Jefe de Complementos/Camara',1,'2019-07-01 06:44:07','2019-07-01 06:44:07'),(62,'noLogin','Role without login access to MySQL',0,'2019-07-01 06:50:19','2019-07-02 13:42:05'),(64,'balanceSheet','Consulta de Balance',0,'2019-07-16 12:12:08','2019-07-16 12:12:08'),(65,'officeBoss','Jefe de filial',1,'2019-08-02 06:54:26','2019-08-02 06:54:26'),(66,'sysadmin','Administrador de sistema',1,'2019-08-08 06:58:56','2019-08-08 06:58:56'),(67,'adminOfficer','categoria profesional oficial de administración',1,'2020-01-03 08:09:23','2020-01-03 08:09:23'),(69,'coolerAssist','Empleado cámara con permiso compras',1,'2020-02-05 12:36:09','2020-02-05 12:36:09'),(70,'trainee','Alumno de prácticas',1,'2020-03-04 11:00:25','2020-03-04 11:00:25'),(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'); +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 departamento',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(15,'logistic','Departamento de compras, responsables de la logistica',1,'2017-05-19 07:04:58','2018-02-12 10:50:10'),(16,'logisticBoss','Jefe del departamento de logística',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(17,'adminBoss','Jefe del departamento de administración',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(18,'salesPerson','Departamento de ventas',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(19,'salesBoss','Jefe del departamento de ventas',1,'2017-05-19 07:04:58','2017-08-16 12:38:27'),(20,'manager','Departamento de gerencia',1,'2017-06-01 14:57:02','2017-06-01 14:57:51'),(21,'salesAssistant','Jefe auxiliar de ventas',1,'2017-08-16 12:40:52','2017-08-16 12:40:52'),(22,'teamManager','Jefe de departamento con privilegios de auxiliar de venta.',1,'2017-09-07 09:08:12','2017-09-07 09:08:12'),(30,'financialBoss','Director finaciero',1,'2017-09-21 11:05:36','2017-09-21 11:05:36'),(31,'freelancer','Trabajadores por cuenta ajena',1,'2017-10-10 12:57:26','2017-10-10 12:59:27'),(32,'ett','Trabajadores de empresa temporal',1,'2017-10-10 12:58:58','2017-10-10 12:59:20'),(33,'invoicing','Personal con acceso a facturación',0,'2018-01-29 16:43:34','2018-01-29 16:43:34'),(34,'agencyBoss','Jefe/a del departamento de agencias',1,'2018-01-29 16:44:39','2018-02-23 07:58:53'),(35,'buyer','Departamento de compras',1,'2018-02-12 10:35:42','2018-02-12 10:35:42'),(36,'replenisher','Trabajadores de camara',1,'2018-02-16 14:07:10','2019-04-12 05:38:08'),(37,'hr','Gestor/a de recursos humanos',1,'2018-02-22 17:34:53','2018-02-22 17:34:53'),(38,'hrBoss','Jefe/a de recursos humanos',1,'2018-02-22 17:35:09','2018-02-22 17:35:09'),(39,'adminAssistant','Jefe auxiliar administrativo',1,'2018-02-23 10:37:36','2018-02-23 10:38:41'),(40,'handmade','Departamento de confección',1,'2018-02-23 11:14:53','2018-02-23 11:39:12'),(41,'handmadeBoss','Jefe de departamento de confección',1,'2018-02-23 11:15:09','2018-02-23 11:39:26'),(42,'artificial','Departamento de artificial',1,'2018-02-23 11:39:59','2018-02-23 11:39:59'),(43,'artificialBoss','Jefe del departamento de artificial',1,'2018-02-23 11:40:16','2018-02-23 11:40:16'),(44,'accessory','Departamento de complementos',1,'2018-02-23 11:41:12','2018-02-23 11:41:12'),(45,'accessoryBoss','Jefe del departamento de complementos',1,'2018-02-23 11:41:23','2018-02-23 11:41:23'),(47,'cooler','Empleados de cámara',1,'2018-02-23 13:08:18','2018-02-23 13:08:18'),(48,'coolerBoss','Jefe del departamento de cámara',1,'2018-02-23 13:12:01','2018-02-23 13:12:01'),(49,'production','Empleado de producción',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'); /*!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),(13,15,57),(114,15,76),(14,16,13),(15,16,15),(127,16,76),(16,17,20),(17,17,37),(18,17,39),(19,17,64),(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),(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),(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),(100,69,47),(101,70,11),(102,71,1),(103,71,58),(104,72,13),(105,72,18),(106,73,5),(108,73,19),(107,73,64); +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),(13,15,57),(114,15,76),(14,16,13),(15,16,15),(127,16,76),(16,17,20),(17,17,37),(18,17,39),(19,17,64),(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),(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),(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),(100,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); /*!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 (30147,1,1),(30148,1,2),(30149,1,3),(30152,1,6),(30151,1,11),(30150,1,70),(30066,2,2),(30068,2,6),(30067,2,11),(29965,3,3),(29967,3,6),(29966,3,11),(29937,5,1),(29944,5,2),(29943,5,3),(29936,5,5),(29948,5,6),(29947,5,11),(29941,5,13),(29945,5,18),(29938,5,21),(29939,5,33),(29946,5,53),(29942,5,70),(29940,5,76),(30215,6,6),(30111,9,1),(30108,9,2),(30096,9,3),(30094,9,5),(30116,9,6),(30086,9,9),(30091,9,11),(30143,9,13),(30125,9,15),(30126,9,16),(30093,9,17),(30141,9,18),(30140,9,19),(30127,9,20),(30139,9,21),(30144,9,22),(30114,9,30),(30115,9,31),(30112,9,32),(30122,9,33),(30097,9,34),(30101,9,35),(30137,9,36),(30119,9,37),(30120,9,38),(30092,9,39),(30117,9,40),(30118,9,41),(30098,9,42),(30099,9,43),(30089,9,44),(30090,9,45),(30105,9,47),(30107,9,48),(30134,9,49),(30136,9,50),(30128,9,51),(30129,9,52),(30121,9,53),(30123,9,54),(30124,9,55),(30109,9,56),(30110,9,57),(30132,9,58),(30133,9,59),(30135,9,60),(30138,9,61),(30130,9,62),(30100,9,64),(30131,9,65),(30142,9,66),(30095,9,67),(30106,9,69),(30145,9,70),(30103,9,71),(30104,9,72),(30113,9,73),(30146,9,74),(30102,9,75),(30087,9,76),(30088,9,100),(29885,11,6),(29884,11,11),(30657,13,1),(30658,13,2),(30659,13,3),(30662,13,6),(30661,13,11),(30656,13,13),(30660,13,70),(30295,15,1),(30299,15,2),(30298,15,3),(30301,15,6),(30300,15,11),(30293,15,13),(30289,15,15),(30290,15,35),(30296,15,56),(30291,15,57),(30297,15,70),(30294,15,75),(30292,15,76),(30308,16,1),(30311,16,2),(30310,16,3),(30315,16,6),(30314,16,11),(30303,16,13),(30304,16,15),(30302,16,16),(30307,16,35),(30313,16,56),(30306,16,57),(30309,16,70),(30312,16,75),(30305,16,76),(29909,17,1),(29919,17,2),(29918,17,3),(29913,17,5),(29931,17,6),(29927,17,11),(29912,17,13),(29923,17,15),(29911,17,16),(29902,17,17),(29924,17,18),(29922,17,19),(29903,17,20),(29914,17,21),(29916,17,33),(29921,17,35),(29933,17,36),(29904,17,37),(29905,17,39),(29935,17,44),(29934,17,47),(29929,17,49),(29920,17,50),(29925,17,53),(29926,17,56),(29915,17,57),(29932,17,58),(29928,17,59),(29906,17,64),(29910,17,65),(29917,17,70),(29908,17,74),(29930,17,75),(29907,17,76),(30588,18,1),(30591,18,2),(30590,18,3),(30594,18,6),(30593,18,11),(30587,18,18),(30592,18,70),(30589,18,76),(30581,19,1),(30584,19,2),(30583,19,3),(30586,19,6),(30585,19,11),(30577,19,13),(30578,19,18),(30575,19,19),(30576,19,21),(30579,19,53),(30582,19,70),(30580,19,76),(30324,20,1),(30330,20,2),(30329,20,3),(30342,20,6),(30339,20,11),(30317,20,13),(30323,20,15),(30318,20,16),(30337,20,18),(30322,20,19),(30316,20,20),(30326,20,21),(30321,20,35),(30335,20,36),(30341,20,44),(30340,20,47),(30332,20,49),(30325,20,50),(30336,20,53),(30338,20,56),(30327,20,57),(30334,20,58),(30333,20,59),(30319,20,65),(30328,20,70),(30331,20,75),(30320,20,76),(30569,21,1),(30572,21,2),(30571,21,3),(30574,21,6),(30573,21,11),(30565,21,13),(30566,21,18),(30564,21,21),(30567,21,53),(30570,21,70),(30568,21,76),(30667,22,1),(30672,22,2),(30671,22,3),(30674,22,6),(30673,22,11),(30664,22,13),(30666,22,18),(30665,22,21),(30663,22,22),(30668,22,53),(30670,22,70),(30669,22,76),(30188,30,1),(30194,30,2),(30193,30,3),(30177,30,5),(30205,30,6),(30201,30,11),(30185,30,13),(30190,30,15),(30184,30,16),(30191,30,18),(30189,30,19),(30178,30,20),(30187,30,21),(30179,30,22),(30176,30,30),(30186,30,33),(30195,30,35),(30203,30,36),(30207,30,44),(30206,30,47),(30198,30,49),(30196,30,50),(30180,30,53),(30204,30,56),(30200,30,57),(30202,30,58),(30197,30,59),(30181,30,64),(30183,30,65),(30192,30,70),(30199,30,75),(30182,30,76),(30209,31,1),(30210,31,2),(30211,31,3),(30214,31,6),(30213,31,11),(30208,31,31),(30212,31,70),(30154,32,1),(30155,32,2),(30156,32,3),(30159,32,6),(30158,32,11),(30153,32,32),(30157,32,70),(30272,33,33),(29969,34,1),(29974,34,2),(29973,34,3),(29976,34,6),(29975,34,11),(29970,34,13),(29971,34,33),(29968,34,34),(29972,34,70),(30011,35,1),(30016,35,2),(30015,35,3),(30018,35,6),(30017,35,11),(30010,35,35),(30014,35,70),(30012,35,75),(30013,35,76),(30486,36,1),(30488,36,2),(30487,36,3),(30491,36,6),(30490,36,11),(30483,36,36),(30484,36,44),(30485,36,47),(30489,36,70),(30246,37,1),(30251,37,2),(30250,37,3),(30253,37,6),(30252,37,11),(30245,37,37),(30249,37,70),(30247,37,74),(30248,37,76),(30259,38,1),(30262,38,2),(30261,38,3),(30264,38,6),(30263,38,11),(30255,38,37),(30254,38,38),(30256,38,64),(30260,38,70),(30258,38,74),(30257,38,76),(29894,39,1),(29899,39,2),(29898,39,3),(29887,39,5),(29901,39,6),(29900,39,11),(29892,39,13),(29891,39,18),(29888,39,21),(29893,39,33),(29886,39,39),(29895,39,53),(29896,39,56),(29889,39,57),(29897,39,70),(29890,39,76),(30217,40,1),(30220,40,2),(30219,40,3),(30227,40,6),(30226,40,11),(30222,40,36),(30216,40,40),(30225,40,44),(30224,40,47),(30218,40,49),(30223,40,58),(30221,40,70),(30235,41,1),(30239,41,2),(30238,41,3),(30244,41,6),(30243,41,11),(30229,41,13),(30230,41,35),(30236,41,36),(30231,41,40),(30228,41,41),(30242,41,44),(30241,41,47),(30233,41,49),(30240,41,58),(30237,41,70),(30234,41,75),(30232,41,76),(29983,42,1),(29988,42,2),(29987,42,3),(29991,42,6),(29990,42,11),(29978,42,35),(29981,42,36),(29977,42,42),(29985,42,44),(29989,42,47),(29979,42,49),(29984,42,58),(29986,42,70),(29982,42,75),(29980,42,76),(29996,43,1),(30002,43,2),(30001,43,3),(30008,43,6),(30007,43,11),(29993,43,13),(29995,43,35),(30003,43,36),(29994,43,42),(29992,43,43),(30006,43,44),(30005,43,47),(29997,43,49),(30004,43,58),(30000,43,70),(29999,43,75),(29998,43,76),(29869,44,1),(29870,44,2),(29871,44,3),(29874,44,6),(29873,44,11),(29868,44,44),(29872,44,70),(29878,45,1),(29880,45,2),(29879,45,3),(29883,45,6),(29882,45,11),(29876,45,13),(29877,45,44),(29875,45,45),(29881,45,70),(30040,47,1),(30041,47,2),(30042,47,3),(30045,47,6),(30044,47,11),(30039,47,47),(30043,47,70),(30060,48,1),(30062,48,2),(30061,48,3),(30065,48,6),(30064,48,11),(30058,48,13),(30059,48,47),(30057,48,48),(30063,48,70),(30428,49,1),(30431,49,2),(30430,49,3),(30433,49,6),(30432,49,11),(30424,49,36),(30427,49,44),(30426,49,47),(30423,49,49),(30425,49,58),(30429,49,70),(30475,50,1),(30480,50,2),(30479,50,3),(30482,50,6),(30481,50,11),(30462,50,13),(30474,50,18),(30463,50,21),(30464,50,35),(30471,50,36),(30477,50,44),(30476,50,47),(30465,50,49),(30461,50,50),(30473,50,53),(30469,50,56),(30466,50,57),(30470,50,58),(30467,50,59),(30478,50,70),(30472,50,75),(30468,50,76),(30344,51,1),(30349,51,2),(30348,51,3),(30351,51,6),(30350,51,11),(30343,51,51),(30347,51,70),(30345,51,74),(30346,51,75),(30361,52,1),(30366,52,2),(30365,52,3),(30368,52,6),(30367,52,11),(30353,52,13),(30363,52,18),(30354,52,19),(30360,52,21),(30355,52,35),(30356,52,51),(30352,52,52),(30362,52,53),(30364,52,70),(30358,52,74),(30359,52,75),(30357,52,76),(30266,53,1),(30267,53,2),(30268,53,3),(30271,53,6),(30270,53,11),(30265,53,53),(30269,53,70),(30274,54,1),(30275,54,2),(30276,54,3),(30279,54,6),(30278,54,11),(30273,54,54),(30277,54,70),(30283,55,1),(30285,55,2),(30284,55,3),(30288,55,6),(30287,55,11),(30281,55,13),(30282,55,54),(30280,55,55),(30286,55,70),(30070,56,1),(30071,56,2),(30072,56,3),(30075,56,6),(30074,56,11),(30069,56,56),(30073,56,70),(30080,57,1),(30083,57,2),(30082,57,3),(30085,57,6),(30084,57,11),(30077,57,13),(30078,57,56),(30076,57,57),(30081,57,70),(30079,57,76),(30395,58,1),(30396,58,2),(30397,58,3),(30400,58,6),(30399,58,11),(30394,58,58),(30398,58,70),(30405,59,1),(30415,59,2),(30414,59,3),(30422,59,6),(30421,59,11),(30402,59,13),(30412,59,18),(30404,59,21),(30406,59,35),(30416,59,36),(30420,59,44),(30419,59,47),(30407,59,49),(30403,59,50),(30411,59,53),(30418,59,56),(30408,59,57),(30417,59,58),(30401,59,59),(30413,59,70),(30410,59,75),(30409,59,76),(30444,60,1),(30456,60,2),(30455,60,3),(30435,60,5),(30460,60,6),(30459,60,11),(30440,60,13),(30453,60,18),(30443,60,21),(30442,60,33),(30445,60,35),(30450,60,36),(30436,60,37),(30458,60,44),(30457,60,47),(30446,60,49),(30437,60,50),(30452,60,53),(30448,60,56),(30438,60,57),(30449,60,58),(30447,60,59),(30434,60,60),(30454,60,70),(30441,60,74),(30451,60,75),(30439,60,76),(30496,61,1),(30500,61,2),(30499,61,3),(30502,61,6),(30501,61,11),(30493,61,13),(30494,61,36),(30495,61,44),(30497,61,47),(30492,61,61),(30498,61,70),(30369,62,62),(30009,64,64),(30377,65,1),(30386,65,2),(30385,65,3),(30393,65,6),(30392,65,11),(30375,65,13),(30388,65,18),(30371,65,19),(30378,65,21),(30372,65,35),(30383,65,36),(30391,65,44),(30390,65,47),(30379,65,49),(30373,65,50),(30387,65,53),(30389,65,56),(30380,65,57),(30382,65,58),(30381,65,59),(30370,65,65),(30384,65,70),(30376,65,75),(30374,65,76),(30621,66,1),(30617,66,2),(30605,66,3),(30603,66,5),(30626,66,6),(30620,66,9),(30600,66,11),(30652,66,13),(30635,66,15),(30636,66,16),(30602,66,17),(30651,66,18),(30650,66,19),(30637,66,20),(30649,66,21),(30653,66,22),(30624,66,30),(30625,66,31),(30622,66,32),(30632,66,33),(30606,66,34),(30610,66,35),(30647,66,36),(30629,66,37),(30630,66,38),(30601,66,39),(30627,66,40),(30628,66,41),(30607,66,42),(30608,66,43),(30598,66,44),(30599,66,45),(30614,66,47),(30616,66,48),(30644,66,49),(30646,66,50),(30638,66,51),(30639,66,52),(30631,66,53),(30633,66,54),(30634,66,55),(30618,66,56),(30619,66,57),(30642,66,58),(30643,66,59),(30645,66,60),(30648,66,61),(30640,66,62),(30609,66,64),(30641,66,65),(30595,66,66),(30604,66,67),(30615,66,69),(30654,66,70),(30612,66,71),(30613,66,72),(30623,66,73),(30655,66,74),(30611,66,75),(30596,66,76),(30597,66,100),(29953,67,1),(29961,67,2),(29960,67,3),(29950,67,5),(29964,67,6),(29963,67,11),(29958,67,13),(29957,67,18),(29952,67,21),(29954,67,33),(29951,67,37),(29962,67,53),(29949,67,67),(29959,67,70),(29956,67,74),(29955,67,76),(30050,69,1),(30054,69,2),(30053,69,3),(30056,69,6),(30055,69,11),(30047,69,35),(30048,69,47),(30046,69,69),(30052,69,70),(30049,69,75),(30051,69,76),(30677,70,6),(30676,70,11),(30675,70,70),(30022,71,1),(30025,71,2),(30024,71,3),(30028,71,6),(30027,71,11),(30023,71,58),(30026,71,70),(30021,71,71),(30033,72,1),(30035,72,2),(30034,72,3),(30038,72,6),(30037,72,11),(30030,72,13),(30031,72,18),(30036,72,70),(30029,72,72),(30032,72,76),(30166,73,1),(30171,73,2),(30170,73,3),(30161,73,5),(30175,73,6),(30174,73,11),(30168,73,13),(30172,73,18),(30162,73,19),(30165,73,21),(30164,73,33),(30173,73,53),(30163,73,64),(30169,73,70),(30160,73,73),(30167,73,76),(30678,74,74),(30019,75,75),(30020,76,76),(30528,100,1),(30524,100,2),(30511,100,3),(30509,100,5),(30533,100,6),(30527,100,9),(30506,100,11),(30560,100,13),(30542,100,15),(30543,100,16),(30508,100,17),(30558,100,18),(30557,100,19),(30544,100,20),(30556,100,21),(30561,100,22),(30531,100,30),(30532,100,31),(30529,100,32),(30539,100,33),(30512,100,34),(30516,100,35),(30554,100,36),(30536,100,37),(30537,100,38),(30507,100,39),(30534,100,40),(30535,100,41),(30513,100,42),(30514,100,43),(30504,100,44),(30505,100,45),(30521,100,47),(30523,100,48),(30551,100,49),(30553,100,50),(30545,100,51),(30546,100,52),(30538,100,53),(30540,100,54),(30541,100,55),(30525,100,56),(30526,100,57),(30549,100,58),(30550,100,59),(30552,100,60),(30555,100,61),(30547,100,62),(30515,100,64),(30548,100,65),(30559,100,66),(30510,100,67),(30522,100,69),(30562,100,70),(30519,100,71),(30520,100,72),(30530,100,73),(30563,100,74),(30517,100,75),(30518,100,76),(30503,100,100); +INSERT INTO `roleRole` VALUES (33021,1,1),(33022,1,2),(33023,1,3),(33027,1,6),(33026,1,11),(33024,1,70),(33025,1,76),(32939,2,2),(32941,2,6),(32940,2,11),(32834,3,3),(32836,3,6),(32835,3,11),(32806,5,1),(32813,5,2),(32812,5,3),(32805,5,5),(32817,5,6),(32816,5,11),(32810,5,13),(32814,5,18),(32807,5,21),(32808,5,33),(32815,5,53),(32811,5,70),(32809,5,76),(33092,6,6),(32985,9,1),(32982,9,2),(32970,9,3),(32968,9,5),(32990,9,6),(32960,9,9),(32965,9,11),(33017,9,13),(32999,9,15),(33000,9,16),(32967,9,17),(33015,9,18),(33014,9,19),(33001,9,20),(33013,9,21),(33018,9,22),(32988,9,30),(32989,9,31),(32986,9,32),(32996,9,33),(32971,9,34),(32975,9,35),(33011,9,36),(32993,9,37),(32994,9,38),(32966,9,39),(32991,9,40),(32992,9,41),(32972,9,42),(32973,9,43),(32963,9,44),(32964,9,45),(32979,9,47),(32981,9,48),(33008,9,49),(33010,9,50),(33002,9,51),(33003,9,52),(32995,9,53),(32997,9,54),(32998,9,55),(32983,9,56),(32984,9,57),(33006,9,58),(33007,9,59),(33009,9,60),(33012,9,61),(33004,9,62),(32974,9,64),(33005,9,65),(33016,9,66),(32969,9,67),(32980,9,69),(33019,9,70),(32977,9,71),(32978,9,72),(32987,9,73),(33020,9,74),(32976,9,75),(32961,9,76),(32962,9,100),(32754,11,6),(32753,11,11),(33553,13,1),(33554,13,2),(33555,13,3),(33559,13,6),(33558,13,11),(33552,13,13),(33556,13,70),(33557,13,76),(33178,15,1),(33185,15,2),(33184,15,3),(33187,15,6),(33186,15,11),(33179,15,13),(33170,15,15),(33171,15,35),(33176,15,36),(33182,15,44),(33181,15,47),(33172,15,49),(33180,15,56),(33173,15,57),(33175,15,58),(33183,15,70),(33177,15,75),(33174,15,76),(33194,16,1),(33199,16,2),(33198,16,3),(33206,16,6),(33205,16,11),(33189,16,13),(33190,16,15),(33188,16,16),(33193,16,35),(33200,16,36),(33204,16,44),(33203,16,47),(33192,16,49),(33202,16,56),(33195,16,57),(33201,16,58),(33197,16,70),(33196,16,75),(33191,16,76),(32778,17,1),(32788,17,2),(32787,17,3),(32782,17,5),(32800,17,6),(32796,17,11),(32781,17,13),(32792,17,15),(32780,17,16),(32771,17,17),(32793,17,18),(32791,17,19),(32772,17,20),(32783,17,21),(32785,17,33),(32790,17,35),(32802,17,36),(32773,17,37),(32774,17,39),(32804,17,44),(32803,17,47),(32799,17,49),(32789,17,50),(32794,17,53),(32795,17,56),(32784,17,57),(32801,17,58),(32797,17,59),(32775,17,64),(32779,17,65),(32786,17,70),(32777,17,74),(32798,17,75),(32776,17,76),(33484,18,1),(33487,18,2),(33486,18,3),(33490,18,6),(33489,18,11),(33483,18,18),(33488,18,70),(33485,18,76),(33477,19,1),(33480,19,2),(33479,19,3),(33482,19,6),(33481,19,11),(33473,19,13),(33474,19,18),(33471,19,19),(33472,19,21),(33475,19,53),(33478,19,70),(33476,19,76),(33215,20,1),(33221,20,2),(33220,20,3),(33233,20,6),(33230,20,11),(33208,20,13),(33214,20,15),(33209,20,16),(33226,20,18),(33213,20,19),(33207,20,20),(33222,20,21),(33212,20,35),(33229,20,36),(33232,20,44),(33231,20,47),(33218,20,49),(33216,20,50),(33225,20,53),(33227,20,56),(33217,20,57),(33228,20,58),(33224,20,59),(33210,20,65),(33219,20,70),(33223,20,75),(33211,20,76),(33465,21,1),(33468,21,2),(33467,21,3),(33470,21,6),(33469,21,11),(33461,21,13),(33462,21,18),(33460,21,21),(33463,21,53),(33466,21,70),(33464,21,76),(33564,22,1),(33569,22,2),(33568,22,3),(33571,22,6),(33570,22,11),(33561,22,13),(33563,22,18),(33562,22,21),(33560,22,22),(33565,22,53),(33567,22,70),(33566,22,76),(33064,30,1),(33070,30,2),(33069,30,3),(33053,30,5),(33081,30,6),(33077,30,11),(33061,30,13),(33066,30,15),(33060,30,16),(33067,30,18),(33065,30,19),(33054,30,20),(33063,30,21),(33055,30,22),(33052,30,30),(33062,30,33),(33071,30,35),(33080,30,36),(33083,30,44),(33082,30,47),(33076,30,49),(33072,30,50),(33056,30,53),(33078,30,56),(33075,30,57),(33079,30,58),(33073,30,59),(33057,30,64),(33059,30,65),(33068,30,70),(33074,30,75),(33058,30,76),(33085,31,1),(33086,31,2),(33087,31,3),(33091,31,6),(33090,31,11),(33084,31,31),(33088,31,70),(33089,31,76),(33029,32,1),(33030,32,2),(33031,32,3),(33035,32,6),(33034,32,11),(33028,32,32),(33032,32,70),(33033,32,76),(33151,33,33),(32838,34,1),(32843,34,2),(32842,34,3),(32846,34,6),(32845,34,11),(32839,34,13),(32840,34,33),(32837,34,34),(32841,34,70),(32844,34,76),(32881,35,1),(32886,35,2),(32885,35,3),(32888,35,6),(32887,35,11),(32880,35,35),(32884,35,70),(32882,35,75),(32883,35,76),(33380,36,1),(33382,36,2),(33381,36,3),(33386,36,6),(33385,36,11),(33377,36,36),(33378,36,44),(33379,36,47),(33383,36,70),(33384,36,76),(33124,37,1),(33129,37,2),(33128,37,3),(33131,37,6),(33130,37,11),(33123,37,37),(33127,37,70),(33125,37,74),(33126,37,76),(33137,38,1),(33140,38,2),(33139,38,3),(33142,38,6),(33141,38,11),(33133,38,37),(33132,38,38),(33134,38,64),(33138,38,70),(33136,38,74),(33135,38,76),(32763,39,1),(32768,39,2),(32767,39,3),(32756,39,5),(32770,39,6),(32769,39,11),(32761,39,13),(32760,39,18),(32757,39,21),(32762,39,33),(32755,39,39),(32764,39,53),(32765,39,56),(32758,39,57),(32766,39,70),(32759,39,76),(33094,40,1),(33097,40,2),(33096,40,3),(33105,40,6),(33104,40,11),(33099,40,36),(33093,40,40),(33102,40,44),(33101,40,47),(33095,40,49),(33100,40,58),(33098,40,70),(33103,40,76),(33113,41,1),(33117,41,2),(33116,41,3),(33122,41,6),(33121,41,11),(33107,41,13),(33108,41,35),(33114,41,36),(33109,41,40),(33106,41,41),(33120,41,44),(33119,41,47),(33111,41,49),(33118,41,58),(33115,41,70),(33112,41,75),(33110,41,76),(32853,42,1),(32858,42,2),(32857,42,3),(32861,42,6),(32860,42,11),(32848,42,35),(32851,42,36),(32847,42,42),(32855,42,44),(32859,42,47),(32849,42,49),(32854,42,58),(32856,42,70),(32852,42,75),(32850,42,76),(32866,43,1),(32872,43,2),(32871,43,3),(32878,43,6),(32877,43,11),(32863,43,13),(32865,43,35),(32873,43,36),(32864,43,42),(32862,43,43),(32876,43,44),(32875,43,47),(32867,43,49),(32874,43,58),(32870,43,70),(32869,43,75),(32868,43,76),(32736,44,1),(32737,44,2),(32738,44,3),(32742,44,6),(32741,44,11),(32735,44,44),(32739,44,70),(32740,44,76),(32746,45,1),(32748,45,2),(32747,45,3),(32752,45,6),(32751,45,11),(32744,45,13),(32745,45,44),(32743,45,45),(32749,45,70),(32750,45,76),(32911,47,1),(32912,47,2),(32913,47,3),(32917,47,6),(32916,47,11),(32910,47,47),(32914,47,70),(32915,47,76),(32932,48,1),(32934,48,2),(32933,48,3),(32938,48,6),(32937,48,11),(32930,48,13),(32931,48,47),(32929,48,48),(32935,48,70),(32936,48,76),(33321,49,1),(33324,49,2),(33323,49,3),(33327,49,6),(33326,49,11),(33317,49,36),(33320,49,44),(33319,49,47),(33316,49,49),(33318,49,58),(33322,49,70),(33325,49,76),(33369,50,1),(33374,50,2),(33373,50,3),(33376,50,6),(33375,50,11),(33356,50,13),(33368,50,18),(33357,50,21),(33358,50,35),(33365,50,36),(33371,50,44),(33370,50,47),(33359,50,49),(33355,50,50),(33367,50,53),(33363,50,56),(33360,50,57),(33364,50,58),(33361,50,59),(33372,50,70),(33366,50,75),(33362,50,76),(33235,51,1),(33240,51,2),(33239,51,3),(33243,51,6),(33242,51,11),(33234,51,51),(33238,51,70),(33236,51,74),(33237,51,75),(33241,51,76),(33253,52,1),(33258,52,2),(33257,52,3),(33260,52,6),(33259,52,11),(33245,52,13),(33255,52,18),(33246,52,19),(33252,52,21),(33247,52,35),(33248,52,51),(33244,52,52),(33254,52,53),(33256,52,70),(33250,52,74),(33251,52,75),(33249,52,76),(33144,53,1),(33145,53,2),(33146,53,3),(33150,53,6),(33149,53,11),(33143,53,53),(33147,53,70),(33148,53,76),(33153,54,1),(33154,54,2),(33155,54,3),(33159,54,6),(33158,54,11),(33152,54,54),(33156,54,70),(33157,54,76),(33163,55,1),(33165,55,2),(33164,55,3),(33169,55,6),(33168,55,11),(33161,55,13),(33162,55,54),(33160,55,55),(33166,55,70),(33167,55,76),(32943,56,1),(32944,56,2),(32945,56,3),(32949,56,6),(32948,56,11),(32942,56,56),(32946,56,70),(32947,56,76),(32954,57,1),(32957,57,2),(32956,57,3),(32959,57,6),(32958,57,11),(32951,57,13),(32952,57,56),(32950,57,57),(32955,57,70),(32953,57,76),(33287,58,1),(33288,58,2),(33289,58,3),(33293,58,6),(33292,58,11),(33286,58,58),(33290,58,70),(33291,58,76),(33298,59,1),(33308,59,2),(33307,59,3),(33315,59,6),(33314,59,11),(33295,59,13),(33305,59,18),(33297,59,21),(33299,59,35),(33309,59,36),(33313,59,44),(33312,59,47),(33300,59,49),(33296,59,50),(33304,59,53),(33311,59,56),(33301,59,57),(33310,59,58),(33294,59,59),(33306,59,70),(33303,59,75),(33302,59,76),(33338,60,1),(33350,60,2),(33349,60,3),(33329,60,5),(33354,60,6),(33353,60,11),(33334,60,13),(33347,60,18),(33337,60,21),(33336,60,33),(33339,60,35),(33344,60,36),(33330,60,37),(33352,60,44),(33351,60,47),(33340,60,49),(33331,60,50),(33346,60,53),(33342,60,56),(33332,60,57),(33343,60,58),(33341,60,59),(33328,60,60),(33348,60,70),(33335,60,74),(33345,60,75),(33333,60,76),(33391,61,1),(33395,61,2),(33394,61,3),(33398,61,6),(33397,61,11),(33388,61,13),(33389,61,36),(33390,61,44),(33392,61,47),(33387,61,61),(33393,61,70),(33396,61,76),(33261,62,62),(32879,64,64),(33269,65,1),(33278,65,2),(33277,65,3),(33285,65,6),(33284,65,11),(33267,65,13),(33280,65,18),(33263,65,19),(33270,65,21),(33264,65,35),(33275,65,36),(33283,65,44),(33282,65,47),(33271,65,49),(33265,65,50),(33279,65,53),(33281,65,56),(33272,65,57),(33274,65,58),(33273,65,59),(33262,65,65),(33276,65,70),(33268,65,75),(33266,65,76),(33517,66,1),(33513,66,2),(33501,66,3),(33499,66,5),(33522,66,6),(33516,66,9),(33496,66,11),(33548,66,13),(33531,66,15),(33532,66,16),(33498,66,17),(33547,66,18),(33546,66,19),(33533,66,20),(33545,66,21),(33549,66,22),(33520,66,30),(33521,66,31),(33518,66,32),(33528,66,33),(33502,66,34),(33506,66,35),(33543,66,36),(33525,66,37),(33526,66,38),(33497,66,39),(33523,66,40),(33524,66,41),(33503,66,42),(33504,66,43),(33494,66,44),(33495,66,45),(33510,66,47),(33512,66,48),(33540,66,49),(33542,66,50),(33534,66,51),(33535,66,52),(33527,66,53),(33529,66,54),(33530,66,55),(33514,66,56),(33515,66,57),(33538,66,58),(33539,66,59),(33541,66,60),(33544,66,61),(33536,66,62),(33505,66,64),(33537,66,65),(33491,66,66),(33500,66,67),(33511,66,69),(33550,66,70),(33508,66,71),(33509,66,72),(33519,66,73),(33551,66,74),(33507,66,75),(33492,66,76),(33493,66,100),(32822,67,1),(32830,67,2),(32829,67,3),(32819,67,5),(32833,67,6),(32832,67,11),(32827,67,13),(32826,67,18),(32821,67,21),(32823,67,33),(32820,67,37),(32831,67,53),(32818,67,67),(32828,67,70),(32825,67,74),(32824,67,76),(32922,69,1),(32926,69,2),(32925,69,3),(32928,69,6),(32927,69,11),(32919,69,35),(32920,69,47),(32918,69,69),(32924,69,70),(32921,69,75),(32923,69,76),(33575,70,6),(33573,70,11),(33572,70,70),(33574,70,76),(32892,71,1),(32895,71,2),(32894,71,3),(32899,71,6),(32898,71,11),(32893,71,58),(32896,71,70),(32891,71,71),(32897,71,76),(32904,72,1),(32906,72,2),(32905,72,3),(32909,72,6),(32908,72,11),(32901,72,13),(32902,72,18),(32907,72,70),(32900,72,72),(32903,72,76),(33042,73,1),(33047,73,2),(33046,73,3),(33037,73,5),(33051,73,6),(33050,73,11),(33044,73,13),(33048,73,18),(33038,73,19),(33041,73,21),(33040,73,33),(33049,73,53),(33039,73,64),(33045,73,70),(33036,73,73),(33043,73,76),(33576,74,74),(32889,75,75),(32890,76,76),(33424,100,1),(33420,100,2),(33407,100,3),(33405,100,5),(33429,100,6),(33423,100,9),(33402,100,11),(33456,100,13),(33438,100,15),(33439,100,16),(33404,100,17),(33454,100,18),(33453,100,19),(33440,100,20),(33452,100,21),(33457,100,22),(33427,100,30),(33428,100,31),(33425,100,32),(33435,100,33),(33408,100,34),(33412,100,35),(33450,100,36),(33432,100,37),(33433,100,38),(33403,100,39),(33430,100,40),(33431,100,41),(33409,100,42),(33410,100,43),(33400,100,44),(33401,100,45),(33417,100,47),(33419,100,48),(33447,100,49),(33449,100,50),(33441,100,51),(33442,100,52),(33434,100,53),(33436,100,54),(33437,100,55),(33421,100,56),(33422,100,57),(33445,100,58),(33446,100,59),(33448,100,60),(33451,100,61),(33443,100,62),(33411,100,64),(33444,100,65),(33455,100,66),(33406,100,67),(33418,100,69),(33458,100,70),(33415,100,71),(33416,100,72),(33426,100,73),(33459,100,74),(33413,100,75),(33414,100,76),(33399,100,100); /*!40000 ALTER TABLE `roleRole` ENABLE KEYS */; UNLOCK TABLES; @@ -120,13 +120,13 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-02-09 12:15:12 +-- Dump completed on 2021-03-30 11:16:49 USE `salix`; --- MariaDB dump 10.18 Distrib 10.5.8-MariaDB, for Linux (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for Linux (x86_64) -- --- Host: test-db.verdnatura.es Database: salix +-- Host: db.verdnatura.es Database: salix -- ------------------------------------------------------ --- Server version 10.4.17-MariaDB-1:10.4.17+maria~buster-log +-- Server version 5.6.25-4-log /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -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'),(243,'SupplierContact','*','WRITE','ALLOW','ROLE','administrative'),(244,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(245,'SupplierContact','*','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'),(255,'SupplierContact','*','WRITE','ALLOW','ROLE','administrative'),(256,'Image','*','WRITE','ALLOW','ROLE','employee'),(257,'FixedPrice','*','*','ALLOW','ROLE','buyer'),(258,'PayDem','*','READ','ALLOW','ROLE','employee'),(259,'Client','createReceipt','*','ALLOW','ROLE','administrative'),(260,'PrintServerQueue','*','WRITE','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'),(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'),(243,'SupplierContact','*','WRITE','ALLOW','ROLE','administrative'),(244,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(245,'SupplierContact','*','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'),(255,'SupplierContact','*','WRITE','ALLOW','ROLE','administrative'),(256,'Image','*','WRITE','ALLOW','ROLE','employee'),(257,'FixedPrice','*','*','ALLOW','ROLE','buyer'),(258,'PayDem','*','READ','ALLOW','ROLE','employee'),(259,'Client','createReceipt','*','ALLOW','ROLE','administrative'),(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'); /*!40000 ALTER TABLE `ACL` ENABLE KEYS */; UNLOCK TABLES; @@ -157,6 +157,16 @@ LOCK TABLES `fieldAcl` WRITE; INSERT INTO `fieldAcl` VALUES (1,'Client','name','update','employee'),(2,'Client','contact','update','employee'),(3,'Client','email','update','employee'),(4,'Client','phone','update','employee'),(5,'Client','mobile','update','employee'),(6,'Client','contactChannelFk','update','employee'),(7,'Client','socialName','update','salesPerson'),(8,'Client','fi','update','salesPerson'),(9,'Client','street','update','salesPerson'),(10,'Client','postcode','update','salesPerson'),(11,'Client','city','update','salesPerson'),(12,'Client','countryFk','update','salesPerson'),(13,'Client','provinceFk','update','salesPerson'),(14,'Client','isActive','update','salesPerson'),(15,'Client','salesPersonFk','update','salesAssistant'),(16,'Client','hasToInvoice','update','salesPerson'),(17,'Client','isToBeMailed','update','salesPerson'),(18,'Client','isEqualizated','update','salesPerson'),(19,'Client','isFreezed','update','salesPerson'),(20,'Client','isVies','update','salesPerson'),(21,'Client','hasToInvoiceByAddress','update','salesPerson'),(22,'Client','isTaxDataChecked','update','salesAssistant'),(23,'Client','payMethodFk','update','salesAssistant'),(24,'Client','dueDay','update','salesAssistant'),(25,'Client','iban','update','salesAssistant'),(26,'Client','bankEntityFk','update','salesAssistant'),(27,'Client','hasLcr','update','salesAssistant'),(28,'Client','hasCoreVnl','update','salesAssistant'),(29,'Client','hasSepaVnl','update','salesAssistant'),(30,'Client','credit','update','teamBoss'),(31,'BankEntity','*','insert','salesAssistant'),(32,'Address','isDefaultAddress','*','employee'),(33,'Address','nickname','*','employee'),(34,'Address','postalCode','*','employee'),(35,'Address','provinceFk','*','employee'),(36,'Address','agencyModeFk','*','employee'),(37,'Address','phone','*','employee'),(38,'Address','mobile','*','employee'),(39,'Address','street','*','employee'),(40,'Address','city','*','employee'),(41,'Address','isActive','*','employee'),(42,'Address','isEqualizated','*','salesAssistant'),(43,'Address','clientFk','insert','employee'),(44,'ClientObservation','*','insert','employee'),(45,'Recovery','*','insert','administrative'),(46,'Recovery','finished','update','administrative'),(47,'CreditClassification','finished','update','creditInsurance'),(48,'Account','*','update','employee'),(49,'Greuge','*','insert','salesAssistant'),(50,'ClientSample','*','insert','employee'),(51,'Item','*','*','buyer'),(52,'Item','*','*','marketingBoss'),(53,'ItemBotanical','*','*','buyer'),(54,'ClaimEnd','*','*','salesAssistant'),(55,'Receipt','*','*','administrative'),(56,'ClaimBeginning','*','*','salesAssistant'),(57,'TicketRequest','*','*','salesPerson'),(58,'ClaimBeginning','*','*','salesAssistant'),(59,'TicketRequest','*','*','salesPerson'),(60,'ClaimBeginning','*','*','salesAssistant'),(61,'TicketRequest','*','*','salesPerson'),(62,'ClaimBeginning','*','*','salesAssistant'),(63,'TicketRequest','*','*','salesPerson'),(64,'ClaimBeginning','*','*','salesAssistant'); /*!40000 ALTER TABLE `fieldAcl` ENABLE KEYS */; UNLOCK TABLES; + +-- +-- Dumping data for table `module` +-- + +LOCK TABLES `module` WRITE; +/*!40000 ALTER TABLE `module` DISABLE KEYS */; +INSERT INTO `module` VALUES ('Claims'),('Clients'),('Entries'),('Invoices in'),('Invoices out'),('Items'),('Orders'),('Routes'),('Suppliers'),('Tickets'),('Travels'),('Users'),('Workers'),('Zones'); +/*!40000 ALTER TABLE `module` ENABLE KEYS */; +UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; @@ -166,13 +176,13 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-02-09 12:15:13 +-- Dump completed on 2021-03-30 11:16:50 USE `vn`; --- MariaDB dump 10.18 Distrib 10.5.8-MariaDB, for Linux (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for Linux (x86_64) -- --- Host: test-db.verdnatura.es Database: vn +-- Host: db.verdnatura.es Database: vn -- ------------------------------------------------------ --- Server version 10.4.17-MariaDB-1:10.4.17+maria~buster-log +-- Server version 5.6.25-4-log /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -340,7 +350,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,0,2,0),(5,'Preparación',5,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,1,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,0,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',2,0,'LAST_CALL',NULL,23,1,0,0,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,1,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,1,0,0,1,1,1,3,0),(29,'Previa Impreso',4,1,'PRINTED PREVIOUS',2,29,1,0,1,1,0,0,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,0,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,0,2,0),(34,'Pte Pago',3,0,'WAITING_FOR_PAYMENT',NULL,34,0,0,0,0,0,0,4,1); +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,1,0,0,1,1,1,3,0),(29,'Previa Impreso',4,1,'PRINTED PREVIOUS',2,29,1,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); /*!40000 ALTER TABLE `state` ENABLE KEYS */; UNLOCK TABLES; @@ -370,7 +380,7 @@ UNLOCK TABLES; LOCK TABLES `component` WRITE; /*!40000 ALTER TABLE `component` DISABLE KEYS */; -INSERT INTO `component` VALUES (10,'Precios Especiales',4,NULL,NULL,1,'specialPrices'),(14,'porte extra por dia semana',6,NULL,NULL,1,'extraCostPerWeekDay'),(15,'reparto',6,NULL,NULL,1,'delivery'),(17,'recobro',5,NULL,NULL,1,'debtCollection'),(21,'ajuste',11,NULL,NULL,1,'adjustment'),(22,'venta por paquete',9,1,NULL,0,'salePerPackage'),(23,'venta por caja',9,2,NULL,0,'salePerBox'),(28,'valor de compra',1,NULL,NULL,1,'purchaseValue'),(29,'margen',4,NULL,NULL,1,'margin'),(32,'descuento ultimas unidades',9,3,-0.05,0,'lastUnitsDiscount'),(33,'venta por caja',9,1,NULL,0,'salePerBox'),(34,'descuento comprador',4,NULL,NULL,1,'buyerDiscount'),(35,'cartera comprador',10,NULL,NULL,1,NULL),(36,'descuadre',12,NULL,NULL,1,'imbalance'),(37,'maná',7,4,NULL,0,'mana'),(38,'embolsado',9,NULL,NULL,1,'bagged'),(39,'maná auto',7,NULL,NULL,1,'autoMana'),(40,'cambios Santos 2016',4,NULL,NULL,1,NULL),(41,'bonificacion porte',4,NULL,NULL,1,'freightCharge'),(42,'promocion Francia',4,NULL,NULL,1,'frenchOffer'),(43,'promocion Floramondo',4,NULL,NULL,1,'floramondoPromo'),(44,'rappel cadena',5,NULL,NULL,1,'rappel'); +INSERT INTO `component` VALUES (10,'Precios Especiales',4,NULL,NULL,1,'specialPrices'),(14,'porte extra por dia semana',6,NULL,NULL,1,'extraCostPerWeekDay'),(15,'reparto',6,NULL,NULL,1,'delivery'),(17,'recobro',5,NULL,NULL,1,'debtCollection'),(21,'ajuste',11,NULL,NULL,1,'adjustment'),(22,'venta por paquete',9,1,NULL,0,'salePerPackage'),(23,'venta por caja',9,2,NULL,0,'salePerBox'),(28,'valor de compra',1,NULL,NULL,1,'purchaseValue'),(29,'margen',4,NULL,NULL,1,'margin'),(32,'descuento ultimas unidades',9,3,-0.05,0,'lastUnitsDiscount'),(33,'venta por caja',9,1,NULL,0,'salePerBox'),(34,'descuento comprador',4,NULL,NULL,1,'buyerDiscount'),(35,'cartera comprador',10,NULL,NULL,1,NULL),(36,'descuadre',12,NULL,NULL,1,'imbalance'),(37,'maná',7,4,NULL,0,'mana'),(38,'embolsado',9,NULL,NULL,1,'bagged'),(39,'maná auto',7,NULL,NULL,1,'autoMana'),(40,'cambios Santos 2016',4,NULL,NULL,1,NULL),(41,'bonificacion porte',6,NULL,NULL,1,'freightCharge'),(42,'promocion Francia',4,NULL,NULL,1,'frenchOffer'),(43,'promocion Floramondo',4,NULL,NULL,1,'floramondoPromo'),(44,'rappel cadena',2,NULL,NULL,1,'rappel'); /*!40000 ALTER TABLE `component` ENABLE KEYS */; UNLOCK TABLES; @@ -380,7 +390,7 @@ UNLOCK TABLES; LOCK TABLES `componentType` WRITE; /*!40000 ALTER TABLE `componentType` DISABLE KEYS */; -INSERT INTO `componentType` VALUES (1,'coste',1,0),(2,'com ventas',1,1),(3,'com compras',1,1),(4,'empresa',1,1),(5,'cliente',0,0),(6,'agencia',0,0),(7,'cartera_comercial',0,0),(8,'cartera_producto',0,1),(9,'maniobra',1,1),(10,'cartera_comprador',0,1),(11,'errores',0,1),(12,'otros',0,1); +INSERT INTO `componentType` VALUES (1,'coste',1,0),(2,'com ventas',1,1),(3,'com compras',1,1),(4,'empresa',1,1),(5,'cliente',0,0),(6,'agencia',0,0),(7,'cartera_comercial',0,0),(8,'cartera_producto',0,1),(9,'maniobra',1,0),(10,'cartera_comprador',0,1),(11,'errores',0,1),(12,'otros',0,1); /*!40000 ALTER TABLE `componentType` ENABLE KEYS */; UNLOCK TABLES; @@ -402,13 +412,13 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-02-09 12:15:15 +-- Dump completed on 2021-03-30 11:16:51 USE `cache`; --- MariaDB dump 10.18 Distrib 10.5.8-MariaDB, for Linux (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for Linux (x86_64) -- --- Host: test-db.verdnatura.es Database: cache +-- Host: db.verdnatura.es Database: cache -- ------------------------------------------------------ --- Server version 10.4.17-MariaDB-1:10.4.17+maria~buster-log +-- Server version 5.6.25-4-log /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -438,13 +448,13 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-02-09 12:15:15 +-- Dump completed on 2021-03-30 11:16:51 USE `hedera`; --- MariaDB dump 10.18 Distrib 10.5.8-MariaDB, for Linux (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for Linux (x86_64) -- --- Host: test-db.verdnatura.es Database: hedera +-- Host: db.verdnatura.es Database: hedera -- ------------------------------------------------------ --- Server version 10.4.17-MariaDB-1:10.4.17+maria~buster-log +-- Server version 5.6.25-4-log /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -504,13 +514,13 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-02-09 12:15:16 +-- Dump completed on 2021-03-30 11:16:51 USE `postgresql`; --- MariaDB dump 10.18 Distrib 10.5.8-MariaDB, for Linux (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for Linux (x86_64) -- --- Host: test-db.verdnatura.es Database: postgresql +-- Host: db.verdnatura.es Database: postgresql -- ------------------------------------------------------ --- Server version 10.4.17-MariaDB-1:10.4.17+maria~buster-log +-- Server version 5.6.25-4-log /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -558,7 +568,7 @@ UNLOCK TABLES; LOCK TABLES `professional_category` WRITE; /*!40000 ALTER TABLE `professional_category` DISABLE KEYS */; -INSERT INTO `professional_category` VALUES (1,'Mozos',5,1,27.5,NULL),(2,'Encargados',3,1,27.5,NULL),(4,'Comprador',3,1,27.5,NULL),(5,'Aux Administracion',NULL,1,27.5,NULL),(6,'Of Administracion',3,1,27.5,NULL),(7,'Jefe Administracion',2,1,27.5,NULL),(8,'Informatico',3,1,27.5,NULL),(9,'Directivo',1,0,27.5,NULL),(10,'Aux Ventas',4,1,27.5,NULL),(11,'Vendedor',4,1,27.5,NULL),(12,'Jefe de Ventas',4,0,27.5,NULL),(13,'Repartidor',5,1,27.5,NULL),(14,'Aprendices',NULL,1,27.5,NULL),(15,'Técnicos',2,1,27.5,NULL),(16,'Aux Florista',5,1,27.5,NULL),(17,'Florista',4,1,27.5,NULL),(18,'Jefe Floristas',2,1,27.5,NULL),(19,'Técnico marketing',3,1,27.5,NULL),(20,'Auxiliar marketing',4,1,27.5,NULL),(21,'Aux Informática',4,1,27.5,NULL),(22,'Peón agrícola',5,1,27.5,NULL),(23,'Oficial mantenimiento',4,1,27.5,NULL),(24,'Aux mantenimiento',5,1,27.5,NULL),(25,'Mozo Aeropuerto',5,1,27.5,NULL),(26,'Coordinador',2,1,27.5,NULL),(28,'Aux Logistica',4,1,27.5,NULL),(29,'Oficial Logistica',3,1,27.5,NULL),(30,'Subencargado',4,1,27.5,NULL),(31,'Conductor +3500kg',NULL,1,27.5,32400),(32,'Oficial 1ª',NULL,1,27.5,NULL),(33,'Oficial 2ª',NULL,1,27.5,NULL),(34,'Supervisor',NULL,1,27.5,NULL); +INSERT INTO `professional_category` VALUES (1,'Mozos',5,1,27.5,NULL),(2,'Encargados',3,1,27.5,NULL),(4,'Comprador',3,1,27.5,NULL),(5,'Aux Administracion',NULL,1,27.5,NULL),(6,'Of Administracion',3,1,27.5,NULL),(7,'Jefe Administracion',2,1,27.5,NULL),(8,'Informatico',3,1,27.5,NULL),(9,'Directivo',1,0,27.5,NULL),(10,'Aux Ventas',4,1,27.5,NULL),(11,'Vendedor',4,1,27.5,NULL),(12,'Jefe de Ventas',4,0,27.5,NULL),(13,'Repartidor',5,1,27.5,NULL),(14,'Aprendices',NULL,1,27.5,NULL),(15,'Técnicos',2,1,27.5,NULL),(16,'Aux Florista',5,1,27.5,NULL),(17,'Florista',4,1,27.5,NULL),(18,'Jefe Floristas',2,1,27.5,NULL),(19,'Técnico marketing',3,1,27.5,NULL),(20,'Auxiliar marketing',4,1,27.5,NULL),(21,'Aux Informática',4,1,27.5,NULL),(22,'Peón agrícola',5,1,27.5,NULL),(23,'Oficial mantenimiento',4,1,27.5,NULL),(24,'Aux mantenimiento',5,1,27.5,NULL),(25,'Mozo Aeropuerto',5,1,27.5,NULL),(26,'Coordinador',2,1,27.5,NULL),(28,'Aux Logistica',4,1,27.5,NULL),(29,'Oficial Logistica',3,1,27.5,NULL),(30,'Subencargado',4,1,27.5,NULL),(31,'Conductor +3500kg',NULL,1,27.5,32400),(32,'Oficial 1ª',NULL,1,27.5,NULL),(33,'Oficial 2ª',NULL,1,27.5,NULL),(34,'Supervisor',NULL,1,27.5,NULL),(35,'Aux.Comerc./Market.',NULL,1,27.5,NULL),(36,'Oficial Comerc./Market.',NULL,1,27.5,NULL),(37,'Coord. Comerc./Market.',NULL,1,27.5,NULL),(38,'Aux. Florista 1ª',NULL,1,27.5,NULL),(39,'Mozo/campo',NULL,1,27.5,NULL); /*!40000 ALTER TABLE `professional_category` ENABLE KEYS */; UNLOCK TABLES; @@ -578,7 +588,7 @@ UNLOCK TABLES; LOCK TABLES `workcenter` WRITE; /*!40000 ALTER TABLE `workcenter` DISABLE KEYS */; -INSERT INTO `workcenter` VALUES (1,'Silla',20,1101,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,2858,5,'Av constitución 3',554145),(6,'Vilassar',88,88031,2,'Cami del Crist, 33',556412),(7,'Tenerife',NULL,NULL,10,NULL,NULL); +INSERT INTO `workcenter` VALUES (1,'Silla',20,1125,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,2858,5,'Av constitución 3',554145),(6,'Vilassar',88,88032,2,'Cami del Crist, 33',556412),(7,'Tenerife',NULL,NULL,10,NULL,NULL),(8,NULL,NULL,NULL,NULL,NULL,NULL),(9,'Algemesi',20,NULL,60,'Fenollars, 20',523549),(10,NULL,NULL,NULL,NULL,NULL,NULL); /*!40000 ALTER TABLE `workcenter` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -590,13 +600,13 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-02-09 12:15:17 +-- Dump completed on 2021-03-30 11:16:52 USE `sage`; --- MariaDB dump 10.18 Distrib 10.5.8-MariaDB, for Linux (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for Linux (x86_64) -- --- Host: test-db.verdnatura.es Database: sage +-- Host: db.verdnatura.es Database: sage -- ------------------------------------------------------ --- Server version 10.4.17-MariaDB-1:10.4.17+maria~buster-log +-- Server version 5.6.25-4-log /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -646,4 +656,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-02-09 12:15:17 +-- Dump completed on 2021-03-30 11:16:52 diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 0492ee980..e99988410 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -294,6 +294,10 @@ INSERT INTO `vn`.`clientManaCache`(`clientFk`, `mana`, `dated`) (103, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), (104, -30, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)); +INSERT INTO `vn`.`clientConfig`(`riskTolerance`) + VALUES + (200); + INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `phone`, `mobile`, `isActive`, `clientFk`, `agencyModeFk`, `longitude`, `latitude`, `isEqualizated`, `isDefaultAddress`) VALUES (1, 'Bruce Wayne', '1007 Mountain Drive, Gotham', 'Silla', 46460, 1, 1111111111, 222222222, 1, 101, 2, NULL, NULL, 0, 1), @@ -711,14 +715,14 @@ INSERT INTO `vn`.`itemCategory`(`id`, `name`, `display`, `color`, `icon`, `code` (7, 'Accessories', 1, NULL, 'icon-accessory', 'accessory'), (8, 'Fruit', 1, NULL, 'icon-fruit', 'fruit'); -INSERT INTO `vn`.`itemType`(`id`, `code`, `name`, `categoryFk`, `life`,`workerFk`, `isPackaging`) +INSERT INTO `vn`.`itemType`(`id`, `code`, `name`, `categoryFk`, `warehouseFk`, `life`,`workerFk`, `isPackaging`) VALUES - (1, 'CRI', 'Crisantemo', 2, 31, 35, 0), - (2, 'ITG', 'Anthurium', 1, 31, 35, 0), - (3, 'WPN', 'Paniculata', 2, 31, 35, 0), - (4, 'PRT', 'Delivery ports', 3, NULL, 35, 1), - (5, 'CON', 'Container', 3, NULL, 35, 1), - (6, 'ALS', 'Alstroemeria', 1, 31, 35, 0); + (1, 'CRI', 'Crisantemo', 2, 1, 31, 35, 0), + (2, 'ITG', 'Anthurium', 1, 1, 31, 35, 0), + (3, 'WPN', 'Paniculata', 2, 1, 31, 35, 0), + (4, 'PRT', 'Delivery ports', 3, 1, NULL, 35, 1), + (5, 'CON', 'Container', 3, 1, NULL, 35, 1), + (6, 'ALS', 'Alstroemeria', 1, 1, 31, 35, 0); INSERT INTO `vn`.`ink`(`id`, `name`, `picture`, `showOrder`, `hex`) VALUES @@ -2254,7 +2258,10 @@ INSERT INTO `vn`.`duaInvoiceIn`(`id`, `duaFk`, `invoiceInFk`) (10, 10, 10); INSERT INTO `vn`.`ticketRecalc`(`ticketFk`) - SELECT `id` FROM `vn`.`ticket`; + SELECT `id` + FROM `vn`.`ticket` t + LEFT JOIN vn.ticketRecalc tr ON tr.ticketFk = t.id + WHERE tr.ticketFk IS NULL; CALL `vn`.`ticket_doRecalc`(); diff --git a/db/dump/structure.sql b/db/dump/structure.sql index e064a32fb..7d79b45d3 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -1,8 +1,8 @@ -- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for Linux (x86_64) -- --- Host: test-db.verdnatura.es Database: account +-- Host: db.verdnatura.es Database: account -- ------------------------------------------------------ --- Server version 10.4.17-MariaDB-1:10.4.17+maria~buster-log +-- Server version 5.6.25-4-log /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -173,7 +173,7 @@ CREATE TABLE `mailAlias` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `alias` varchar(50) CHARACTER SET utf8 NOT NULL, `description` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `isPublic` tinyint(4) NOT NULL DEFAULT 1, + `isPublic` tinyint(4) NOT NULL DEFAULT '1', PRIMARY KEY (`id`), UNIQUE KEY `alias` (`alias`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Mail aliases'; @@ -271,9 +271,9 @@ CREATE TABLE `role` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(14) COLLATE utf8_unicode_ci NOT NULL COMMENT 'MySQL doesn''t support more than 14 chars for proxied user names', `description` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, - `hasLogin` tinyint(3) unsigned NOT NULL DEFAULT 1, - `created` timestamp NOT NULL DEFAULT current_timestamp(), - `modified` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `hasLogin` tinyint(3) unsigned NOT NULL DEFAULT '1', + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Roles'; @@ -381,7 +381,7 @@ CREATE TABLE `sambaConfig` ( `adController` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'The hosname of domain controller', `adUser` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Active directory user', `adPassword` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Active directory password', - `verifyCert` tinyint(3) unsigned NOT NULL DEFAULT 1 COMMENT 'Whether to verify server certificate', + `verifyCert` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT 'Whether to verify server certificate', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Global configuration parameters for accounts'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -399,19 +399,19 @@ CREATE TABLE `user` ( `name` varchar(30) CHARACTER SET utf8 NOT NULL, `nickname` varchar(127) COLLATE utf8_unicode_ci NOT NULL, `bcryptPassword` varchar(512) COLLATE utf8_unicode_ci DEFAULT NULL, - `role` int(10) unsigned NOT NULL DEFAULT 2, - `active` tinyint(1) NOT NULL DEFAULT 1, + `role` int(10) unsigned NOT NULL DEFAULT '2', + `active` tinyint(1) NOT NULL DEFAULT '1', `email` varchar(255) CHARACTER SET utf8 DEFAULT NULL, `emailVerified` tinyint(1) DEFAULT NULL, `verificationToken` varchar(512) CHARACTER SET utf8 DEFAULT NULL, `lang` char(2) CHARACTER SET utf8 DEFAULT NULL, - `recoverPass` tinyint(3) unsigned NOT NULL DEFAULT 1, + `recoverPass` tinyint(3) unsigned NOT NULL DEFAULT '1', `lastPassChange` datetime DEFAULT NULL, - `created` timestamp NOT NULL DEFAULT current_timestamp(), - `updated` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `password` char(64) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Deprecated', `image` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `sync` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'Deprecated', + `sync` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Deprecated', PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`), KEY `role` (`role`), @@ -2409,12 +2409,12 @@ DROP TABLE IF EXISTS `bancos_evolution`; CREATE TABLE `bancos_evolution` ( `Fecha` date NOT NULL, `Id_Banco` int(11) NOT NULL, - `saldo` decimal(10,2) NOT NULL DEFAULT 0.00, - `quilla` decimal(10,2) NOT NULL DEFAULT 0.00, - `deuda` decimal(10,2) NOT NULL DEFAULT 0.00, - `liquidez` decimal(10,2) NOT NULL DEFAULT 0.00, - `disponibilidad ajena` decimal(10,2) NOT NULL DEFAULT 0.00, - `saldo_aux` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT 'Saldo auxiliar para el calculo de lo dispuesto en las polizas', + `saldo` decimal(10,2) NOT NULL DEFAULT '0.00', + `quilla` decimal(10,2) NOT NULL DEFAULT '0.00', + `deuda` decimal(10,2) NOT NULL DEFAULT '0.00', + `liquidez` decimal(10,2) NOT NULL DEFAULT '0.00', + `disponibilidad ajena` decimal(10,2) NOT NULL DEFAULT '0.00', + `saldo_aux` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT 'Saldo auxiliar para el calculo de lo dispuesto en las polizas', PRIMARY KEY (`Fecha`,`Id_Banco`), KEY `fk_banco_evolution_idx` (`Id_Banco`), CONSTRAINT `fk_banco_evolution` FOREIGN KEY (`Id_Banco`) REFERENCES `vn`.`bank` (`id`) ON DELETE CASCADE ON UPDATE CASCADE @@ -2460,7 +2460,7 @@ DROP TABLE IF EXISTS `clientDied`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `clientDied` ( - `id` int(11) NOT NULL DEFAULT 0, + `id` int(11) NOT NULL DEFAULT '0', `clientName` varchar(50) COLLATE utf8_unicode_ci NOT NULL, `lastInvoiced` date DEFAULT NULL, `workerCode` varchar(3) COLLATE utf8_unicode_ci NOT NULL, @@ -2481,7 +2481,7 @@ CREATE TABLE `clientNewBorn` ( `clientFk` int(11) NOT NULL, `firstShipped` date NOT NULL COMMENT 'Primer pedido o de la relacion comercial, o después de un año de inactividad', `lastShipped` date NOT NULL COMMENT 'último pedido del cliente', - `isModified` tinyint(4) DEFAULT 0, + `isModified` tinyint(4) DEFAULT '0', PRIMARY KEY (`clientFk`), CONSTRAINT `clientNewBorn_fk1` FOREIGN KEY (`clientFk`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Listado de clientes que se consideran nuevos a efectos de cobrar la comision adicional del comercial'; @@ -2596,7 +2596,7 @@ DROP TABLE IF EXISTS `defaulter`; CREATE TABLE `defaulter` ( `clientFk` int(11) NOT NULL, `created` date NOT NULL, - `amount` double NOT NULL DEFAULT 0, + `amount` double NOT NULL DEFAULT '0', `defaulterSinced` date DEFAULT NULL, `hasChanged` tinyint(1) DEFAULT NULL, `frozened` date DEFAULT NULL, @@ -2615,7 +2615,7 @@ DROP TABLE IF EXISTS `experienceIberflora2016`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `experienceIberflora2016` ( `Id_Cliente` int(11) NOT NULL, - `isVisitor` tinyint(4) NOT NULL DEFAULT 0, + `isVisitor` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`Id_Cliente`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Lista de clientes que participan en el estudio sobre la mejora del consumo tras la visita a las instalaciones de Silla'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -2726,14 +2726,14 @@ CREATE TABLE `m3` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `fecha` date NOT NULL, `provinceFk` smallint(5) unsigned DEFAULT NULL, - `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT 0, + `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT '0', `m3` decimal(10,2) DEFAULT NULL, `year` int(11) DEFAULT NULL, `month` int(11) DEFAULT NULL, `week` int(11) DEFAULT NULL, `day` int(11) DEFAULT NULL, `dayName` varchar(12) COLLATE utf8_unicode_ci DEFAULT NULL, - `euros` decimal(10,2) DEFAULT 0.00, + `euros` decimal(10,2) DEFAULT '0.00', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -2978,8 +2978,8 @@ DROP TABLE IF EXISTS `payMethodClient`; CREATE TABLE `payMethodClient` ( `id` int(11) NOT NULL AUTO_INCREMENT, `dated` date NOT NULL, - `payMethodFk` tinyint(3) unsigned NOT NULL DEFAULT 0, - `clientFk` int(11) NOT NULL DEFAULT 0, + `payMethodFk` tinyint(3) unsigned NOT NULL DEFAULT '0', + `clientFk` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `FkPayMethod_idx` (`payMethodFk`), KEY `FkClientPayMethod_idx` (`clientFk`), @@ -3016,9 +3016,9 @@ DROP TABLE IF EXISTS `produccion`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `produccion` ( `dated` date NOT NULL, - `m3` int(11) NOT NULL DEFAULT 0, - `cost` int(11) NOT NULL DEFAULT 0, - `eurosM3` decimal(10,2) NOT NULL DEFAULT 0.00, + `m3` int(11) NOT NULL DEFAULT '0', + `cost` int(11) NOT NULL DEFAULT '0', + `eurosM3` decimal(10,2) NOT NULL DEFAULT '0.00', PRIMARY KEY (`dated`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -3031,7 +3031,7 @@ DROP TABLE IF EXISTS `salaries2018`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `salaries2018` ( - `person_id` int(11) NOT NULL DEFAULT 0, + `person_id` int(11) NOT NULL DEFAULT '0', `sex` enum('M','F') CHARACTER SET utf8 NOT NULL DEFAULT 'F' COMMENT 'M Masculino F Femenino', `edad` int(6) DEFAULT NULL, `antiguedad` int(6) DEFAULT NULL, @@ -3058,9 +3058,9 @@ DROP TABLE IF EXISTS `salePersonEvolution__`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `salePersonEvolution__` ( `dated` date NOT NULL DEFAULT '0000-00-00', - `amount` decimal(10,2) NOT NULL DEFAULT 0.00, - `equalizationTax` decimal(10,2) NOT NULL DEFAULT 0.00, - `salesPersonFk` int(11) NOT NULL DEFAULT 0, + `amount` decimal(10,2) NOT NULL DEFAULT '0.00', + `equalizationTax` decimal(10,2) NOT NULL DEFAULT '0.00', + `salesPersonFk` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`dated`,`salesPersonFk`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -3091,9 +3091,9 @@ CREATE TABLE `salesByclientSalesPerson` ( `dated` date NOT NULL DEFAULT '0000-00-00', `salesPersonFk` int(11) DEFAULT NULL, `clientFk` int(11) NOT NULL, - `amount` decimal(10,3) NOT NULL DEFAULT 0.000, - `equalizationTax` decimal(10,3) NOT NULL DEFAULT 0.000, - `amountNewBorn` decimal(10,3) NOT NULL DEFAULT 0.000, + `amount` decimal(10,3) NOT NULL DEFAULT '0.000', + `equalizationTax` decimal(10,3) NOT NULL DEFAULT '0.000', + `amountNewBorn` decimal(10,3) NOT NULL DEFAULT '0.000', PRIMARY KEY (`dated`,`clientFk`), KEY `clientSalePersonEvolution_clientFk` (`clientFk`), KEY `salesByclientSalesPerson_salesPerson` (`salesPersonFk`), @@ -3116,7 +3116,7 @@ CREATE TABLE `salesMonthlySnapshot` ( `year` int(4) NOT NULL, `month` int(2) NOT NULL, `departmentFk` int(11) NOT NULL, - `ownSalesAmount` decimal(10,2) DEFAULT 0.00, + `ownSalesAmount` decimal(10,2) DEFAULT '0.00', `ownSalesPosition` int(11) DEFAULT NULL, `ownSalesBonus` int(11) DEFAULT NULL, `ownSalesScore` int(11) DEFAULT NULL, @@ -3167,9 +3167,9 @@ CREATE TABLE `salesPersonEvolution` ( `id` int(11) NOT NULL AUTO_INCREMENT, `dated` date NOT NULL DEFAULT '0000-00-00', `salesPersonFk` int(11) DEFAULT NULL, - `amount` decimal(10,3) NOT NULL DEFAULT 0.000, - `equalizationTax` decimal(10,3) NOT NULL DEFAULT 0.000, - `amountNewBorn` decimal(10,3) NOT NULL DEFAULT 0.000, + `amount` decimal(10,3) NOT NULL DEFAULT '0.000', + `equalizationTax` decimal(10,3) NOT NULL DEFAULT '0.000', + `amountNewBorn` decimal(10,3) NOT NULL DEFAULT '0.000', PRIMARY KEY (`id`), KEY `salesPersonEvolution_salesPerson` (`salesPersonFk`), CONSTRAINT `salesPersonEvolution_salesPerson` FOREIGN KEY (`salesPersonFk`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE @@ -3213,7 +3213,7 @@ CREATE TABLE `vendedores` ( `sustitucionArrendada` decimal(10,2) DEFAULT NULL, `itemTypeBorrowed` decimal(10,2) DEFAULT NULL, `portfolioWeight` decimal(10,2) DEFAULT NULL COMMENT 'Pero de la cartera del comercial a fecha vendedores.updated', - `updated` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `updated` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`Id_Trabajador`,`año`,`mes`), CONSTRAINT `trabajador_trabajador` FOREIGN KEY (`Id_Trabajador`) REFERENCES `vn`.`worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -3245,13 +3245,13 @@ DROP TABLE IF EXISTS `ventas`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ventas` ( `Id_Movimiento` int(11) NOT NULL, - `importe` decimal(10,3) NOT NULL DEFAULT 0.000, - `recargo` decimal(10,3) NOT NULL DEFAULT 0.000, + `importe` decimal(10,3) NOT NULL DEFAULT '0.000', + `recargo` decimal(10,3) NOT NULL DEFAULT '0.000', `fecha` date NOT NULL, `tipo_id` smallint(5) unsigned NOT NULL, - `Id_Cliente` int(11) NOT NULL DEFAULT 1, - `empresa_id` smallint(5) unsigned NOT NULL DEFAULT 442, - `margen` decimal(10,3) NOT NULL DEFAULT 0.000, + `Id_Cliente` int(11) NOT NULL DEFAULT '1', + `empresa_id` smallint(5) unsigned NOT NULL DEFAULT '442', + `margen` decimal(10,3) NOT NULL DEFAULT '0.000', PRIMARY KEY (`Id_Movimiento`), KEY `tip_to_tip_idx` (`tipo_id`), KEY `clientes_bs_ventas_idx` (`Id_Cliente`), @@ -3367,7 +3367,7 @@ DROP TABLE IF EXISTS `workerSpeed__`; CREATE TABLE `workerSpeed__` ( `workerCode` varchar(3) COLLATE utf8_unicode_ci NOT NULL, `accion` varchar(15) COLLATE utf8_unicode_ci NOT NULL, - `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT 1, + `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT '1', `LitrosMinuto` decimal(10,1) DEFAULT NULL, `LitrosMinutoLastHour` decimal(10,1) DEFAULT NULL, `lastUpdated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', @@ -4504,13 +4504,13 @@ ALTER DATABASE `bs` CHARACTER SET utf8 COLLATE utf8_unicode_ci ; /*!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 sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`z-developer`@`%` PROCEDURE `fruitsEvolution`() +CREATE DEFINER=`root`@`%` PROCEDURE `fruitsEvolution`() BEGIN select Id_Cliente, Cliente, count(semana) as semanas, (w.code IS NOT NULL) isWorker @@ -4744,60 +4744,6 @@ BEGIN 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 `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=`z-developer`@`%` PROCEDURE `kk`() -BEGIN - - - DECLARE vDated DATE; - DECLARE vDateEnd DATETIME; - - SET vDated = '2020-2-15'; - - SET vDateEnd = util.dayend(vDated); - - WHILE vDated > '2020-01-01' DO - - UPDATE bs.ventas v - JOIN ( - SELECT s.id, sum(s.quantity * sc.value ) AS margen, s.quantity * s.price * (100 - s.discount ) / 100 AS pvp - FROM vn.sale s - JOIN vn.ticket t ON t.id = s.ticketFk - JOIN vn.saleComponent sc ON sc.saleFk = s.id - JOIN vn.component c ON c.id = sc.componentFk - JOIN vn.componentType ct ON ct.id = c.typeFk - WHERE t.shipped BETWEEN vDated AND vDateEnd - AND ct.isMargin = TRUE - GROUP BY s.id) sub ON sub.id = v.Id_Movimiento - SET v.margen = sub.margen + v.importe + v.recargo - sub.pvp; - - - SET vDated = TIMESTAMPADD(DAY,-1,vDated); - SET vDateEnd = util.dayend(vDated); - - IF DAY(vDated) MOD 5 = 0 THEN - - SELECT vDated; - - END IF; - - END WHILE; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -5394,7 +5340,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`z-developer`@`%` PROCEDURE `saleGraphic`(vItemFk INT, +CREATE DEFINER=`root`@`%` PROCEDURE `saleGraphic`(vItemFk INT, vTypeFk INT, vCategoryFk INT, vFromDate DATE, @@ -7040,9 +6986,9 @@ DROP TABLE IF EXISTS `addressFriendship`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `addressFriendship` ( - `addressFk1` int(11) NOT NULL DEFAULT 0, - `addressFk2` int(11) NOT NULL DEFAULT 0, - `friendship` int(11) NOT NULL DEFAULT 0, + `addressFk1` int(11) NOT NULL DEFAULT '0', + `addressFk2` int(11) NOT NULL DEFAULT '0', + `friendship` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`addressFk1`,`addressFk2`), KEY `addressFriendship_fk2_idx` (`addressFk2`), CONSTRAINT `addressFriendship_fk1` FOREIGN KEY (`addressFk1`) REFERENCES `vn`.`address` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, @@ -7112,7 +7058,7 @@ CREATE TABLE `cache_calc` ( `params` varchar(100) CHARACTER SET utf8 NOT NULL DEFAULT '', `last_refresh` datetime DEFAULT NULL, `expires` datetime DEFAULT NULL, - `created` timestamp NOT NULL DEFAULT current_timestamp(), + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `connection_id` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `cache_name` (`cache_id`,`params`), @@ -7146,8 +7092,8 @@ DROP TABLE IF EXISTS `departure_limit`; CREATE TABLE `departure_limit` ( `warehouse_id` smallint(6) unsigned NOT NULL, `fecha` date NOT NULL, - `hora` int(11) NOT NULL DEFAULT 0, - `minSpeed` decimal(10,2) NOT NULL DEFAULT 0.00, + `hora` int(11) NOT NULL DEFAULT '0', + `minSpeed` decimal(10,2) NOT NULL DEFAULT '0.00', PRIMARY KEY (`warehouse_id`,`fecha`), CONSTRAINT `warehouse_departure` FOREIGN KEY (`warehouse_id`) REFERENCES `vn`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -7180,11 +7126,11 @@ DROP TABLE IF EXISTS `prod_graphic_source`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `prod_graphic_source` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `m3` double NOT NULL DEFAULT 0, + `m3` double NOT NULL DEFAULT '0', `warehouse_id` int(11) NOT NULL, `hora` int(11) NOT NULL, - `order` int(11) NOT NULL DEFAULT 0, - `graphCategory` int(11) NOT NULL DEFAULT 0, + `order` int(11) NOT NULL DEFAULT '0', + `graphCategory` int(11) NOT NULL DEFAULT '0', `Agencia` varchar(45) CHARACTER SET utf8 NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -7232,7 +7178,7 @@ DROP TABLE IF EXISTS `zoneAgencyFriendship`; CREATE TABLE `zoneAgencyFriendship` ( `agencyModeFk` int(11) NOT NULL, `zoneFk` int(11) NOT NULL, - `friendship` bigint(21) NOT NULL DEFAULT 0, + `friendship` bigint(21) NOT NULL DEFAULT '0', PRIMARY KEY (`agencyModeFk`,`zoneFk`), KEY `zoneAgencyFriendship_fk1_idx` (`zoneFk`), CONSTRAINT `zoneAgencyFriendship` FOREIGN KEY (`agencyModeFk`) REFERENCES `vn`.`agencyMode` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, @@ -7487,11 +7433,11 @@ 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 sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `available_clean`() BEGIN @@ -7505,6 +7451,11 @@ BEGIN FROM available a LEFT JOIN tCalc c ON c.id = a.calc_id WHERE c.id IS NULL; + + DELETE a + FROM availableNoRaids a + LEFT JOIN tCalc c ON c.id = a.calc_id + WHERE c.id IS NULL; DROP TEMPORARY TABLE tCalc; END ;; @@ -8579,7 +8530,7 @@ DROP TABLE IF EXISTS `VMPSettings`; CREATE TABLE `VMPSettings` ( `VMPID` int(11) NOT NULL, `name` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `isEktSender` tinyint(4) NOT NULL DEFAULT 0, + `isEktSender` tinyint(4) NOT NULL DEFAULT '0', `MessageID` int(11) NOT NULL, `dateTimeTry` timestamp NULL DEFAULT NULL, `isVmpBA` tinyint(4) DEFAULT NULL COMMENT 'Basic authentication', @@ -8595,7 +8546,7 @@ CREATE TABLE `VMPSettings` ( `closedFrom` int(11) DEFAULT NULL, `closedTo` int(11) DEFAULT NULL, `totalRefreshHours` int(11) DEFAULT NULL COMMENT 'Numero > 4 para no saturar, no repetir para que no solapen las actualizaciones', - `UseSupplierEmbalageCode` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'vmp you want to see their embalage code', + `UseSupplierEmbalageCode` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'vmp you want to see their embalage code', PRIMARY KEY (`VMPID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -8661,10 +8612,12 @@ CREATE TABLE `deliveryInformation` ( `FirstOrderDateTime` datetime DEFAULT NULL, `LatestOrderDateTime` datetime DEFAULT NULL, `supplyResponseID` int(11) DEFAULT NULL, + `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`ID`), KEY `fgbSupplyResponse_idx` (`supplyResponseID`), KEY `fgbSupplyResponse_idx2` (`FirstOrderDateTime`), KEY `fgbSupplyResponse_idx3` (`LatestOrderDateTime`) USING BTREE, + KEY `deliveryInformation_updated_IDX` (`updated`) USING BTREE, CONSTRAINT `fgbSupplyResponse` FOREIGN KEY (`supplyResponseID`) REFERENCES `supplyResponse` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -8683,11 +8636,11 @@ CREATE TABLE `ekt` ( `deliveryNumber` bigint(20) unsigned DEFAULT NULL, `fec` date DEFAULT NULL, `hor` time DEFAULT NULL, - `now` timestamp NULL DEFAULT current_timestamp(), + `now` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `ptj` mediumint(8) unsigned DEFAULT NULL, `ref` int(11) NOT NULL, `item` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `pac` int(11) DEFAULT 0, + `pac` int(11) DEFAULT '0', `qty` int(10) NOT NULL, `ori` varchar(3) COLLATE utf8_unicode_ci DEFAULT 'NL', `cat` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL, @@ -8710,10 +8663,10 @@ CREATE TABLE `ekt` ( `s4` varchar(4) COLLATE utf8_unicode_ci DEFAULT NULL, `s5` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, `s6` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, - `ok` tinyint(4) NOT NULL DEFAULT 0, + `ok` tinyint(4) NOT NULL DEFAULT '0', `trolleyFk` int(11) DEFAULT NULL, `putOrderFk` int(10) unsigned DEFAULT NULL, - `scanned` tinyint(1) NOT NULL DEFAULT 0, + `scanned` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) USING BTREE, UNIQUE KEY `barcode_year` (`barcode`,`entryYear`), UNIQUE KEY `entry_year` (`deliveryNumber`,`entryYear`) USING BTREE, @@ -8866,7 +8819,7 @@ CREATE TABLE `genus` ( `entry_date` date DEFAULT NULL, `expiry_date` date DEFAULT NULL, `change_date_time` datetime DEFAULT NULL, - `isHazard` tinyint(1) NOT NULL DEFAULT 0, + `isHazard` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`genus_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='/tmp/floricode/florecompc2/FG130916.txt'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -9022,7 +8975,7 @@ CREATE TABLE `item_groupToOffer` ( `group_code` int(11) unsigned NOT NULL, `itemTypeFk` smallint(5) unsigned NOT NULL, `intrastatFk` int(8) unsigned zerofill NOT NULL, - `originFk` tinyint(2) unsigned NOT NULL DEFAULT 17, + `originFk` tinyint(2) unsigned NOT NULL DEFAULT '17', `expenseFk` varchar(10) COLLATE utf8_unicode_ci DEFAULT '7001000000', PRIMARY KEY (`group_code`), KEY `item_groupToOffer_fk2_idx` (`itemTypeFk`), @@ -9043,20 +8996,20 @@ DROP TABLE IF EXISTS `item_track`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `item_track` ( `item_id` int(10) unsigned NOT NULL, - `s1` tinyint(3) NOT NULL DEFAULT 0, - `s2` tinyint(3) NOT NULL DEFAULT 0, - `s3` tinyint(3) NOT NULL DEFAULT 0, - `s4` tinyint(3) NOT NULL DEFAULT 0, - `pac` tinyint(3) NOT NULL DEFAULT 0, - `cat` tinyint(3) NOT NULL DEFAULT 0, - `ori` tinyint(3) NOT NULL DEFAULT 0, - `pro` tinyint(3) NOT NULL DEFAULT 0, - `package` tinyint(3) NOT NULL DEFAULT 0, - `s5` tinyint(3) NOT NULL DEFAULT 0, - `s6` tinyint(3) NOT NULL DEFAULT 0, - `kop` tinyint(3) NOT NULL DEFAULT 0, - `sub` tinyint(3) NOT NULL DEFAULT 0, - `item` tinyint(3) NOT NULL DEFAULT 0, + `s1` tinyint(3) NOT NULL DEFAULT '0', + `s2` tinyint(3) NOT NULL DEFAULT '0', + `s3` tinyint(3) NOT NULL DEFAULT '0', + `s4` tinyint(3) NOT NULL DEFAULT '0', + `pac` tinyint(3) NOT NULL DEFAULT '0', + `cat` tinyint(3) NOT NULL DEFAULT '0', + `ori` tinyint(3) NOT NULL DEFAULT '0', + `pro` tinyint(3) NOT NULL DEFAULT '0', + `package` tinyint(3) NOT NULL DEFAULT '0', + `s5` tinyint(3) NOT NULL DEFAULT '0', + `s6` tinyint(3) NOT NULL DEFAULT '0', + `kop` tinyint(3) NOT NULL DEFAULT '0', + `sub` tinyint(3) NOT NULL DEFAULT '0', + `item` tinyint(3) NOT NULL DEFAULT '0', PRIMARY KEY (`item_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -9073,7 +9026,7 @@ CREATE TABLE `log` ( `tableName` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `fieldName` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `fieldValue` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, - `created` timestamp NOT NULL DEFAULT current_timestamp(), + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -9092,7 +9045,7 @@ CREATE TABLE `mail` ( `messageId` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `nExchanges` int(10) unsigned NOT NULL, `error` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `created` timestamp NOT NULL DEFAULT current_timestamp(), + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `mail_id` (`messageId`), KEY `sender_id` (`senderFk`), @@ -9126,11 +9079,11 @@ DROP TABLE IF EXISTS `marketPlace`; CREATE TABLE `marketPlace` ( `id` varchar(13) COLLATE utf8_unicode_ci NOT NULL, `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `supplierFk` int(11) NOT NULL DEFAULT 1433, - `isOffered` tinyint(2) NOT NULL DEFAULT 0, + `supplierFk` int(11) NOT NULL DEFAULT '1433', + `isOffered` tinyint(2) NOT NULL DEFAULT '0', `MaxLatestDeliveryHour` int(11) DEFAULT NULL COMMENT 'Maxima hora para tener en cuenta la oferta', - `isLatestOrderDateTimeRelevant` tinyint(2) DEFAULT 0 COMMENT 'Se tiene en cuenta para calcular el próximo travel posible', - `isEarlyBird` tinyint(4) NOT NULL DEFAULT 0, + `isLatestOrderDateTimeRelevant` tinyint(2) DEFAULT '0' COMMENT 'Se tiene en cuenta para calcular el próximo travel posible', + `isEarlyBird` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `marketPlaceisOfferedIdx` (`isOffered`), KEY `marketPlaceMaxLatestIdx` (`MaxLatestDeliveryHour`), @@ -9150,9 +9103,9 @@ CREATE TABLE `param` ( `code` varchar(30) COLLATE utf8_unicode_ci NOT NULL, `name` varchar(5) COLLATE utf8_unicode_ci NOT NULL, `subname` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL, - `position` tinyint(3) unsigned NOT NULL DEFAULT 1, + `position` tinyint(3) unsigned NOT NULL DEFAULT '1', `type` enum('INTEGER','DOUBLE','STRING','DATE','TIME') COLLATE utf8_unicode_ci NOT NULL, - `required` tinyint(3) unsigned NOT NULL DEFAULT 1, + `required` tinyint(3) unsigned NOT NULL DEFAULT '1', PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`,`subname`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Parameters to capture of every exchange'; @@ -9188,11 +9141,11 @@ CREATE TABLE `putOrder` ( `deliveryInformationID` int(11) DEFAULT NULL, `supplyResponseID` int(11) DEFAULT NULL, `orderTradelineItemID` int(11) DEFAULT NULL COMMENT 'ticketFk or EntryFk?', - `OrderTradeLineDateTime` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'fecha de creacion en la tabla', + `OrderTradeLineDateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'fecha de creacion en la tabla', `quantity` int(11) DEFAULT NULL, `EndUserPartyID` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `EndUserPartyGLN` varchar(13) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'The grower can use this reference in his EKT in the NAD (MA) segment.', - `OrderStatus` int(11) DEFAULT 0 COMMENT '1 pending\n2 confirmed\n3 canceled', + `OrderStatus` int(11) DEFAULT '0' COMMENT '1 pending\n2 confirmed\n3 canceled', `isOrderProcessed` tinyint(4) DEFAULT NULL, `error` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `barcode` varchar(25) COLLATE utf8_unicode_ci DEFAULT NULL, @@ -9393,7 +9346,8 @@ CREATE TABLE `supplier` ( `entry_date` date NOT NULL, `expiry_date` date NOT NULL, `change_date_time` datetime NOT NULL, - `isAllowedDirectSales` tinyint(1) NOT NULL DEFAULT 0, + `isAllowedDirectSales` tinyint(1) NOT NULL DEFAULT '0', + `isBanned` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`supplier_id`), UNIQUE KEY `supplier_UN` (`glnAddressCode`), KEY `glnaddressCodeidx` (`glnAddressCode`) @@ -9461,8 +9415,9 @@ CREATE TABLE `supplyResponse` ( `widthMeasure` int(11) DEFAULT NULL COMMENT 'mm Embalage Width', `lengthMeasure` int(11) DEFAULT NULL COMMENT 'mm Embalage Length', `heightMeasure` int(11) DEFAULT NULL COMMENT 'mm Embalage Height', - `created` datetime NOT NULL DEFAULT current_timestamp(), + `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `EmbalageCodeSupplier` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, + `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`ID`), KEY `IX_TransNumber` (`TransactionNumber`) COMMENT 'Agregado por Ernesto 11.6.2019\nSe ejecutaba 1 consulta por segundo desde MAIL y consumia un 20% de CPU de todo el servidor !!!!!\nCPU usada es mas estable que Indice en SendererID, cpu vs espacio que ocupa?\n', KEY `supplyResponse_Ix1` (`Item_ArticleCode`), @@ -9470,6 +9425,7 @@ CREATE TABLE `supplyResponse` ( KEY `supplyResponseNumberOfUnitsIdx` (`NumberOfUnits`), KEY `supplyResponseEmbalageCodeIdx` (`EmbalageCode`), KEY `supplyResponseputOrder_FK` (`vmpID`), + KEY `supplyResponse_updated_IDX` (`updated`) USING BTREE, CONSTRAINT `supplyResponse_fk2` FOREIGN KEY (`MarketPlaceID`) REFERENCES `marketPlace` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `supplyResponseputOrder_FK` FOREIGN KEY (`vmpID`) REFERENCES `VMPSettings` (`VMPID`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -9481,9 +9437,12 @@ CREATE TABLE `supplyResponse` ( /*!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 ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`z-developer`@`%`*/ /*!50003 TRIGGER `edi`.`supplyResponse_AFTER_UPDATE` AFTER UPDATE ON `supplyResponse` FOR EACH ROW +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER supplyResponse_AFTER_UPDATE + AFTER UPDATE + ON supplyResponse + FOR EACH ROW BEGIN /* IF NEW.NumberOfUnits = 0 AND OLD.NumberOfUnits <> 0 AND NEW.MarketPlaceID = 8713783439043 THEN @@ -9544,10 +9503,10 @@ DROP TABLE IF EXISTS `warehouseFloramondo`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `warehouseFloramondo` ( `warehouseFk` smallint(6) unsigned NOT NULL, - `travellingDays` int(11) NOT NULL DEFAULT 1, + `travellingDays` int(11) NOT NULL DEFAULT '1', `entryFk` int(11) DEFAULT NULL, `isFV` int(11) DEFAULT NULL COMMENT 'NULL indiferente\n0 no\n1 si\n', - `dayRange` int(11) NOT NULL DEFAULT 0 COMMENT 'dias de margen a futuro', + `dayRange` int(11) NOT NULL DEFAULT '0' COMMENT 'dias de margen a futuro', PRIMARY KEY (`warehouseFk`), KEY `warehouseFloramondo_FK2_idx` (`entryFk`), CONSTRAINT `warehouseFloramondo_FK2` FOREIGN KEY (`entryFk`) REFERENCES `vn`.`entry` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, @@ -9571,7 +9530,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-developer`@`%`*/ /*!50106 EVENT `floramondo` ON SCHEDULE EVERY 6 MINUTE STARTS '2020-07-29 01:58:29' ON COMPLETION NOT PRESERVE ENABLE DO CALL edi.floramondo_offerRefresh() */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`%`*/ /*!50106 EVENT `floramondo` ON SCHEDULE EVERY 6 MINUTE STARTS '2020-07-29 01:58:29' ON COMPLETION NOT PRESERVE ENABLE DO CALL edi.floramondo_offerRefresh() */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -9593,7 +9552,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`z-developer`@`%` FUNCTION `imageName`(vPictureReference VARCHAR(255)) RETURNS varchar(255) CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`%` FUNCTION `imageName`(vPictureReference VARCHAR(255)) RETURNS varchar(255) CHARSET utf8 COLLATE utf8_unicode_ci DETERMINISTIC BEGIN @@ -10083,7 +10042,7 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `floramondo_offerRefresh`() proc: BEGIN - + DECLARE vLanded DATETIME; DECLARE done INT DEFAULT FALSE; DECLARE vFreeId INT; @@ -10139,7 +10098,428 @@ proc: BEGIN ORDER BY (MarketPlaceID = vAalsmeerMarketPlaceID) DESC, NumberOfUnits DESC) t JOIN edi.item_groupToOffer igo ON igo.group_code = t.group_id LEFT JOIN edi.item_defaultType idt ON idt.item_id = t.Item_ArticleCode - GROUP BY Item_ArticleCode, s1, s2, s3, s4, s5, s6, company_name, Quality, NumberOfItemsPerCask, EmbalageCode, Price + GROUP BY Item_ArticleCode, s1, s2, s3, s4, s5, s6, company_name, Quality, NumberOfItemsPerCask, EmbalageCode, Price, PictureReference + ; + + -- -- 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 + 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 + FROM tmp so + LEFT JOIN edi.item_feature eif1 ON eif1.item_id = so.Item_ArticleCode + AND eif1.presentation_order = 1 AND eif1.expiry_date IS NULL + LEFT JOIN edi.item_feature eif2 ON eif2.item_id = so.Item_ArticleCode + AND eif2.presentation_order = 2 AND eif2.expiry_date IS NULL + LEFT JOIN edi.item_feature eif3 ON eif3.item_id = so.Item_ArticleCode + AND eif3.presentation_order = 3 AND eif3.expiry_date IS NULL + LEFT JOIN edi.item_feature eif4 ON eif4.item_id = so.Item_ArticleCode + AND eif4.presentation_order = 4 AND eif4.expiry_date IS NULL + LEFT JOIN edi.item_feature eif5 ON eif5.item_id = so.Item_ArticleCode + AND eif5.presentation_order = 5 AND eif5.expiry_date IS NULL + LEFT JOIN edi.item_feature eif6 ON eif6.item_id = so.Item_ArticleCode + AND eif6.presentation_order = 6 AND eif6.expiry_date IS NULL + LEFT JOIN edi.`value` ev1 ON ev1.type_id = eif1.feature AND so.s1 = ev1.type_value + LEFT JOIN edi.`value` ev2 ON ev2.type_id = eif2.feature AND so.s2 = ev2.type_value + LEFT JOIN edi.`value` ev3 ON ev3.type_id = eif3.feature AND so.s3 = ev3.type_value + LEFT JOIN edi.`value` ev4 ON ev4.type_id = eif4.feature AND so.s4 = ev4.type_value + LEFT JOIN edi.`value` ev5 ON ev5.type_id = eif5.feature AND so.s5 = ev5.type_value + LEFT JOIN edi.`value` ev6 ON ev6.type_id = eif6.feature AND so.s6 = ev6.type_value + ORDER BY Price; + + DROP TEMPORARY TABLE tmp; + + + START TRANSACTION; + + -- Actualizamos el campo supplyResponseFk para aquellos articulos que ya estan creados y reutilizamos + UPDATE IGNORE edi.offer o + JOIN vn.item i + ON i.name = o.product_name + AND i.subname <=> o.company_name + AND i.value5 <=> o.s1Value + AND i.value6 <=> o.s2Value + AND i.value7 <=> o.s3Value + AND i.value8 <=> o.s4Value + AND i.value9 <=> o.s5Value + AND i.value10 <=> o.s6Value + AND i.NumberOfItemsPerCask <=> o.NumberOfItemsPerCask + AND i.EmbalageCode <=> o.EmbalageCode + AND i.quality <=> o.Quality + JOIN vn.itemType it ON it.id = i.typeFk + LEFT JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk + LEFT JOIN deliveryInformation di ON di.supplyResponseID = sr.ID + SET i.supplyResponseFk = o.srID + WHERE ( sr.ID IS NULL + OR sr.NumberOfUnits = 0 + OR di.LatestOrderDateTime < NOW() + OR di.ID IS NULL) + AND it.isInventory + ; + -- select now(),'Antes de crear ITO'; + DROP TEMPORARY TABLE IF EXISTS itemToInsert; + CREATE TEMPORARY TABLE itemToInsert ENGINE = MEMORY + SELECT o.*, CAST(NULL AS DECIMAL(6,0)) as itemFk + FROM edi.offer o + LEFT JOIN vn.item i ON i.supplyResponseFk = o.srId + WHERE i.id IS NULL + LIMIT vMaxNewItems; + + -- Reciclado de nº de item + OPEN cur1; + OPEN cur2; + + read_loop: LOOP + + FETCH cur2 INTO vSupplyResponseFk; + FETCH cur1 INTO vFreeId; + + IF done THEN + LEAVE read_loop; + END IF; + + UPDATE itemToInsert + SET itemFk = vFreeId + WHERE srId = vSupplyResponseFk; + + END LOOP; + + CLOSE cur1; + CLOSE cur2; + + -- Insertamos todos los items en Articles de la oferta + INSERT INTO vn.item( id, + `name`, + longName, + subName, + expenceFk, + typeFk, + intrastatFk, + originFk, + supplyResponseFk, + numberOfItemsPerCask, + embalageCode, + quality, + isFloramondo) + SELECT itemFk, + product_name, + product_name, + company_name, + expenseFk, + itemTypeFk, + intrastatFk, + originFk, + `srId`, + NumberOfItemsPerCask, + EmbalageCode, + Quality, + TRUE + FROM itemToInsert; + + INSERT IGNORE INTO vn.itemImageQueue(itemFk, url) + SELECT i.id, PictureReference + FROM itemToInsert ii + JOIN vn.item i ON i.supplyResponseFk = ii.srId + WHERE PictureReference IS NOT NULL; + + INSERT INTO edi.log(tableName, fieldName,fieldValue) + SELECT 'itemImageQueue','NumImagenesPtes', COUNT(*) + FROM vn.itemImageQueue + WHERE attempts = 0; + + -- Inserta si se añadiesen tags nuevos + INSERT IGNORE INTO vn.tag (name, ediTypeFk) + SELECT description, type_id FROM edi.type; + + -- Inserta los tags sólo en los articulos nuevos + + -- desabilita el trigger para recalcular los tags al final + SET @isTriggerDisabled = TRUE; + + INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) + SELECT i.id, t.id , ii.product_name, 1 + FROM itemToInsert ii + JOIN vn.tag t ON t.`name` = 'Producto' + JOIN vn.item i ON i.supplyResponseFk = ii.`srId`; + + INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) + SELECT i.id, t.id , ii.Quality, 3 + FROM itemToInsert ii + JOIN vn.tag t ON t.`name` = 'Calidad' + JOIN vn.item i ON i.supplyResponseFk = ii.`srId`; + + INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) + SELECT i.id, t.id , ii.company_name, 4 + FROM itemToInsert ii + JOIN vn.tag t ON t.`name` = 'Productor' + JOIN vn.item i ON i.supplyResponseFk = ii.`srId`; + + INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) + SELECT i.id, t.id , s1Value, 5 + FROM itemToInsert ii + JOIN vn.tag t ON t.ediTypeFk = ii.ef1 + JOIN vn.item i ON i.supplyResponseFk = ii.`srId` + WHERE s1Value != ''; + + INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) + SELECT i.id, t.id , s2Value, 6 + FROM itemToInsert ii + JOIN vn.tag t ON t.ediTypeFk = ii.ef2 + JOIN vn.item i ON i.supplyResponseFk = ii.`srId` + WHERE s2Value != ''; + + INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) + SELECT i.id, t.id , s3Value, 7 + FROM itemToInsert ii + JOIN vn.tag t ON t.ediTypeFk = ii.ef3 + JOIN vn.item i ON i.supplyResponseFk = ii.`srId` + WHERE s3Value != ''; + + INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) + SELECT i.id, t.id , s4Value, 8 + FROM itemToInsert ii + JOIN vn.tag t ON t.ediTypeFk = ii.ef4 + JOIN vn.item i ON i.supplyResponseFk = ii.`srId` + WHERE s4Value != ''; + + INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) + SELECT i.id, t.id , s5Value, 9 + FROM itemToInsert ii + JOIN vn.tag t ON t.ediTypeFk = ii.ef5 + JOIN vn.item i ON i.supplyResponseFk = ii.`srId` + WHERE s5Value != ''; + + INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) + SELECT i.id, t.id , s6Value, 10 + FROM itemToInsert ii + JOIN vn.tag t ON t.ediTypeFk = ii.ef6 + JOIN vn.item i ON i.supplyResponseFk = ii.`srId` + WHERE s6Value != ''; + + INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) + SELECT i.id, t.id, ink.name, 11 + FROM itemToInsert ii + JOIN vn.item i ON i.supplyResponseFk = ii.`srId` + JOIN vn.tag t ON t.`name` = 'Color' + JOIN edi.feature f ON f.item_id = ii.Item_ArticleCode + JOIN edi.`type` tp ON tp.type_id = f.feature_type_id AND tp.`description` = 'Hoofdkleur 1' + JOIN vn.ink ON ink.dutchCode = f.feature_value; + + UPDATE vn.item i + JOIN itemToInsert ii ON i.supplyResponseFk = ii.`srId` + JOIN vn.packaging p ON p.id LIKE ii.EmbalageCode AND hasCompressionVariations + JOIN vn.itemTag diameter ON diameter.itemFk = i.id + JOIN vn.tag tDiameter ON tDiameter.overwrite = 'diameter' AND tDiameter.id = diameter.tagFk + JOIN vn.itemTag size ON size.itemFk = i.id + JOIN vn.tag tSize ON tSize.overwrite = 'size' AND tSize.id = size.tagFk + SET i.`compression` = + (PI() * POW(diameter.`value`/ 2, 2) * size.`value`) + / + ((p.width * p.depth * p.height) / ii.NumberOfItemsPerCask); + + DROP TABLE IF EXISTS tmp.item; + CREATE TABLE tmp.item + (PRIMARY KEY (id)) + SELECT i.id FROM vn.item i + JOIN itemToInsert ii ON i.supplyResponseFk = ii.`srId`; + + CALL vn.item_refreshTags(); + + SET @isTriggerDisabled = FALSE; + + SELECT MIN(LatestDeliveryDateTime) INTO vLanded + FROM edi.supplyResponse sr + JOIN edi.deliveryInformation di ON di.supplyResponseID = sr.ID + JOIN edi.marketPlace mp ON mp.id = sr.MarketPlaceID + JOIN vn.floramondoConfig fc + WHERE mp.isLatestOrderDateTimeRelevant + AND di.LatestOrderDateTime > IF(fc.MaxLatestOrderHour > HOUR(NOW()), CURDATE(), TIMESTAMPADD(DAY,1,CURDATE())); + + 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 + JOIN vn.travel tr ON tr.id = e.travelFk + JOIN vn.agencyMode am ON am.id = tr.agencyFk + JOIN vn.item i ON i.id = b.itemFk + LEFT JOIN edi.supplyResponse sr ON i.supplyResponseFk = sr.ID + LEFT JOIN edi.deliveryInformation di ON di.ID = b.deliveryFk + SET b.quantity = 0 + WHERE (IFNULL(di.LatestOrderDateTime,NOW()) <= NOW() + OR i.supplyResponseFk IS NULL + OR sr.NumberOfUnits = 0) + AND am.name = 'LOGIFLORA' + AND e.isRaid; + + -- Localiza las entradas de cada almacen + UPDATE edi.warehouseFloramondo + SET entryFk = vn.floramondo_getEntry(TIMESTAMPADD(DAY,travellingDays,vLanded), warehouseFk); + + IF vLanded IS NOT NULL THEN + -- actualiza la oferta existente + UPDATE vn.buy b + JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk + JOIN vn.item i ON i.id = b.itemFk + JOIN edi.offer o ON i.supplyResponseFk = o.`srId` + SET b.quantity = o.NumberOfUnits * o.NumberOfItemsPerCask, + b.buyingValue = o.price + WHERE (b.quantity <> o.NumberOfUnits * o.NumberOfItemsPerCask OR b.buyingValue <> o.price); + + -- Se eliminan las ofertas ya incluidas en las entradas + DELETE o + FROM edi.offer o + JOIN vn.item i ON i.supplyResponseFk = o.srId + JOIN vn.buy b ON i.id = b.itemFk + JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk; + + -- Se inserta el resto + SET vLastInserted := NOW(); + + -- Inserta la oferta + INSERT INTO vn.buy(entryFk, + itemFk, + quantity, + buyingValue, + stickers, + packing, + `grouping`, + groupingMode, + packageFk, + deliveryFk) + + SELECT wf.entryFk, + i.id, + o.NumberOfUnits * o.NumberOfItemsPerCask as quantity, + o.Price, + o.NumberOfUnits as etiquetas, + o.NumberOfItemsPerCask as packing, + GREATEST(1, IFNULL(o.MinimumQuantity,0)) * o.NumberOfItemsPerCask as `grouping`, + 2, -- Obliga al Packing + o.embalageCode, + o.diId + FROM edi.offer o + JOIN vn.item i ON i.supplyResponseFk = o.srId + -- JOIN vn.itemType it ON it.id = i.typeFk + JOIN edi.warehouseFloramondo wf + JOIN vn.packaging p ON p.id LIKE o.embalageCode; -- llevar esta linea i mirar de crear els packages a temps real + + DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc; + + CREATE TEMPORARY TABLE tmp.buyRecalc + SELECT b.id + FROM vn.buy b + JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk + WHERE b.created >= vLastInserted; + + CALL vn.buy_recalcPrices(); + + END IF; + + DROP TEMPORARY TABLE + edi.offer, + itemToInsert; + + DROP TABLE tmp.item; + + COMMIT; + + -- Esto habria que pasarlo a procesos programados o trabajar con tags y dejar las familias + UPDATE vn.item i + SET typeFk = 121 + WHERE i.longName LIKE 'Rosa Garden %' + AND typeFk = 17; + + UPDATE vn.item i + SET typeFk = 156 + WHERE i.longName LIKE 'Rosa ec %' + AND typeFk = 17; + + INSERT INTO edi.log(tableName, fieldName,fieldValue) + VALUES('floramondo_offerRefresh','Tiempo de proceso',TIMEDIFF(NOW(),vStartingTime)); + +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 `floramondo_offerRefresh_beta` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `floramondo_offerRefresh_beta`() +proc: BEGIN + + DECLARE vLanded DATETIME; + DECLARE done INT DEFAULT FALSE; + DECLARE vFreeId INT; + DECLARE vSupplyResponseFk INT; + DECLARE vLastInserted DATETIME; + DECLARE vIsAuctionDay BOOLEAN; + DECLARE vMaxNewItems INT DEFAULT 100000; + DECLARE vStartingTime DATETIME; + DECLARE vAalsmeerMarketPlaceID VARCHAR(13) DEFAULT '8713783439043'; + DECLARE vLastUpdated DATETIME DEFAULT now(); + + DECLARE cur1 CURSOR FOR + SELECT id + FROM edi.item_free; + + DECLARE cur2 CURSOR FOR + SELECT srId + FROM itemToInsert; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; + DECLARE EXIT HANDLER FOR SQLSTATE '45000' + BEGIN + ROLLBACK; + RESIGNAL; + END; + + SET vStartingTime = NOW(); + + -- CALL vn.clean_logiflora(); + + -- Refresca las fotos de los items existentes, con prioridad baja (0.7 seg) + INSERT IGNORE INTO vn.itemImageQueue(itemFk, url,priority) + SELECT i.id, sr.PictureReference , 100 + FROM edi.supplyResponse sr + JOIN vn.item i ON i.supplyResponseFk = sr.ID + WHERE i.image != edi.imageName(sr.PictureReference) + AND sr.NumberOfUnits > 0; + + -- Elimina de la lista de items libres aquellos que ya existen + DELETE itf.* + FROM edi.item_free itf + JOIN vn.item i ON i.id = itf.id; + + DROP TEMPORARY TABLE IF EXISTS tmp; + CREATE TEMPORARY TABLE tmp (INDEX (`Item_ArticleCode`)) ENGINE = MEMORY + SELECT t.*, + IFNULL(idt.itemTypeFk, igo.itemTypeFk) itemTypeFk, + igo.expenseFk , + igo.intrastatFk , + igo.originFk + FROM ( + SELECT * + FROM edi.supplyOffer so + JOIN vn.floramondoConfig fc + WHERE so.supplyResponseUpdated > fc.LastUpdated + ORDER BY (MarketPlaceID = vAalsmeerMarketPlaceID) DESC, NumberOfUnits DESC) t + JOIN edi.item_groupToOffer igo ON igo.group_code = t.group_id + LEFT JOIN edi.item_defaultType idt ON idt.item_id = t.Item_ArticleCode + GROUP BY Item_ArticleCode, s1, s2, s3, s4, s5, s6, company_name, Quality, NumberOfItemsPerCask, EmbalageCode, Price, PictureReference ; -- -- select now(),'Antes de crear edi.offer'; @@ -10484,430 +10864,7 @@ proc: BEGIN INSERT INTO edi.log(tableName, fieldName,fieldValue) VALUES('floramondo_offerRefresh','Tiempo de proceso',TIMEDIFF(NOW(),vStartingTime)); - - -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 `floramondo_offerRefresh__` */; -/*!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 `floramondo_offerRefresh__`() -proc: BEGIN - - DECLARE vLanded DATETIME; - DECLARE done INT DEFAULT FALSE; - DECLARE vFreeId INT; - DECLARE vSupplyResponseFk INT; - DECLARE vLastInserted DATETIME; - DECLARE vIsAuctionDay BOOLEAN; - DECLARE vMaxNewItems INT DEFAULT 100000; - DECLARE vStartingTime DATETIME; - - DECLARE cur1 CURSOR FOR - SELECT id - FROM edi.item_free; - - DECLARE cur2 CURSOR FOR - SELECT srId - FROM itemToInsert; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; - DECLARE EXIT HANDLER FOR SQLSTATE '45000' - BEGIN - ROLLBACK; - RESIGNAL; - END; - - SET vStartingTime = NOW(); - - -- CALL vn.clean_logiflora(); - - -- Refresca las fotos de los items existentes, con prioridad baja (0.7 seg) - INSERT IGNORE INTO vn.itemImageQueue(itemFk, url,priority) - SELECT i.id, sr.PictureReference , 100 - FROM edi.supplyResponse sr - JOIN vn.item i ON i.supplyResponseFk = sr.ID - WHERE i.image != edi.imageName(sr.PictureReference) - AND sr.NumberOfUnits > 0; - - DELETE itf.* - FROM edi.item_free itf - JOIN vn.item i ON i.id = itf.id; - - -- -- select now(),'Tras borrar'; - DROP TEMPORARY TABLE IF EXISTS tmp; - CREATE TEMPORARY TABLE tmp (INDEX (`Item_ArticleCode`)) ENGINE = MEMORY - SELECT t.*, - IFNULL(idt.itemTypeFk, igo.itemTypeFk) itemTypeFk, - igo.expenseFk , - igo.intrastatFk , - igo.originFk - FROM ( - SELECT * - FROM edi.supplyOffer - ORDER BY NumberOfUnits DESC) t - JOIN edi.item_groupToOffer igo ON igo.group_code = t.group_id - LEFT JOIN edi.item_defaultType idt ON idt.item_id = t.Item_ArticleCode - GROUP BY Item_ArticleCode, s1, s2, s3, s4, s5, s6, company_name, Quality, NumberOfItemsPerCask, EmbalageCode, Price ; - - -- -- 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 - 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 - FROM tmp so - LEFT JOIN edi.item_feature eif1 ON eif1.item_id = so.Item_ArticleCode - AND eif1.presentation_order = 1 AND eif1.expiry_date IS NULL - LEFT JOIN edi.item_feature eif2 ON eif2.item_id = so.Item_ArticleCode - AND eif2.presentation_order = 2 AND eif2.expiry_date IS NULL - LEFT JOIN edi.item_feature eif3 ON eif3.item_id = so.Item_ArticleCode - AND eif3.presentation_order = 3 AND eif3.expiry_date IS NULL - LEFT JOIN edi.item_feature eif4 ON eif4.item_id = so.Item_ArticleCode - AND eif4.presentation_order = 4 AND eif4.expiry_date IS NULL - LEFT JOIN edi.item_feature eif5 ON eif5.item_id = so.Item_ArticleCode - AND eif5.presentation_order = 5 AND eif5.expiry_date IS NULL - LEFT JOIN edi.item_feature eif6 ON eif6.item_id = so.Item_ArticleCode - AND eif6.presentation_order = 6 AND eif6.expiry_date IS NULL - LEFT JOIN edi.`value` ev1 ON ev1.type_id = eif1.feature AND so.s1 = ev1.type_value - LEFT JOIN edi.`value` ev2 ON ev2.type_id = eif2.feature AND so.s2 = ev2.type_value - LEFT JOIN edi.`value` ev3 ON ev3.type_id = eif3.feature AND so.s3 = ev3.type_value - LEFT JOIN edi.`value` ev4 ON ev4.type_id = eif4.feature AND so.s4 = ev4.type_value - LEFT JOIN edi.`value` ev5 ON ev5.type_id = eif5.feature AND so.s5 = ev5.type_value - LEFT JOIN edi.`value` ev6 ON ev6.type_id = eif6.feature AND so.s6 = ev6.type_value - ORDER BY Price; - - DROP TEMPORARY TABLE tmp; - - - START TRANSACTION; - - -- Actualizamos el campo supplyResponseFk para aquellos articulos que ya estan creados y reutilizamos - UPDATE IGNORE edi.offer o - LEFT JOIN vn.item iExist ON iExist.supplyResponseFk = o.srID - JOIN vn.item i - ON i.name = o.product_name - AND i.subname <=> o.company_name - AND i.value5 <=> o.s1Value - AND i.value6 <=> o.s2Value - AND i.value7 <=> o.s3Value - AND i.value8 <=> o.s4Value - AND i.value9 <=> o.s5Value - AND i.value10 <=> o.s6Value - AND i.NumberOfItemsPerCask <=> o.NumberOfItemsPerCask - AND i.EmbalageCode <=> o.EmbalageCode - AND i.quality <=> o.Quality - LEFT JOIN deliveryInformation di ON di.supplyResponseID = i.supplyResponseFk - JOIN vn.itemType it ON it.id = i.typeFk - SET i.supplyResponseFk = o.srID - WHERE iExist.id IS NULL - AND (di.LatestOrderDateTime < NOW() OR di.ID IS NULL) - AND it.isInventory - ; - -- select now(),'Antes de crear ITO'; - DROP TEMPORARY TABLE IF EXISTS itemToInsert; - CREATE TEMPORARY TABLE itemToInsert ENGINE = MEMORY - SELECT o.*, CAST(NULL AS DECIMAL(6,0)) as itemFk - FROM edi.offer o - LEFT JOIN vn.item i ON i.supplyResponseFk = o.srId - WHERE i.id IS NULL - LIMIT vMaxNewItems; - - -- Reciclado de nº de item - OPEN cur1; - OPEN cur2; - - read_loop: LOOP - - FETCH cur2 INTO vSupplyResponseFk; - FETCH cur1 INTO vFreeId; - - IF done THEN - LEAVE read_loop; - END IF; - - UPDATE itemToInsert - SET itemFk = vFreeId - WHERE srId = vSupplyResponseFk; - - END LOOP; - - CLOSE cur1; - CLOSE cur2; - - -- Insertamos todos los items en Articles de la oferta - INSERT INTO vn.item( id, - `name`, - longName, - subName, - expenceFk, - typeFk, - intrastatFk, - originFk, - supplyResponseFk, - numberOfItemsPerCask, - embalageCode, - quality, - isFloramondo) - SELECT itemFk, - product_name, - product_name, - company_name, - expenseFk, - itemTypeFk, - intrastatFk, - originFk, - `srId`, - NumberOfItemsPerCask, - EmbalageCode, - Quality, - TRUE - FROM itemToInsert; - - INSERT IGNORE INTO vn.itemImageQueue(itemFk, url) - SELECT i.id, PictureReference - FROM itemToInsert ii - JOIN vn.item i ON i.supplyResponseFk = ii.srId - WHERE PictureReference IS NOT NULL; - - INSERT INTO edi.log(tableName, fieldName,fieldValue) - SELECT 'itemImageQueue','NumImagenesPtes', COUNT(*) - FROM vn.itemImageQueue - WHERE attempts = 0; - - -- Inserta si se añadiesen tags nuevos - INSERT IGNORE INTO vn.tag (name, ediTypeFk) - SELECT description, type_id FROM edi.type; - - -- Inserta los tags sólo en los articulos nuevos - - -- desabilita el trigger para recalcular los tags al final - SET @isTriggerDisabled = TRUE; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , ii.product_name, 1 - FROM itemToInsert ii - JOIN vn.tag t ON t.`name` = 'Producto' - JOIN vn.item i ON i.supplyResponseFk = ii.`srId`; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , ii.Quality, 3 - FROM itemToInsert ii - JOIN vn.tag t ON t.`name` = 'Calidad' - JOIN vn.item i ON i.supplyResponseFk = ii.`srId`; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , ii.company_name, 4 - FROM itemToInsert ii - JOIN vn.tag t ON t.`name` = 'Productor' - JOIN vn.item i ON i.supplyResponseFk = ii.`srId`; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , s1Value, 5 - FROM itemToInsert ii - JOIN vn.tag t ON t.ediTypeFk = ii.ef1 - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE s1Value != ''; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , s2Value, 6 - FROM itemToInsert ii - JOIN vn.tag t ON t.ediTypeFk = ii.ef2 - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE s2Value != ''; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , s3Value, 7 - FROM itemToInsert ii - JOIN vn.tag t ON t.ediTypeFk = ii.ef3 - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE s3Value != ''; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , s4Value, 8 - FROM itemToInsert ii - JOIN vn.tag t ON t.ediTypeFk = ii.ef4 - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE s4Value != ''; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , s5Value, 9 - FROM itemToInsert ii - JOIN vn.tag t ON t.ediTypeFk = ii.ef5 - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE s5Value != ''; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , s6Value, 10 - FROM itemToInsert ii - JOIN vn.tag t ON t.ediTypeFk = ii.ef6 - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE s6Value != ''; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id, ink.name, 11 - FROM itemToInsert ii - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - JOIN vn.tag t ON t.`name` = 'Color' - JOIN edi.feature f ON f.item_id = ii.Item_ArticleCode - JOIN edi.`type` tp ON tp.type_id = f.feature_type_id AND tp.`description` = 'Hoofdkleur 1' - JOIN vn.ink ON ink.dutchCode = f.feature_value; - - UPDATE vn.item i - JOIN itemToInsert ii ON i.supplyResponseFk = ii.`srId` - JOIN vn.packaging p ON p.id LIKE ii.EmbalageCode AND hasCompressionVariations - JOIN vn.itemTag diameter ON diameter.itemFk = i.id - JOIN vn.tag tDiameter ON tDiameter.overwrite = 'diameter' AND tDiameter.id = diameter.tagFk - JOIN vn.itemTag size ON size.itemFk = i.id - JOIN vn.tag tSize ON tSize.overwrite = 'size' AND tSize.id = size.tagFk - SET i.`compression` = - (PI() * POW(diameter.`value`/ 2, 2) * size.`value`) - / - ((p.width * p.depth * p.height) / ii.NumberOfItemsPerCask); - - DROP TABLE IF EXISTS tmp.item; - CREATE TABLE tmp.item - (PRIMARY KEY (id)) - SELECT i.id FROM vn.item i - JOIN itemToInsert ii ON i.supplyResponseFk = ii.`srId`; - - CALL vn.item_refreshTags(); - - SET @isTriggerDisabled = FALSE; - - SELECT MIN(LatestDeliveryDateTime) INTO vLanded - FROM edi.supplyResponse sr - JOIN edi.deliveryInformation di ON di.supplyResponseID = sr.ID - JOIN edi.marketPlace mp ON mp.id = sr.MarketPlaceID - JOIN vn.floramondoConfig fc - WHERE mp.isLatestOrderDateTimeRelevant - AND di.LatestOrderDateTime > IF(fc.MaxLatestOrderHour > HOUR(NOW()), CURDATE(), TIMESTAMPADD(DAY,1,CURDATE())); - - 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 - JOIN vn.travel tr ON tr.id = e.travelFk - JOIN vn.agencyMode am ON am.id = tr.agencyFk - JOIN vn.item i ON i.id = b.itemFk - JOIN edi.supplyResponse sr ON i.supplyResponseFk = sr.ID - LEFT JOIN edi.putOrder po ON b.deliveryFk = po.deliveryInformationID - LEFT JOIN edi.deliveryInformation di ON di.ID = b.deliveryFk - SET b.quantity = 0 - WHERE (po.id IS NULL OR di.LatestOrderDateTime < NOW()) - AND sr.ID IS NULL - AND am.name = 'LOGIFLORA' - AND e.isRaid; - - UPDATE vn.buy b - JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk - JOIN vn.item i ON i.id = b.itemFk - LEFT JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk - SET b.quantity = 0 - WHERE sr.ID IS NULL; - - -- Localiza las entradas de cada almacen - UPDATE edi.warehouseFloramondo - SET entryFk = vn.floramondo_getEntry(TIMESTAMPADD(DAY,travellingDays,vLanded), warehouseFk); - - IF vLanded IS NOT NULL THEN - -- actualiza la oferta existente - UPDATE vn.buy b - JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk - JOIN vn.item i ON i.id = b.itemFk - JOIN edi.offer o ON i.supplyResponseFk = o.`srId` - SET b.quantity = o.NumberOfUnits * o.NumberOfItemsPerCask, - b.buyingValue = o.price - WHERE (b.quantity <> o.NumberOfUnits * o.NumberOfItemsPerCask OR b.buyingValue <> o.price); - - -- Se eliminan las ofertas ya incluidas en las entradas - DELETE o - FROM edi.offer o - JOIN vn.item i ON i.supplyResponseFk = o.srId - JOIN vn.buy b ON i.id = b.itemFk - JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk; - - -- Se inserta el resto - SET vLastInserted := NOW(); - - -- Inserta la oferta - INSERT INTO vn.buy(entryFk, - itemFk, - quantity, - buyingValue, - stickers, - packing, - `grouping`, - groupingMode, - packageFk, - deliveryFk) - - SELECT wf.entryFk, - i.id, - o.NumberOfUnits * o.NumberOfItemsPerCask as quantity, - o.Price, - o.NumberOfUnits as etiquetas, - o.NumberOfItemsPerCask as packing, - GREATEST(1, IFNULL(o.MinimumQuantity,0)) * o.NumberOfItemsPerCask as `grouping`, - 2, -- Obliga al Packing - o.embalageCode, - o.diId - FROM edi.offer o - JOIN vn.item i ON i.supplyResponseFk = o.srId - JOIN vn.itemType it ON it.id = i.typeFk - JOIN edi.warehouseFloramondo wf ON wf.isFV = it.isFV OR wf.isFV IS NULL - JOIN vn.packaging p ON p.id LIKE o.embalageCode; -- llevar esta linea i mirar de crear els packages a temps real - - DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc; - - CREATE TEMPORARY TABLE tmp.buyRecalc - SELECT b.id - FROM vn.buy b - JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk - WHERE b.created >= vLastInserted; - - CALL vn.buy_recalcPrices(); - - END IF; - - DROP TEMPORARY TABLE - edi.offer, - itemToInsert; - - DROP TABLE tmp.item; - - COMMIT; - - -- Esto habria que pasarlo a procesos programados o trabajar con tags y dejar las familias - UPDATE vn.item i - SET typeFk = 121 - WHERE i.longName LIKE 'Rosa Garden %' - AND typeFk = 17; - - UPDATE vn.item i - SET typeFk = 156 - WHERE i.longName LIKE 'Rosa ec %' - AND typeFk = 17; - - INSERT INTO edi.log(tableName, fieldName,fieldValue) - VALUES('floramondo_offerRefresh','Tiempo de proceso',TIMEDIFF(NOW(),vStartingTime)); - - + UPDATE vn.floramondoConfig SET LastUpdated = vLastUpdated; END ;; DELIMITER ; @@ -11076,7 +11033,7 @@ CREATE TABLE `image` ( `collectionFk` varchar(50) COLLATE utf8_unicode_ci NOT NULL, `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `updated` int(11) DEFAULT NULL, - `nRefs` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'Number of references, don''t modify this column manually', + `nRefs` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Number of references, don''t modify this column manually', PRIMARY KEY (`id`), UNIQUE KEY `collection` (`collectionFk`,`name`), CONSTRAINT `image_ibfk_1` FOREIGN KEY (`collectionFk`) REFERENCES `imageCollection` (`name`) ON UPDATE CASCADE @@ -11101,8 +11058,8 @@ CREATE TABLE `imageCollection` ( `schema` varchar(50) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Deprecated', `table` varchar(50) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Deprecated', `column` varchar(50) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Deprecated', - `readRoleFk` int(10) unsigned DEFAULT 1, - `writeRoleFk` int(10) unsigned DEFAULT 1, + `readRoleFk` int(10) unsigned DEFAULT '1', + `writeRoleFk` int(10) unsigned DEFAULT '1', PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`), KEY `role_id_writeRoleFk` (`writeRoleFk`), @@ -11124,7 +11081,7 @@ CREATE TABLE `imageCollectionSize` ( `collectionFk` int(10) unsigned NOT NULL, `width` int(10) unsigned NOT NULL, `height` int(10) unsigned NOT NULL, - `crop` tinyint(3) unsigned NOT NULL DEFAULT 0, + `crop` tinyint(3) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `image_schema_id` (`collectionFk`), CONSTRAINT `imageCollectionSize_ibfk_1` FOREIGN KEY (`collectionFk`) REFERENCES `imageCollection` (`id`) ON UPDATE CASCADE @@ -11158,7 +11115,7 @@ CREATE TABLE `language` ( `code` varchar(10) CHARACTER SET utf8 NOT NULL, `name` varchar(20) COLLATE utf8_unicode_ci NOT NULL, `orgName` varchar(255) COLLATE utf8_unicode_ci NOT NULL, - `isActive` tinyint(1) NOT NULL DEFAULT 0, + `isActive` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -11275,8 +11232,8 @@ DROP TABLE IF EXISTS `mailConfig`; CREATE TABLE `mailConfig` ( `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Identifier', `host` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'localhost' COMMENT 'SMTP host', - `port` smallint(6) NOT NULL DEFAULT 465 COMMENT 'SMTP port', - `secure` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Wether to use a secure connection', + `port` smallint(6) NOT NULL DEFAULT '465' COMMENT 'SMTP port', + `secure` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Wether to use a secure connection', `sender` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'The sender mail address', `senderName` varchar(75) CHARACTER SET utf8 NOT NULL COMMENT 'The sender name', `user` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'SMTP user', @@ -11325,7 +11282,7 @@ CREATE TABLE `menu` ( `path` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `roleFk` int(10) unsigned NOT NULL, `parentFk` int(10) unsigned DEFAULT NULL, - `displayOrder` tinyint(4) unsigned NOT NULL DEFAULT 1, + `displayOrder` tinyint(4) unsigned NOT NULL DEFAULT '1', PRIMARY KEY (`id`), KEY `group_id` (`roleFk`), KEY `parent` (`parentFk`), @@ -11676,8 +11633,8 @@ CREATE TABLE `news` ( `text` text COLLATE utf8_unicode_ci NOT NULL, `image` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `userFk` int(10) unsigned NOT NULL, - `created` timestamp NOT NULL DEFAULT current_timestamp(), - `priority` tinyint(3) unsigned NOT NULL DEFAULT 3, + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `priority` tinyint(3) unsigned NOT NULL DEFAULT '3', `tag` varchar(15) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'new', PRIMARY KEY (`id`), KEY `user` (`userFk`), @@ -11775,15 +11732,15 @@ CREATE TABLE `order` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `date_send` date NOT NULL DEFAULT '0000-00-00', `customer_id` int(11) NOT NULL, - `delivery_method_id` int(11) DEFAULT 3, - `agency_id` int(11) DEFAULT 2, + `delivery_method_id` int(11) DEFAULT '3', + `agency_id` int(11) DEFAULT '2', `address_id` int(11) DEFAULT NULL, - `company_id` smallint(5) unsigned NOT NULL DEFAULT 442, + `company_id` smallint(5) unsigned NOT NULL DEFAULT '442', `note` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `source_app` set('WEB','ANDROID','IOS','SALIX','TPV','TABLET_VN','') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'TPV', - `is_bionic` tinyint(1) NOT NULL DEFAULT 1, - `confirmed` tinyint(1) NOT NULL DEFAULT 0, - `date_make` timestamp NOT NULL DEFAULT current_timestamp(), + `is_bionic` tinyint(1) NOT NULL DEFAULT '1', + `confirmed` tinyint(1) NOT NULL DEFAULT '0', + `date_make` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `first_row_stamp` datetime DEFAULT NULL, `confirm_date` datetime DEFAULT NULL, `taxableBase` decimal(10,2) NOT NULL, @@ -11904,14 +11861,14 @@ DROP TABLE IF EXISTS `orderRow`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `orderRow` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `orderFk` int(10) unsigned NOT NULL DEFAULT 0, - `itemFk` int(11) NOT NULL DEFAULT 0, + `orderFk` int(10) unsigned NOT NULL DEFAULT '0', + `itemFk` int(11) NOT NULL DEFAULT '0', `warehouseFk` int(11) DEFAULT NULL, `shipment` date DEFAULT NULL, - `amount` smallint(6) unsigned NOT NULL DEFAULT 0, + `amount` smallint(6) unsigned NOT NULL DEFAULT '0', `price` decimal(10,2) DEFAULT NULL, `rate` smallint(5) unsigned DEFAULT NULL, - `created` timestamp NOT NULL DEFAULT current_timestamp(), + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `saleFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `item` (`itemFk`), @@ -12136,7 +12093,7 @@ CREATE TABLE `shelfConfig` ( `shelf` int(10) unsigned NOT NULL, `maxAmount` smallint(5) unsigned DEFAULT NULL, `showPacking` tinyint(4) NOT NULL, - `stack` tinyint(4) NOT NULL DEFAULT 0, + `stack` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `shelf_id` (`shelf`), KEY `family_id` (`family`), @@ -12190,7 +12147,7 @@ CREATE TABLE `surveyAnswer` ( `id` int(10) unsigned NOT NULL, `surveyFk` int(10) unsigned NOT NULL, `answer` varchar(30) COLLATE utf8_unicode_ci NOT NULL, - `votes` int(10) unsigned NOT NULL DEFAULT 0, + `votes` int(10) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `survey` (`surveyFk`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -12228,7 +12185,7 @@ CREATE TABLE `tpvConfig` ( `maxAmount` int(10) unsigned DEFAULT NULL, `employeeFk` int(10) NOT NULL, `url` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'The bank web service URL for production environment', - `testMode` tinyint(3) unsigned NOT NULL DEFAULT 0 COMMENT 'Whether test mode is enabled', + `testMode` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT 'Whether test mode is enabled', `testUrl` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT 'The bank web service URL for test environment', `testKey` varchar(50) CHARACTER SET utf8 DEFAULT NULL COMMENT 'The bank secret key for test environment', `merchantUrl` varchar(255) CHARACTER SET utf8 DEFAULT NULL, @@ -12299,7 +12256,7 @@ DROP TABLE IF EXISTS `tpvMerchantEnable`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `tpvMerchantEnable` ( - `merchantFk` int(10) unsigned NOT NULL DEFAULT 0, + `merchantFk` int(10) unsigned NOT NULL DEFAULT '0', `companyFk` smallint(6) unsigned NOT NULL, PRIMARY KEY (`merchantFk`,`companyFk`), UNIQUE KEY `company_id` (`companyFk`), @@ -12337,7 +12294,7 @@ CREATE TABLE `tpvTransaction` ( `response` smallint(5) unsigned DEFAULT NULL COMMENT 'Status notified by bank: NULL if no notification, 0 if success, error otherwise', `errorCode` char(7) COLLATE utf8_unicode_ci DEFAULT NULL, `status` enum('started','ok','ko') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'started', - `created` timestamp NOT NULL DEFAULT current_timestamp(), + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `merchant_id` (`merchantFk`), KEY `receipt_id` (`receiptFk`), @@ -12358,10 +12315,10 @@ DROP TABLE IF EXISTS `userSession`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `userSession` ( - `created` datetime NOT NULL DEFAULT current_timestamp(), - `lastUpdate` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `lastUpdate` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `ssid` char(64) COLLATE utf8_unicode_ci NOT NULL, - `data` text COLLATE utf8_unicode_ci DEFAULT NULL, + `data` text COLLATE utf8_unicode_ci, `userVisitFk` int(10) unsigned DEFAULT NULL, UNIQUE KEY `ssid` (`ssid`), KEY `userVisit` (`userVisitFk`), @@ -12395,7 +12352,7 @@ DROP TABLE IF EXISTS `visitAccess`; CREATE TABLE `visitAccess` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `agentFk` int(10) unsigned NOT NULL, - `stamp` datetime NOT NULL DEFAULT current_timestamp(), + `stamp` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `ip` int(10) unsigned DEFAULT NULL, `referer` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), @@ -12441,7 +12398,7 @@ CREATE TABLE `visitUser` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `accessFk` int(10) unsigned NOT NULL, `userFk` int(10) unsigned DEFAULT NULL, - `stamp` timestamp NOT NULL DEFAULT current_timestamp(), + `stamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `access_id` (`accessFk`), KEY `date_time` (`stamp`), @@ -15845,8 +15802,8 @@ CREATE TABLE `labourTree` ( `id` int(11) NOT NULL AUTO_INCREMENT, `lft` int(11) NOT NULL, `rgt` int(11) NOT NULL, - `depth` int(11) NOT NULL DEFAULT 0, - `sons` int(11) NOT NULL DEFAULT 0, + `depth` int(11) NOT NULL DEFAULT '0', + `sons` int(11) NOT NULL DEFAULT '0', `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -16267,7 +16224,7 @@ DROP TABLE IF EXISTS `cdr`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `cdr` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `call_date` datetime NOT NULL DEFAULT current_timestamp(), + `call_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `clid` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `src` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `dst` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', @@ -16276,10 +16233,10 @@ CREATE TABLE `cdr` ( `dst_channel` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `last_app` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `last_data` varchar(80) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `duration` int(11) NOT NULL DEFAULT 0, - `billsec` int(11) NOT NULL DEFAULT 0, + `duration` int(11) NOT NULL DEFAULT '0', + `billsec` int(11) NOT NULL DEFAULT '0', `disposition` varchar(45) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `ama_flags` int(11) NOT NULL DEFAULT 0, + `ama_flags` int(11) NOT NULL DEFAULT '0', `account_code` varchar(20) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `unique_id` varchar(32) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `user_field` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', @@ -16659,7 +16616,7 @@ DROP TABLE IF EXISTS `sip`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `sip` ( - `user_id` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'The user id', + `user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'The user id', `extension` varchar(128) CHARACTER SET utf8 NOT NULL COMMENT 'The softphone extension', `md5Secret` varchar(80) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'MD5 hash of extension and password', `secret` varchar(80) CHARACTER SET utf8 DEFAULT NULL COMMENT 'Deprecated', @@ -17178,7 +17135,7 @@ CREATE TABLE `business` ( `provider_id` int(11) DEFAULT NULL, `date_start` date DEFAULT NULL, `date_end` date DEFAULT NULL, - `workerBusiness` longtext DEFAULT NULL, + `workerBusiness` longtext, `reasonEndFk` int(11) DEFAULT NULL, PRIMARY KEY (`business_id`), KEY `business_client` (`client_id`), @@ -17197,12 +17154,12 @@ DROP TABLE IF EXISTS `business_labour`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `business_labour` ( `business_id` int(11) NOT NULL, - `notes` longtext DEFAULT NULL, - `department_id` int(11) DEFAULT 2, - `professional_category_id` int(11) DEFAULT 0, - `incentivo` double DEFAULT 0, - `calendar_labour_type_id` int(11) DEFAULT 1, - `porhoras` smallint(6) NOT NULL DEFAULT 0, + `notes` longtext, + `department_id` int(11) DEFAULT '2', + `professional_category_id` int(11) DEFAULT '0', + `incentivo` double DEFAULT '0', + `calendar_labour_type_id` int(11) DEFAULT '1', + `porhoras` smallint(6) NOT NULL DEFAULT '0', `labour_agreement_id` int(11) DEFAULT NULL, `workcenter_id` int(11) DEFAULT NULL, PRIMARY KEY (`business_id`), @@ -17230,7 +17187,7 @@ CREATE TABLE `business_labour_payroll` ( `cod_tarifa` int(11) DEFAULT NULL, `cod_categoria` int(11) DEFAULT NULL, `cod_contrato` int(11) DEFAULT NULL, - `importepactado` decimal(10,2) NOT NULL DEFAULT 0.00, + `importepactado` decimal(10,2) NOT NULL DEFAULT '0.00', PRIMARY KEY (`business_id`), KEY `business_labour_payroll_cod_categoria_idx` (`cod_categoria`), KEY `business_labour_payroll_cod_contrato` (`cod_contrato`), @@ -17306,7 +17263,7 @@ DROP TABLE IF EXISTS `calendar_labour_legend__`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `calendar_labour_legend__` ( `calendar_labour_legend_id` int(11) NOT NULL AUTO_INCREMENT, - `descripcion` longtext DEFAULT NULL, + `descripcion` longtext, PRIMARY KEY (`calendar_labour_legend_id`), UNIQUE KEY `calendar_labour_legend_calendar_labour_legend_id_key` (`calendar_labour_legend_id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8; @@ -17324,7 +17281,7 @@ CREATE TABLE `calendar_labour_type` ( `descripcion` varchar(50) DEFAULT NULL, `pausa_remunerada` time DEFAULT NULL, `hours_week` smallint(6) DEFAULT NULL, - `isPartial` tinyint(1) NOT NULL DEFAULT 0, + `isPartial` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`calendar_labour_type_id`), UNIQUE KEY `hours_labour_hours_labour_id_key` (`calendar_labour_type_id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8; @@ -17341,13 +17298,13 @@ CREATE TABLE `calendar_state` ( `calendar_state_id` int(11) NOT NULL AUTO_INCREMENT, `type` varchar(30) NOT NULL, `rgb` varchar(7) NOT NULL, - `color` bigint(20) DEFAULT 0, + `color` bigint(20) DEFAULT '0', `permissionRate` decimal(3,2) DEFAULT NULL, `code` varchar(45) DEFAULT NULL, - `isAllowedToWork` tinyint(4) NOT NULL DEFAULT 0, - `isPrintable` tinyint(1) NOT NULL DEFAULT 0, + `isAllowedToWork` tinyint(4) NOT NULL DEFAULT '0', + `isPrintable` tinyint(1) NOT NULL DEFAULT '0', `discountRate` decimal(3,2) DEFAULT NULL, - `holidayEntitlementRate` decimal(3,2) DEFAULT 1.00, + `holidayEntitlementRate` decimal(3,2) DEFAULT '1.00', PRIMARY KEY (`calendar_state_id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -17391,11 +17348,11 @@ DROP TABLE IF EXISTS `income_employee`; CREATE TABLE `income_employee` ( `id` int(11) NOT NULL AUTO_INCREMENT, `debe` decimal(10,2) DEFAULT NULL, - `haber` decimal(10,2) DEFAULT 0.00, + `haber` decimal(10,2) DEFAULT '0.00', `id_incomeType` int(11) DEFAULT NULL, `odbc_date` date DEFAULT NULL, `person_id` int(11) DEFAULT NULL, - `concepto` longtext DEFAULT NULL, + `concepto` longtext, PRIMARY KEY (`id`), KEY `fincometype_id` (`id_incomeType`), KEY `fperson_id` (`person_id`), @@ -17414,8 +17371,8 @@ DROP TABLE IF EXISTS `incometype_employee`; CREATE TABLE `incometype_employee` ( `id_incometype` int(11) NOT NULL, `descripcion` varchar(255) DEFAULT NULL, - `nomina` smallint(6) DEFAULT 0, - `isExtraSalarial` tinyint(4) NOT NULL DEFAULT 0, + `nomina` smallint(6) DEFAULT '0', + `isExtraSalarial` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`id_incometype`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -17429,11 +17386,12 @@ DROP TABLE IF EXISTS `journey`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `journey` ( `journey_id` int(11) NOT NULL AUTO_INCREMENT, - `day_id` smallint(6) NOT NULL DEFAULT 1 COMMENT 'Lunes = 1 \nDomingo = 7', + `day_id` smallint(6) NOT NULL DEFAULT '1' COMMENT 'Lunes = 1 \nDomingo = 7', `start` time DEFAULT NULL, `end` time DEFAULT NULL, `business_id` int(11) NOT NULL, PRIMARY KEY (`journey_id`), + UNIQUE KEY `day_id` (`day_id`,`start`,`end`,`business_id`), KEY `fki_business_journey` (`business_id`), CONSTRAINT `business_journey` FOREIGN KEY (`business_id`) REFERENCES `business` (`business_id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8; @@ -17499,10 +17457,10 @@ DROP TABLE IF EXISTS `nation__`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `nation__` ( `nation_id` int(11) NOT NULL AUTO_INCREMENT, - `currency_id` int(11) NOT NULL DEFAULT 1, + `currency_id` int(11) NOT NULL DEFAULT '1', `name` varchar(20) NOT NULL, `brief` char(3) NOT NULL, - `flag` longblob DEFAULT NULL, + `flag` longblob, PRIMARY KEY (`nation_id`), UNIQUE KEY `nation_name_key` (`name`), KEY `nation_currency_id_idx` (`currency_id`), @@ -17538,12 +17496,12 @@ CREATE TABLE `person` ( `nif` varchar(15) DEFAULT NULL, `birth` date DEFAULT NULL, `firstname` varchar(20) DEFAULT NULL, - `p2` longtext DEFAULT NULL, + `p2` longtext, `nis` int(11) DEFAULT NULL, `id_trabajador` int(11) DEFAULT NULL, - `isDisable` smallint(6) NOT NULL DEFAULT 0, - `isFreelance` smallint(6) NOT NULL DEFAULT 0 COMMENT 'M Male\nF Female', - `isSsDiscounted` smallint(6) NOT NULL DEFAULT 0, + `isDisable` smallint(6) NOT NULL DEFAULT '0', + `isFreelance` smallint(6) NOT NULL DEFAULT '0' COMMENT 'M Male\nF Female', + `isSsDiscounted` smallint(6) NOT NULL DEFAULT '0', `sex` enum('M','F') NOT NULL DEFAULT 'F' COMMENT 'M Masculino F Femenino', PRIMARY KEY (`person_id`), UNIQUE KEY `person_nis` (`person_id`), @@ -17567,7 +17525,7 @@ CREATE TABLE `professional_category` ( `professional_category_id` int(11) NOT NULL AUTO_INCREMENT, `category_name` varchar(50) NOT NULL, `professional_levels_id` int(11) DEFAULT NULL, - `fichajes` tinyint(4) NOT NULL DEFAULT 1, + `fichajes` tinyint(4) NOT NULL DEFAULT '1', `holiday_days` decimal(3,1) DEFAULT NULL, `dayBreak` int(11) DEFAULT NULL, PRIMARY KEY (`professional_category_id`), @@ -17600,7 +17558,7 @@ DROP TABLE IF EXISTS `profile`; CREATE TABLE `profile` ( `profile_id` int(11) NOT NULL AUTO_INCREMENT, `person_id` int(11) NOT NULL, - `profile_type_id` int(11) NOT NULL DEFAULT 1, + `profile_type_id` int(11) NOT NULL DEFAULT '1', PRIMARY KEY (`profile_id`), KEY `profile_person_id_idx` (`person_id`), KEY `profile_profile_type_id_idx` (`profile_type_id`), @@ -17703,7 +17661,7 @@ DROP TABLE IF EXISTS `workcenter`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workcenter` ( `workcenter_id` int(11) NOT NULL AUTO_INCREMENT, - `name` longtext DEFAULT NULL, + `name` longtext, `center_id` int(11) DEFAULT NULL, `counter` bigint(20) DEFAULT NULL, `warehouseFk` smallint(6) DEFAULT NULL, @@ -17740,7 +17698,7 @@ DROP TABLE IF EXISTS `workers20190711_FichadasAbril`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workers20190711_FichadasAbril` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `person_id` int(11) NOT NULL DEFAULT 0, + `person_id` int(11) NOT NULL DEFAULT '0', `nif` varchar(15) CHARACTER SET utf8 DEFAULT NULL, `Apellidos` varchar(60) CHARACTER SET utf8 NOT NULL, `Nombre` varchar(20) CHARACTER SET utf8 DEFAULT NULL, @@ -17748,7 +17706,7 @@ CREATE TABLE `workers20190711_FichadasAbril` ( `Hora` int(2) DEFAULT NULL, `Minuto` int(2) DEFAULT NULL, `sumable` double DEFAULT NULL, - `jornada` decimal(5,2) NOT NULL DEFAULT 8.00, + `jornada` decimal(5,2) NOT NULL DEFAULT '8.00', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -17798,16 +17756,16 @@ DROP TABLE IF EXISTS `Naciones`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `Naciones` ( `countryFk` mediumint(8) NOT NULL, - `CodigoNacion` smallint(6) NOT NULL DEFAULT 108, - `CodigoNacion347` smallint(6) NOT NULL DEFAULT 108, + `CodigoNacion` smallint(6) NOT NULL DEFAULT '108', + `CodigoNacion347` smallint(6) NOT NULL DEFAULT '108', `Nacion` varchar(25) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `SiglaNacion` varchar(2) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'ES', `TipoCodigo` varchar(1) CHARACTER SET utf8 NOT NULL DEFAULT 'A', - `Longitud1` tinyint(4) NOT NULL DEFAULT 0, - `Longitud2` tinyint(4) NOT NULL DEFAULT 0, - `Longitud3` tinyint(4) NOT NULL DEFAULT 0, - `Longitud4` tinyint(4) NOT NULL DEFAULT 0, - `NacionCEE` smallint(6) NOT NULL DEFAULT 0, + `Longitud1` tinyint(4) NOT NULL DEFAULT '0', + `Longitud2` tinyint(4) NOT NULL DEFAULT '0', + `Longitud3` tinyint(4) NOT NULL DEFAULT '0', + `Longitud4` tinyint(4) NOT NULL DEFAULT '0', + `NacionCEE` smallint(6) NOT NULL DEFAULT '0', `FechaCEE` datetime DEFAULT NULL, `NacionISO` varchar(3) CHARACTER SET utf8 NOT NULL DEFAULT '', PRIMARY KEY (`countryFk`,`CodigoNacion`) @@ -17826,7 +17784,7 @@ CREATE TABLE `Provincias` ( `CodigoProvincia` varchar(5) NOT NULL DEFAULT '', `CodigoMatricula` varchar(2) NOT NULL DEFAULT '', `Provincia` varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `RecargoProvincial` decimal(28,10) NOT NULL DEFAULT 0.0000000000, + `RecargoProvincial` decimal(28,10) NOT NULL DEFAULT '0.0000000000', PRIMARY KEY (`CodigoProvincia`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -17839,12 +17797,12 @@ DROP TABLE IF EXISTS `TiposIva`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `TiposIva` ( - `CodigoIva` smallint(6) NOT NULL DEFAULT 0, - `CodigoTerritorio` smallint(6) NOT NULL DEFAULT 0, + `CodigoIva` smallint(6) NOT NULL DEFAULT '0', + `CodigoTerritorio` smallint(6) NOT NULL DEFAULT '0', `Iva` varchar(30) NOT NULL DEFAULT '', - `BaseCorrectora` decimal(28,10) NOT NULL DEFAULT 0.0000000000, - `PorcentajeIva` decimal(28,10) NOT NULL DEFAULT 0.0000000000, - `RecargoEquivalencia` decimal(28,10) NOT NULL DEFAULT 0.0000000000, + `BaseCorrectora` decimal(28,10) NOT NULL DEFAULT '0.0000000000', + `PorcentajeIva` decimal(28,10) NOT NULL DEFAULT '0.0000000000', + `RecargoEquivalencia` decimal(28,10) NOT NULL DEFAULT '0.0000000000', `CuentaIvaSoportado` varchar(15) NOT NULL DEFAULT '', `CuentaIvaRepercutido` varchar(15) NOT NULL DEFAULT '', `CuentaRecargo` varchar(15) NOT NULL DEFAULT '', @@ -17863,8 +17821,8 @@ CREATE TABLE `TiposIva` ( `CuentaIVARecCaja` varchar(15) NOT NULL DEFAULT '', `CuentaIVARecCajaPu` varchar(15) NOT NULL DEFAULT '', `CuentaIVARecCajaVen` varchar(15) NOT NULL DEFAULT '', - `IGICImplicito` smallint(6) NOT NULL DEFAULT 0, - `isIntracommunity` tinyint(2) NOT NULL DEFAULT 0, + `IGICImplicito` smallint(6) NOT NULL DEFAULT '0', + `isIntracommunity` tinyint(2) NOT NULL DEFAULT '0', PRIMARY KEY (`CodigoIva`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -17877,9 +17835,9 @@ DROP TABLE IF EXISTS `TiposRetencion`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `TiposRetencion` ( - `CodigoRetencion` smallint(6) NOT NULL DEFAULT 0, + `CodigoRetencion` smallint(6) NOT NULL DEFAULT '0', `Retencion` varchar(50) NOT NULL DEFAULT '', - `PorcentajeRetencion` decimal(28,10) NOT NULL DEFAULT 0.0000000000, + `PorcentajeRetencion` decimal(28,10) NOT NULL DEFAULT '0.0000000000', `CuentaCargo` varchar(15) DEFAULT NULL, `CuentaAbono` varchar(15) DEFAULT NULL, `ClaveIrpf` varchar(2) DEFAULT NULL, @@ -17898,10 +17856,10 @@ DROP TABLE IF EXISTS `TiposTransacciones`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `TiposTransacciones` ( - `CodigoTransaccion` tinyint(4) NOT NULL DEFAULT 0, + `CodigoTransaccion` tinyint(4) NOT NULL DEFAULT '0', `Transaccion` varchar(50) NOT NULL DEFAULT '', `TipoFactura` varchar(1) NOT NULL DEFAULT '', - `Autofactura` smallint(6) NOT NULL DEFAULT 0, + `Autofactura` smallint(6) NOT NULL DEFAULT '0', `ClaveOperacionDefecto` varchar(1) NOT NULL DEFAULT '', PRIMARY KEY (`CodigoTransaccion`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -17923,7 +17881,7 @@ CREATE TABLE `XDiario_movConta_IVA` ( `CuotaIva1` double DEFAULT NULL, `PorRecargoEquivalencia1` double DEFAULT NULL, `RecargoEquivalencia1` double DEFAULT NULL, - `CodigoTransaccion1` double NOT NULL DEFAULT 0, + `CodigoTransaccion1` double NOT NULL DEFAULT '0', `CodigoIva1` smallint(6) NOT NULL, `BaseIva2` double DEFAULT NULL, `PorBaseCorrectora2` double DEFAULT NULL, @@ -17931,7 +17889,7 @@ CREATE TABLE `XDiario_movConta_IVA` ( `CuotaIva2` double DEFAULT NULL, `PorRecargoEquivalencia2` double DEFAULT NULL, `RecargoEquivalencia2` double DEFAULT NULL, - `CodigoTransaccion2` double NOT NULL DEFAULT 0, + `CodigoTransaccion2` double NOT NULL DEFAULT '0', `CodigoIva2` smallint(6) NOT NULL, `BaseIva3` double DEFAULT NULL, `PorBaseCorrectora3` double DEFAULT NULL, @@ -17939,7 +17897,7 @@ CREATE TABLE `XDiario_movConta_IVA` ( `CuotaIva3` double DEFAULT NULL, `PorRecargoEquivalencia3` double DEFAULT NULL, `RecargoEquivalencia3` double DEFAULT NULL, - `CodigoTransaccion3` double NOT NULL DEFAULT 0, + `CodigoTransaccion3` double NOT NULL DEFAULT '0', `CodigoIva3` smallint(6) NOT NULL, `BaseIva4` double DEFAULT NULL, `PorBaseCorrectora4` double DEFAULT NULL, @@ -17947,7 +17905,7 @@ CREATE TABLE `XDiario_movConta_IVA` ( `CuotaIva4` double DEFAULT NULL, `PorRecargoEquivalencia4` double DEFAULT NULL, `RecargoEquivalencia4` double DEFAULT NULL, - `CodigoTransaccion4` double NOT NULL DEFAULT 0, + `CodigoTransaccion4` double NOT NULL DEFAULT '0', `CodigoIva4` smallint(6) NOT NULL, `Año` int(11) DEFAULT NULL, `Serie` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, @@ -17967,7 +17925,7 @@ CREATE TABLE `XDiario_movConta_IVA` ( `EjercicioFactura` int(2) DEFAULT NULL, `FechaOperacion` date DEFAULT NULL, `Exclusion347` int(2) DEFAULT NULL, - `MantenerAsiento` int(2) DEFAULT -1, + `MantenerAsiento` int(2) DEFAULT '-1', `Metalico347` int(2) DEFAULT NULL, `ClaveOperacionFactura` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, `TipoRectificativa` int(2) DEFAULT NULL, @@ -17977,13 +17935,13 @@ CREATE TABLE `XDiario_movConta_IVA` ( `ClaseAbonoRectificativas` int(2) DEFAULT NULL, `RecargoEquivalenciaOriginal` double DEFAULT NULL, `LibreA1` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, - `IvaDeducible1` int(2) NOT NULL DEFAULT -1, - `IvaDeducible2` int(2) NOT NULL DEFAULT -1, - `IvaDeducible3` int(2) NOT NULL DEFAULT -1, - `IvaDeducible4` int(2) NOT NULL DEFAULT -1, + `IvaDeducible1` int(2) NOT NULL DEFAULT '-1', + `IvaDeducible2` int(2) NOT NULL DEFAULT '-1', + `IvaDeducible3` int(2) NOT NULL DEFAULT '-1', + `IvaDeducible4` int(2) NOT NULL DEFAULT '-1', `FechaGrabacion` date DEFAULT NULL, - `Intracomunitaria` tinyint(1) DEFAULT 0, - `moveData` tinyint(1) DEFAULT 1, + `Intracomunitaria` tinyint(1) DEFAULT '0', + `moveData` tinyint(1) DEFAULT '1', PRIMARY KEY (`id`), CONSTRAINT `XDiario_movConta_IVA_fk1` FOREIGN KEY (`id`) REFERENCES `vn`.`XDiario` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Informa del valor de los campos de IVA para enlazar en la tabla vn.movConta'; @@ -18035,9 +17993,9 @@ CREATE TABLE `clientesProveedores` ( `CodigoRetencion` smallint(6) NOT NULL, `Deducible` smallint(6) NOT NULL, `CodigoIva` smallint(6) NOT NULL, - `Mediacion` smallint(6) NOT NULL DEFAULT 0, - `Exclusion347` smallint(6) NOT NULL DEFAULT 0, - `NumeroPlazos` tinyint(4) NOT NULL DEFAULT 1, + `Mediacion` smallint(6) NOT NULL DEFAULT '0', + `Exclusion347` smallint(6) NOT NULL DEFAULT '0', + `NumeroPlazos` tinyint(4) NOT NULL DEFAULT '1', `DiasPrimerPlazo` smallint(6) NOT NULL, `DiasEntrePlazos` smallint(6) NOT NULL, `DiasFijos1` tinyint(4) NOT NULL, @@ -18064,8 +18022,8 @@ CREATE TABLE `clientesProveedores` ( `IBAN` varchar(34) COLLATE utf8_unicode_ci NOT NULL, `CodigoCondiciones` smallint(6) NOT NULL, `StatusTraspasadoIME` tinyint(4) NOT NULL, - `TipoImportacionIME` tinyint(4) NOT NULL DEFAULT 2, - `TipoPlanCuentaIME` smallint(6) NOT NULL DEFAULT 2, + `TipoImportacionIME` tinyint(4) NOT NULL DEFAULT '2', + `TipoPlanCuentaIME` smallint(6) NOT NULL DEFAULT '2', `Contrapartida` varchar(15) COLLATE utf8_unicode_ci NOT NULL, `CodigoCuentaImpagado` varchar(15) COLLATE utf8_unicode_ci NOT NULL, `CodigoCuentaEfecto` varchar(15) COLLATE utf8_unicode_ci NOT NULL, @@ -18108,7 +18066,7 @@ CREATE TABLE `clientesProveedores` ( `sysTick` int(11) NOT NULL, `RiesgoMaximo` decimal(28,10) NOT NULL, `PlazoMedioPCMA` smallint(6) NOT NULL, - `CriterioIvaIME` smallint(6) NOT NULL DEFAULT 0, + `CriterioIvaIME` smallint(6) NOT NULL DEFAULT '0', `ReferenciaMandato` varchar(35) COLLATE utf8_unicode_ci NOT NULL, `%Comision` decimal(28,10) NOT NULL, `CodigoZona` int(11) NOT NULL, @@ -18140,203 +18098,6 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `movConta` --- - -DROP TABLE IF EXISTS `movConta`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `movConta` ( - `OrdenMovimientos` int(11) NOT NULL AUTO_INCREMENT, - `MovPosicion` varchar(64) COLLATE utf8_unicode_ci NOT NULL, - `Ejercicio` smallint(6) NOT NULL, - `CodigoEmpresa` smallint(6) NOT NULL, - `Asiento` int(11) NOT NULL, - `CargoAbono` varchar(1) COLLATE utf8_unicode_ci NOT NULL, - `CodigoCuenta` varchar(15) CHARACTER SET utf8 NOT NULL, - `Contrapartida` varchar(15) COLLATE utf8_unicode_ci NOT NULL, - `FechaAsiento` datetime NOT NULL, - `TipoDocumento` varchar(6) COLLATE utf8_unicode_ci NOT NULL, - `DocumentoConta` varchar(9) COLLATE utf8_unicode_ci NOT NULL, - `Comentario` varchar(40) COLLATE utf8_unicode_ci NOT NULL, - `ImporteAsiento` decimal(28,10) NOT NULL, - `CodigoDiario` smallint(6) NOT NULL, - `CodigoCanal` varchar(10) COLLATE utf8_unicode_ci NOT NULL, - `CodigoActividad` varchar(1) COLLATE utf8_unicode_ci NOT NULL, - `FechaVencimiento` datetime DEFAULT NULL, - `NumeroPeriodo` smallint(6) NOT NULL, - `CodigoUsuario` smallint(6) NOT NULL, - `FechaGrabacion` datetime NOT NULL, - `TipoEntrada` varchar(2) COLLATE utf8_unicode_ci NOT NULL, - `CodigoDepartamento` varchar(10) COLLATE utf8_unicode_ci NOT NULL, - `CodigoSeccion` varchar(10) COLLATE utf8_unicode_ci NOT NULL, - `CodigoDivisa` varchar(3) COLLATE utf8_unicode_ci NOT NULL, - `ImporteCambio` decimal(28,10) NOT NULL, - `ImporteDivisa` decimal(28,10) NOT NULL, - `FactorCambio` decimal(28,10) NOT NULL, - `CodigoProyecto` varchar(10) COLLATE utf8_unicode_ci NOT NULL, - `LibreN1` int(11) NOT NULL, - `LibreN2` int(11) NOT NULL, - `LibreA1` varchar(15) COLLATE utf8_unicode_ci NOT NULL, - `LibreA2` varchar(15) COLLATE utf8_unicode_ci NOT NULL, - `IdDelegacion` varchar(10) COLLATE utf8_unicode_ci NOT NULL, - `MovCartera` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL, - `IdProcesoIME` varchar(64) COLLATE utf8_unicode_ci NOT NULL, - `TipoCarteraIME` smallint(6) NOT NULL, - `TipoAnaliticaIME` smallint(6) NOT NULL, - `StatusTraspasadoIME` tinyint(4) NOT NULL, - `TipoImportacionIME` tinyint(4) NOT NULL, - `BaseIva1` decimal(28,10) NOT NULL, - `PorBaseCorrectora1` decimal(28,10) NOT NULL, - `PorIva1` decimal(28,10) NOT NULL, - `CuotaIva1` decimal(28,10) NOT NULL, - `PorRecargoEquivalencia1` decimal(28,10) NOT NULL, - `RecargoEquivalencia1` decimal(28,10) NOT NULL, - `CodigoTransaccion1` tinyint(4) NOT NULL, - `BaseIva2` decimal(28,10) NOT NULL, - `PorBaseCorrectora2` decimal(28,10) NOT NULL, - `PorIva2` decimal(28,10) NOT NULL, - `CuotaIva2` decimal(28,10) NOT NULL, - `PorRecargoEquivalencia2` decimal(28,10) NOT NULL, - `RecargoEquivalencia2` decimal(28,10) NOT NULL, - `CodigoTransaccion2` tinyint(4) NOT NULL, - `BaseIva3` decimal(28,10) NOT NULL, - `PorBaseCorrectora3` decimal(28,10) NOT NULL, - `PorIva3` decimal(28,10) NOT NULL, - `CuotaIva3` decimal(28,10) NOT NULL, - `PorRecargoEquivalencia3` decimal(28,10) NOT NULL, - `RecargoEquivalencia3` decimal(28,10) NOT NULL, - `CodigoTransaccion3` tinyint(4) NOT NULL, - `baseIva4` decimal(28,10) NOT NULL, - `PorBaseCorrectora4` decimal(28,10) NOT NULL, - `PorIva4` decimal(28,10) NOT NULL, - `CuotaIva4` decimal(28,10) NOT NULL, - `PorRecargoEquivalencia4` decimal(28,10) NOT NULL, - `RecargoEquivalencia4` decimal(28,10) NOT NULL, - `CodigoTransaccion4` tinyint(4) NOT NULL, - `Año` smallint(6) NOT NULL, - `Serie` varchar(10) COLLATE utf8_unicode_ci NOT NULL, - `Factura` int(11) NOT NULL, - `SuFacturaNo` varchar(40) COLLATE utf8_unicode_ci NOT NULL, - `FechaFactura` datetime NOT NULL, - `ImporteFactura` decimal(28,10) NOT NULL, - `TipoFactura` varchar(1) COLLATE utf8_unicode_ci NOT NULL, - `CodigoCuentaFactura` varchar(15) COLLATE utf8_unicode_ci NOT NULL, - `CifDni` varchar(13) COLLATE utf8_unicode_ci NOT NULL, - `Nombre` varchar(35) COLLATE utf8_unicode_ci NOT NULL, - `CodigoRetencion` smallint(6) NOT NULL, - `BaseRetencion` decimal(28,10) NOT NULL, - `PorRetencion` decimal(28,10) NOT NULL, - `ImporteRetencion` decimal(28,10) NOT NULL, - `AbonoIva` smallint(6) NOT NULL, - `CodigoActividadF` varchar(1) COLLATE utf8_unicode_ci NOT NULL, - `Intracomunitaria` smallint(6) NOT NULL, - `CodigoTerritorio` smallint(6) NOT NULL, - `SiglaNacion` varchar(2) COLLATE utf8_unicode_ci NOT NULL, - `RetencionInformativa` smallint(6) NOT NULL, - `EjercicioFacturaOriginal` smallint(6) NOT NULL, - `SerieFacturaOriginal` varchar(10) COLLATE utf8_unicode_ci NOT NULL, - `NumeroFacturaOriginal` int(11) NOT NULL, - `EjercicioFactura` smallint(6) NOT NULL, - `CobroPagoRetencion` varchar(1) COLLATE utf8_unicode_ci NOT NULL, - `FechaOperacion` datetime NOT NULL, - `Exclusion347` smallint(6) NOT NULL, - `MovIdentificadorIME` varchar(64) COLLATE utf8_unicode_ci NOT NULL, - `Previsiones` varchar(1) COLLATE utf8_unicode_ci NOT NULL, - `MantenerAsiento` tinyint(4) NOT NULL, - `OrdenMovIME` smallint(6) NOT NULL, - `Metalico347` smallint(6) NOT NULL, - `ClaveOperacionFactura_` varchar(1) COLLATE utf8_unicode_ci NOT NULL, - `SerieAgrupacion_` varchar(10) COLLATE utf8_unicode_ci NOT NULL, - `NumeroFacturaInicial_` int(11) NOT NULL, - `NumeroFacturaFinal_` int(11) NOT NULL, - `IdAsientoExterno` varchar(50) COLLATE utf8_unicode_ci NOT NULL, - `IdDiarioExterno` varchar(10) COLLATE utf8_unicode_ci NOT NULL, - `IdFacturaExterno` varchar(50) COLLATE utf8_unicode_ci NOT NULL, - `IdMovimiento` varchar(40) COLLATE utf8_unicode_ci NOT NULL, - `IdCuadre` smallint(6) NOT NULL, - `FechaCuadre` datetime NOT NULL, - `TipoCuadre` varchar(4) COLLATE utf8_unicode_ci NOT NULL, - `AgrupacionCuadre` int(11) NOT NULL, - `StatusSaldo` smallint(6) NOT NULL, - `StatusConciliacion` smallint(6) NOT NULL, - `CodigoConciliacion` int(11) NOT NULL, - `FechaConciliacion` datetime NOT NULL, - `TipoConciliacion` smallint(6) NOT NULL, - `IndicadorContaBanco` varchar(1) COLLATE utf8_unicode_ci NOT NULL, - `Descripcion3` varchar(40) COLLATE utf8_unicode_ci NOT NULL, - `Descripcion4` varchar(40) COLLATE utf8_unicode_ci NOT NULL, - `Descripcion5` varchar(40) COLLATE utf8_unicode_ci NOT NULL, - `Descripcion6` varchar(40) COLLATE utf8_unicode_ci NOT NULL, - `Descripcion7` varchar(40) COLLATE utf8_unicode_ci NOT NULL, - `Descripcion8` varchar(50) COLLATE utf8_unicode_ci NOT NULL, - `Descripcion9` varchar(50) COLLATE utf8_unicode_ci NOT NULL, - `Descripcion2` varchar(250) COLLATE utf8_unicode_ci NOT NULL, - `Descripcion1` varchar(250) COLLATE utf8_unicode_ci NOT NULL, - `Punteo1` smallint(6) NOT NULL, - `Punteo9` smallint(6) NOT NULL, - `Punteo8` smallint(6) NOT NULL, - `Punteo7` smallint(6) NOT NULL, - `Punteo6` smallint(6) NOT NULL, - `Punteo5` smallint(6) NOT NULL, - `Punteo4` smallint(6) NOT NULL, - `Punteo3` smallint(6) NOT NULL, - `Punteo2` smallint(6) NOT NULL, - `CodigoIva1` smallint(6) NOT NULL, - `CodigoIva2` smallint(6) NOT NULL, - `CodigoIva3` smallint(6) NOT NULL, - `CodigoIva4` smallint(6) NOT NULL, - `CriterioIva` tinyint(4) NOT NULL, - `FechaMaxVencimiento` datetime NOT NULL, - `TipoCriterioCaja` tinyint(4) NOT NULL, - `MovFacturaOrigenIME` varchar(50) COLLATE utf8_unicode_ci NOT NULL, - `IdFacturaExternoFinal` varchar(50) COLLATE utf8_unicode_ci NOT NULL, - `IdFacturaExternoInicial` varchar(50) COLLATE utf8_unicode_ci NOT NULL, - `IdFacturaExternoOriginal` varchar(50) COLLATE utf8_unicode_ci NOT NULL, - `NumFacturasExternoAgrupacion` int(11) NOT NULL, - `CodigoMedioCobro` varchar(1) COLLATE utf8_unicode_ci NOT NULL, - `MedioCobro` varchar(31) COLLATE utf8_unicode_ci NOT NULL, - `IvaDeducible1` smallint(6) NOT NULL DEFAULT 1, - `IvaDeducible2` smallint(6) NOT NULL DEFAULT 1, - `IvaDeducible3` smallint(6) NOT NULL DEFAULT 1, - `IvaDeducible4` smallint(6) NOT NULL DEFAULT 1, - `TipoRectificativa` smallint(6) NOT NULL, - `FechaFacturaOriginal` datetime NOT NULL, - `BaseImponibleOriginal` decimal(28,10) NOT NULL, - `CuotaIvaOriginal` decimal(28,10) NOT NULL, - `ClaseAbonoRectificativas` smallint(6) NOT NULL, - `RecargoEquivalenciaOriginal` decimal(28,10) NOT NULL, - `ObjetoFactura` varchar(500) COLLATE utf8_unicode_ci NOT NULL, - `enlazadoSage` tinyint(1) NOT NULL DEFAULT 0, - PRIMARY KEY (`OrdenMovimientos`,`LibreN1`), - KEY `ix_movconta` (`enlazadoSage`), - KEY `ix_movconta2` (`IdProcesoIME`), - KEY `CodigoCuenta` (`CodigoCuenta`), - KEY `movConta_Asiento` (`Asiento`) -) 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 = 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 `sage`.`movConta_BEFORE_UPDATE` BEFORE UPDATE ON `movConta` FOR EACH ROW -BEGIN - IF NEW.enlazadoSage = TRUE THEN - UPDATE vn.XDiario SET enlazadoSage = TRUE WHERE ASIEN = NEW.Asiento; - 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 `movContaCopia` -- @@ -18345,7 +18106,7 @@ DROP TABLE IF EXISTS `movContaCopia`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `movContaCopia` ( - `OrdenMovimientos` int(11) NOT NULL DEFAULT 0, + `OrdenMovimientos` int(11) NOT NULL DEFAULT '0', `MovPosicion` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, `Ejercicio` smallint(6) NOT NULL, `CodigoEmpresa` smallint(6) NOT NULL, @@ -18494,10 +18255,10 @@ CREATE TABLE `movContaCopia` ( `NumFacturasExternoAgrupacion` int(11) NOT NULL, `CodigoMedioCobro` varchar(1) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, `MedioCobro` varchar(31) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `IvaDeducible1` smallint(6) NOT NULL DEFAULT 1, - `IvaDeducible2` smallint(6) NOT NULL DEFAULT 1, - `IvaDeducible3` smallint(6) NOT NULL DEFAULT 1, - `IvaDeducible4` smallint(6) NOT NULL DEFAULT 1, + `IvaDeducible1` smallint(6) NOT NULL DEFAULT '1', + `IvaDeducible2` smallint(6) NOT NULL DEFAULT '1', + `IvaDeducible3` smallint(6) NOT NULL DEFAULT '1', + `IvaDeducible4` smallint(6) NOT NULL DEFAULT '1', `TipoRectificativa` smallint(6) NOT NULL, `FechaFacturaOriginal` datetime NOT NULL, `BaseImponibleOriginal` decimal(28,10) NOT NULL, @@ -18505,7 +18266,7 @@ CREATE TABLE `movContaCopia` ( `ClaseAbonoRectificativas` smallint(6) NOT NULL, `RecargoEquivalenciaOriginal` decimal(28,10) NOT NULL, `ObjetoFactura` varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `enlazado` tinyint(1) NOT NULL DEFAULT 0, + `enlazado` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`OrdenMovimientos`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -18541,15 +18302,15 @@ CREATE TABLE `planCuentasPGC` ( `ClienteOProveedor` varchar(1) COLLATE utf8_unicode_ci NOT NULL, `CodigoDivisa` varchar(3) COLLATE utf8_unicode_ci NOT NULL, `IndicadorProrrata` smallint(6) NOT NULL, - `TipoPlanCuentaIME` smallint(6) NOT NULL DEFAULT 2, + `TipoPlanCuentaIME` smallint(6) NOT NULL DEFAULT '2', `StatusAnalitica` smallint(6) NOT NULL, `AnaCodigoCuenta` varchar(15) COLLATE utf8_unicode_ci NOT NULL, - `StatusTraspasadoIME` tinyint(4) NOT NULL DEFAULT 0, - `TipoImportacionIME` tinyint(4) NOT NULL DEFAULT 0, - `CierrePatrimonio_` smallint(6) NOT NULL DEFAULT 0, + `StatusTraspasadoIME` tinyint(4) NOT NULL DEFAULT '0', + `TipoImportacionIME` tinyint(4) NOT NULL DEFAULT '0', + `CierrePatrimonio_` smallint(6) NOT NULL DEFAULT '0', `CuentaPatrimonio_` varchar(15) COLLATE utf8_unicode_ci NOT NULL, - `CuentaVarios` smallint(6) NOT NULL DEFAULT 0, - `TodasLasActividades` smallint(6) NOT NULL DEFAULT 0, + `CuentaVarios` smallint(6) NOT NULL DEFAULT '0', + `TodasLasActividades` smallint(6) NOT NULL DEFAULT '0', `ValorDelegacion` varchar(10) COLLATE utf8_unicode_ci NOT NULL, `ValorDepartamento` varchar(10) COLLATE utf8_unicode_ci NOT NULL, `ValorProyecto` varchar(10) COLLATE utf8_unicode_ci NOT NULL, @@ -18948,6 +18709,551 @@ BEGIN GROUP BY pc.codigoCuenta ) sub ON sub.codigoCuenta = pc.codigoCuenta ; +-- DUAS + UPDATE movConta m + 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.CodigoTransaccion1 = 56 , + m.CodigoIva1 = 22, + m.IvaDeducible1 = TRUE, + m.FechaFacturaOriginal = x.FECHA_EX, + m.SuFacturaNo = x.FACTURAEX, + m.FechaOperacion = x.FECHA_OP + WHERE m.CodigoCuenta = 4700000999 + AND m.enlazadoSage = FALSE + AND x.SERIE='D' + AND x.IVA = 10; + + UPDATE movConta m + 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.CodigoTransaccion2 = 56 , + m.CodigoIva2 = 90, + m.IvaDeducible2 = TRUE + WHERE m.CodigoCuenta = 4700000999 + AND m.enlazadoSage = FALSE + AND x.SERIE='D' + AND x.IVA = 21; + +-- 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 */ ; +/*!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 @@ -19228,7 +19534,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 `movContaAdd_` */; +/*!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 */ ; @@ -19238,574 +19544,7 @@ DELIMITER ; /*!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"; - --- 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'; - - -/*-- m.Año m.FechaFactura -WHERE (x.SUBCTA = '4700000999' OR x.CONTRA = "4330002067") AND - x.SERIE IN ('R','D'); */ - - - --- 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 ; - - - --- Gastos - -UPDATE movConta m - JOIN (SELECT x.ASIEN, x.SUBCTA - FROM vn.XDiario x - JOIN XDiario_movConta_IVA xmi ON xmi.id = x.id AND xmi.moveData = 2 - )sub ON m.Asiento = sub.ASIEN - SET m.Contrapartida = sub.SUBCTA - WHERE m.CargoAbono = "D" AND CodigoCuenta > 6000000000; - -UPDATE movConta m - JOIN (SELECT x.ASIEN - FROM vn.XDiario x - JOIN XDiario_movConta_IVA xmi ON xmi.id = x.id AND xmi.moveData = 2 - )sub ON m.Asiento = sub.ASIEN - JOIN (SELECT SUBCTA, ASIEN - FROM vn.XDiario - WHERE EUROHABER IS NULL AND SUBCTA > 6000000000 - )sub2 ON m.Asiento = sub2.ASIEN - SET m.CodigoCuenta = sub2.SUBCTA - WHERE m.CargoAbono = "D" AND CodigoCuenta < 6000000000; - - --- 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 */ ; -/*!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__`() +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 @@ -20373,7 +20112,7 @@ BEGIN DECLARE rs CURSOR FOR -- IVA SELECT it.taxableBase BASEEURO, - ( it.taxableBase/100) * t.PorcentajeIva vat, + CAST((( it.taxableBase / 100) * t.PorcentajeIva) AS DECIMAL (10,2)) vat, t.PorcentajeIva rate, it.transactionTypeSageFk transactionCode, it.taxTypeSageFk taxCode, @@ -20909,6 +20648,261 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `XDiario_movConta_IVA_InvoiceInAdd_Manager`() +BEGIN + DECLARE done BOOL DEFAULT FALSE; + DECLARE vInvoiceFk INT; + DECLARE vXDiarioFk INT; + DECLARE vDated DATE; + DECLARE rs CURSOR FOR + SELECT IFNULL(ii.id,x.FACTURA) invoiceInFk, x.id XDiarioFk + FROM vn2008.XDiario x + JOIN(SELECT DISTINCT (x.ASIEN) + FROM vn2008.XDiario x + LEFT JOIN vn.invoiceIn ii ON x.CLAVE = ii.id + LEFT JOIN vn.invoiceInTax it ON it.invoiceInFk = ii.id + WHERE it.taxTypeSageFk IS NOT NULL AND + x.enlazadoSage = FALSE AND + x.FECHA >= vDated + ) sub ON sub.ASIEN =x.ASIEN -- Elimina las Facturas con IVA 0 (-) no se trasladan a sage + LEFT JOIN vn.invoiceIn ii ON x.CLAVE = ii.id + WHERE x.enlazadoSage = FALSE AND + x.FECHA >= vDated AND + ii.id IS NOT NULL ; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; + + SELECT CONCAT(YEAR(CURDATE()), "-01-01") INTO vDated; + DROP TEMPORARY TABLE IF EXISTS tmp.invoiceDua; + CREATE TEMPORARY TABLE tmp.invoiceDua + SELECT id + FROM vn2008.XDiario x + WHERE ASIEN IN (SELECT ASIEN + FROM vn.invoiceIn ii + JOIN vn2008.XDiario x ON x.CLAVE = ii.id + WHERE x.enlazadoSage = FALSE AND + x.SUBCTA = '4700000999' AND + x.FECHA >= vDated + ) AND + NOT CONTRA <=> "4330002067"; + + DROP TEMPORARY TABLE IF EXISTS tmp.invoiceInList; + CREATE TEMPORARY TABLE tmp.invoiceInList + SELECT i.id id, + i.supplierRef supplierRef, + i.serial serial, + i.supplierFk supplierFk, + i.issued issued, + i.isVatDeductible isVatDeductible, + i.serialNumber serialNumber, + IF(c.code = "EUR", '',c.code) currencyFk + FROM vn.invoiceIn i + JOIN vn.currency c ON c.id = i.currencyFk + WHERE i.bookEntried >= vDated + UNION ALL + SELECT d.id , + d.code , + 'D' , + d.companyFk , + d.issued , + FALSE, + d.id, + '' -- EUROS + FROM vn.dua d + WHERE d.issued IS NOT NULL AND + code IS NOT NULL; + + OPEN rs; + FETCH rs INTO vInvoiceFk, vXDiarioFk; + WHILE NOT done DO + CALL XDiario_movConta_IVA_InvoiceInAdd(vInvoiceFk, vXDiarioFk); + FETCH rs INTO vInvoiceFk, vXDiarioFk; + END WHILE; + CLOSE rs; + + DROP TEMPORARY TABLE tmp.invoiceDua; + DROP TEMPORARY TABLE tmp.invoiceInList; + + -- ASIENTOS CON IVA SOPORTADO 472. y 477. hay que informar 2 líneas la info de facturas una como tipo de factura emitida y otra como recibida + DROP TEMPORARY TABLE IF EXISTS tmp.XDiario_movConta_IVA; + CREATE TEMPORARY TABLE tmp.XDiario_movConta_IVA + SELECT + sub3.id, + mc.CodigoDivisa, + mc.BaseIva1, + mc.PorBaseCorrectora1, + mc.PorIva1, + mc.CuotaIva1, + mc.PorRecargoEquivalencia1, + mc.RecargoEquivalencia1, + mc.CodigoTransaccion1, + mc.CodigoIva1, + mc.BaseIva2, + mc.PorBaseCorrectora2, + mc.PorIva2, + mc.CuotaIva2, + mc.PorRecargoEquivalencia2, + mc.RecargoEquivalencia2, + mc.CodigoTransaccion2, + mc.CodigoIva2, + mc.BaseIva3, + mc.PorBaseCorrectora3, + mc.PorIva3, + mc.CuotaIva3, + mc.PorRecargoEquivalencia3, + mc.RecargoEquivalencia3, + mc.CodigoTransaccion3, + mc.CodigoIva3, + mc.BaseIva4, + mc.PorBaseCorrectora4, + mc.PorIva4, + mc.CuotaIva4, + mc.PorRecargoEquivalencia4, + mc.RecargoEquivalencia4, + mc.CodigoTransaccion4, + mc.CodigoIva4, + mc.Año, + mc.Serie, + mc.Factura, + mc.SuFacturaNo, + mc.FechaFactura, + mc.ImporteFactura, + 'E', + mc.CodigoCuentaFactura, + mc.CifDni, + mc.Nombre, + mc.CodigoRetencion, + mc.BaseRetencion, + mc.PorRetencion, + mc.ImporteRetencion, + mc.SiglaNacion, + mc.EjercicioFactura, + x.FECHA, + mc.Exclusion347, + mc.MantenerAsiento, + mc.Metalico347, + mc.ClaveOperacionFactura, + mc.TipoRectificativa, + mc.FechaFacturaOriginal, + mc.CuotaIvaOriginal, + mc.BaseImponibleOriginal, + mc.ClaseAbonoRectificativas, + mc.RecargoEquivalenciaOriginal, + mc.LibreA1, + mc.IvaDeducible1, + mc.IvaDeducible2, + mc.IvaDeducible3, + mc.IvaDeducible4, + mc.FechaGrabacion, + mc.Intracomunitaria, + mc.moveData + FROM sage.XDiario_movConta_IVA mc + JOIN vn.XDiario x ON x.id = mc.id + JOIN (SELECT x.ASIEN, x.id + FROM vn.XDiario x + JOIN(SELECT DISTINCT(x.ASIEN) ASIEN + FROM (SELECT DISTINCT(ASIEN) + FROM vn.XDiario x + WHERE SUBCTA LIKE '472%' AND + x.enlazadoSage = FALSE AND + x.FECHA >= vDated + ) sub JOIN vn.XDiario x ON x.ASIEN = sub.ASIEN + WHERE x.SUBCTA LIKE '477%' + )sub2 ON sub2.ASIEN = x.ASIEN + WHERE x.CONTRA IS NOT NULL AND x.SUBCTA LIKE '477%' + GROUP BY x.ASIEN + )sub3 ON sub3.ASIEN = x.ASIEN; + + INSERT INTO sage.XDiario_movConta_IVA + (`id`, + `CodigoDivisa`, + `BaseIva1`, + `PorBaseCorrectora1`, + `PorIva1`, + `CuotaIva1`, + `PorRecargoEquivalencia1`, + `RecargoEquivalencia1`, + `CodigoTransaccion1`, + `CodigoIva1`, + `BaseIva2`, + `PorBaseCorrectora2`, + `PorIva2`, + `CuotaIva2`, + `PorRecargoEquivalencia2`, + `RecargoEquivalencia2`, + `CodigoTransaccion2`, + `CodigoIva2`, + `BaseIva3`, + `PorBaseCorrectora3`, + `PorIva3`, + `CuotaIva3`, + `PorRecargoEquivalencia3`, + `RecargoEquivalencia3`, + `CodigoTransaccion3`, + `CodigoIva3`, + `BaseIva4`, + `PorBaseCorrectora4`, + `PorIva4`, + `CuotaIva4`, + `PorRecargoEquivalencia4`, + `RecargoEquivalencia4`, + `CodigoTransaccion4`, + `CodigoIva4`, + `Año`, + `Serie`, + `Factura`, + `SuFacturaNo`, + `FechaFactura`, + `ImporteFactura`, + `TipoFactura`, + `CodigoCuentaFactura`, + `CifDni`, + `Nombre`, + `CodigoRetencion`, + `BaseRetencion`, + `PorRetencion`, + `ImporteRetencion`, + `SiglaNacion`, + `EjercicioFactura`, + `FechaOperacion`, + `Exclusion347`, + `MantenerAsiento`, + `Metalico347`, + `ClaveOperacionFactura`, + `TipoRectificativa`, + `FechaFacturaOriginal`, + `CuotaIvaOriginal`, + `BaseImponibleOriginal`, + `ClaseAbonoRectificativas`, + `RecargoEquivalenciaOriginal`, + `LibreA1`, + `IvaDeducible1`, + `IvaDeducible2`, + `IvaDeducible3`, + `IvaDeducible4`, + `FechaGrabacion`, + `Intracomunitaria`, + `moveData`) + SELECT * + FROM tmp.XDiario_movConta_IVA; + DROP TEMPORARY TABLE tmp.XDiario_movConta_IVA; + +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 `XDiario_movConta_IVA_InvoiceInAdd_Manager__` */; +/*!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 `XDiario_movConta_IVA_InvoiceInAdd_Manager__`() BEGIN DECLARE done BOOL DEFAULT FALSE; DECLARE vInvoiceFk INT; @@ -21154,7 +21148,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 `XDiario_movConta_IVA_InvoiceInAdd_Manager_` */; +/*!50003 DROP PROCEDURE IF EXISTS `XDiario_movConta_IVA_InvoiceInAdd_Manager___` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -21164,293 +21158,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `XDiario_movConta_IVA_InvoiceInAdd_Manager_`() -BEGIN - DECLARE done BOOL DEFAULT FALSE; - DECLARE vInvoiceFk INT; - DECLARE vXDiarioFk INT; - DECLARE vDated DATE; - DECLARE rs CURSOR FOR - SELECT IFNULL(ii.id,x.FACTURA) invoiceInFk, x.id XDiarioFk - FROM vn2008.XDiario x - LEFT JOIN vn.invoiceIn ii ON x.CLAVE = ii.id - WHERE x.enlazadoSage = FALSE AND - x.FECHA >= vDated AND - ((SUBCTA<>"4700000999" AND ii.id IS NOT NULL) - OR (SUBCTA LIKE '472%' AND CONTRA ='4330002067' AND ii.id IS NULL)) ; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; - - SELECT CONCAT(YEAR(CURDATE()), "-01-01") INTO vDated; - DROP TEMPORARY TABLE IF EXISTS tmp.invoiceDua; - CREATE TEMPORARY TABLE tmp.invoiceDua - SELECT id - FROM vn2008.XDiario x - WHERE ASIEN IN (SELECT ASIEN - FROM vn.invoiceIn ii - JOIN vn2008.XDiario x ON x.CLAVE = ii.id - WHERE x.enlazadoSage = FALSE AND - x.SUBCTA = '4700000999' AND - x.FECHA >= vDated - ) AND - NOT CONTRA <=> "4330002067"; - - DROP TEMPORARY TABLE IF EXISTS tmp.invoiceInList; - CREATE TEMPORARY TABLE tmp.invoiceInList - SELECT i.id id, - i.supplierRef supplierRef, - i.serial serial, - i.supplierFk supplierFk, - i.issued issued, - i.isVatDeductible isVatDeductible, - i.serialNumber serialNumber, - IF(c.code = "EUR", '',c.code) currencyFk - FROM vn.invoiceIn i - JOIN vn.currency c ON c.id = i.currencyFk - WHERE - i.issued >= CONCAT(YEAR(NOW())-1, "-01-01" ) - UNION ALL - SELECT d.id , - d.code , - 'D' , - 442 , - d.issued , - FALSE, - d.id, - c.code - FROM vn.dua d - JOIN vn.awb a ON a.id= d.awbFk - JOIN vn.invoiceIn i ON i.id = a.invoiceInFk - JOIN vn.currency c ON c.id = i.currencyFk; - - OPEN rs; - FETCH rs INTO vInvoiceFk, vXDiarioFk; - WHILE NOT done DO - CALL XDiario_movConta_IVA_InvoiceInAdd(vInvoiceFk, vXDiarioFk); - FETCH rs INTO vInvoiceFk, vXDiarioFk; - END WHILE; - CLOSE rs; - -/* --Facturas con IVA 0 (-) no se trasladan a sage - UPDATE sage.XDiario_movConta_IVA xmi - JOIN ( SELECT sub.invoiceIn invoiceIn, XDiarioFk, SUM(total) total, tipo - FROM (SELECT IFNULL(ii.id,x.FACTURA) invoiceIn, x.id XDiarioFk,tc.type tipo, 1 as total - FROM vn2008.XDiario x - LEFT JOIN vn.invoiceIn ii ON x.CLAVE = ii.id - LEFT JOIN vn.invoiceInTax iit ON iit.invoiceInFk = ii.id - LEFT JOIN vn.taxCode tc ON tc.id = iit.taxCodeFk - WHERE x.enlazadoSage = 0 AND - ((SUBCTA<>"4700000999" AND ii.id IS NOT NULL) OR - (SUBCTA LIKE '472%' AND CONTRA ='4330002067' AND ii.id IS NULL)) AND - serial='R' - GROUP BY invoiceIn, XDiarioFk,tc.type - )sub - GROUP BY sub.invoiceIn, sub.XDiarioFk - HAVING tipo='-' AND total = 1 - ) sub2 ON sub2.invoiceIn = xmi.LibreA1 AND sub2.XDiarioFk = xmi.id - SET moveData = FALSE;*/ - - -- Gastos - UPDATE XDiario_movConta_IVA xm - JOIN vn.XDiario x ON x.id = xm.id - JOIN(SELECT x.id,x.ASIEN, BASEEURO - FROM vn.XDiario x - JOIN (SELECT DISTINCT(x.ASIEN) id - FROM XDiario_movConta_IVA xm - JOIN vn.XDiario x ON x.id = xm.id - WHERE xm.moveData = FALSE - ) sub ON sub.id = x.ASIEN - WHERE x.FACTURA>0 AND x.CLAVE IS NULL AND x.SERIE = 'R' - )sub2 ON sub2.ASIEN = x.ASIEN - SET xm.moveData = 2, - xm.BaseIva1 = sub2.BASEEURO, - xm.CuotaIva1 = ( sub2.BASEEURO/100) * xm.PorIva1 - WHERE xm.moveData = FALSE; - - DROP TEMPORARY TABLE tmp.invoiceDua; - DROP TEMPORARY TABLE tmp.invoiceInList; - - -- ASIENTOS CON IVA SOPORTADO 472. y 477. hay que informar 2 líneas la info de facturas una como tipo de factura emitida y otra como recibida - DROP TEMPORARY TABLE IF EXISTS tmp.XDiario_movConta_IVA; - CREATE TEMPORARY TABLE tmp.XDiario_movConta_IVA - SELECT - sub3.id, - mc.CodigoDivisa, - mc.BaseIva1, - mc.PorBaseCorrectora1, - mc.PorIva1, - mc.CuotaIva1, - mc.PorRecargoEquivalencia1, - mc.RecargoEquivalencia1, - mc.CodigoTransaccion1, - mc.CodigoIva1, - mc.BaseIva2, - mc.PorBaseCorrectora2, - mc.PorIva2, - mc.CuotaIva2, - mc.PorRecargoEquivalencia2, - mc.RecargoEquivalencia2, - mc.CodigoTransaccion2, - mc.CodigoIva2, - mc.BaseIva3, - mc.PorBaseCorrectora3, - mc.PorIva3, - mc.CuotaIva3, - mc.PorRecargoEquivalencia3, - mc.RecargoEquivalencia3, - mc.CodigoTransaccion3, - mc.CodigoIva3, - mc.BaseIva4, - mc.PorBaseCorrectora4, - mc.PorIva4, - mc.CuotaIva4, - mc.PorRecargoEquivalencia4, - mc.RecargoEquivalencia4, - mc.CodigoTransaccion4, - mc.CodigoIva4, - mc.Año, - mc.Serie, - mc.Factura, - mc.SuFacturaNo, - mc.FechaFactura, - mc.ImporteFactura, - 'E', - mc.CodigoCuentaFactura, - mc.CifDni, - mc.Nombre, - mc.CodigoRetencion, - mc.BaseRetencion, - mc.PorRetencion, - mc.ImporteRetencion, - mc.SiglaNacion, - mc.EjercicioFactura, - mc.FechaOperacion, - mc.Exclusion347, - mc.MantenerAsiento, - mc.Metalico347, - mc.ClaveOperacionFactura, - mc.TipoRectificativa, - mc.FechaFacturaOriginal, - mc.CuotaIvaOriginal, - mc.BaseImponibleOriginal, - mc.ClaseAbonoRectificativas, - mc.RecargoEquivalenciaOriginal, - mc.LibreA1, - mc.IvaDeducible1, - mc.IvaDeducible2, - mc.IvaDeducible3, - mc.IvaDeducible4, - mc.FechaGrabacion, - mc.Intracomunitaria, - mc.moveData - FROM sage.XDiario_movConta_IVA mc - JOIN vn.XDiario x ON x.id = mc.id - JOIN (SELECT x.ASIEN, x.id - FROM vn.XDiario x - JOIN(SELECT DISTINCT(x.ASIEN) ASIEN - FROM (SELECT DISTINCT(ASIEN) - FROM vn.XDiario x - WHERE SUBCTA LIKE '472%' AND - x.enlazadoSage = FALSE AND - x.FECHA >= vDated - ) sub JOIN vn.XDiario x ON x.ASIEN = sub.ASIEN - WHERE x.SUBCTA LIKE '477%' - )sub2 ON sub2.ASIEN = x.ASIEN - WHERE x.CONTRA IS NOT NULL AND x.SUBCTA LIKE '477%' - GROUP BY x.ASIEN - )sub3 ON sub3.ASIEN = x.ASIEN; - - INSERT INTO sage.XDiario_movConta_IVA - (`id`, - `CodigoDivisa`, - `BaseIva1`, - `PorBaseCorrectora1`, - `PorIva1`, - `CuotaIva1`, - `PorRecargoEquivalencia1`, - `RecargoEquivalencia1`, - `CodigoTransaccion1`, - `CodigoIva1`, - `BaseIva2`, - `PorBaseCorrectora2`, - `PorIva2`, - `CuotaIva2`, - `PorRecargoEquivalencia2`, - `RecargoEquivalencia2`, - `CodigoTransaccion2`, - `CodigoIva2`, - `BaseIva3`, - `PorBaseCorrectora3`, - `PorIva3`, - `CuotaIva3`, - `PorRecargoEquivalencia3`, - `RecargoEquivalencia3`, - `CodigoTransaccion3`, - `CodigoIva3`, - `BaseIva4`, - `PorBaseCorrectora4`, - `PorIva4`, - `CuotaIva4`, - `PorRecargoEquivalencia4`, - `RecargoEquivalencia4`, - `CodigoTransaccion4`, - `CodigoIva4`, - `Año`, - `Serie`, - `Factura`, - `SuFacturaNo`, - `FechaFactura`, - `ImporteFactura`, - `TipoFactura`, - `CodigoCuentaFactura`, - `CifDni`, - `Nombre`, - `CodigoRetencion`, - `BaseRetencion`, - `PorRetencion`, - `ImporteRetencion`, - `SiglaNacion`, - `EjercicioFactura`, - `FechaOperacion`, - `Exclusion347`, - `MantenerAsiento`, - `Metalico347`, - `ClaveOperacionFactura`, - `TipoRectificativa`, - `FechaFacturaOriginal`, - `CuotaIvaOriginal`, - `BaseImponibleOriginal`, - `ClaseAbonoRectificativas`, - `RecargoEquivalenciaOriginal`, - `LibreA1`, - `IvaDeducible1`, - `IvaDeducible2`, - `IvaDeducible3`, - `IvaDeducible4`, - `FechaGrabacion`, - `Intracomunitaria`, - `moveData`) - SELECT * - FROM tmp.XDiario_movConta_IVA; - DROP TEMPORARY TABLE tmp.XDiario_movConta_IVA; - -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 `XDiario_movConta_IVA_InvoiceInAdd_Manager__` */; -/*!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 `XDiario_movConta_IVA_InvoiceInAdd_Manager__`() +CREATE DEFINER=`root`@`%` PROCEDURE `XDiario_movConta_IVA_InvoiceInAdd_Manager___`() BEGIN DECLARE done BOOL DEFAULT FALSE; @@ -22181,6 +21889,19 @@ CREATE TABLE `fieldAcl` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `module` +-- + +DROP TABLE IF EXISTS `module`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `module` ( + `code` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `userConfigView` -- @@ -22192,7 +21913,7 @@ CREATE TABLE `userConfigView` ( `id` int(11) NOT NULL AUTO_INCREMENT, `userFk` int(10) unsigned NOT NULL, `tableCode` varchar(255) COLLATE utf8_unicode_ci NOT NULL, - `configuration` text COLLATE utf8_unicode_ci DEFAULT NULL, + `configuration` text COLLATE utf8_unicode_ci, PRIMARY KEY (`id`), UNIQUE KEY `uniqueUser_TableCode` (`userFk`,`tableCode`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -22205,61 +21926,6 @@ CREATE TABLE `userConfigView` ( -- -- Dumping routines for database 'salix' -- -/*!50003 DROP PROCEDURE IF EXISTS `production_control_source` */; -/*!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 `production_control_source`(idWarehouse INT, scopeDays TINYINT) -BEGIN - CALL vn2008.production_control_source(idWarehouse, scopeDays); - - SET @id = 0; - - DROP TEMPORARY TABLE IF EXISTS tmp.production; - CREATE TEMPORARY TABLE tmp.production - ENGINE = MEMORY - SELECT - @id := @id+1 id, - p.Id_Ticket ticketFk, - p.Id_Cliente clientFk, - p.Alias client, - p.Fecha `date`, - p.Hora hour, - p.POBLACION city, - p.PROVINCIA province, - p.province_id provinceFk, - p.Agencia agency, - p.agency_id agencyFk, - p.lines, - p.m3, - p.problems, - p.problem, - p.state stateFk, - t.Id_Trabajador workerfk, - CONCAT(t.Nombre, ' ', t.Apellidos) worker, - tt.Id_Trabajador salesPersonFk, - CONCAT(tt.Nombre, ' ', tt.Apellidos) salesPerson, - s.name state, - p.Cajas boxes, - p.Id_Ruta routeFk - FROM tmp.production_buffer p - JOIN vn2008.state s ON p.state = s.id - JOIN vn2008.Trabajadores t ON p.CodigoTrabajador = t.CodigoTrabajador COLLATE utf8_unicode_ci - JOIN vn2008.Trabajadores tt ON p.Comercial = tt.CodigoTrabajador COLLATE utf8_unicode_ci; - - DROP TEMPORARY TABLE tmp.production_buffer; -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 */ ; -- -- Current Database: `stock` @@ -22281,7 +21947,7 @@ CREATE TABLE `inbound` ( `tableName` set('buy','sale') NOT NULL, `tableId` int(10) unsigned NOT NULL, `isSync` tinyint(4) NOT NULL, - `isPicked` tinyint(4) NOT NULL DEFAULT 0, + `isPicked` tinyint(4) NOT NULL DEFAULT '0', `warehouseFk` int(10) unsigned NOT NULL, `itemFk` int(10) unsigned NOT NULL, `dated` datetime NOT NULL, @@ -22404,7 +22070,7 @@ CREATE TABLE `outbound` ( `tableName` set('sale','buy','orderRow') NOT NULL, `tableId` int(10) unsigned NOT NULL, `isSync` tinyint(3) unsigned NOT NULL, - `isPicked` tinyint(4) NOT NULL DEFAULT 0, + `isPicked` tinyint(4) NOT NULL DEFAULT '0', `warehouseFk` int(10) unsigned NOT NULL, `itemFk` int(10) unsigned NOT NULL, `dated` datetime NOT NULL, @@ -23589,7 +23255,7 @@ DROP TABLE IF EXISTS `config`; CREATE TABLE `config` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `dbVersion` char(11) CHARACTER SET utf8 DEFAULT NULL COMMENT 'The current database version', - `hasTriggersDisabled` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Defines if triggers are disabled', + `hasTriggersDisabled` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Defines if triggers are disabled', `environment` varchar(45) CHARACTER SET utf8 DEFAULT NULL COMMENT 'The current Database environment', `lastDump` datetime DEFAULT NULL COMMENT 'Timestamp of the last data dump', PRIMARY KEY (`id`) @@ -23605,7 +23271,7 @@ DROP TABLE IF EXISTS `debug`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `debug` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `connectionId` int(10) unsigned DEFAULT NULL, `user` varchar(255) CHARACTER SET utf8 DEFAULT NULL, `host` varchar(255) CHARACTER SET utf8 DEFAULT NULL, @@ -23627,7 +23293,7 @@ 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(), + `updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -23644,7 +23310,7 @@ CREATE TABLE `versionUser` ( `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(), + `updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`code`,`user`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -23933,6 +23599,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 `midnight` */; +/*!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 `midnight`() RETURNS datetime + READS SQL DATA +BEGIN + + RETURN TIMESTAMPADD(SECOND, 24 * 60 * 60 - 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 FUNCTION IF EXISTS `nextWeek` */; ALTER DATABASE `util` CHARACTER SET utf8 COLLATE utf8_general_ci ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -24720,7 +24408,7 @@ CREATE TABLE `XDiario` ( `FACTURA` varchar(8) COLLATE utf8_unicode_ci DEFAULT '0', `BASEIMPO` decimal(10,2) DEFAULT NULL, `IVA` decimal(10,2) DEFAULT NULL, - `RECEQUIV` decimal(10,2) DEFAULT 0.00, + `RECEQUIV` decimal(10,2) DEFAULT '0.00', `DOCUMENTO` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, `DEPARTA` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, `CLAVE` int(11) DEFAULT NULL, @@ -24738,24 +24426,24 @@ CREATE TABLE `XDiario` ( `CODDIVISA` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL, `IMPAUXME` decimal(10,2) DEFAULT NULL, `MONEDAUSO` varchar(1) COLLATE utf8_unicode_ci DEFAULT '2', - `NOCONV` tinyint(1) NOT NULL DEFAULT 0, + `NOCONV` tinyint(1) NOT NULL DEFAULT '0', `NUMEROINV` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, `TIPOOPE` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, - `NFACTICK` tinyint(1) NOT NULL DEFAULT 1, - `TERIDNIF` tinyint(1) NOT NULL DEFAULT 2, + `NFACTICK` tinyint(1) NOT NULL DEFAULT '1', + `TERIDNIF` tinyint(1) NOT NULL DEFAULT '2', `TERNIF` varchar(20) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'I.F.', `TERNOM` varchar(50) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'Nombre Importador', - `OPBIENES` tinyint(1) NOT NULL DEFAULT 1, + `OPBIENES` tinyint(1) NOT NULL DEFAULT '1', `TIPOFAC` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, `TIPOIVA` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, - `L340` tinyint(2) NOT NULL DEFAULT 0, - `enlazado` tinyint(1) NOT NULL DEFAULT 0, + `L340` tinyint(2) NOT NULL DEFAULT '0', + `enlazado` tinyint(1) NOT NULL DEFAULT '0', `FECHA_EX` date DEFAULT NULL COMMENT 'FEcha de expedicion de la factura', - `LRECT349` tinyint(1) NOT NULL DEFAULT 0, - `empresa_id` smallint(5) unsigned NOT NULL DEFAULT 442, - `LDIFADUAN` tinyint(4) NOT NULL DEFAULT 0, - `METAL` tinyint(1) NOT NULL DEFAULT 0, - `METALIMP` decimal(10,2) NOT NULL DEFAULT 0.00, + `LRECT349` tinyint(1) NOT NULL DEFAULT '0', + `empresa_id` smallint(5) unsigned NOT NULL DEFAULT '442', + `LDIFADUAN` tinyint(4) NOT NULL DEFAULT '0', + `METAL` tinyint(1) NOT NULL DEFAULT '0', + `METALIMP` decimal(10,2) NOT NULL DEFAULT '0.00', `CLIENTE` varchar(12) COLLATE utf8_unicode_ci DEFAULT NULL, `METALEJE` varchar(4) COLLATE utf8_unicode_ci DEFAULT NULL, `FECHA_OP` date DEFAULT NULL COMMENT 'FEcha de operacion', @@ -24769,12 +24457,12 @@ CREATE TABLE `XDiario` ( `FACTU_RT` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, `BASEIMP_RT` decimal(10,2) DEFAULT NULL, `BASEIMP_RF` decimal(10,2) DEFAULT NULL, - `RECTIFICA` int(1) NOT NULL DEFAULT 0, + `RECTIFICA` int(1) NOT NULL DEFAULT '0', `FECHA_RT` date DEFAULT NULL, - `created` timestamp NULL DEFAULT current_timestamp(), - `updated` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `updated` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `FECREGCON` date DEFAULT NULL, - `enlazadoSage` tinyint(1) NOT NULL DEFAULT 0, + `enlazadoSage` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `empresa_id` (`empresa_id`), KEY `ASIENidx` (`id`,`ASIEN`), @@ -24888,11 +24576,11 @@ DROP TABLE IF EXISTS `accountingType`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `accountingType` ( - `id` smallint(6) NOT NULL DEFAULT 0, + `id` smallint(6) NOT NULL DEFAULT '0', `description` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `receiptDescription` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Descripción por defecto al crear nuevo recibo', `code` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - `isAutoConciliated` tinyint(1) DEFAULT 1 COMMENT 'Si hay que marcar como conciliado el recibo al usar este tipo', + `isAutoConciliated` tinyint(1) DEFAULT '1' COMMENT 'Si hay que marcar como conciliado el recibo al usar este tipo', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='descripcio dels valors de la columna "cash" de la taula vn2008.Bancios'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -24920,9 +24608,9 @@ DROP TABLE IF EXISTS `activityTaxDismissed`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `activityTaxDismissed` ( `clientFk` int(11) NOT NULL, - `isNotified` tinyint(1) DEFAULT 0, - `isDismissed` tinyint(1) DEFAULT 0, - `notified` int(11) DEFAULT 0, + `isNotified` tinyint(1) DEFAULT '0', + `isDismissed` tinyint(1) DEFAULT '0', + `notified` int(11) DEFAULT '0', PRIMARY KEY (`clientFk`), CONSTRAINT `clientFk` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -24937,8 +24625,8 @@ DROP TABLE IF EXISTS `address`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `address` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `clientFk` int(11) NOT NULL DEFAULT 0, - `warehouseFk` smallint(6) unsigned DEFAULT 1, + `clientFk` int(11) NOT NULL DEFAULT '0', + `warehouseFk` smallint(6) unsigned DEFAULT '1', `street` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `city` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `provinceFk` smallint(5) unsigned DEFAULT NULL, @@ -24946,12 +24634,12 @@ CREATE TABLE `address` ( `phone` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, `mobile` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, `nickname` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL, - `isDefaultAddress` tinyint(1) NOT NULL DEFAULT 0, - `agencyModeFk` int(11) NOT NULL DEFAULT 2, + `isDefaultAddress` tinyint(1) NOT NULL DEFAULT '0', + `agencyModeFk` int(11) NOT NULL DEFAULT '2', `notes__` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `hasInsurance__` tinyint(1) NOT NULL DEFAULT 0, + `hasInsurance__` tinyint(1) NOT NULL DEFAULT '0', `porte__` double DEFAULT NULL, - `isActive` tinyint(4) NOT NULL DEFAULT 1, + `isActive` tinyint(4) NOT NULL DEFAULT '1', `postcodeOLD__` int(11) unsigned DEFAULT NULL, `longitude` decimal(11,7) DEFAULT NULL, `latitude` decimal(11,7) DEFAULT NULL, @@ -24959,8 +24647,8 @@ CREATE TABLE `address` ( `isEqualizated` tinyint(1) DEFAULT NULL, `customsAgentFk` int(11) DEFAULT NULL, `incotermsFk` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, - `isVilassarBuyer__` tinyint(4) NOT NULL DEFAULT 0, - `isLogifloraAllowed` tinyint(4) NOT NULL DEFAULT 0, + `isVilassarBuyer__` tinyint(4) NOT NULL DEFAULT '0', + `isLogifloraAllowed` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `Id_Agencia` (`agencyModeFk`), KEY `Id_cliente` (`clientFk`), @@ -25084,7 +24772,7 @@ DROP TABLE IF EXISTS `addressForPackaging`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `addressForPackaging` ( `addressFk` int(11) NOT NULL, - `packagingValue` decimal(10,2) NOT NULL DEFAULT 0.04, + `packagingValue` decimal(10,2) NOT NULL DEFAULT '0.04', PRIMARY KEY (`addressFk`), CONSTRAINT `addresForPackaging_fk1` FOREIGN KEY (`addressFk`) REFERENCES `address` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -25121,11 +24809,11 @@ CREATE TABLE `agency` ( `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(25) COLLATE utf8_unicode_ci NOT NULL, `warehouseFk` smallint(5) unsigned DEFAULT NULL COMMENT 'A nulo si se puede enrutar desde todos los almacenes', - `isVolumetric` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'Si el calculo del porte se hacer por volumen', - `bankFk` int(11) NOT NULL DEFAULT 8 COMMENT 'para realizar los reembolsos', + `isVolumetric` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Si el calculo del porte se hacer por volumen', + `bankFk` int(11) NOT NULL DEFAULT '8' COMMENT 'para realizar los reembolsos', `warehouseAliasFk` smallint(5) unsigned DEFAULT NULL, - `isOwn` tinyint(1) NOT NULL DEFAULT 0, - `labelZone` tinyint(4) NOT NULL DEFAULT 0, + `isOwn` tinyint(1) NOT NULL DEFAULT '0', + `labelZone` tinyint(4) NOT NULL DEFAULT '0', `workCenterFk` int(11) DEFAULT NULL, `supplierFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), @@ -25191,23 +24879,24 @@ CREATE TABLE `agencyMode` ( `name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `description` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `deliveryMethodFk` int(11) DEFAULT NULL, - `m3` double DEFAULT 0, - `cod71__` tinyint(3) unsigned DEFAULT 0, - `web` smallint(1) unsigned zerofill NOT NULL DEFAULT 0, + `m3` double DEFAULT '0', + `cod71__` tinyint(3) unsigned DEFAULT '0', + `web` smallint(1) unsigned zerofill NOT NULL DEFAULT '0', `agencyFk` smallint(5) unsigned NOT NULL, - `inflation` decimal(5,2) NOT NULL DEFAULT 0.00 COMMENT 'Este valor se utiliza para aumentar el valor del componente porte.', - `isVolumetric` tinyint(1) NOT NULL DEFAULT 0, + `inflation` decimal(5,2) NOT NULL DEFAULT '0.00' COMMENT 'Este valor se utiliza para aumentar el valor del componente porte.', + `isVolumetric` tinyint(1) NOT NULL DEFAULT '0', `reportMail` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, - `showAgencyName` tinyint(1) DEFAULT 1 COMMENT 'obsoleta', - `isActive` tinyint(1) NOT NULL DEFAULT 1, - `isExternalAgency` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'obsoleta', - `flag` blob DEFAULT NULL COMMENT 'obsoleta', + `showAgencyName` tinyint(1) DEFAULT '1' COMMENT 'obsoleta', + `isActive` tinyint(1) NOT NULL DEFAULT '1', + `isExternalAgency` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'obsoleta', + `flag` blob COMMENT 'obsoleta', `code` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `isRiskFree` tinyint(1) NOT NULL DEFAULT 0, + `isRiskFree` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `Agencias` (`name`), KEY `Vista` (`deliveryMethodFk`), KEY `agencyMode_agencyFk` (`agencyFk`), + KEY `agencyMode_code` (`code`), CONSTRAINT `agencyMode_agencyFk` FOREIGN KEY (`agencyFk`) REFERENCES `agency` (`id`) ON UPDATE CASCADE, CONSTRAINT `agencyMode_deliveryMethodFk` FOREIGN KEY (`deliveryMethodFk`) REFERENCES `deliveryMethod` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -25239,11 +24928,11 @@ DROP TABLE IF EXISTS `agencyTerm`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `agencyTerm` ( `agencyFk` smallint(5) unsigned NOT NULL, - `minimumPackages` int(11) NOT NULL DEFAULT 0 COMMENT 'numero minimo de bultos', - `kmPrice` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT 'precio extra por km', - `packagePrice` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT 'precio extra por bulto', + `minimumPackages` int(11) NOT NULL DEFAULT '0' COMMENT 'numero minimo de bultos', + `kmPrice` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT 'precio extra por km', + `packagePrice` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT 'precio extra por bulto', `routePrice` decimal(10,2) DEFAULT NULL COMMENT 'precio fijo por ruta', - `minimumKm` int(11) NOT NULL DEFAULT 0, + `minimumKm` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`agencyFk`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -25338,7 +25027,7 @@ DROP TABLE IF EXISTS `autoRadioLogCall`; CREATE TABLE `autoRadioLogCall` ( `id` int(11) NOT NULL AUTO_INCREMENT, `ticketFk` int(11) NOT NULL, - `created` timestamp NOT NULL DEFAULT current_timestamp(), + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `response` longtext COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`), KEY `ticket_idx` (`ticketFk`), @@ -25376,12 +25065,12 @@ CREATE TABLE `awb` ( `code` varchar(18) COLLATE utf8_unicode_ci NOT NULL, `package` float unsigned NOT NULL, `weight` float unsigned DEFAULT NULL, - `created` timestamp NOT NULL DEFAULT current_timestamp(), - `transitoryFk` int(11) NOT NULL DEFAULT 582, - `taxFk` int(10) unsigned DEFAULT 62, + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `transitoryFk` int(11) NOT NULL DEFAULT '582', + `taxFk` int(10) unsigned DEFAULT '62', `duakk` varchar(18) COLLATE utf8_unicode_ci DEFAULT NULL, `docFk` int(11) DEFAULT NULL, - `amount` double NOT NULL DEFAULT 0, + `amount` double NOT NULL DEFAULT '0', `freightFk` int(11) DEFAULT NULL, `m3` double unsigned DEFAULT NULL, `stems` int(10) unsigned DEFAULT NULL, @@ -25394,11 +25083,11 @@ CREATE TABLE `awb` ( `operated` datetime DEFAULT NULL, `bookEntried` date DEFAULT NULL, `invoiceInFk` mediumint(8) unsigned DEFAULT NULL, - `isChecked` tinyint(3) DEFAULT 0, - `isTransitoryChecked` tinyint(3) DEFAULT 0, + `isChecked` tinyint(3) DEFAULT '0', + `isTransitoryChecked` tinyint(3) DEFAULT '0', `year` int(4) DEFAULT NULL, `observation` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `hasFreightPrepaid` tinyint(3) DEFAULT 0, + `hasFreightPrepaid` tinyint(3) DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `codigo_UNIQUE` (`code`,`year`), KEY `proveedor_id` (`transitoryFk`), @@ -25535,13 +25224,13 @@ DROP TABLE IF EXISTS `bank`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `bank` ( - `id` int(11) NOT NULL DEFAULT 0, + `id` int(11) NOT NULL DEFAULT '0', `bank` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `account` varchar(10) CHARACTER SET utf8 DEFAULT NULL, - `cash` smallint(6) NOT NULL DEFAULT 0, + `cash` smallint(6) NOT NULL DEFAULT '0', `entityFk` int(10) unsigned NOT NULL, - `isActive` tinyint(4) NOT NULL DEFAULT 1, - `currencyFk` tinyint(3) unsigned DEFAULT 1, + `isActive` tinyint(4) NOT NULL DEFAULT '1', + `currencyFk` tinyint(3) unsigned DEFAULT '1', `code` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `BancosBanco` (`bank`), @@ -25561,7 +25250,7 @@ DROP TABLE IF EXISTS `bankEntity`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `bankEntity` ( - `countryFk` mediumint(8) unsigned NOT NULL DEFAULT 1, + `countryFk` mediumint(8) unsigned NOT NULL DEFAULT '1', `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, `bic` varchar(11) CHARACTER SET utf8 DEFAULT NULL, @@ -25615,12 +25304,12 @@ DROP TABLE IF EXISTS `bookingPlanner`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `bookingPlanner` ( `id` int(10) NOT NULL AUTO_INCREMENT, - `effectived` timestamp NOT NULL DEFAULT current_timestamp(), + `effectived` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `pgcFk` varchar(10) COLLATE utf8_unicode_ci NOT NULL, `taxAreaFk` varchar(15) CHARACTER SET utf8 NOT NULL DEFAULT 'SPAIN', `priority` int(2) unsigned DEFAULT NULL, - `taxClassFk` tinyint(3) unsigned NOT NULL DEFAULT 1, - `countryFk` mediumint(8) unsigned NOT NULL DEFAULT 1, + `taxClassFk` tinyint(3) unsigned NOT NULL DEFAULT '1', + `countryFk` mediumint(8) unsigned NOT NULL DEFAULT '1', PRIMARY KEY (`id`), KEY `pgcFk_bookingPlanner_idx` (`pgcFk`), KEY `taxClassFk` (`taxClassFk`), @@ -25647,7 +25336,7 @@ CREATE TABLE `botanicExport` ( `countryFk` mediumint(8) unsigned DEFAULT NULL, `restriction` enum('Sin restriccion','Importacion Prohibida','pasaporte fitosanitario','pasaporte individual','declaracion origen') CHARACTER SET utf8 NOT NULL, `description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `isProtectedZone` tinyint(1) NOT NULL DEFAULT 0, + `isProtectedZone` tinyint(1) NOT NULL DEFAULT '0', `code` enum('importProhibited','phytosanitaryPassport','individualPassport') COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `Id_Paises` (`countryFk`), @@ -25716,33 +25405,33 @@ DROP TABLE IF EXISTS `buy`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `buy` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `entryFk` int(11) NOT NULL DEFAULT 0, - `itemFk` int(11) NOT NULL DEFAULT 90, - `quantity` int(11) DEFAULT 0, - `dispatched` int(11) NOT NULL DEFAULT 0, - `buyingValue` decimal(10,3) DEFAULT 0.000, - `freightValue` decimal(10,3) DEFAULT 0.000, - `isIgnored` tinyint(1) NOT NULL DEFAULT 0, - `stickers` int(11) DEFAULT 0, - `packing` int(11) DEFAULT 0, - `grouping` smallint(5) unsigned NOT NULL DEFAULT 1, - `groupingMode` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0=sin obligar 1=groping 2=packing', + `entryFk` int(11) NOT NULL DEFAULT '0', + `itemFk` int(11) NOT NULL DEFAULT '90', + `quantity` int(11) DEFAULT '0', + `dispatched` int(11) NOT NULL DEFAULT '0', + `buyingValue` decimal(10,3) DEFAULT '0.000', + `freightValue` decimal(10,3) DEFAULT '0.000', + `isIgnored` tinyint(1) NOT NULL DEFAULT '0', + `stickers` int(11) DEFAULT '0', + `packing` int(11) DEFAULT '0', + `grouping` smallint(5) unsigned NOT NULL DEFAULT '1', + `groupingMode` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0=sin obligar 1=groping 2=packing', `containerFk` smallint(5) unsigned DEFAULT NULL, - `comissionValue` decimal(10,3) DEFAULT 0.000, - `packageValue` decimal(10,3) DEFAULT 0.000, + `comissionValue` decimal(10,3) DEFAULT '0.000', + `packageValue` decimal(10,3) DEFAULT '0.000', `location` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL, `packageFk` varchar(10) COLLATE utf8_unicode_ci DEFAULT '--', - `price1` decimal(10,2) DEFAULT 0.00, - `price2` decimal(10,2) DEFAULT 0.00, - `price3` decimal(10,2) DEFAULT 0.00, - `minPrice` decimal(10,2) DEFAULT 0.00, + `price1` decimal(10,2) DEFAULT '0.00', + `price2` decimal(10,2) DEFAULT '0.00', + `price3` decimal(10,2) DEFAULT '0.00', + `minPrice` decimal(10,2) DEFAULT '0.00', `producer` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `printedStickers` int(11) DEFAULT 0, - `workerFk` int(11) DEFAULT 0, - `isChecked` tinyint(1) NOT NULL DEFAULT 0, - `isPickedOff` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Esta mercancia no va a la zona de picking.', - `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), - `__cm2` int(10) unsigned NOT NULL DEFAULT 0, + `printedStickers` int(11) DEFAULT '0', + `workerFk` int(11) DEFAULT '0', + `isChecked` tinyint(1) NOT NULL DEFAULT '0', + `isPickedOff` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Esta mercancia no va a la zona de picking.', + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `__cm2` int(10) unsigned NOT NULL DEFAULT '0', `ektFk` int(11) DEFAULT NULL, `weight` decimal(10,2) unsigned DEFAULT NULL, `deliveryFk` int(11) DEFAULT NULL, @@ -25989,7 +25678,7 @@ CREATE TABLE `buyMark` ( `id` int(11) NOT NULL, `comment` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `mark` tinyint(1) DEFAULT NULL, - `odbcDate` timestamp NULL DEFAULT current_timestamp(), + `odbcDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), CONSTRAINT `Compres_mark_ibfk_1` FOREIGN KEY (`id`) REFERENCES `buy` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -26125,8 +25814,8 @@ DROP TABLE IF EXISTS `campaign`; CREATE TABLE `campaign` ( `id` int(11) NOT NULL AUTO_INCREMENT, `code` enum('mothersDay','allSaints','valentinesDay') COLLATE utf8_unicode_ci NOT NULL, - `dated` datetime NOT NULL DEFAULT current_timestamp(), - `scopeDays` int(11) NOT NULL DEFAULT 15, + `dated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `scopeDays` int(11) NOT NULL DEFAULT '15', PRIMARY KEY (`id`), UNIQUE KEY `campaign_dated_uindex` (`dated`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -26157,7 +25846,7 @@ DROP TABLE IF EXISTS `chain`; CREATE TABLE `chain` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `rappel` decimal(5,2) NOT NULL DEFAULT 0.00, + `rappel` decimal(5,2) NOT NULL DEFAULT '0.00', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Grupos de clientes'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -26190,13 +25879,13 @@ CREATE TABLE `claim` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `ticketCreated` date NOT NULL, `claimDepartmentFk__` tinyint(3) unsigned DEFAULT NULL, - `claimStateFk` int(10) unsigned NOT NULL DEFAULT 1, - `observation` text COLLATE utf8_unicode_ci DEFAULT NULL, + `claimStateFk` int(10) unsigned NOT NULL DEFAULT '1', + `observation` text COLLATE utf8_unicode_ci, `clientFk` int(11) NOT NULL, `workerFk` int(11) NOT NULL, - `responsibility` int(1) unsigned NOT NULL DEFAULT 3, - `isChargedToMana` tinyint(1) NOT NULL DEFAULT 0, - `created` timestamp NULL DEFAULT current_timestamp(), + `responsibility` int(1) unsigned NOT NULL DEFAULT '3', + `isChargedToMana` tinyint(1) NOT NULL DEFAULT '0', + `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `ticketFk` int(11) DEFAULT NULL, `hasToPickUp` tinyint(1) NOT NULL, PRIMARY KEY (`id`), @@ -26223,8 +25912,8 @@ CREATE TABLE `claimBeginning` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `claimFk` int(10) unsigned NOT NULL, `saleFk` int(11) DEFAULT NULL, - `claimComplaintFk__` int(10) unsigned NOT NULL DEFAULT 1, - `claimRequestFk__` int(1) unsigned NOT NULL DEFAULT 1, + `claimComplaintFk__` int(10) unsigned NOT NULL DEFAULT '1', + `claimRequestFk__` int(1) unsigned NOT NULL DEFAULT '1', `quantity` double DEFAULT NULL, PRIMARY KEY (`id`), KEY `Id_Movimiento` (`saleFk`), @@ -26289,12 +25978,12 @@ DROP TABLE IF EXISTS `claimDevelopment`; CREATE TABLE `claimDevelopment` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `claimFk` int(10) unsigned NOT NULL, - `claimResponsibleFk` int(10) unsigned NOT NULL DEFAULT 1, + `claimResponsibleFk` int(10) unsigned NOT NULL DEFAULT '1', `workerFk` int(11) DEFAULT NULL, - `claimReasonFk` int(10) unsigned NOT NULL DEFAULT 1, - `claimResultFk` int(10) unsigned NOT NULL DEFAULT 1, - `claimRedeliveryFk` tinyint(3) unsigned NOT NULL DEFAULT 1, - `claimDestinationFk` tinyint(3) unsigned NOT NULL DEFAULT 2, + `claimReasonFk` int(10) unsigned NOT NULL DEFAULT '1', + `claimResultFk` int(10) unsigned NOT NULL DEFAULT '1', + `claimRedeliveryFk` tinyint(3) unsigned NOT NULL DEFAULT '1', + `claimDestinationFk` tinyint(3) unsigned NOT NULL DEFAULT '2', PRIMARY KEY (`id`), KEY `cl_main_id` (`claimFk`), KEY `cl_res_id` (`claimResponsibleFk`), @@ -26341,9 +26030,9 @@ CREATE TABLE `claimEnd` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `saleFk` int(11) DEFAULT NULL, `claimFk` int(10) unsigned NOT NULL, - `workerFk` int(11) NOT NULL DEFAULT 20, + `workerFk` int(11) NOT NULL DEFAULT '20', `claimDestinationFk` tinyint(4) DEFAULT NULL, - `isGreuge` tinyint(4) NOT NULL DEFAULT 0, + `isGreuge` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `cl_main_id` (`claimFk`), KEY `Id_Trabajador` (`workerFk`), @@ -26367,11 +26056,11 @@ CREATE TABLE `claimLog` ( `originFk` int(10) 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, + `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `description` text CHARACTER SET utf8, `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, + `oldInstance` text COLLATE utf8_unicode_ci, + `newInstance` text COLLATE utf8_unicode_ci, `changedModelId` int(11) DEFAULT NULL, `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), @@ -26390,12 +26079,12 @@ DROP TABLE IF EXISTS `claimRatio`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `claimRatio` ( - `clientFk` int(11) NOT NULL DEFAULT 0, + `clientFk` int(11) NOT NULL DEFAULT '0', `yearSale` decimal(10,2) DEFAULT NULL, `claimAmount` decimal(10,2) DEFAULT NULL, `claimingRate` decimal(5,2) DEFAULT NULL, `priceIncreasing` decimal(5,2) DEFAULT NULL, - `packingRate` decimal(5,2) NOT NULL DEFAULT 1.00, + `packingRate` decimal(5,2) NOT NULL DEFAULT '1.00', PRIMARY KEY (`clientFk`), CONSTRAINT `claimRatio_ibfk_1` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -26457,7 +26146,7 @@ DROP TABLE IF EXISTS `claimResponsible`; CREATE TABLE `claimResponsible` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `responsability` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'if=1 >sensib >culpa', + `responsability` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'if=1 >sensib >culpa', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Responsables de las causas'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -26487,8 +26176,8 @@ CREATE TABLE `claimState` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `code` varchar(45) CHARACTER SET utf8 DEFAULT NULL, `description` varchar(15) COLLATE utf8_unicode_ci NOT NULL, - `roleFk` int(10) unsigned NOT NULL DEFAULT 1, - `priority` int(11) NOT NULL DEFAULT 1, + `roleFk` int(10) unsigned NOT NULL DEFAULT '1', + `priority` int(11) NOT NULL DEFAULT '1', PRIMARY KEY (`id`), KEY `roleFgn_idx` (`roleFk`), CONSTRAINT `roleFgn` FOREIGN KEY (`roleFk`) REFERENCES `account`.`role` (`id`) ON UPDATE CASCADE @@ -26505,66 +26194,66 @@ DROP TABLE IF EXISTS `client`; CREATE TABLE `client` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(50) COLLATE utf8_unicode_ci NOT NULL, - `discount` tinyint(3) unsigned NOT NULL DEFAULT 0 COMMENT 'obsoleta (comprobar)', + `discount` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT 'obsoleta (comprobar)', `defaultAddressFk` int(11) DEFAULT NULL, - `street` longtext COLLATE utf8_unicode_ci DEFAULT NULL, + `street` longtext COLLATE utf8_unicode_ci, `fi` varchar(14) COLLATE utf8_unicode_ci DEFAULT NULL, `phone` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, `fax` varchar(11) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'obsoleta (comprobar)', `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)', - `isTaxDataChecked` tinyint(1) NOT NULL DEFAULT 0, + `dueDay` smallint(6) NOT NULL DEFAULT '5', + `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, - `isEqualizated` tinyint(1) NOT NULL DEFAULT 0, + `isEqualizated` tinyint(1) NOT NULL DEFAULT '0', `city` varchar(25) COLLATE utf8_unicode_ci DEFAULT NULL, `provinceFk` smallint(5) unsigned DEFAULT NULL, `postcode` varchar(8) COLLATE utf8_unicode_ci DEFAULT NULL, `socialName` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL, `contact` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `wholesaler` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'obsoleta (comprobar)', - `isReExpedition` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'obsoleta (comprobar)', - `hasToInvoice` tinyint(1) NOT NULL DEFAULT 1, - `notes` text COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'obsoleta (comprobar)', + `wholesaler` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'obsoleta (comprobar)', + `isReExpedition` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'obsoleta (comprobar)', + `hasToInvoice` tinyint(1) NOT NULL DEFAULT '1', + `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)', - `isFreezed` tinyint(1) NOT NULL DEFAULT 0, + `invoiceCopy` 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(11) DEFAULT NULL, - `credit` decimal(10,2) NOT NULL DEFAULT 0.00, + `credit` decimal(10,2) NOT NULL DEFAULT '0.00', `cyc` double DEFAULT NULL COMMENT 'obsoleta (comprobar)', - `countryFk` mediumint(8) unsigned NOT NULL DEFAULT 1, - `isActive` tinyint(1) NOT NULL DEFAULT 1, + `countryFk` mediumint(8) unsigned NOT NULL DEFAULT '1', + `isActive` tinyint(1) NOT NULL DEFAULT '1', `gestdocFk` int(11) DEFAULT NULL, - `quality` int(2) DEFAULT 11, - `payMethodFk` tinyint(3) unsigned NOT NULL DEFAULT 5, - `created` timestamp NULL DEFAULT current_timestamp(), - `isToBeMailed` tinyint(1) NOT NULL DEFAULT 1, + `quality` int(2) DEFAULT '11', + `payMethodFk` tinyint(3) unsigned NOT NULL DEFAULT '5', + `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `isToBeMailed` tinyint(1) NOT NULL DEFAULT '1', `contactChannelFk` smallint(6) DEFAULT NULL, - `isVies` tinyint(4) NOT NULL DEFAULT 0, - `splitHolland` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'obsoleta (comprobar)', - `sepaFth` tinyint(1) DEFAULT 0 COMMENT 'campo para recibir los escritos de los clientes para el sepa\n\nobsoleta (comprobar)', - `hasSepaVnl` tinyint(1) DEFAULT 0, - `coreFth` tinyint(1) DEFAULT 0 COMMENT 'obsoleta (comprobar)', - `hasCoreVnl` tinyint(1) DEFAULT 0, + `isVies` tinyint(4) NOT NULL DEFAULT '0', + `splitHolland` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'obsoleta (comprobar)', + `sepaFth` tinyint(1) DEFAULT '0' COMMENT 'campo para recibir los escritos de los clientes para el sepa\n\nobsoleta (comprobar)', + `hasSepaVnl` tinyint(1) DEFAULT '0', + `coreFth` tinyint(1) DEFAULT '0' COMMENT 'obsoleta (comprobar)', + `hasCoreVnl` tinyint(1) DEFAULT '0', `riskCalculated` date NOT NULL, - `hasCoreVnh` tinyint(1) DEFAULT 0, - `isRelevant` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Define los clientes cuyas ventas hay que tener en cuenta en los calculos estadisticos.', - `clientTypeFk` int(11) NOT NULL DEFAULT 1, + `hasCoreVnh` tinyint(1) DEFAULT '0', + `isRelevant` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Define los clientes cuyas ventas hay que tener en cuenta en los calculos estadisticos.', + `clientTypeFk` int(11) NOT NULL DEFAULT '1', `postcodeOld` int(11) unsigned DEFAULT NULL COMMENT 'obsoleta (comprobar)', `mailAddress` int(11) DEFAULT NULL, `codposOLD` char(5) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'obsoleta (comprobar)', `creditInsurance` int(11) DEFAULT NULL, - `eypbc` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Email\\nYesterday\\nPurchases\\nBy\\nConsigna', - `hasToInvoiceByAddress` tinyint(1) DEFAULT 0, - `cplusTerIdNifFk` int(11) NOT NULL DEFAULT 1 COMMENT 'OBSOLETO', - `isCreatedAsServed` tinyint(1) DEFAULT 0, - `hasInvoiceSimplified` tinyint(1) NOT NULL DEFAULT 0, + `eypbc` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Email\\nYesterday\\nPurchases\\nBy\\nConsigna', + `hasToInvoiceByAddress` tinyint(1) DEFAULT '0', + `cplusTerIdNifFk` int(11) NOT NULL DEFAULT '1' COMMENT 'OBSOLETO', + `isCreatedAsServed` tinyint(1) DEFAULT '0', + `hasInvoiceSimplified` tinyint(1) NOT NULL DEFAULT '0', `iban` varchar(45) CHARACTER SET utf8 DEFAULT NULL, - `hasLcr` tinyint(1) NOT NULL DEFAULT 0, + `hasLcr` tinyint(1) NOT NULL DEFAULT '0', `bankEntityFk` int(10) DEFAULT NULL, `typeFk` varchar(20) CHARACTER SET utf8 NOT NULL DEFAULT 'normal', `taxTypeSageFk` smallint(6) DEFAULT NULL COMMENT 'Tipo de Iva por defecto asociado al cliente en SAGE', @@ -26756,6 +26445,20 @@ CREATE TABLE `clientChain` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `clientConfig` +-- + +DROP TABLE IF EXISTS `clientConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `clientConfig` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `riskTolerance` int(11) DEFAULT NULL COMMENT 'Maximo riesgo de un cliente para preparar su pedido', + PRIMARY KEY (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `clientContact` -- @@ -26783,7 +26486,7 @@ CREATE TABLE `clientCredit` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `clientFk` int(11) NOT NULL, `amount` double unsigned NOT NULL, - `created` timestamp NOT NULL DEFAULT current_timestamp(), + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `workerFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `workers_fk_idx` (`workerFk`), @@ -26840,11 +26543,11 @@ CREATE TABLE `clientLog` ( `originFk` int(11) 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, + `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `description` text CHARACTER SET utf8, `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, + `oldInstance` text COLLATE utf8_unicode_ci, + `newInstance` text COLLATE utf8_unicode_ci, `changedModelId` int(11) DEFAULT NULL, `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), @@ -26864,7 +26567,7 @@ DROP TABLE IF EXISTS `clientManaCache`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `clientManaCache` ( `clientFk` int(11) NOT NULL, - `mana` decimal(10,0) NOT NULL DEFAULT 0, + `mana` decimal(10,0) NOT NULL DEFAULT '0', `dated` date NOT NULL, PRIMARY KEY (`clientFk`,`dated`), KEY `manaCustomerIdx1` (`dated`), @@ -26899,7 +26602,7 @@ CREATE TABLE `clientObservation` ( `clientFk` int(11) NOT NULL, `workerFk` int(11) NOT NULL, `text` text COLLATE utf8_unicode_ci NOT NULL, - `created` timestamp NOT NULL DEFAULT current_timestamp(), + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `Id_Trabajador` (`workerFk`), KEY `Id_Cliente` (`clientFk`), @@ -26960,7 +26663,7 @@ DROP TABLE IF EXISTS `clientProtected`; CREATE TABLE `clientProtected` ( `clientFk` int(11) NOT NULL, `workerFk` int(11) NOT NULL, - `isValidated__` tinyint(1) NOT NULL DEFAULT 0, + `isValidated__` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`clientFk`), KEY `clientProtected_fk2_idx` (`workerFk`), CONSTRAINT `clientProtected_fk1` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, @@ -26976,8 +26679,8 @@ DROP TABLE IF EXISTS `clientRisk`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `clientRisk` ( - `clientFk` int(11) NOT NULL DEFAULT 0, - `companyFk` smallint(6) unsigned NOT NULL DEFAULT 0, + `clientFk` int(11) NOT NULL DEFAULT '0', + `companyFk` smallint(6) unsigned NOT NULL DEFAULT '0', `amount` decimal(10,2) DEFAULT NULL, PRIMARY KEY (`clientFk`,`companyFk`), KEY `company_id` (`companyFk`), @@ -27012,7 +26715,7 @@ CREATE TABLE `clientSample` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `clientFk` int(10) unsigned NOT NULL, `typeFk` int(10) unsigned NOT NULL, - `created` datetime NOT NULL DEFAULT current_timestamp(), + `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `workerFk` int(10) unsigned NOT NULL, `balance` float NOT NULL, `companyFk` smallint(5) unsigned DEFAULT NULL, @@ -27034,7 +26737,7 @@ CREATE TABLE `clientType` ( `id` int(11) NOT NULL AUTO_INCREMENT, `code` varchar(20) CHARACTER SET utf8 NOT NULL, `type` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `isCreatedAsServed` tinyint(1) DEFAULT 0, + `isCreatedAsServed` tinyint(1) DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `code_UNIQUE` (`code`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Establece categorias para poder agrupar las ventas'; @@ -27072,7 +26775,7 @@ CREATE TABLE `cmr` ( `senderInstruccions` varchar(255) COLLATE utf8_unicode_ci DEFAULT 'Flowers 4º C. Plants 14º C', `paymentInstruccions` varchar(255) COLLATE utf8_unicode_ci DEFAULT 'Carriage paid', `specialAgreements` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `created` timestamp NULL DEFAULT current_timestamp(), + `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `companyFk` smallint(5) unsigned DEFAULT NULL, `addressToFk` int(11) DEFAULT NULL, `addressFromFk` int(11) DEFAULT NULL, @@ -27141,7 +26844,7 @@ CREATE TABLE `cmr_expeditionPallet` ( `id` int(11) NOT NULL AUTO_INCREMENT, `cmrFk` int(11) NOT NULL, `expeditionPalletFk` int(11) NOT NULL, - `scanned` timestamp NOT NULL DEFAULT current_timestamp(), + `scanned` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `cmr_expeditionPallet_fk1_idx` (`cmrFk`), KEY `cmr_expeditionPallet_fk2_idx` (`expeditionPalletFk`), @@ -27203,16 +26906,84 @@ DROP TABLE IF EXISTS `collection`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `collection` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `created` timestamp NOT NULL DEFAULT current_timestamp(), + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `workerFk` int(11) DEFAULT NULL, `stateFk` tinyint(3) unsigned DEFAULT NULL, + `itemPackingTypeFk` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, + `saleTotalCount` int(11) NOT NULL DEFAULT '0', + `salePickedCount` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `ticketCollection_idx` (`workerFk`), KEY `collection_id2_idx` (`stateFk`), + KEY `collection_FK` (`itemPackingTypeFk`), CONSTRAINT `collection_id2` FOREIGN KEY (`stateFk`) REFERENCES `state` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `ticketCollection` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`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 */ ; +/*!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 ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER collection_BEFORE_UPDATE +BEFORE UPDATE +ON collection FOR EACH ROW +BEGIN + + DECLARE vStateFk INT; + DECLARE vTotalLines INT; + DECLARE vPickedLines INT; + + IF NEW.saleTotalCount <= NEW.salePickedCount + AND (NEW.saleTotalCount != OLD.saleTotalCount + OR NEW.salePickedCount != OLD.salePickedCount) + THEN + + SELECT id INTO vStateFk + FROM vn.state + WHERE code = 'PREPARED'; + + SET NEW.stateFk = vStateFk; + + END IF; + + IF NEW.saleTotalCount > NEW.salePickedCount + AND (NEW.saleTotalCount != OLD.saleTotalCount OR NEW.salePickedCount != OLD.salePickedCount) THEN + + SELECT id INTO vStateFk + FROM vn.state + WHERE code = 'ON_PREPARATION'; + + SET NEW.stateFk = vStateFk; + + 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 `collectionColors` +-- + +DROP TABLE IF EXISTS `collectionColors`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `collectionColors` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `code` varchar(20) COLLATE utf8_unicode_ci NOT NULL, + `shelve` int(11) NOT NULL DEFAULT '1', + `wagon` int(11) NOT NULL DEFAULT '1', + PRIMARY KEY (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Recoge los colores para las baldas de las colecciones'; +/*!40101 SET character_set_client = @saved_cs_client */; -- -- Temporary table structure for view `collectionReportSource` @@ -27243,10 +27014,10 @@ DROP TABLE IF EXISTS `collectionVolumetry`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `collectionVolumetry` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `level` int(10) unsigned NOT NULL DEFAULT 0, - `lines` int(10) unsigned NOT NULL DEFAULT 1, - `liters` int(10) unsigned NOT NULL DEFAULT 0, - `height` int(10) unsigned NOT NULL DEFAULT 20, + `level` int(10) unsigned NOT NULL DEFAULT '0', + `lines` int(10) unsigned NOT NULL DEFAULT '1', + `liters` int(10) unsigned NOT NULL DEFAULT '0', + `height` int(10) unsigned NOT NULL DEFAULT '20', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -27260,10 +27031,10 @@ DROP TABLE IF EXISTS `collectionVolumetry_Paloma`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `collectionVolumetry_Paloma` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `level` int(10) unsigned NOT NULL DEFAULT 0, - `lines` int(10) unsigned NOT NULL DEFAULT 1, - `liters` int(10) unsigned NOT NULL DEFAULT 0, - `height` int(10) unsigned NOT NULL DEFAULT 20, + `level` int(10) unsigned NOT NULL DEFAULT '0', + `lines` int(10) unsigned NOT NULL DEFAULT '1', + `liters` int(10) unsigned NOT NULL DEFAULT '0', + `height` int(10) unsigned NOT NULL DEFAULT '20', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -27276,7 +27047,7 @@ DROP TABLE IF EXISTS `commissionConfig`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `commissionConfig` ( - `rate` decimal(5,4) NOT NULL DEFAULT 0.0000, + `rate` decimal(5,4) NOT NULL DEFAULT '0.0000', `plusTeamAmount` int(11) DEFAULT NULL, `plusNewBornAmount` int(11) DEFAULT NULL, `plusSalesAmount` int(11) DEFAULT NULL, @@ -27302,22 +27073,22 @@ CREATE TABLE `company` ( `workerManagerFk` int(11) NOT NULL, `registered` date NOT NULL, `expired` date DEFAULT NULL, - `logo` longblob DEFAULT NULL, - `isOfficial` tinyint(1) unsigned NOT NULL DEFAULT 1, - `hasCyc` tinyint(1) unsigned zerofill NOT NULL DEFAULT 0, + `logo` longblob, + `isOfficial` tinyint(1) unsigned NOT NULL DEFAULT '1', + `hasCyc` tinyint(1) unsigned zerofill NOT NULL DEFAULT '0', `rgb` varchar(6) COLLATE utf8_unicode_ci NOT NULL, `email` varchar(30) COLLATE utf8_unicode_ci NOT NULL, - `stamp` blob DEFAULT NULL, - `created` timestamp NOT NULL ON UPDATE current_timestamp(), + `stamp` blob, + `created` timestamp NOT NULL ON UPDATE CURRENT_TIMESTAMP, `clientFk` int(11) DEFAULT NULL, `sage200Company` int(2) DEFAULT NULL, `supplierAccountFk` mediumint(8) unsigned DEFAULT NULL, - `isDefaulter` tinyint(4) NOT NULL DEFAULT 0, - `companyGroupFk` int(11) NOT NULL DEFAULT 1 COMMENT 'usado para calcular los greuges ', + `isDefaulter` tinyint(4) NOT NULL DEFAULT '0', + `companyGroupFk` int(11) NOT NULL DEFAULT '1' COMMENT 'usado para calcular los greuges ', `companyCode` int(2) DEFAULT NULL COMMENT 'Campo para movConta', `companyCodeTest` int(2) DEFAULT NULL, - `footnotes` longtext COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'pie de paginas en las facturas', - `phytosanitary` longtext COLLATE utf8_unicode_ci DEFAULT NULL, + `footnotes` longtext COLLATE utf8_unicode_ci COMMENT 'pie de paginas en las facturas', + `phytosanitary` longtext COLLATE utf8_unicode_ci, PRIMARY KEY (`id`), KEY `gerente_id` (`workerManagerFk`), KEY `empresa_cliente_idx` (`clientFk`), @@ -27357,7 +27128,7 @@ CREATE TABLE `component` ( `typeFk` int(11) NOT NULL, `classRate` smallint(6) DEFAULT NULL, `tax` double DEFAULT NULL, - `isRenewable` tinyint(2) NOT NULL DEFAULT 1, + `isRenewable` tinyint(2) NOT NULL DEFAULT '1', `code` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `series_componentes_idx` (`typeFk`), @@ -27395,8 +27166,8 @@ DROP TABLE IF EXISTS `componentType`; CREATE TABLE `componentType` ( `id` int(11) NOT NULL AUTO_INCREMENT, `type` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `isBase` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'Marca aquellas series que se utilizan para calcular el precio base de las ventas, a efectos estadisticos', - `isMargin` tinyint(4) NOT NULL DEFAULT 0, + `isBase` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Marca aquellas series que se utilizan para calcular el precio base de las ventas, a efectos estadisticos', + `isMargin` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `Serie_UNIQUE` (`type`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Permite organizar de forma ordenada los distintos componentes'; @@ -27476,47 +27247,47 @@ DROP TABLE IF EXISTS `config`; CREATE TABLE `config` ( `id` int(11) NOT NULL AUTO_INCREMENT, `ochoa` int(10) unsigned NOT NULL, - `invoiceOutFk` int(11) DEFAULT 0, - `bookFk` int(11) DEFAULT 0, - `serialAFk` int(11) DEFAULT 0, - `serialEFk` int(11) DEFAULT 0, - `serialRFk` int(11) DEFAULT 0, - `serialCFk` int(11) DEFAULT 0, + `invoiceOutFk` int(11) DEFAULT '0', + `bookFk` int(11) DEFAULT '0', + `serialAFk` int(11) DEFAULT '0', + `serialEFk` int(11) DEFAULT '0', + `serialRFk` int(11) DEFAULT '0', + `serialCFk` int(11) DEFAULT '0', `serialHFk` int(11) NOT NULL, - `serialPFk` int(11) DEFAULT 0, - `serialTFk` int(11) DEFAULT 0, + `serialPFk` int(11) DEFAULT '0', + `serialTFk` int(11) DEFAULT '0', `inventoried` datetime DEFAULT NULL, - `serialMFk` int(11) DEFAULT 0, - `itemLog` int(11) DEFAULT 0, + `serialMFk` int(11) DEFAULT '0', + `itemLog` int(11) DEFAULT '0', `weekGoal` int(11) DEFAULT NULL, `photosPath` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `cashBoxNumber` int(11) DEFAULT 0, + `cashBoxNumber` int(11) DEFAULT '0', `redCode` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `TabletTime` datetime DEFAULT NULL, - `t0` int(11) NOT NULL DEFAULT 0, - `t1` int(11) NOT NULL DEFAULT 0, - `t2` int(11) NOT NULL DEFAULT 0, - `t3` int(11) NOT NULL DEFAULT 0, - `cc` double NOT NULL DEFAULT 0, - `palet` double NOT NULL DEFAULT 0, + `t0` int(11) NOT NULL DEFAULT '0', + `t1` int(11) NOT NULL DEFAULT '0', + `t2` int(11) NOT NULL DEFAULT '0', + `t3` int(11) NOT NULL DEFAULT '0', + `cc` double NOT NULL DEFAULT '0', + `palet` double NOT NULL DEFAULT '0', `campaign` datetime NOT NULL, `campaignLife` tinyint(3) unsigned NOT NULL, `truckDays` tinyint(3) unsigned NOT NULL, `transportCharges` double NOT NULL, `escanerPath` varchar(50) COLLATE utf8_unicode_ci NOT NULL, `printedTurn` int(4) DEFAULT NULL, - `truckLength` int(11) DEFAULT 24, + `truckLength` int(11) DEFAULT '24', `fuelConsumption` int(11) DEFAULT NULL, `petrol` decimal(10,1) DEFAULT NULL, `maintenance` decimal(10,1) DEFAULT NULL, `hourPrice` decimal(10,1) DEFAULT NULL, `meterPrice` decimal(10,1) DEFAULT NULL, `kmPrice` decimal(10,1) DEFAULT NULL, - `routeOption` int(11) DEFAULT 1, - `dbproduccion` tinyint(1) NOT NULL DEFAULT 1, + `routeOption` int(11) DEFAULT '1', + `dbproduccion` tinyint(1) NOT NULL DEFAULT '1', `mdbServer` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `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', + `defaultersMaxAmount` int(10) DEFAULT '200' COMMENT 'maxima deuda permitida a partir de la cual se bloquea a un usuario', `ASIEN` bigint(20) DEFAULT NULL, PRIMARY KEY (`id`), KEY `fechainv_idx` (`inventoried`) @@ -27565,7 +27336,7 @@ CREATE TABLE `contratos_subvencion_270619` ( `workerFk` int(11) NOT NULL, `cod_centroFk` int(11) NOT NULL, `CodContratoFk` int(11) NOT NULL, - `journey` decimal(5,2) NOT NULL DEFAULT 8.00, + `journey` decimal(5,2) NOT NULL DEFAULT '8.00', `name` varchar(50) COLLATE utf8_unicode_ci NOT NULL, `nif` varchar(12) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`), @@ -27588,13 +27359,13 @@ DROP TABLE IF EXISTS `conveyor`; CREATE TABLE `conveyor` ( `id` int(11) NOT NULL AUTO_INCREMENT, `typeFk` int(11) NOT NULL, - `stratum` int(11) NOT NULL DEFAULT 0, + `stratum` int(11) NOT NULL DEFAULT '0', `length` int(11) DEFAULT NULL, `width` int(11) DEFAULT NULL, `height` int(11) DEFAULT NULL, `x` int(11) DEFAULT NULL, `y` int(11) DEFAULT NULL, - `color` int(11) DEFAULT 14548991, + `color` int(11) DEFAULT '14548991', PRIMARY KEY (`id`), KEY `conveyor_fk1_idx` (`typeFk`), CONSTRAINT `conveyor_fk1` FOREIGN KEY (`typeFk`) REFERENCES `conveyorType` (`id`) ON UPDATE CASCADE @@ -27611,7 +27382,7 @@ DROP TABLE IF EXISTS `conveyorBuildingClass`; CREATE TABLE `conveyorBuildingClass` ( `id` int(11) NOT NULL AUTO_INCREMENT, `description` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `priority` int(11) NOT NULL DEFAULT 0, + `priority` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Tipo de caja para el montaje de pallets'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -27644,15 +27415,15 @@ DROP TABLE IF EXISTS `conveyorExpedition`; CREATE TABLE `conveyorExpedition` ( `expeditionFk` int(11) NOT NULL, `conveyorFk` int(11) DEFAULT NULL, - `created` timestamp NOT NULL DEFAULT current_timestamp(), + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `conveyorBuildingClassFk` int(11) NOT NULL, - `length` int(11) NOT NULL DEFAULT 1, - `width` int(11) NOT NULL DEFAULT 1, - `height` int(11) NOT NULL DEFAULT 1, - `x` int(11) NOT NULL DEFAULT 1, - `y` int(11) NOT NULL DEFAULT 1, + `length` int(11) NOT NULL DEFAULT '1', + `width` int(11) NOT NULL DEFAULT '1', + `height` int(11) NOT NULL DEFAULT '1', + `x` int(11) NOT NULL DEFAULT '1', + `y` int(11) NOT NULL DEFAULT '1', `routeFk` int(11) NOT NULL, - `isBuilt` tinyint(4) NOT NULL DEFAULT 0, + `isBuilt` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`expeditionFk`), KEY `conveyorExpedition_fk1_idx` (`conveyorFk`), KEY `conveyorExpedition_fk2_idx` (`conveyorBuildingClassFk`), @@ -27672,7 +27443,7 @@ CREATE TABLE `conveyorMode` ( `code` varchar(20) COLLATE utf8_unicode_ci NOT NULL, `saturacion` int(11) NOT NULL, `gap` int(11) NOT NULL, - `isActive` tinyint(4) NOT NULL DEFAULT 0, + `isActive` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -27719,13 +27490,13 @@ DROP TABLE IF EXISTS `country`; CREATE TABLE `country` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, `country` varchar(25) COLLATE utf8_unicode_ci NOT NULL, - `CEE` tinyint(1) NOT NULL DEFAULT 1, + `CEE` tinyint(1) NOT NULL DEFAULT '1', `code` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL, - `currencyFk` tinyint(3) unsigned NOT NULL DEFAULT 1, + `currencyFk` tinyint(3) unsigned NOT NULL DEFAULT '1', `politicalCountryFk` mediumint(8) unsigned NOT NULL COMMENT 'Pais Real(apaño por culpa del España Exento)', `geoFk` int(11) DEFAULT NULL, - `hasDailyInvoice` tinyint(4) NOT NULL DEFAULT 0, - `isUeeMember` tinyint(4) NOT NULL DEFAULT 0, + `hasDailyInvoice` tinyint(4) NOT NULL DEFAULT '0', + `isUeeMember` tinyint(4) NOT NULL DEFAULT '0', `ibanLength` tinyint(4) DEFAULT NULL, `continentFk` tinyint(4) DEFAULT NULL, PRIMARY KEY (`id`), @@ -27997,7 +27768,7 @@ CREATE TABLE `creditInsurance` ( `id` int(11) NOT NULL AUTO_INCREMENT, `creditClassification` int(11) DEFAULT NULL, `credit` int(11) DEFAULT NULL, - `creationDate` timestamp NOT NULL DEFAULT current_timestamp(), + `creationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `grade` tinyint(1) DEFAULT NULL, PRIMARY KEY (`id`), KEY `CreditInsurance_Fk1_idx` (`creditClassification`), @@ -28037,7 +27808,7 @@ CREATE TABLE `currency` ( `id` tinyint(3) unsigned NOT NULL, `code` varchar(3) COLLATE utf8_unicode_ci NOT NULL, `name` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `ratio` double NOT NULL DEFAULT 1, + `ratio` double NOT NULL DEFAULT '1', PRIMARY KEY (`id`), UNIQUE KEY `Moneda_UNIQUE` (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -28175,14 +27946,14 @@ CREATE TABLE `department` ( `bossFk__` int(11) DEFAULT NULL, `x__` int(11) DEFAULT NULL, `y__` int(11) DEFAULT NULL, - `isProduction` tinyint(4) NOT NULL DEFAULT 0, - `isSelected` tinyint(1) NOT NULL DEFAULT 0, - `depth` int(11) NOT NULL DEFAULT 0, - `sons` decimal(10,0) NOT NULL DEFAULT 0, + `isProduction` tinyint(4) NOT NULL DEFAULT '0', + `isSelected` tinyint(1) NOT NULL DEFAULT '0', + `depth` int(11) NOT NULL DEFAULT '0', + `sons` decimal(10,0) NOT NULL DEFAULT '0', `parentFk` int(10) unsigned DEFAULT NULL, `path` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `chatName` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `isTeleworking` tinyint(1) DEFAULT 0, + `isTeleworking` tinyint(1) DEFAULT '0', `notificationEmail` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `name_UNIQUE` (`name`), @@ -28334,7 +28105,7 @@ CREATE TABLE `deviceProduction` ( `macWifi` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `serialNumber` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `departmentFk` int(11) DEFAULT NULL, - `isOutOfService` tinyint(1) NOT NULL DEFAULT 0, + `isOutOfService` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `device_id_UNIQUE` (`id`), UNIQUE KEY `sn_UNIQUE` (`imei`), @@ -28398,17 +28169,17 @@ DROP TABLE IF EXISTS `dms`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `dms` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `dmsTypeFk` int(11) NOT NULL DEFAULT 1, + `dmsTypeFk` int(11) NOT NULL DEFAULT '1', `reference` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, `description` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL, - `companyFk` smallint(5) unsigned NOT NULL DEFAULT 442, + `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', `hardCopyNumber` mediumint(8) unsigned DEFAULT NULL, `contentType` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, `file` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL, - `hasFile` tinyint(4) NOT NULL DEFAULT 0, + `hasFile` tinyint(4) NOT NULL DEFAULT '0', `workerFk` int(11) DEFAULT NULL, - `created` timestamp NULL DEFAULT current_timestamp(), - `warehouseFk` smallint(5) unsigned NOT NULL DEFAULT 1, + `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `warehouseFk` smallint(5) unsigned NOT NULL DEFAULT '1', PRIMARY KEY (`id`), UNIQUE KEY `emp_id` (`companyFk`,`hardCopyNumber`,`warehouseFk`), KEY `trabajador_id` (`workerFk`), @@ -28500,7 +28271,7 @@ DROP TABLE IF EXISTS `dmsRecover`; CREATE TABLE `dmsRecover` ( `id` int(11) NOT NULL AUTO_INCREMENT, `ticketFk` int(11) DEFAULT NULL, - `sign` text COLLATE utf8_unicode_ci DEFAULT NULL, + `sign` text COLLATE utf8_unicode_ci, PRIMARY KEY (`id`), KEY `ticketFk_idx` (`ticketFk`), CONSTRAINT `ticketFk` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE @@ -28546,7 +28317,7 @@ CREATE TABLE `dua` ( `bookEntried` date DEFAULT NULL, `gestdocFk` int(11) DEFAULT NULL, `customsValue` decimal(10,2) DEFAULT NULL, - `companyFk` smallint(5) unsigned NOT NULL DEFAULT 442, + `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', `ASIEN` double DEFAULT NULL, PRIMARY KEY (`id`), KEY `fk_awb_dua_awb_idx` (`awbFk`), @@ -28590,7 +28361,7 @@ CREATE TABLE `duaIntrastat` ( `id` int(11) NOT NULL AUTO_INCREMENT, `duaFk` int(11) NOT NULL, `intrastatFk` int(8) unsigned NOT NULL, - `amount` decimal(10,2) NOT NULL DEFAULT 0.00, + `amount` decimal(10,2) NOT NULL DEFAULT '0.00', PRIMARY KEY (`id`), KEY `duaIntrastat_fk1_idx` (`intrastatFk`), KEY `duaIntrastat_fk2_idx` (`duaFk`), @@ -28809,24 +28580,24 @@ DROP TABLE IF EXISTS `entry`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `entry` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `supplierFk` int(11) NOT NULL DEFAULT 644, + `supplierFk` int(11) NOT NULL DEFAULT '644', `dated` datetime NOT NULL, `ref` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `isBooked` tinyint(1) NOT NULL DEFAULT 0, - `isInventory` tinyint(1) NOT NULL DEFAULT 0, - `notes` longtext COLLATE utf8_unicode_ci DEFAULT NULL, - `isConfirmed` tinyint(1) NOT NULL DEFAULT 0, - `isOrdered` tinyint(1) NOT NULL DEFAULT 0, - `isRaid` tinyint(1) NOT NULL DEFAULT 0, - `commission` float DEFAULT 0, - `created` timestamp NOT NULL DEFAULT current_timestamp(), + `isBooked` tinyint(1) NOT NULL DEFAULT '0', + `isInventory` tinyint(1) NOT NULL DEFAULT '0', + `notes` longtext COLLATE utf8_unicode_ci, + `isConfirmed` tinyint(1) NOT NULL DEFAULT '0', + `isOrdered` tinyint(1) NOT NULL DEFAULT '0', + `isRaid` tinyint(1) NOT NULL DEFAULT '0', + `commission` float DEFAULT '0', + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `evaNotes` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `travelFk` int(11) unsigned DEFAULT NULL, - `currencyFk` tinyint(3) unsigned DEFAULT 1, - `companyFk` smallint(5) unsigned NOT NULL DEFAULT 442, + `currencyFk` tinyint(3) unsigned DEFAULT '1', + `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', `gestDocFk` int(11) DEFAULT NULL, `invoiceInFk` mediumint(8) unsigned DEFAULT NULL, - `isBlocked` tinyint(4) NOT NULL DEFAULT 0, + `isBlocked` tinyint(4) NOT NULL DEFAULT '0', `loadPriority` int(11) DEFAULT NULL, `kop` int(11) DEFAULT NULL, `sub` mediumint(8) unsigned DEFAULT NULL, @@ -29070,11 +28841,11 @@ CREATE TABLE `entryLog` ( `originFk` int(11) NOT NULL, `userFk` int(10) unsigned NOT 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, + `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `description` text CHARACTER SET utf8, `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, + `oldInstance` text COLLATE utf8_unicode_ci, + `newInstance` text COLLATE utf8_unicode_ci, `changedModelId` int(11) DEFAULT NULL, `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), @@ -29096,7 +28867,7 @@ CREATE TABLE `entryObservation` ( `id` int(11) NOT NULL AUTO_INCREMENT, `entryFk` int(11) NOT NULL, `observationTypeFk` tinyint(3) unsigned DEFAULT NULL, - `description` text COLLATE utf8_unicode_ci DEFAULT NULL, + `description` text COLLATE utf8_unicode_ci, PRIMARY KEY (`id`), UNIQUE KEY `entryFk_observationTypeFk_UNIQUE` (`entryFk`,`observationTypeFk`), KEY `observationType_id_observationTypeFk` (`observationTypeFk`), @@ -29114,7 +28885,7 @@ DROP TABLE IF EXISTS `entryShelving__`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `entryShelving__` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `entryFk` int(11) NOT NULL DEFAULT 204539, + `entryFk` int(11) NOT NULL DEFAULT '204539', `shelvingFk` varchar(10) CHARACTER SET utf8 NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `shelvingFk_UNIQUE` (`shelvingFk`), @@ -29204,7 +28975,7 @@ CREATE TABLE `envialiaConfig` ( `endRange` bigint(25) DEFAULT NULL COMMENT 'limite del rango que nos proporciona enviaría', `cargoAgency` varchar(25) COLLATE utf8_unicode_ci DEFAULT '004666' COMMENT 'numero de verdnatura dado por enviaría', `actualNumber` bigint(25) DEFAULT NULL COMMENT 'Numero actual de etiquetas imprimidas , comprimido entre startRange y endRange, ', - `isAlreadyNotified` int(1) NOT NULL DEFAULT 0 COMMENT 'Booleano para que el evento vn.envialiaRangeChecker compruebe si se a enviado una notificación\n', + `isAlreadyNotified` int(1) NOT NULL DEFAULT '0' COMMENT 'Booleano para que el evento vn.envialiaRangeChecker compruebe si se a enviado una notificación\n', `notificationThrehold` int(11) DEFAULT NULL COMMENT 'Umbral para avisar a enviaría de reseetar el startRange y endRange\nSe avisara a enviaría si el umbral + el actualNumber es superior a endRange\n', PRIMARY KEY (`serviceType`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -29238,7 +29009,7 @@ CREATE TABLE `erte` ( `workerFk` int(11) NOT NULL, `started` date DEFAULT NULL, `ended` date DEFAULT NULL, - `reduction` int(3) NOT NULL DEFAULT 1, + `reduction` int(3) NOT NULL DEFAULT '1', `monday` tinyint(1) DEFAULT NULL, `tuesday` tinyint(1) DEFAULT NULL, `wednesday` tinyint(1) DEFAULT NULL, @@ -29324,7 +29095,7 @@ DROP TABLE IF EXISTS `excuse`; CREATE TABLE `excuse` ( `id` int(11) NOT NULL AUTO_INCREMENT, `txt` varchar(255) CHARACTER SET latin1 NOT NULL, - `date` datetime NOT NULL DEFAULT current_timestamp(), + `date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -29340,25 +29111,28 @@ CREATE TABLE `expedition` ( `id` int(11) NOT NULL AUTO_INCREMENT, `agencyModeFk` int(11) NOT NULL, `ticketFk` int(10) NOT NULL, - `isBox` int(11) DEFAULT 1 COMMENT 'Este campo realmente en un campo itemFk, haciendo referencia al artículo que nos va a facturar el proveedor de transporte.\nSe debería llamar freightItemFk', - `created` timestamp NULL DEFAULT current_timestamp(), + `isBox` int(11) DEFAULT '1' COMMENT 'Este campo realmente en un campo itemFk, haciendo referencia al artículo que nos va a facturar el proveedor de transporte.\nSe debería llamar freightItemFk', + `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `isRefund` bit(1) DEFAULT b'0', `isPickUp` bit(1) DEFAULT b'0', `itemFk` int(11) DEFAULT NULL COMMENT 'Este campo hace referencia al artículo que habria que facturar si las cajas no fueran incluidos.\\nSe debería llamar packageItemFk', `counter` smallint(5) unsigned NOT NULL, - `checked` tinyint(4) NOT NULL DEFAULT 0, + `checked` tinyint(4) NOT NULL DEFAULT '0', `workerFk` int(11) DEFAULT NULL, `externalId` bigint(25) DEFAULT NULL, `packagingFk` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, + `itemPackingTypeFk` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `index1` (`agencyModeFk`), KEY `index2` (`isBox`), KEY `index3` (`created`), KEY `index4` (`ticketFk`), KEY `expedition_fk3_idx` (`packagingFk`), + KEY `expedition_itemPackingTypeFk` (`itemPackingTypeFk`), CONSTRAINT `expedition_fk1` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE, CONSTRAINT `expedition_fk2` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `expedition_fk3` FOREIGN KEY (`packagingFk`) REFERENCES `packaging` (`id`) ON UPDATE CASCADE + CONSTRAINT `expedition_fk3` FOREIGN KEY (`packagingFk`) REFERENCES `packaging` (`id`) ON UPDATE CASCADE, + CONSTRAINT `expedition_itemPackingTypeFk` FOREIGN KEY (`itemPackingTypeFk`) REFERENCES `itemPackingType` (`code`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -29502,9 +29276,9 @@ DROP TABLE IF EXISTS `expeditionPallet`; CREATE TABLE `expeditionPallet` ( `id` int(11) NOT NULL AUTO_INCREMENT, `truckFk` int(11) NOT NULL, - `built` datetime NOT NULL DEFAULT current_timestamp(), + `built` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `position` int(11) DEFAULT NULL, - `isPrint` tinyint(4) NOT NULL DEFAULT 2, + `isPrint` tinyint(4) NOT NULL DEFAULT '2', PRIMARY KEY (`id`), KEY `expeditionPallet_fk1_idx` (`truckFk`), CONSTRAINT `expeditionPallet_fk1` FOREIGN KEY (`truckFk`) REFERENCES `expeditionTruck` (`id`) ON DELETE CASCADE ON UPDATE CASCADE @@ -29600,7 +29374,7 @@ DROP TABLE IF EXISTS `expeditionScan`; CREATE TABLE `expeditionScan` ( `id` int(11) NOT NULL AUTO_INCREMENT, `expeditionFk` int(11) NOT NULL, - `scanned` datetime NOT NULL DEFAULT current_timestamp(), + `scanned` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `palletFk` int(11) NOT NULL, `workerFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), @@ -29805,9 +29579,9 @@ CREATE TABLE `expence` ( `id` varchar(10) NOT NULL, `taxTypeFk` tinyint(4) NOT NULL, `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, - `isConbase` tinyint(4) NOT NULL DEFAULT 1, - `isWithheld` tinyint(4) NOT NULL DEFAULT 0, - `isForSale` tinyint(4) NOT NULL DEFAULT 0, + `isConbase` tinyint(4) NOT NULL DEFAULT '1', + `isWithheld` tinyint(4) NOT NULL DEFAULT '0', + `isForSale` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`id`,`taxTypeFk`), KEY `iva_tipo_id` (`taxTypeFk`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -29854,13 +29628,13 @@ DROP TABLE IF EXISTS `floramondoConfig`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `floramondoConfig` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `entryFk__` int(11) DEFAULT NULL COMMENT 'ultima entrada de floramondo', `nextLanded` datetime DEFAULT NULL, `warehouseInFk` smallint(6) unsigned DEFAULT NULL, `warehouseOutFk__` smallint(6) unsigned DEFAULT NULL, `agencyModeFk__` int(11) DEFAULT NULL, `MaxLatestDeliveryHour` int(11) DEFAULT NULL, - `MaxLatestOrderHour` int(11) DEFAULT 12 COMMENT 'Hora máxima para aceptar pedidos hoy', + `MaxLatestOrderHour` int(11) DEFAULT '12' COMMENT 'Hora máxima para aceptar pedidos hoy', + `LastUpdated` datetime DEFAULT NULL, PRIMARY KEY (`id`), KEY `floramondoConfigWarehouseIn_idx` (`warehouseInFk`), KEY `floramondoConfigWarehouseOut_idx` (`warehouseOutFk__`), @@ -29947,8 +29721,8 @@ CREATE TABLE `greuge` ( `clientFk` int(10) unsigned NOT NULL, `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, `amount` decimal(10,2) NOT NULL, - `shipped` datetime NOT NULL DEFAULT current_timestamp(), - `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `shipped` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `greugeTypeFk` int(11) DEFAULT NULL, `ticketFk` int(11) DEFAULT NULL, PRIMARY KEY (`Id`), @@ -30096,8 +29870,8 @@ CREATE TABLE `ink` ( `name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `picture` blob NOT NULL, `showOrder` int(11) NOT NULL, - `ball` blob DEFAULT NULL, - `isCargex` tinyint(4) NOT NULL DEFAULT 0, + `ball` blob, + `isCargex` tinyint(4) NOT NULL DEFAULT '0', `dutchCode` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, `hex` varchar(6) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), @@ -30145,9 +29919,9 @@ DROP TABLE IF EXISTS `intrastat`; CREATE TABLE `intrastat` ( `id` int(8) unsigned zerofill NOT NULL, `description` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `import__` tinyint(4) NOT NULL DEFAULT 0, - `taxClassFk` tinyint(3) unsigned NOT NULL DEFAULT 2, - `taxCodeFk` tinyint(2) unsigned NOT NULL DEFAULT 64, + `import__` tinyint(4) NOT NULL DEFAULT '0', + `taxClassFk` tinyint(3) unsigned NOT NULL DEFAULT '2', + `taxCodeFk` tinyint(2) unsigned NOT NULL DEFAULT '64', PRIMARY KEY (`id`), KEY `iva_group_id` (`taxClassFk`), CONSTRAINT `intrastat_ibfk_1` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`id`) ON UPDATE CASCADE @@ -30212,7 +29986,7 @@ CREATE TABLE `invoiceCorrection` ( `correctedFk` int(10) unsigned NOT NULL COMMENT 'Factura rectificada', `cplusRectificationTypeFk` int(10) unsigned NOT NULL, `cplusInvoiceType477Fk` int(10) unsigned NOT NULL, - `invoiceCorrectionTypeFk` int(11) NOT NULL DEFAULT 3, + `invoiceCorrectionTypeFk` int(11) NOT NULL DEFAULT '3', PRIMARY KEY (`correctingFk`), KEY `correctedFk_idx` (`correctedFk`), KEY `invoiceCorrection_ibfk_1_idx` (`cplusRectificationTypeFk`), @@ -30275,20 +30049,20 @@ CREATE TABLE `invoiceIn` ( `supplierFk` int(11) NOT NULL, `issued` date NOT NULL COMMENT 'Fecha de emision de la factura', `supplierRef` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `isBooked` tinyint(1) NOT NULL DEFAULT 0, - `currencyFk` tinyint(3) unsigned NOT NULL DEFAULT 1, - `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), - `companyFk` smallint(5) unsigned NOT NULL DEFAULT 442, + `isBooked` tinyint(1) NOT NULL DEFAULT '0', + `currencyFk` tinyint(3) unsigned NOT NULL DEFAULT '1', + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', `docFk` int(11) DEFAULT NULL, `booked` date DEFAULT NULL COMMENT 'Fecha de contabilizacion', `operated` date DEFAULT NULL COMMENT 'Fecha de entrega de la mercancia o el suministro', - `cplusInvoiceType472Fk` int(10) unsigned DEFAULT 1, - `cplusRectificationTypeFk` int(10) unsigned DEFAULT 1, - `cplusSubjectOpFk` int(10) unsigned DEFAULT 1, - `cplusTaxBreakFk` int(10) unsigned DEFAULT 1, - `cplusTrascendency472Fk` int(10) unsigned DEFAULT 1, + `cplusInvoiceType472Fk` int(10) unsigned DEFAULT '1', + `cplusRectificationTypeFk` int(10) unsigned DEFAULT '1', + `cplusSubjectOpFk` int(10) unsigned DEFAULT '1', + `cplusTaxBreakFk` int(10) unsigned DEFAULT '1', + `cplusTrascendency472Fk` int(10) unsigned DEFAULT '1', `bookEntried` date DEFAULT NULL COMMENT 'Fecha Asiento', - `isVatDeductible` tinyint(1) NOT NULL DEFAULT 1, + `isVatDeductible` tinyint(1) NOT NULL DEFAULT '1', `withholdingSageFk` smallint(6) DEFAULT NULL COMMENT 'Tipos de retención SAGE', PRIMARY KEY (`id`), KEY `proveedor_id` (`supplierFk`), @@ -30456,10 +30230,10 @@ CREATE TABLE `invoiceInDueDay` ( `id` int(11) NOT NULL AUTO_INCREMENT, `invoiceInFk` mediumint(8) unsigned NOT NULL, `dueDated` date NOT NULL, - `bankFk` int(11) NOT NULL DEFAULT 3117, - `amount` decimal(10,2) NOT NULL DEFAULT 0.00, + `bankFk` int(11) NOT NULL DEFAULT '3117', + `amount` decimal(10,2) NOT NULL DEFAULT '0.00', `foreignValue` decimal(10,2) DEFAULT NULL, - `created` timestamp NOT NULL DEFAULT current_timestamp(), + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `recibida_id` (`invoiceInFk`), KEY `banco_id` (`bankFk`), @@ -30625,7 +30399,7 @@ DROP TABLE IF EXISTS `invoiceInSerial`; CREATE TABLE `invoiceInSerial` ( `code` varchar(2) COLLATE utf8_unicode_ci NOT NULL, `description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `cplusTerIdNifFk` int(11) NOT NULL DEFAULT 1, + `cplusTerIdNifFk` int(11) NOT NULL DEFAULT '1', `taxAreaFk` varchar(15) CHARACTER SET utf8 DEFAULT NULL, PRIMARY KEY (`code`), KEY `InvoiceInSerial_Fk1_idx` (`cplusTerIdNifFk`), @@ -30651,7 +30425,7 @@ CREATE TABLE `invoiceInTax` ( `foreignValue` decimal(10,2) DEFAULT NULL, `taxTypeSageFk` smallint(6) DEFAULT NULL COMMENT 'Tipo de IVA SAGE', `transactionTypeSageFk` tinyint(4) DEFAULT NULL COMMENT 'Tipo de transacción SAGE', - `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `recibida_id` (`invoiceInFk`), KEY `recibida_iva_ibfk_2` (`taxCodeFk`), @@ -30702,13 +30476,13 @@ DROP TABLE IF EXISTS `invoiceInTaxBookingAccount`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `invoiceInTaxBookingAccount` ( `id` int(10) NOT NULL AUTO_INCREMENT, - `effectived` timestamp NOT NULL DEFAULT current_timestamp(), + `effectived` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `account` varchar(10) COLLATE utf8_unicode_ci NOT NULL, `taxAreaFk` varchar(15) CHARACTER SET utf8 NOT NULL, `priority` int(2) unsigned DEFAULT NULL, - `taxClassFk` tinyint(3) unsigned NOT NULL DEFAULT 1, - `countryFk` mediumint(8) unsigned NOT NULL DEFAULT 1, - `rate` decimal(5,2) NOT NULL DEFAULT 0.00, + `taxClassFk` tinyint(3) unsigned NOT NULL DEFAULT '1', + `countryFk` mediumint(8) unsigned NOT NULL DEFAULT '1', + `rate` decimal(5,2) NOT NULL DEFAULT '0.00', PRIMARY KEY (`id`), KEY `invoiceInTaxBookingAccount_fk1_idx` (`taxAreaFk`), KEY `invoiceInTaxBookingAccount_fk2_idx` (`taxClassFk`), @@ -30764,28 +30538,28 @@ CREATE TABLE `invoiceOut` ( `ref` varchar(15) COLLATE utf8_unicode_ci NOT NULL, `serial` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, `issued` date DEFAULT NULL, - `amount` decimal(12,2) DEFAULT 0.00, + `amount` decimal(12,2) DEFAULT '0.00', `dued` datetime DEFAULT NULL, `bankFk` int(11) DEFAULT NULL, - `clientFk` int(11) DEFAULT 0, + `clientFk` int(11) DEFAULT '0', `Id_Remesa__` int(11) DEFAULT NULL, - `Remesar__` tinyint(1) NOT NULL DEFAULT 0, - `taxableBase7` decimal(12,2) DEFAULT 0.00, - `taxableBase16` decimal(12,2) DEFAULT 0.00, - `equ1` decimal(12,2) DEFAULT 0.00, - `equ4` decimal(12,2) DEFAULT 0.00, - `vat7` decimal(12,2) DEFAULT 0.00, - `vat16` decimal(12,2) DEFAULT 0.00, - `workerFk` int(11) DEFAULT 0, - `created` timestamp NOT NULL DEFAULT current_timestamp(), - `companyFk` smallint(5) unsigned NOT NULL DEFAULT 442, - `liquidacion__` smallint(6) DEFAULT 0, - `hasPdf` tinyint(3) unsigned NOT NULL DEFAULT 0, + `Remesar__` tinyint(1) NOT NULL DEFAULT '0', + `taxableBase7` decimal(12,2) DEFAULT '0.00', + `taxableBase16` decimal(12,2) DEFAULT '0.00', + `equ1` decimal(12,2) DEFAULT '0.00', + `equ4` decimal(12,2) DEFAULT '0.00', + `vat7` decimal(12,2) DEFAULT '0.00', + `vat16` decimal(12,2) DEFAULT '0.00', + `workerFk` int(11) DEFAULT '0', + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', + `liquidacion__` smallint(6) DEFAULT '0', + `hasPdf` tinyint(3) unsigned NOT NULL DEFAULT '0', `booked` date DEFAULT NULL, - `cplusInvoiceType477Fk` int(10) unsigned NOT NULL DEFAULT 1, - `cplusTaxBreakFk` int(10) unsigned NOT NULL DEFAULT 1, - `cplusSubjectOpFk` int(10) unsigned NOT NULL DEFAULT 1, - `cplusTrascendency477Fk` int(10) unsigned NOT NULL DEFAULT 1, + `cplusInvoiceType477Fk` int(10) unsigned NOT NULL DEFAULT '1', + `cplusTaxBreakFk` int(10) unsigned NOT NULL DEFAULT '1', + `cplusSubjectOpFk` int(10) unsigned NOT NULL DEFAULT '1', + `cplusTrascendency477Fk` int(10) unsigned NOT NULL DEFAULT '1', PRIMARY KEY (`id`,`ref`), UNIQUE KEY `Id_Factura` (`ref`), KEY `Id_Banco` (`bankFk`), @@ -30917,9 +30691,9 @@ DROP TABLE IF EXISTS `invoiceOutExpence`; CREATE TABLE `invoiceOutExpence` ( `id` int(11) NOT NULL AUTO_INCREMENT, `invoiceOutFk` int(10) unsigned NOT NULL, - `amount` decimal(10,2) NOT NULL DEFAULT 0.00, + `amount` decimal(10,2) NOT NULL DEFAULT '0.00', `expenceFk` varchar(10) CHARACTER SET utf8 NOT NULL, - `created` timestamp NULL DEFAULT current_timestamp(), + `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `invoiceOutExpence_FK_1_idx` (`invoiceOutFk`), KEY `invoiceOutExpence_FK_2_idx` (`expenceFk`), @@ -30938,11 +30712,11 @@ DROP TABLE IF EXISTS `invoiceOutSerial`; CREATE TABLE `invoiceOutSerial` ( `code` varchar(2) COLLATE utf8_unicode_ci NOT NULL, `description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `isTaxed` tinyint(1) NOT NULL DEFAULT 1, + `isTaxed` tinyint(1) NOT NULL DEFAULT '1', `taxAreaFk` varchar(15) CHARACTER SET utf8 NOT NULL DEFAULT 'NATIONAL', - `isCEE` tinyint(1) NOT NULL DEFAULT 0, - `cplusInvoiceType477Fk` int(10) unsigned DEFAULT 1, - `footNotes` longtext COLLATE utf8_unicode_ci DEFAULT NULL, + `isCEE` tinyint(1) NOT NULL DEFAULT '0', + `cplusInvoiceType477Fk` int(10) unsigned DEFAULT '1', + `footNotes` longtext COLLATE utf8_unicode_ci, PRIMARY KEY (`code`), KEY `taxAreaFk_idx` (`taxAreaFk`), CONSTRAINT `invoiceOutSeriaTaxArea` FOREIGN KEY (`taxAreaFk`) REFERENCES `taxArea` (`code`) ON UPDATE CASCADE @@ -30960,8 +30734,8 @@ CREATE TABLE `invoiceOutTax` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `invoiceOutFk` int(10) unsigned NOT NULL, `taxableBase` decimal(10,2) NOT NULL, - `created` timestamp NOT NULL DEFAULT current_timestamp(), - `vat` decimal(10,2) NOT NULL DEFAULT 0.00, + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `vat` decimal(10,2) NOT NULL DEFAULT '0.00', `pgcFk` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0000000000', PRIMARY KEY (`id`), UNIQUE KEY `invoiceOutTax_Resctriccion` (`invoiceOutFk`,`pgcFk`), @@ -30984,33 +30758,33 @@ CREATE TABLE `item` ( `equivalent` int(11) unsigned DEFAULT NULL, `name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `size` int(10) unsigned DEFAULT NULL, - `stems` int(11) DEFAULT 1, - `minPrice` double DEFAULT 0, - `isToPrint` tinyint(1) NOT NULL DEFAULT 0, - `isDeliveryNote__` tinyint(1) NOT NULL DEFAULT 0, - `taxClassFk` tinyint(4) unsigned NOT NULL DEFAULT 1, + `stems` int(11) DEFAULT '1', + `minPrice` double DEFAULT '0', + `isToPrint` tinyint(1) NOT NULL DEFAULT '0', + `isDeliveryNote__` tinyint(1) NOT NULL DEFAULT '0', + `taxClassFk` tinyint(4) unsigned NOT NULL DEFAULT '1', `family` varchar(3) COLLATE utf8_unicode_ci DEFAULT 'VT', - `box` tinyint(1) NOT NULL DEFAULT 0, + `box` tinyint(1) NOT NULL DEFAULT '0', `category` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, `originFk` tinyint(2) unsigned NOT NULL, - `doPhoto` tinyint(4) NOT NULL DEFAULT 0, + `doPhoto` tinyint(4) NOT NULL DEFAULT '0', `image` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `inkFk` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, `niche` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `intrastatFk` int(8) unsigned zerofill NOT NULL DEFAULT 06039010, - `hasMinPrice` tinyint(1) NOT NULL DEFAULT 0, - `created` timestamp NOT NULL DEFAULT current_timestamp(), - `isOnOffer` tinyint(4) NOT NULL DEFAULT 0, - `isBargain` tinyint(4) NOT NULL DEFAULT 0, + `intrastatFk` int(8) unsigned zerofill NOT NULL DEFAULT '06039010', + `hasMinPrice` tinyint(1) NOT NULL DEFAULT '0', + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `isOnOffer` tinyint(4) NOT NULL DEFAULT '0', + `isBargain` tinyint(4) NOT NULL DEFAULT '0', `comment` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, `typeFk` smallint(5) unsigned NOT NULL, - `generic` tinyint(1) unsigned zerofill NOT NULL DEFAULT 0, + `generic` tinyint(1) unsigned zerofill NOT NULL DEFAULT '0', `producerFk` mediumint(3) unsigned DEFAULT NULL, `description` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `density` int(11) NOT NULL DEFAULT 167 COMMENT 'Almacena la densidad en kg/m3 para el calculo de los portes, si no se especifica se pone por defecto la del tipo en un trigger', - `relevancy` tinyint(1) NOT NULL DEFAULT 0, + `density` int(11) NOT NULL DEFAULT '167' COMMENT 'Almacena la densidad en kg/m3 para el calculo de los portes, si no se especifica se pone por defecto la del tipo en un trigger', + `relevancy` tinyint(1) NOT NULL DEFAULT '0', `expenceFk` varchar(10) CHARACTER SET utf8 NOT NULL DEFAULT '7001000000', - `isActive` tinyint(1) NOT NULL DEFAULT 1, + `isActive` tinyint(1) NOT NULL DEFAULT '1', `longName` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `subName` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `tag5` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, @@ -31025,19 +30799,20 @@ CREATE TABLE `item` ( `value9` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `tag10` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, `value10` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `compression` decimal(5,2) NOT NULL DEFAULT 1.00 COMMENT 'Relacion de compresividad entre el volumen de las entradas en Silla y el empaquetado en los envios a clientes.\n\nMenor que 1 significa que se puede comprimir más que el volumen original.', - `minimum` decimal(10,0) unsigned NOT NULL DEFAULT 3 COMMENT 'Cantidad máxima de cajas / cubos que cabe en un nicho', - `upToDown` decimal(10,0) unsigned NOT NULL DEFAULT 0 COMMENT 'Se muestra el precio por kilo ', + `compression` decimal(5,2) NOT NULL DEFAULT '1.00' COMMENT 'Relacion de compresividad entre el volumen de las entradas en Silla y el empaquetado en los envios a clientes.\n\nMenor que 1 significa que se puede comprimir más que el volumen original.', + `minimum` decimal(10,0) unsigned NOT NULL DEFAULT '3' COMMENT 'Cantidad máxima de cajas / cubos que cabe en un nicho', + `upToDown` decimal(10,0) unsigned NOT NULL DEFAULT '0' COMMENT 'Se muestra el precio por kilo ', `supplyResponseFk` int(11) DEFAULT NULL, - `hasKgPrice` tinyint(1) NOT NULL DEFAULT 0, - `sectorFk` int(11) DEFAULT 2, - `isFloramondo` tinyint(1) NOT NULL DEFAULT 0, - `isFragile` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'articulos solo para recogidas por su fragilidad', + `hasKgPrice` tinyint(1) NOT NULL DEFAULT '0', + `sectorFk` int(11) DEFAULT '2', + `isFloramondo` tinyint(1) NOT NULL DEFAULT '0', + `isFragile` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'articulos solo para recogidas por su fragilidad', `numberOfItemsPerCask` int(11) DEFAULT NULL COMMENT 'Campo para Floramondo', `embalageCode` int(11) DEFAULT NULL COMMENT 'Campo para Floramondo', `quality` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Campo para Floramondo', `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', + `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, PRIMARY KEY (`id`), UNIQUE KEY `item_supplyResponseFk_idx` (`supplyResponseFk`), KEY `Color` (`inkFk`), @@ -31077,6 +30852,7 @@ DELIMITER ;; BEGIN DECLARE vDensity DOUBLE; DECLARE vCompression DOUBLE; + DECLARE vItemPackingType VARCHAR(1); IF NEW.density IS NULL THEN SELECT density INTO vDensity @@ -31092,7 +30868,15 @@ BEGIN SET NEW.compression = vCompression; END IF; + IF NEW.itemPackingTypeFk IS NULL THEN + SELECT itemPackingTypeFk INTO vItemPackingType + FROM vn.itemType it + WHERE id = NEW.typeFk; + + SET NEW.itemPackingTypeFk = vItemPackingType; + + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -31224,9 +31008,9 @@ CREATE TABLE `itemBotanical` ( /*!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 ;; @@ -31236,9 +31020,9 @@ 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.botanical >= '') THEN + /*IF (NEW.botanical >= '') THEN CALL util.throw('no se puede modificar el nombre botanico, use los campos genero y especie'); - END IF; + END IF;*/ END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -31295,13 +31079,13 @@ CREATE TABLE `itemCategory` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, `order` int(10) unsigned DEFAULT NULL, - `display` tinyint(4) NOT NULL DEFAULT 1, + `display` tinyint(4) NOT NULL DEFAULT '1', `color` char(6) COLLATE utf8_unicode_ci DEFAULT NULL, - `shortLife` int(11) NOT NULL DEFAULT 0 COMMENT 'Sirve para filtrar aquellos reinos que tienen precios estables', - `merchandise` tinyint(1) NOT NULL DEFAULT 1, + `shortLife` int(11) NOT NULL DEFAULT '0' COMMENT 'Sirve para filtrar aquellos reinos que tienen precios estables', + `merchandise` tinyint(1) NOT NULL DEFAULT '1', `icon` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `code` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `isReclining` tinyint(4) NOT NULL DEFAULT 1, + `isReclining` tinyint(4) NOT NULL DEFAULT '1', PRIMARY KEY (`id`), UNIQUE KEY `reino_UNIQUE` (`name`), KEY `itemCategory_idx3` (`merchandise`), @@ -31379,15 +31163,15 @@ DROP TABLE IF EXISTS `itemCost`; CREATE TABLE `itemCost` ( `itemFk` int(11) NOT NULL, `warehouseFk` smallint(6) unsigned NOT NULL, - `quantity` int(10) NOT NULL DEFAULT 0, - `rotation` decimal(10,4) NOT NULL DEFAULT 0.0000, - `cm3` int(11) NOT NULL DEFAULT 0, - `storage` decimal(10,4) NOT NULL DEFAULT 0.0000, - `handling` decimal(10,4) NOT NULL DEFAULT 0.0000, - `extraCharge` decimal(10,4) NOT NULL DEFAULT 0.0000, - `wasted` decimal(10,4) NOT NULL DEFAULT 0.0000, - `cm3delivery` int(11) NOT NULL DEFAULT 0, - `grams` int(11) NOT NULL DEFAULT 0 COMMENT 'peso en gramos de una unidad de venta', + `quantity` int(10) NOT NULL DEFAULT '0', + `rotation` decimal(10,4) NOT NULL DEFAULT '0.0000', + `cm3` int(11) NOT NULL DEFAULT '0', + `storage` decimal(10,4) NOT NULL DEFAULT '0.0000', + `handling` decimal(10,4) NOT NULL DEFAULT '0.0000', + `extraCharge` decimal(10,4) NOT NULL DEFAULT '0.0000', + `wasted` decimal(10,4) NOT NULL DEFAULT '0.0000', + `cm3delivery` int(11) NOT NULL DEFAULT '0', + `grams` int(11) NOT NULL DEFAULT '0' COMMENT 'peso en gramos de una unidad de venta', PRIMARY KEY (`itemFk`,`warehouseFk`), KEY `warehouse_id_rotacion_idx` (`warehouseFk`), CONSTRAINT `id_article_rotaci` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, @@ -31482,11 +31266,11 @@ DROP TABLE IF EXISTS `itemImageQueue`; CREATE TABLE `itemImageQueue` ( `itemFk` int(11) NOT NULL, `url` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `error` text COLLATE utf8_unicode_ci DEFAULT NULL, - `attempts` int(11) DEFAULT 0, - `created` timestamp NULL DEFAULT current_timestamp(), - `updated` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), - `priority` int(11) DEFAULT 99, + `error` text COLLATE utf8_unicode_ci, + `attempts` int(11) DEFAULT '0', + `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `updated` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `priority` int(11) DEFAULT '99', PRIMARY KEY (`itemFk`), CONSTRAINT `itemImageQueueItemIdx` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Cola para añadir las imagenes al campo vn.item.image a partir de una url'; @@ -31521,11 +31305,11 @@ CREATE TABLE `itemLog` ( `originFk` int(11) 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, + `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `description` text CHARACTER SET utf8, `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, + `oldInstance` text COLLATE utf8_unicode_ci, + `newInstance` text COLLATE utf8_unicode_ci, `changedModelId` int(11) DEFAULT NULL, `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), @@ -31536,6 +31320,20 @@ CREATE TABLE `itemLog` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `itemPackingType` +-- + +DROP TABLE IF EXISTS `itemPackingType`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `itemPackingType` ( + `code` varchar(1) COLLATE utf8_unicode_ci NOT NULL, + `description` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Define la linea de encajado para cada producto'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `itemPlacement` -- @@ -31546,11 +31344,11 @@ DROP TABLE IF EXISTS `itemPlacement`; CREATE TABLE `itemPlacement` ( `id` int(11) NOT NULL AUTO_INCREMENT, `itemFk` int(11) NOT NULL, - `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT 1, + `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT '1', `code` varchar(10) COLLATE utf8_unicode_ci NOT NULL, - `modificationDate` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `modificationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `reserve` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `pickable` int(11) unsigned NOT NULL DEFAULT 0, + `pickable` int(11) unsigned NOT NULL DEFAULT '0', `sectorFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `Id_Article_UNIQUE` (`itemFk`,`warehouseFk`), @@ -31613,9 +31411,9 @@ DROP TABLE IF EXISTS `itemPlacementSupply`; CREATE TABLE `itemPlacementSupply` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `itemFk` int(11) NOT NULL, - `quantity` decimal(10,0) NOT NULL DEFAULT 0, - `priority` int(10) unsigned NOT NULL DEFAULT 0, - `created` timestamp NOT NULL DEFAULT current_timestamp(), + `quantity` decimal(10,0) NOT NULL DEFAULT '0', + `priority` int(10) unsigned NOT NULL DEFAULT '0', + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `userFk` int(10) unsigned NOT NULL COMMENT 'Persona que crea la orden', `repoUserFk` int(10) unsigned DEFAULT NULL COMMENT 'Reponedor que la tiene asignada', `sectorFk` int(11) DEFAULT NULL, @@ -31681,7 +31479,7 @@ DROP TABLE IF EXISTS `itemProposal`; CREATE TABLE `itemProposal` ( `itemFk` int(11) NOT NULL, `mateFk` int(11) NOT NULL, - `counter` int(11) NOT NULL DEFAULT 0, + `counter` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`itemFk`,`mateFk`), KEY `itemProposal_fk2_idx` (`mateFk`), CONSTRAINT `itemProposal_fk1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, @@ -31698,7 +31496,7 @@ DROP TABLE IF EXISTS `itemRepo`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `itemRepo` ( `itemFk` int(11) NOT NULL, - `quantity` int(10) unsigned NOT NULL DEFAULT 0, + `quantity` int(10) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`itemFk`), CONSTRAINT `itemRepo_fk1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -31716,11 +31514,11 @@ CREATE TABLE `itemShelving` ( `itemFk` int(11) NOT NULL, `shelvingFk` varchar(10) CHARACTER SET utf8 NOT NULL, `shelve` varchar(2) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'A', - `deep` int(11) unsigned NOT NULL DEFAULT 1, - `quantity` int(11) NOT NULL DEFAULT 0, - `visible` int(11) NOT NULL DEFAULT 0, - `available` int(11) NOT NULL DEFAULT 0, - `created` timestamp NOT NULL DEFAULT current_timestamp(), + `deep` int(11) unsigned NOT NULL DEFAULT '1', + `quantity` int(11) NOT NULL DEFAULT '0', + `visible` int(11) NOT NULL DEFAULT '0', + `available` int(11) NOT NULL DEFAULT '0', + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `priority` int(11) unsigned DEFAULT NULL COMMENT 'El 0 es la mínima prioridad', `grouping` smallint(5) unsigned DEFAULT NULL, `packing` int(11) unsigned DEFAULT NULL, @@ -31953,7 +31751,7 @@ CREATE TABLE `itemShelvingLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, `itemShelvingFk` int(10) unsigned DEFAULT NULL, `workerFk` int(11) DEFAULT NULL, - `created` timestamp NOT NULL DEFAULT current_timestamp(), + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `accion` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, `itemFk` int(11) DEFAULT NULL, `shelvingFk` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, @@ -31979,10 +31777,10 @@ CREATE TABLE `itemShelvingPlacementSupply` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `itemShelvingFk` int(10) unsigned NOT NULL, `itemPlacementSupplyFk` int(10) unsigned NOT NULL, - `quantity` decimal(10,0) NOT NULL DEFAULT 0, - `created` timestamp NOT NULL DEFAULT current_timestamp(), + `quantity` decimal(10,0) NOT NULL DEFAULT '0', + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `userFk` int(10) unsigned NOT NULL, - `isPicked` tinyint(4) NOT NULL DEFAULT 0, + `isPicked` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `itemShelvingPlacementSupply_fk1_idx` (`itemShelvingFk`), KEY `itemShelvingPlacementSupply_fk2_idx` (`itemPlacementSupplyFk`), @@ -32053,8 +31851,8 @@ CREATE TABLE `itemShelvingSale` ( `id` int(11) NOT NULL AUTO_INCREMENT, `itemShelvingFk` int(10) unsigned NOT NULL, `saleFk` int(11) NOT NULL, - `quantity` decimal(10,0) NOT NULL DEFAULT 0, - `created` timestamp NOT NULL DEFAULT current_timestamp(), + `quantity` decimal(10,0) NOT NULL DEFAULT '0', + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `userFk` int(11) unsigned NOT NULL, PRIMARY KEY (`id`), KEY `itemShelvingSale_fk1_idx` (`itemShelvingFk`), @@ -32194,6 +31992,21 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `itemShelvingStock_byWarehouse` +-- + +DROP TABLE IF EXISTS `itemShelvingStock_byWarehouse`; +/*!50001 DROP VIEW IF EXISTS `itemShelvingStock_byWarehouse`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `itemShelvingStock_byWarehouse` ( + `itemFk` tinyint NOT NULL, + `visible` tinyint NOT NULL, + `warehouseFk` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `itemTag` -- @@ -32207,7 +32020,7 @@ CREATE TABLE `itemTag` ( `tagFk` int(11) NOT NULL, `value` varchar(50) COLLATE utf8_unicode_ci NOT NULL, `intValue` int(11) DEFAULT NULL, - `priority` int(2) NOT NULL DEFAULT 0, + `priority` int(2) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `itemFk` (`itemFk`,`tagFk`,`value`) USING BTREE, KEY `tagFk` (`tagFk`,`value`), @@ -32371,8 +32184,8 @@ CREATE TABLE `itemTaxCountry` ( `id` int(11) NOT NULL AUTO_INCREMENT, `itemFk` int(11) DEFAULT NULL, `countryFk` mediumint(8) unsigned DEFAULT NULL, - `taxClassFk` tinyint(3) unsigned NOT NULL DEFAULT 1, - `effectived` timestamp NOT NULL DEFAULT current_timestamp(), + `taxClassFk` tinyint(3) unsigned NOT NULL DEFAULT '1', + `effectived` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `itemFk_UNIQUE` (`itemFk`,`countryFk`), KEY `taxClassFK_idx` (`taxClassFk`), @@ -32417,32 +32230,33 @@ CREATE TABLE `itemType` ( `name` varchar(30) COLLATE utf8_unicode_ci NOT NULL, `gramsMin` int(11) DEFAULT NULL, `gramsMax` int(11) DEFAULT NULL, - `order` int(11) DEFAULT 0, - `temperature` tinyint(1) unsigned NOT NULL DEFAULT 0, + `order` int(11) DEFAULT '0', + `temperature` tinyint(1) unsigned NOT NULL DEFAULT '0', `categoryFk` int(10) unsigned NOT NULL, `workerFk` int(11) 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', - `created` timestamp NULL DEFAULT current_timestamp(), - `f11` tinyint(4) NOT NULL DEFAULT 0, + `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', + `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `f11` tinyint(4) NOT NULL DEFAULT '0', `father__` smallint(5) DEFAULT NULL, - `transaction` tinyint(4) NOT NULL DEFAULT 0, + `transaction` tinyint(4) NOT NULL DEFAULT '0', `making` int(10) unsigned DEFAULT NULL, `location` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, `life` smallint(5) unsigned DEFAULT NULL, - `maneuver` double NOT NULL DEFAULT 0.21, - `target` double NOT NULL DEFAULT 0.15, - `topMargin` double NOT NULL DEFAULT 0.3, - `profit` double NOT NULL DEFAULT 0.02, - `isFV` tinyint(3) DEFAULT 1, - `density` double NOT NULL DEFAULT 167 COMMENT 'Almacena el valor por defecto de la densidad en kg/m3 para el calculo de los portes aereos, en articulos se guarda la correcta', - `promo` double NOT NULL DEFAULT 0, - `isBox__` tinyint(4) NOT NULL DEFAULT 0, - `CYM__` int(11) NOT NULL DEFAULT 0, - `isPackaging` tinyint(1) NOT NULL DEFAULT 0, - `hasComponents` tinyint(1) NOT NULL DEFAULT 1, + `maneuver` double NOT NULL DEFAULT '0.21', + `target` double NOT NULL DEFAULT '0.15', + `topMargin` double NOT NULL DEFAULT '0.3', + `profit` double NOT NULL DEFAULT '0.02', + `isFV` tinyint(3) DEFAULT '1', + `density` double NOT NULL DEFAULT '167' COMMENT 'Almacena el valor por defecto de la densidad en kg/m3 para el calculo de los portes aereos, en articulos se guarda la correcta', + `promo` double NOT NULL DEFAULT '0', + `isBox__` tinyint(4) NOT NULL DEFAULT '0', + `CYM__` int(11) NOT NULL DEFAULT '0', + `isPackaging` tinyint(1) NOT NULL DEFAULT '0', + `hasComponents` tinyint(1) NOT NULL DEFAULT '1', `roleCodeFk__` varchar(14) COLLATE utf8_unicode_ci DEFAULT NULL, - `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT 1, - `compression` decimal(5,2) DEFAULT 1.00, + `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT '60', + `compression` decimal(5,2) DEFAULT '1.00', + `itemPackingTypeFk` varchar(1) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'H', PRIMARY KEY (`code`), UNIQUE KEY `tipo_id_UNIQUE` (`id`), UNIQUE KEY `Tipo_UNIQUE` (`name`,`categoryFk`), @@ -32461,28 +32275,23 @@ CREATE TABLE `itemType` ( /*!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`.`itemType_beforeUpdate` BEFORE UPDATE ON `itemType` FOR EACH ROW -- Edit trigger body code below this line. Do not edit lines above this one BEGIN - /* - Jgallego 12-08-2019 - - DECLARE strCOD VARCHAR(40); - - SELECT redCode INTO strCOD FROM config LIMIT 1; - IF strCOD <> 'tipos' - THEN - SET NEW.maneuver = OLD.maneuver ; - SET NEW.target = OLD.target ; - SET NEW.top_margin = OLD.top_margin ; - SET NEW.profit = OLD.profit ; - END IF;*/ + + IF NEW.itemPackingTypeFk != OLD.itemPackingTypeFk THEN + + UPDATE vn.item + SET itemPackingTypeFk = NEW.itemPackingTypeFk + WHERE typeFk = NEW.id; + + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -32530,7 +32339,7 @@ CREATE TABLE `itemTypeTag` ( `id` int(11) NOT NULL AUTO_INCREMENT, `itemTypeFk` smallint(5) unsigned NOT NULL, `tagFk` int(11) NOT NULL, - `priority` int(2) unsigned NOT NULL DEFAULT 0, + `priority` int(2) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `itemTypeFk_UNIQUE` (`itemTypeFk`,`tagFk`), KEY `itemTypeTagTipo_idx` (`itemTypeFk`), @@ -32604,11 +32413,11 @@ DROP TABLE IF EXISTS `labourTree`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `labourTree` ( - `id` int(11) NOT NULL DEFAULT 0, + `id` int(11) NOT NULL DEFAULT '0', `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, `lft` int(11) NOT NULL, `rgt` int(11) NOT NULL, - `depth` bigint(22) NOT NULL DEFAULT 0, + `depth` bigint(22) NOT NULL DEFAULT '0', `sons` decimal(10,0) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -32687,13 +32496,13 @@ CREATE TABLE `mail` ( `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, - `sent` tinyint(2) NOT NULL DEFAULT 0, - `creationDate` timestamp NOT NULL DEFAULT current_timestamp(), + `sent` tinyint(2) NOT NULL DEFAULT '0', + `creationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `attachment` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `status` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'OK', `senderFk` int(11) DEFAULT NULL, `recipientFk` int(11) DEFAULT NULL, - `plainTextBody` text COLLATE utf8_unicode_ci DEFAULT NULL, + `plainTextBody` text COLLATE utf8_unicode_ci, PRIMARY KEY (`id`), KEY `sent_idx` (`sent`), KEY `creation_idx` (`creationDate`) @@ -32727,7 +32536,7 @@ CREATE TABLE `mandate` ( `clientFk` int(11) NOT NULL, `companyFk` smallint(5) unsigned NOT NULL, `code` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, - `created` timestamp NULL DEFAULT current_timestamp(), + `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `finished` timestamp NULL DEFAULT NULL, `mandateTypeFk` smallint(5) NOT NULL, PRIMARY KEY (`id`), @@ -32788,8 +32597,8 @@ DROP TABLE IF EXISTS `manuscript`; CREATE TABLE `manuscript` ( `id` int(11) NOT NULL AUTO_INCREMENT, `code` varchar(45) CHARACTER SET utf8 NOT NULL, - `description` text COLLATE utf8_unicode_ci DEFAULT NULL, - `enabled` tinyint(1) NOT NULL DEFAULT 1, + `description` text COLLATE utf8_unicode_ci, + `enabled` tinyint(1) NOT NULL DEFAULT '1', PRIMARY KEY (`id`), UNIQUE KEY `code_UNIQUE` (`code`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -32825,7 +32634,7 @@ CREATE TABLE `medicalReview` ( `isFit` tinyint(1) DEFAULT NULL, `amount` double DEFAULT NULL, `invoice` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `remark` longtext COLLATE utf8_unicode_ci DEFAULT NULL, + `remark` longtext COLLATE utf8_unicode_ci, PRIMARY KEY (`id`), KEY `frgcenter_idx` (`centerFk`), KEY `frgnkWorker_idx` (`workerFk`), @@ -32846,8 +32655,8 @@ CREATE TABLE `message` ( `uuid` varchar(50) CHARACTER SET utf8 NOT NULL, `sender` varchar(50) CHARACTER SET utf8 NOT NULL, `recipient` varchar(50) CHARACTER SET utf8 NOT NULL, - `message` longtext CHARACTER SET utf8 DEFAULT NULL, - `sendDate` timestamp NULL DEFAULT current_timestamp(), + `message` longtext CHARACTER SET utf8, + `sendDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `sender` (`sender`), KEY `recipient` (`recipient`), @@ -32868,8 +32677,8 @@ CREATE TABLE `messageInbox` ( `sender` varchar(50) CHARACTER SET utf8 NOT NULL, `recipient` varchar(45) CHARACTER SET utf8 NOT NULL, `finalRecipient` varchar(50) CHARACTER SET utf8 NOT NULL, - `message` longtext CHARACTER SET utf8 DEFAULT NULL, - `sendDate` timestamp NULL DEFAULT current_timestamp(), + `message` longtext CHARACTER SET utf8, + `sendDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `read` varchar(45) CHARACTER SET utf8 NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `uuid` (`uuid`(8)), @@ -32941,7 +32750,7 @@ DROP TABLE IF EXISTS `mobileAppVersionControl`; CREATE TABLE `mobileAppVersionControl` ( `id` int(11) NOT NULL AUTO_INCREMENT, `appName` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `version` int(11) NOT NULL DEFAULT 0, + `version` int(11) NOT NULL 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 */; @@ -33009,9 +32818,9 @@ CREATE TABLE `noticeCategory` ( `keyName` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `name` varchar(50) COLLATE utf8_unicode_ci NOT NULL, `subject` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `description` text COLLATE utf8_unicode_ci DEFAULT NULL, - `isEnabled` tinyint(1) NOT NULL DEFAULT 1, - `requiredRole` int(11) NOT NULL DEFAULT 1, + `description` text COLLATE utf8_unicode_ci, + `isEnabled` tinyint(1) NOT NULL DEFAULT '1', + `requiredRole` int(11) NOT NULL DEFAULT '1', PRIMARY KEY (`id`), UNIQUE KEY `keyName_UNIQUE` (`keyName`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -33025,8 +32834,8 @@ DROP TABLE IF EXISTS `noticeSubscription`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `noticeSubscription` ( - `noticeCategoryFk` int(11) NOT NULL DEFAULT 0, - `userFk` int(10) unsigned NOT NULL DEFAULT 0, + `noticeCategoryFk` int(11) NOT NULL DEFAULT '0', + `userFk` int(10) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`noticeCategoryFk`,`userFk`), KEY `noticeSubscription_ibfk_2` (`userFk`), CONSTRAINT `noticeSubscription_ibfk_1` FOREIGN KEY (`noticeCategoryFk`) REFERENCES `noticeCategory` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, @@ -33058,7 +32867,7 @@ DROP TABLE IF EXISTS `orderTicket`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `orderTicket` ( `orderFk` int(10) unsigned NOT NULL, - `ticketFk` int(11) NOT NULL DEFAULT 0, + `ticketFk` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`ticketFk`,`orderFk`), KEY `order_id` (`orderFk`), CONSTRAINT `hedera_id` FOREIGN KEY (`orderFk`) REFERENCES `hedera`.`order` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, @@ -33077,10 +32886,10 @@ CREATE TABLE `origin` ( `id` tinyint(2) unsigned NOT NULL AUTO_INCREMENT, `code` varchar(3) COLLATE utf8_unicode_ci NOT NULL, `name` varchar(20) COLLATE utf8_unicode_ci NOT NULL, - `warehouseFk` smallint(5) unsigned DEFAULT 4, - `flag` blob DEFAULT NULL, - `nl` tinyint(4) NOT NULL DEFAULT 0, - `countryFk` mediumint(8) unsigned NOT NULL DEFAULT 1, + `warehouseFk` smallint(5) unsigned DEFAULT '4', + `flag` blob, + `nl` tinyint(4) NOT NULL DEFAULT '0', + `countryFk` mediumint(8) unsigned NOT NULL DEFAULT '1', PRIMARY KEY (`id`), UNIQUE KEY `Abreviatura` (`code`), KEY `warehouse_id` (`warehouseFk`), @@ -33190,25 +32999,25 @@ DROP TABLE IF EXISTS `packaging`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `packaging` ( `id` varchar(10) COLLATE utf8_unicode_ci NOT NULL, - `volume` decimal(10,2) DEFAULT 0.00, - `width` decimal(10,2) DEFAULT 0.00, - `depth` decimal(10,2) DEFAULT 0.00, - `height` decimal(10,2) DEFAULT 0.00, - `value` decimal(10,2) DEFAULT 0.00, - `isPackageReturnable` tinyint(1) NOT NULL DEFAULT 0, - `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `volume` decimal(10,2) DEFAULT '0.00', + `width` decimal(10,2) DEFAULT '0.00', + `depth` decimal(10,2) DEFAULT '0.00', + `height` decimal(10,2) DEFAULT '0.00', + `value` decimal(10,2) DEFAULT '0.00', + `isPackageReturnable` tinyint(1) NOT NULL DEFAULT '0', + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `packagingReturnFk` int(11) DEFAULT NULL, `lower` int(11) DEFAULT NULL, `upload` int(11) DEFAULT NULL, `base` decimal(10,2) DEFAULT NULL, `itemFk` int(11) DEFAULT NULL, `price` decimal(10,2) NOT NULL, - `isBox` tinyint(1) NOT NULL DEFAULT 0, + `isBox` tinyint(1) NOT NULL DEFAULT '0', `cubicPackage` decimal(10,2) DEFAULT NULL, - `returnCost` decimal(10,2) NOT NULL DEFAULT 0.00, + `returnCost` decimal(10,2) NOT NULL DEFAULT '0.00', `cmrName` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `freightItemFk` int(11) DEFAULT NULL, - `hasCompressionVariations` tinyint(1) DEFAULT 0 COMMENT 'Floramondo puede servirlos no llenos del todo', + `hasCompressionVariations` tinyint(1) DEFAULT '0' COMMENT 'Floramondo puede servirlos no llenos del todo', PRIMARY KEY (`id`), KEY `packaging_fk1` (`itemFk`), KEY `packaging_fk2_idx` (`freightItemFk`), @@ -33242,7 +33051,7 @@ CREATE TABLE `parking` ( `id` int(11) NOT NULL AUTO_INCREMENT, `column` varchar(5) CHARACTER SET utf8 DEFAULT '--', `row` varchar(5) CHARACTER SET utf8 DEFAULT '--', - `sectorFk` int(11) NOT NULL DEFAULT 2, + `sectorFk` int(11) NOT NULL DEFAULT '2', `code` varchar(8) CHARACTER SET utf8 DEFAULT NULL, `pickingOrder` int(11) DEFAULT NULL, PRIMARY KEY (`id`), @@ -33318,10 +33127,10 @@ CREATE TABLE `payMethod` ( `code` varchar(50) CHARACTER SET utf8 DEFAULT NULL, `name` varchar(20) COLLATE utf8_unicode_ci NOT NULL, `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, - `isNotified` tinyint(3) NOT NULL DEFAULT 1, + `outstandingDebt` tinyint(3) unsigned zerofill NOT NULL DEFAULT '000', + `graceDays` int(11) unsigned NOT NULL DEFAULT '0', + `ibanRequired` tinyint(3) DEFAULT '0', + `isNotified` tinyint(3) NOT NULL DEFAULT '1', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -33337,16 +33146,16 @@ CREATE TABLE `payment` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `received` date NOT NULL, `supplierFk` int(11) NOT NULL, - `amount` decimal(10,2) NOT NULL DEFAULT 0.00, - `currencyFk` tinyint(3) unsigned NOT NULL DEFAULT 1, + `amount` decimal(10,2) NOT NULL DEFAULT '0.00', + `currencyFk` tinyint(3) unsigned NOT NULL DEFAULT '1', `divisa` decimal(10,2) DEFAULT NULL, - `bankFk` int(11) NOT NULL DEFAULT 0, + `bankFk` int(11) NOT NULL DEFAULT '0', `payMethodFk` tinyint(3) unsigned NOT NULL, - `bankingFees` double(6,2) unsigned NOT NULL DEFAULT 0.00, + `bankingFees` double(6,2) unsigned NOT NULL DEFAULT '0.00', `concept` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL, - `companyFk` smallint(5) unsigned NOT NULL DEFAULT 442, - `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), - `isConciliated` tinyint(1) unsigned zerofill NOT NULL DEFAULT 0, + `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `isConciliated` tinyint(1) unsigned zerofill NOT NULL DEFAULT '0', `exchangeInsuranceFk` int(11) DEFAULT NULL, `dueDated` date DEFAULT NULL, PRIMARY KEY (`id`), @@ -33452,7 +33261,7 @@ DROP TABLE IF EXISTS `pcs`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `pcs` ( - `created` timestamp NULL DEFAULT current_timestamp(), + `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `routeFk` int(10) unsigned DEFAULT NULL, `id` int(11) NOT NULL AUTO_INCREMENT, `pallet` int(11) DEFAULT NULL, @@ -33469,7 +33278,7 @@ DROP TABLE IF EXISTS `pcs_graf`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `pcs_graf` ( - `id` int(11) NOT NULL DEFAULT 0, + `id` int(11) NOT NULL DEFAULT '0', `dia` date DEFAULT NULL, `created` datetime DEFAULT NULL, `box` decimal(4,0) DEFAULT NULL, @@ -33527,9 +33336,9 @@ CREATE TABLE `person` ( `birth` date DEFAULT NULL, `readerId` int(11) DEFAULT NULL, `workerFk` int(11) DEFAULT NULL, - `isDisable` tinyint(1) NOT NULL DEFAULT 0, - `isFreelance` tinyint(1) NOT NULL DEFAULT 0, - `isSsDiscounted` tinyint(1) NOT NULL DEFAULT 0, + `isDisable` tinyint(1) NOT NULL DEFAULT '0', + `isFreelance` tinyint(1) NOT NULL DEFAULT '0', + `isSsDiscounted` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `nif` (`fi`), KEY `nifIndex` (`fi`), @@ -33563,11 +33372,11 @@ CREATE TABLE `pgc` ( `code` varchar(10) COLLATE utf8_unicode_ci NOT NULL, `rate` decimal(10,2) NOT NULL, `name` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `cplusTaxBreakFk` int(10) unsigned DEFAULT 1, - `mod340` tinyint(1) NOT NULL DEFAULT 0, - `mod347` tinyint(1) NOT NULL DEFAULT 0, - `cplusTrascendency477Fk` int(10) unsigned DEFAULT 1, - `isEqualizated` tinyint(1) DEFAULT 0, + `cplusTaxBreakFk` int(10) unsigned DEFAULT '1', + `mod340` tinyint(1) NOT NULL DEFAULT '0', + `mod347` tinyint(1) NOT NULL DEFAULT '0', + `cplusTrascendency477Fk` int(10) unsigned DEFAULT '1', + `isEqualizated` tinyint(1) DEFAULT '0', PRIMARY KEY (`code`), KEY `pgc_fk1_idx` (`cplusTaxBreakFk`), KEY `pgc_fk2_idx` (`cplusTrascendency477Fk`), @@ -33618,7 +33427,7 @@ CREATE TABLE `plantpassport` ( `producerFk` mediumint(3) unsigned NOT NULL, `plantpassportAuthorityFk` mediumint(3) unsigned NOT NULL, `number` varchar(25) CHARACTER SET utf8 DEFAULT NULL, - `isRequested` tinyint(2) NOT NULL DEFAULT 0, + `isRequested` tinyint(2) NOT NULL DEFAULT '0', PRIMARY KEY (`producerFk`,`plantpassportAuthorityFk`), KEY `plantpassport_authority_idx` (`plantpassportAuthorityFk`), KEY `producer_id_idx` (`producerFk`), @@ -33758,11 +33567,11 @@ DROP TABLE IF EXISTS `ppe`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ppe` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `amortization` decimal(10,2) NOT NULL DEFAULT 0.00, + `amortization` decimal(10,2) NOT NULL DEFAULT '0.00', `firstAmortizated` date DEFAULT NULL, `lastAmortizated` date DEFAULT NULL, `finished` date DEFAULT NULL, - `value` decimal(10,2) NOT NULL DEFAULT 0.00, + `value` decimal(10,2) NOT NULL DEFAULT '0.00', `planFk` int(11) NOT NULL, `groupFk` int(11) DEFAULT NULL, `account` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, @@ -33772,10 +33581,10 @@ CREATE TABLE `ppe` ( `location` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL, `discharged` date DEFAULT NULL, `cause` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `photo` blob DEFAULT NULL, - `isInvestmentAsset` tinyint(4) NOT NULL DEFAULT 0, + `photo` blob, + `isInvestmentAsset` tinyint(4) NOT NULL DEFAULT '0', `workerFk` int(11) DEFAULT NULL, - `companyFk` smallint(5) unsigned NOT NULL DEFAULT 442, + `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', `description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `ppe_fk1_idx` (`workerFk`), @@ -33806,7 +33615,7 @@ CREATE TABLE `ppeComponent` ( `id` int(11) NOT NULL AUTO_INCREMENT, `ppeFk` int(11) NOT NULL, `invoiceInFk` mediumint(8) unsigned NOT NULL, - `amount` decimal(10,2) NOT NULL DEFAULT 0.00, + `amount` decimal(10,2) NOT NULL DEFAULT '0.00', PRIMARY KEY (`id`), KEY `ppeComponent_fk1_idx` (`ppeFk`), KEY `ppeComponent_fk2_idx` (`invoiceInFk`), @@ -33857,8 +33666,8 @@ DROP TABLE IF EXISTS `ppePlan`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ppePlan` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `rate` decimal(3,2) NOT NULL DEFAULT 1.00, - `days` int(11) NOT NULL DEFAULT 365, + `rate` decimal(3,2) NOT NULL DEFAULT '1.00', + `days` int(11) NOT NULL DEFAULT '365', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Plan de amortizacion para la tabla ppe'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -33920,9 +33729,9 @@ CREATE TABLE `priceFixed` ( `rate3` double NOT NULL, `started` date NOT NULL, `ended` date NOT NULL, - `bonus` double NOT NULL DEFAULT 0, - `warehouseFk` smallint(5) unsigned NOT NULL DEFAULT 0, - `created` timestamp NOT NULL DEFAULT current_timestamp(), + `bonus` double NOT NULL DEFAULT '0', + `warehouseFk` smallint(5) unsigned NOT NULL DEFAULT '0', + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `id` int(11) NOT NULL AUTO_INCREMENT, `grouping` smallint(5) DEFAULT NULL, `packing` int(11) DEFAULT NULL, @@ -33996,16 +33805,16 @@ CREATE TABLE `printServerQueue` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `printerFk` tinyint(3) unsigned DEFAULT NULL, `priorityFk` tinyint(3) unsigned DEFAULT NULL, - `reportFk` tinyint(3) unsigned DEFAULT 0, - `statusFk` tinyint(3) unsigned DEFAULT 1, + `reportFk` tinyint(3) unsigned DEFAULT '0', + `statusFk` tinyint(3) unsigned DEFAULT '1', `started` datetime DEFAULT NULL, `finished` datetime DEFAULT NULL, `param1` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `workerFk` int(11) DEFAULT NULL, `param2` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `param3` text COLLATE utf8_unicode_ci DEFAULT NULL, - `error` text COLLATE utf8_unicode_ci DEFAULT NULL, - `created` timestamp NOT NULL DEFAULT current_timestamp(), + `param3` text COLLATE utf8_unicode_ci, + `error` text COLLATE utf8_unicode_ci, + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `Id_Impresora_2` (`printerFk`,`priorityFk`,`reportFk`,`statusFk`,`param1`,`workerFk`,`param2`), KEY `Id_estado` (`statusFk`), @@ -34015,7 +33824,7 @@ CREATE TABLE `printServerQueue` ( KEY `Id_Trabajador` (`workerFk`), CONSTRAINT `printServerQueue_ibfk_3` FOREIGN KEY (`priorityFk`) REFERENCES `queuePriority` (`id`) ON UPDATE CASCADE, CONSTRAINT `printServerQueue_ibfk_4` FOREIGN KEY (`printerFk`) REFERENCES `vn2008`.`Impresoras` (`Id_Impresora`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -34029,15 +33838,15 @@ CREATE TABLE `printServerQueue2` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `printerFk` tinyint(3) unsigned DEFAULT NULL, `priorityFk` tinyint(3) unsigned DEFAULT NULL, - `reportFk` tinyint(3) unsigned DEFAULT 0, - `statusFk` tinyint(3) unsigned DEFAULT 1, + `reportFk` tinyint(3) unsigned DEFAULT '0', + `statusFk` tinyint(3) unsigned DEFAULT '1', `started` datetime DEFAULT NULL, `finished` datetime DEFAULT NULL, `param1` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `workerFk` int(11) DEFAULT NULL, `param2` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `param3` text COLLATE utf8_unicode_ci DEFAULT NULL, - `error` text COLLATE utf8_unicode_ci DEFAULT NULL, + `param3` text COLLATE utf8_unicode_ci, + `error` text COLLATE utf8_unicode_ci, PRIMARY KEY (`id`), UNIQUE KEY `Id_Impresora_2` (`printerFk`,`priorityFk`,`reportFk`,`statusFk`,`param1`,`workerFk`,`param2`), KEY `Id_estado` (`statusFk`), @@ -34056,9 +33865,9 @@ DROP TABLE IF EXISTS `printingQueueCheck`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `printingQueueCheck` ( - `lastCount` int(11) unsigned NOT NULL DEFAULT 0, - `lastCheckSum` int(11) unsigned NOT NULL DEFAULT 0, - `isAlreadyNotified` tinyint(2) NOT NULL DEFAULT 0, + `lastCount` int(11) unsigned NOT NULL DEFAULT '0', + `lastCheckSum` int(11) unsigned NOT NULL DEFAULT '0', + `isAlreadyNotified` tinyint(2) NOT NULL DEFAULT '0', PRIMARY KEY (`lastCount`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Comprueba que el servidor de impresion no esta parado'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -34073,7 +33882,7 @@ DROP TABLE IF EXISTS `producer`; CREATE TABLE `producer` ( `id` mediumint(3) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `isVisible` tinyint(1) NOT NULL DEFAULT 1, + `isVisible` tinyint(1) NOT NULL DEFAULT '1', PRIMARY KEY (`id`), UNIQUE KEY `name_UNIQUE` (`name`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -34137,7 +33946,7 @@ DROP TABLE IF EXISTS `profile`; CREATE TABLE `profile` ( `id` int(11) NOT NULL AUTO_INCREMENT, `personFk` int(11) DEFAULT NULL, - `profileTypeFk` int(11) NOT NULL DEFAULT 1, + `profileTypeFk` int(11) NOT NULL DEFAULT '1', PRIMARY KEY (`id`), KEY `personFk` (`personFk`), KEY `profileTypeFk` (`profileTypeFk`), @@ -34280,7 +34089,7 @@ DROP TABLE IF EXISTS `punchState`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `punchState` ( `workerFk` int(11) NOT NULL, - `state` tinyint(4) DEFAULT 1, + `state` tinyint(4) DEFAULT '1', `created` datetime DEFAULT NULL, PRIMARY KEY (`workerFk`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Table for storing punches that have cars with errors'; @@ -34294,7 +34103,7 @@ DROP TABLE IF EXISTS `queuePriority`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `queuePriority` ( - `id` tinyint(3) unsigned NOT NULL DEFAULT 0, + `id` tinyint(3) unsigned NOT NULL DEFAULT '0', `priority` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -34399,15 +34208,15 @@ DROP TABLE IF EXISTS `receipt`; 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, + `amountPaid` decimal(10,2) NOT NULL DEFAULT '0.00', + `amountUnpaid` decimal(10,2) NOT NULL DEFAULT '0.00', `payed` datetime DEFAULT NULL, `workerFk` int(11) DEFAULT NULL, - `bankFk` int(11) DEFAULT 0, - `clientFk` int(11) DEFAULT 0, - `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), - `companyFk` smallint(5) unsigned NOT NULL DEFAULT 442, - `isConciliate` tinyint(1) unsigned zerofill NOT NULL DEFAULT 0, + `bankFk` int(11) DEFAULT '0', + `clientFk` int(11) DEFAULT '0', + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', + `isConciliate` tinyint(1) unsigned zerofill NOT NULL DEFAULT '0', PRIMARY KEY (`Id`), KEY `Id_Banco` (`bankFk`), KEY `Id_Trabajador` (`workerFk`), @@ -34539,7 +34348,7 @@ CREATE TABLE `recipe` ( `originFk` tinyint(2) unsigned DEFAULT NULL, `typeFk` smallint(5) unsigned DEFAULT NULL, `longName` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `quantity` int(11) NOT NULL DEFAULT 1, + `quantity` int(11) NOT NULL DEFAULT '1', `element` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `inkFk` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), @@ -34576,11 +34385,11 @@ DROP TABLE IF EXISTS `recovery`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `recovery` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `clientFk` int(11) NOT NULL DEFAULT 0, + `clientFk` int(11) NOT NULL DEFAULT '0', `started` date NOT NULL COMMENT 'Fecha a partir de la que comienza el recobro', `finished` date DEFAULT NULL COMMENT 'Fecha en la que acaba', `amount` double NOT NULL, - `period` tinyint(3) unsigned NOT NULL DEFAULT 7 COMMENT 'numero de dias que indica cada cuanto hare el recobro', + `period` tinyint(3) unsigned NOT NULL DEFAULT '7' COMMENT 'numero de dias que indica cada cuanto hare el recobro', PRIMARY KEY (`id`), KEY `cliente_idx` (`clientFk`), CONSTRAINT `cliente333` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE, @@ -34629,7 +34438,7 @@ DROP TABLE IF EXISTS `referenceRateConfig`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `referenceRateConfig` ( - `simulatedValue` float unsigned NOT NULL DEFAULT 1.2309, + `simulatedValue` float unsigned NOT NULL DEFAULT '1.2309', PRIMARY KEY (`simulatedValue`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -34664,7 +34473,7 @@ CREATE TABLE `route` ( `vehicleFk` int(10) unsigned DEFAULT NULL, `agencyModeFk` int(11) DEFAULT NULL, `time` datetime DEFAULT NULL, - `isOk` tinyint(1) unsigned NOT NULL DEFAULT 0, + `isOk` tinyint(1) unsigned NOT NULL DEFAULT '0', `kmStart` mediumint(9) NOT NULL, `kmEnd` mediumint(9) NOT NULL, `started` datetime NOT NULL, @@ -34672,9 +34481,9 @@ CREATE TABLE `route` ( `gestdocFk` int(11) DEFAULT NULL, `cost` double unsigned DEFAULT NULL, `m3` decimal(10,1) unsigned DEFAULT NULL, - `description` text COLLATE utf8_unicode_ci DEFAULT NULL, + `description` text COLLATE utf8_unicode_ci, `zoneFk` int(11) DEFAULT NULL, - `priority` int(11) NOT NULL DEFAULT 0, + `priority` int(11) NOT NULL DEFAULT '0', `invoiceInFk` mediumint(8) unsigned DEFAULT NULL, `beachFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), @@ -34842,18 +34651,20 @@ CREATE TABLE `routeGate` ( `deviceId` varchar(30) CHARACTER SET utf8 NOT NULL, `displayText` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `status` set('idle','doing','done','') CHARACTER SET utf8 DEFAULT 'idle', - `gateAreaFk` int(11) NOT NULL DEFAULT 1, - `routeFk` int(11) DEFAULT NULL, + `gateAreaFk` int(11) NOT NULL DEFAULT '1', + `routeFk` int(11) NOT NULL, `freeTickets` int(11) DEFAULT NULL, `expeditions` int(11) DEFAULT NULL, `scanned` int(11) DEFAULT NULL, - `flag` blob DEFAULT NULL, + `flag` blob, `pallets` int(11) DEFAULT NULL, `lastScanned` datetime DEFAULT NULL, - `ready` tinyint(4) NOT NULL DEFAULT 0, - PRIMARY KEY (`deviceId`), + `ready` tinyint(4) NOT NULL DEFAULT '0', + `id` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`), + UNIQUE KEY `routeFk_UNIQUE` (`routeFk`), KEY `routeGate_fk1_idx` (`gateAreaFk`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) 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 */ ; @@ -34918,11 +34729,11 @@ CREATE TABLE `routeLog` ( `originFk` int(10) 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, + `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `description` text CHARACTER SET utf8, `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, + `oldInstance` text COLLATE utf8_unicode_ci, + `newInstance` text COLLATE utf8_unicode_ci, `changedModelId` int(11) DEFAULT NULL, `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), @@ -34989,16 +34800,16 @@ CREATE TABLE `sale` ( `itemFk` int(11) NOT NULL, `ticketFk` int(11) NOT NULL, `concept` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `quantity` decimal(10,2) NOT NULL DEFAULT 0.00, + `quantity` decimal(10,2) NOT NULL DEFAULT '0.00', `originalQuantity` double(9,1) DEFAULT NULL, - `price` decimal(10,2) DEFAULT 0.00, - `discount` tinyint(2) unsigned NOT NULL DEFAULT 0, - `priceFixed` decimal(10,2) NOT NULL DEFAULT 0.00, - `reserved` tinyint(1) NOT NULL DEFAULT 0, - `isPicked` tinyint(1) NOT NULL DEFAULT 0, - `isPriceFixed` tinyint(1) NOT NULL DEFAULT 0, - `created` timestamp NOT NULL DEFAULT current_timestamp(), - `isAdded` tinyint(1) NOT NULL DEFAULT 0, + `price` decimal(10,2) DEFAULT '0.00', + `discount` tinyint(2) unsigned NOT NULL DEFAULT '0', + `priceFixed` decimal(10,2) NOT NULL DEFAULT '0.00', + `reserved` tinyint(1) NOT NULL DEFAULT '0', + `isPicked` tinyint(1) NOT NULL DEFAULT '0', + `isPriceFixed` tinyint(1) NOT NULL DEFAULT '0', + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `isAdded` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `Id_Ticket` (`ticketFk`), KEY `itemFk_ticketFk` (`itemFk`,`ticketFk`), @@ -35021,6 +34832,18 @@ DELIMITER ;; BEGIN CALL stock.log_add('sale', NEW.id, NULL); CALL ticket_requestRecalc(NEW.ticketFk); + + IF NEW.quantity > 0 THEN + + 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 + AND (c.itemPackingTypeFk = i.itemPackingTypeFk + OR ISNULL(c.itemPackingTypeFk)) + SET c.saleTotalCount = c.saleTotalCount + 1; + + END IF; + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -35063,13 +34886,15 @@ 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 ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `sale_afterUpdate` AFTER UPDATE ON `sale` FOR EACH ROW BEGIN DECLARE vIsToSendMail BOOL; + DECLARE vPickedLines INT; + DECLARE vCollectionFk INT; IF !(NEW.id <=> OLD.id) OR !(NEW.ticketFk <=> OLD.ticketFk) @@ -35112,6 +34937,30 @@ BEGIN ); END IF; END IF; + + IF !(ABS(NEW.isPicked) <=> ABS(OLD.isPicked)) AND NEW.quantity > 0 THEN + + 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 + AND (c.itemPackingTypeFk = i.itemPackingTypeFk + OR ISNULL(c.itemPackingTypeFk)) + SET c.salePickedCount = c.salePickedCount + IF(NEW.isPicked != 0, 1, -1); + + + END IF; + + IF !(NEW.quantity <=> OLD.quantity) AND (NEW.quantity = 0 OR OLD.quantity = 0) THEN + + 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 + AND (c.itemPackingTypeFk = i.itemPackingTypeFk + OR ISNULL(c.itemPackingTypeFk)) + SET c.saleTotalCount = c.saleTotalCount + IF(OLD.quantity = 0, 1, -1); + + END IF; + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -35131,25 +34980,37 @@ DELIMITER ;; AFTER DELETE ON `sale` FOR EACH ROW BEGIN - DECLARE vIsToSendMail BOOL; + DECLARE vIsToSendMail BOOL; CALL stock.log_add('sale', NULL, OLD.id); - CALL ticket_requestRecalc(OLD.ticketFk); + CALL ticket_requestRecalc(OLD.ticketFk); SELECT COUNT(*) INTO vIsToSendMail FROM vncontrol.inter i JOIN vn.state s ON s.id = i.state_id WHERE s.code='PACKED' AND i.Id_Ticket = OLD.ticketFk - LIMIT 1; - - IF vIsToSendMail THEN + LIMIT 1; + + IF vIsToSendMail THEN CALL vn.mail_insert('jefesventas@verdnatura.es', 'noreply@verdnatura.es', CONCAT('Ticket ', OLD.ticketFk ,' eliminado artículo tras encajado' ), CONCAT('Ticket ', OLD.ticketFk ,'.
', 'Eliminado artículo ', OLD.itemFk, ' tras estado encajado del ticket.
Este email se ha generado automáticamente' ) - ); - END IF; + ); + END IF; + + IF OLD.quantity > 0 THEN + + UPDATE vn.collection c + JOIN vn.ticketCollection tc ON tc.collectionFk = c.id AND tc.ticketFk = OLD.ticketFk + JOIN vn.item i ON i.id = OLD.itemFk + AND (c.itemPackingTypeFk = i.itemPackingTypeFk + OR ISNULL(c.itemPackingTypeFk)) + SET c.saleTotalCount = c.saleTotalCount - 1, + c.salePickedCount = c.salePickedCount - 1; + + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -35167,7 +35028,7 @@ DROP TABLE IF EXISTS `saleBuy`; CREATE TABLE `saleBuy` ( `saleFk` int(11) NOT NULL, `buyFk` int(11) NOT NULL, - `created` timestamp NOT NULL DEFAULT current_timestamp(), + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `workerFk` int(11) NOT NULL, PRIMARY KEY (`saleFk`), KEY `saleBuy_FK` (`buyFk`), @@ -35208,7 +35069,7 @@ DROP TABLE IF EXISTS `saleChecked`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `saleChecked` ( `saleFk` int(11) NOT NULL, - `isChecked` int(11) NOT NULL DEFAULT 0, + `isChecked` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`saleFk`), CONSTRAINT `fk_Movimientos_checked_1` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -35242,8 +35103,8 @@ CREATE TABLE `saleComponent` ( `saleFk` int(11) NOT NULL, `componentFk` int(11) NOT NULL, `value` double NOT NULL, - `isGreuge` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'Indica si ya se ha tenido en cuenta para calcular el greuge', - `created` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `isGreuge` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Indica si ya se ha tenido en cuenta para calcular el greuge', + `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`saleFk`,`componentFk`), KEY `fk_mov_comp_idx` (`componentFk`), CONSTRAINT `mc_fk1` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, @@ -35283,8 +35144,8 @@ CREATE TABLE `saleItemShelving` ( `id` int(11) NOT NULL AUTO_INCREMENT, `saleFk` int(11) NOT NULL, `itemShelvingFk` int(10) unsigned NOT NULL, - `quantity` int(11) NOT NULL DEFAULT 0, - `isPicked` tinyint(4) NOT NULL DEFAULT 0, + `quantity` int(11) NOT NULL DEFAULT '0', + `isPicked` tinyint(4) NOT NULL DEFAULT '0', `ubication` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `saleItemShelving_fk1_idx` (`itemShelvingFk`) @@ -35303,7 +35164,7 @@ CREATE TABLE `saleMistake` ( `saleFk` int(11) NOT NULL, `userFk` int(11) NOT NULL, `typeFk` int(11) NOT NULL, - `created` timestamp NOT NULL DEFAULT current_timestamp(), + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `saleMistake_fk1_idx` (`saleFk`), KEY `saleMistake_fk2_idx` (`userFk`), @@ -35396,8 +35257,8 @@ DROP TABLE IF EXISTS `saleTracking`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `saleTracking` ( `saleFk` int(11) NOT NULL, - `isChecked` tinyint(3) unsigned NOT NULL DEFAULT 0, - `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `isChecked` tinyint(3) unsigned NOT NULL DEFAULT '0', + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `originalQuantity` double DEFAULT NULL, `workerFk` int(11) NOT NULL, `actionFk` int(11) DEFAULT NULL, @@ -35420,7 +35281,7 @@ CREATE TABLE `saleTracking` ( /*!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 ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`saleTracking_beforeInsert` BEFORE INSERT ON `saleTracking` FOR EACH ROW BEGIN @@ -35431,6 +35292,36 @@ BEGIN IF(NEW.stateFk = 8) THEN SET NEW.actionFk = 4; END IF; + +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER saleTracking_After_Insert +AFTER INSERT +ON saleTracking FOR EACH ROW +BEGIN + + IF NEW.isChecked THEN + + UPDATE vn.sale s + SET s.isPicked = TRUE + WHERE s.id = NEW.saleFk + AND s.isPicked = 0; + + END IF; + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -35582,9 +35473,9 @@ CREATE TABLE `sample` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `code` varchar(20) CHARACTER SET utf8 NOT NULL, `description` varchar(105) COLLATE utf8_unicode_ci NOT NULL, - `isVisible` tinyint(1) unsigned NOT NULL DEFAULT 1, - `hasCompany` tinyint(1) unsigned NOT NULL DEFAULT 0, - `hasPreview` tinyint(1) unsigned NOT NULL DEFAULT 1, + `isVisible` tinyint(1) unsigned NOT NULL DEFAULT '1', + `hasCompany` tinyint(1) unsigned NOT NULL DEFAULT '0', + `hasPreview` tinyint(1) unsigned NOT NULL DEFAULT '1', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -35599,16 +35490,18 @@ DROP TABLE IF EXISTS `sector`; CREATE TABLE `sector` ( `id` int(11) NOT NULL AUTO_INCREMENT, `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT 1, - `isPreviousPreparedByPacking` tinyint(4) NOT NULL DEFAULT 1, + `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT '1', + `isPreviousPreparedByPacking` tinyint(4) NOT NULL DEFAULT '1', `code` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, `pickingPlacement` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, `path` int(11) DEFAULT NULL, - `isPreviousPrepared` tinyint(1) NOT NULL DEFAULT 0, - `isPackagingArea` tinyint(1) NOT NULL DEFAULT 0, + `isPreviousPrepared` tinyint(1) NOT NULL DEFAULT '0', + `isPackagingArea` tinyint(1) NOT NULL DEFAULT '0', `labelReport` int(11) DEFAULT NULL, `sonFk` int(11) DEFAULT NULL, - `isMain` tinyint(1) NOT NULL DEFAULT 0, + `isMain` tinyint(1) NOT NULL DEFAULT '0', + `itemPackingTypeFk` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, + `workerFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`,`warehouseFk`), UNIQUE KEY `code_UNIQUE` (`code`), KEY `sector_fk1_idx` (`warehouseFk`), @@ -35629,7 +35522,7 @@ CREATE TABLE `sharingCart` ( `started` date NOT NULL, `ended` date NOT NULL, `workerSubstitute` int(11) NOT NULL, - `created` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `workerFk_UNIQUE` (`workerFk`,`started`,`ended`,`workerSubstitute`), KEY `Suplent` (`workerSubstitute`), @@ -35727,7 +35620,7 @@ CREATE TABLE `sharingCartDaily` ( `ownerFk` int(11) NOT NULL, `substituteFk` int(11) NOT NULL, `dated` date NOT NULL, - `created` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `sharingCartDailyWorker_idx` (`ownerFk`,`dated`), KEY `sharingCartDailySubstitute_idx` (`substituteFk`), @@ -35805,9 +35698,9 @@ DROP TABLE IF EXISTS `shelving`; CREATE TABLE `shelving` ( `code` varchar(10) CHARACTER SET utf8 NOT NULL, `parkingFk` int(11) DEFAULT NULL, - `isPrinted` tinyint(4) NOT NULL DEFAULT 0, + `isPrinted` tinyint(4) NOT NULL DEFAULT '0', `priority` int(11) DEFAULT NULL, - `parked` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `parked` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `userFk` int(11) DEFAULT NULL, PRIMARY KEY (`code`), KEY `shelving_fk1_idx` (`parkingFk`), @@ -35858,9 +35751,9 @@ CREATE TABLE `sinister` ( `supplierFk` int(11) NOT NULL, `clientFk` int(11) NOT NULL, `amount` decimal(10,2) NOT NULL, - `created` timestamp NOT NULL DEFAULT current_timestamp(), - `insureRate` decimal(3,2) NOT NULL DEFAULT 0.75, - `isBooked` tinyint(4) NOT NULL DEFAULT 0, + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `insureRate` decimal(3,2) NOT NULL DEFAULT '0.75', + `isBooked` tinyint(4) NOT NULL DEFAULT '0', `workerFk` int(11) NOT NULL, `companyFk` smallint(5) unsigned NOT NULL, PRIMARY KEY (`id`), @@ -35885,10 +35778,10 @@ DROP TABLE IF EXISTS `sinisterDetail`; CREATE TABLE `sinisterDetail` ( `id` int(11) NOT NULL, `sinisterFk` int(11) NOT NULL, - `created` timestamp NOT NULL DEFAULT current_timestamp(), + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `amountIn` decimal(10,2) DEFAULT NULL, `amountOut` decimal(10,2) DEFAULT NULL, - `isConciliated` tinyint(1) NOT NULL DEFAULT 0, + `isConciliated` tinyint(1) NOT NULL DEFAULT '0', `workerFk` int(11) NOT NULL, `bankFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), @@ -35915,9 +35808,9 @@ CREATE TABLE `sms` ( `sender` varchar(15) CHARACTER SET utf8 NOT NULL DEFAULT '693474205', `destination` varchar(15) CHARACTER SET utf8 NOT NULL, `message` varchar(160) COLLATE utf8_unicode_ci NOT NULL, - `statusCode` smallint(9) NOT NULL DEFAULT 0, + `statusCode` smallint(9) NOT NULL DEFAULT '0', `status` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `created` timestamp NOT NULL DEFAULT current_timestamp(), + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -36041,21 +35934,21 @@ DROP TABLE IF EXISTS `sorter`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `sorter` ( - `id` int(11) NOT NULL DEFAULT 0, + `id` int(11) NOT NULL DEFAULT '0', `created` datetime NOT NULL, `routeFk` int(10) unsigned NOT NULL, `ticketFk` int(10) NOT NULL, - `isBox` int(11) DEFAULT 1, + `isBox` int(11) DEFAULT '1', `itemFk` int(11) DEFAULT NULL, - `width` decimal(10,2) DEFAULT 0.00, - `depth` decimal(10,2) DEFAULT 0.00, - `height` decimal(10,2) DEFAULT 0.00, - `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT 1, - `weight` decimal(5,2) NOT NULL DEFAULT 0.00, - `buildingOrder` int(5) NOT NULL DEFAULT 0, + `width` decimal(10,2) DEFAULT '0.00', + `depth` decimal(10,2) DEFAULT '0.00', + `height` decimal(10,2) DEFAULT '0.00', + `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT '1', + `weight` decimal(5,2) NOT NULL DEFAULT '0.00', + `buildingOrder` int(5) NOT NULL DEFAULT '0', `ETD` time NOT NULL DEFAULT '23:59:00', `palletOrder` int(5) DEFAULT NULL, - `lungGrow` int(11) DEFAULT 0, + `lungGrow` int(11) DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -36069,9 +35962,9 @@ DROP TABLE IF EXISTS `specialPrice`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `specialPrice` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `clientFk` int(11) NOT NULL DEFAULT 0, - `itemFk` int(11) NOT NULL DEFAULT 0, - `value` double NOT NULL DEFAULT 0, + `clientFk` int(11) NOT NULL DEFAULT '0', + `itemFk` int(11) NOT NULL DEFAULT '0', + `value` double NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `Id_Cliente_2` (`clientFk`,`itemFk`), KEY `Id_Article` (`itemFk`), @@ -36106,7 +35999,7 @@ CREATE TABLE `specie` ( /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`z-developer`@`%`*/ /*!50003 TRIGGER `vn`.`specie_BEFORE_INSERT` BEFORE INSERT ON `specie` FOR EACH ROW +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`specie_BEFORE_INSERT` BEFORE INSERT ON `specie` FOR EACH ROW BEGIN SET NEW.name = LCASE(NEW.name); END */;; @@ -36124,7 +36017,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`z-developer`@`%`*/ /*!50003 TRIGGER `vn`.`specie_BEFORE_UPDATE` BEFORE UPDATE ON `specie` FOR EACH ROW +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`specie_BEFORE_UPDATE` BEFORE UPDATE ON `specie` FOR EACH ROW BEGIN SET NEW.name = LCASE(NEW.name); END */;; @@ -36134,6 +36027,25 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +-- +-- Table structure for table `starredModule` +-- + +DROP TABLE IF EXISTS `starredModule`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `starredModule` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `workerFk` int(10) NOT NULL, + `moduleFk` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`id`), + KEY `starred_workerFk` (`workerFk`), + KEY `starred_moduleFk` (`moduleFk`), + CONSTRAINT `starred_moduleFk` FOREIGN KEY (`moduleFk`) REFERENCES `salix`.`module` (`code`) ON UPDATE CASCADE, + CONSTRAINT `starred_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `state` -- @@ -36145,18 +36057,18 @@ CREATE TABLE `state` ( `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(15) COLLATE utf8_unicode_ci NOT NULL, `order` tinyint(3) unsigned DEFAULT NULL, - `alertLevel` int(11) NOT NULL DEFAULT 0, + `alertLevel` int(11) NOT NULL DEFAULT '0', `code` varchar(45) CHARACTER SET utf8 NOT NULL, `sectorProdPriority` tinyint(3) DEFAULT NULL, `nextStateFk` tinyint(4) NOT NULL COMMENT 'Estado al que tiene que cambiar el ticket despues de preparacion previa', - `isPreviousPreparable` tinyint(1) NOT NULL DEFAULT 0, - `isPicked` tinyint(1) NOT NULL DEFAULT 0, - `isPreparable` tinyint(1) NOT NULL DEFAULT 0, - `semaphore` int(11) NOT NULL DEFAULT 0, - `isPrintable` tinyint(4) NOT NULL DEFAULT 0, - `isOK` tinyint(4) NOT NULL DEFAULT 0, - `graphCategory` int(11) NOT NULL DEFAULT 0, - `isNotValidated` tinyint(1) DEFAULT 0 COMMENT 'Los tienen que ser validados por un comercial para prepararse', + `isPreviousPreparable` tinyint(1) NOT NULL DEFAULT '0', + `isPicked` tinyint(1) NOT NULL DEFAULT '0', + `isPreparable` tinyint(1) NOT NULL DEFAULT '0', + `semaphore` int(11) NOT NULL DEFAULT '0', + `isPrintable` tinyint(4) NOT NULL DEFAULT '0', + `isOK` tinyint(4) NOT NULL DEFAULT '0', + `graphCategory` int(11) NOT NULL DEFAULT '0', + `isNotValidated` tinyint(1) DEFAULT '0' COMMENT 'Los tienen que ser validados por un comercial para prepararse', PRIMARY KEY (`id`), UNIQUE KEY `code_UNIQUE` (`code`), KEY `state_id3` (`semaphore`) @@ -36175,7 +36087,7 @@ CREATE TABLE `stockBuyed` ( `user` int(10) unsigned DEFAULT NULL, `buyed` decimal(10,2) DEFAULT NULL, `date` date DEFAULT NULL, - `creationDate` timestamp NULL DEFAULT current_timestamp(), + `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `reserved` decimal(10,2) DEFAULT NULL, `requested` decimal(10,2) DEFAULT NULL, PRIMARY KEY (`id`), @@ -36195,7 +36107,7 @@ DROP TABLE IF EXISTS `stowaway`; CREATE TABLE `stowaway` ( `id` int(11) NOT NULL COMMENT 'ticket pequeño', `shipFk` int(11) NOT NULL COMMENT 'ticket grande', - `created` timestamp NOT NULL DEFAULT current_timestamp(), + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Tickets polizones y sus naves de embarque'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -36216,26 +36128,27 @@ CREATE TABLE `supplier` ( `provinceFk` smallint(5) unsigned DEFAULT NULL, `countryFk` mediumint(8) unsigned DEFAULT NULL, `nif` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, - `isOfficial` tinyint(1) NOT NULL DEFAULT 1, - `isFarmer` tinyint(1) NOT NULL DEFAULT 0, + `isOfficial` tinyint(1) NOT NULL DEFAULT '1', + `isFarmer` tinyint(1) NOT NULL DEFAULT '0', `retAccount` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, `phone` varchar(16) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, `Fax__` varchar(16) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, - `commission` float NOT NULL DEFAULT 0, + `commission` float NOT NULL DEFAULT '0', `nickname` varchar(45) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, `payMethodFk` tinyint(3) unsigned NOT NULL, `payDay` tinyint(4) unsigned DEFAULT NULL, - `payDemFk` tinyint(3) unsigned NOT NULL DEFAULT 7, - `created` timestamp NOT NULL DEFAULT current_timestamp(), - `isSerious` tinyint(1) unsigned zerofill DEFAULT 1, - `note` text CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, + `payDemFk` tinyint(3) unsigned NOT NULL DEFAULT '7', + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `isSerious` tinyint(1) unsigned zerofill DEFAULT '1', + `note` text CHARACTER SET utf8 COLLATE utf8_unicode_ci, `postcodeFk` int(11) unsigned DEFAULT NULL, `postCode` char(5) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, - `isActive` tinyint(4) DEFAULT 1, + `isActive` tinyint(4) DEFAULT '1', `taxTypeSageFk` smallint(6) DEFAULT NULL COMMENT 'Tipo de IVA SAGE', `withholdingSageFk` smallint(6) DEFAULT NULL COMMENT 'Tipos de retención SAGE', `transactionTypeSageFk` tinyint(4) DEFAULT NULL COMMENT 'Ti po de transacción SAGE', - `isTrucker` tinyint(1) NOT NULL DEFAULT 0, + `isTrucker` tinyint(1) NOT NULL DEFAULT '0', + `workerFk` int(11) DEFAULT NULL COMMENT 'Responsible for approving invoices', `supplierActivityFk` varchar(45) NOT NULL DEFAULT 'flowersPlants', `healthRegister` varchar(45) DEFAULT NULL, PRIMARY KEY (`id`), @@ -36250,6 +36163,7 @@ CREATE TABLE `supplier` ( KEY `supplier_withholdingFk_idx` (`withholdingSageFk`), KEY `supplier_transactionFk_idx` (`transactionTypeSageFk`), KEY `suppplier_supplierActivityFk` (`supplierActivityFk`), + KEY `supplier_workerFk` (`workerFk`), CONSTRAINT `Id_Pais` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE, CONSTRAINT `pay_dem_id` FOREIGN KEY (`payDemFk`) REFERENCES `payDem` (`id`) ON UPDATE CASCADE, CONSTRAINT `pay_met_id` FOREIGN KEY (`payMethodFk`) REFERENCES `payMethod` (`id`) ON UPDATE CASCADE, @@ -36257,6 +36171,7 @@ CREATE TABLE `supplier` ( CONSTRAINT `supplier_taxTypeFk` FOREIGN KEY (`taxTypeSageFk`) REFERENCES `sage`.`TiposIva` (`CodigoIva`) ON UPDATE CASCADE, CONSTRAINT `supplier_transactionFk` FOREIGN KEY (`transactionTypeSageFk`) REFERENCES `sage`.`TiposTransacciones` (`CodigoTransaccion`) ON UPDATE CASCADE, CONSTRAINT `supplier_withholdingFk` FOREIGN KEY (`withholdingSageFk`) REFERENCES `sage`.`TiposRetencion` (`CodigoRetencion`) ON UPDATE CASCADE, + CONSTRAINT `supplier_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `suppplier_supplierActivityFk` FOREIGN KEY (`supplierActivityFk`) REFERENCES `supplierActivity` (`code`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -36340,7 +36255,7 @@ CREATE TABLE `supplierContact` ( `phone` varchar(16) COLLATE utf8_unicode_ci DEFAULT NULL, `mobile` varchar(16) COLLATE utf8_unicode_ci DEFAULT NULL, `email` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `observation` text COLLATE utf8_unicode_ci DEFAULT NULL, + `observation` text COLLATE utf8_unicode_ci, `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `supplier_id` (`supplierFk`), @@ -36359,13 +36274,13 @@ CREATE TABLE `supplierExpense` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `dated` date NOT NULL, `supplierFk` int(11) NOT NULL, - `currencyFk` tinyint(3) unsigned NOT NULL DEFAULT 2, - `amount` decimal(10,2) NOT NULL DEFAULT 0.00, + `currencyFk` tinyint(3) unsigned NOT NULL DEFAULT '2', + `amount` decimal(10,2) NOT NULL DEFAULT '0.00', `description` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `companyFk` smallint(5) unsigned NOT NULL DEFAULT 442, + `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', `dmsFk` int(11) DEFAULT NULL, - `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), - `isConciliated` tinyint(1) unsigned zerofill NOT NULL DEFAULT 0, + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `isConciliated` tinyint(1) unsigned zerofill NOT NULL DEFAULT '0', `dueDated` date NOT NULL, PRIMARY KEY (`id`), KEY `empresa_id` (`companyFk`), @@ -36393,11 +36308,11 @@ CREATE TABLE `supplierLog` ( `originFk` int(11) NOT NULL, `userFk` int(10) unsigned NOT 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, + `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `description` text CHARACTER SET utf8, `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, + `oldInstance` text COLLATE utf8_unicode_ci, + `newInstance` text COLLATE utf8_unicode_ci, `changedModelId` int(11) DEFAULT NULL, `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), @@ -36473,8 +36388,8 @@ CREATE TABLE `tag` ( `id` int(11) NOT NULL AUTO_INCREMENT, `code` varchar(45) CHARACTER SET utf8 DEFAULT NULL, `name` varchar(25) COLLATE utf8_unicode_ci NOT NULL, - `isFree` tinyint(1) NOT NULL DEFAULT 1, - `isQuantitatif` tinyint(4) NOT NULL DEFAULT 0, + `isFree` tinyint(1) NOT NULL DEFAULT '1', + `isQuantitatif` tinyint(4) NOT NULL DEFAULT '0', `sourceTable` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `unit` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `ediTypeFk` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, @@ -36609,16 +36524,16 @@ CREATE TABLE `taxCode` ( `dated` date NOT NULL, `code` varchar(10) CHARACTER SET utf8 NOT NULL, `taxTypeFk` tinyint(2) NOT NULL, - `rate` decimal(4,1) NOT NULL DEFAULT 0.0, - `equalizationTax` decimal(4,1) NOT NULL DEFAULT 0.0, + `rate` decimal(4,1) NOT NULL DEFAULT '0.0', + `equalizationTax` decimal(4,1) NOT NULL DEFAULT '0.0', `type` char(1) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Solo rellenar si en el asiento ira en el DEBE', - `link` tinyint(4) unsigned DEFAULT 0 COMMENT 'las que tienen el mismo valor se contabilizan emparejadas', - `isActive` tinyint(2) NOT NULL DEFAULT 1, - `updated` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `link` tinyint(4) unsigned DEFAULT '0' COMMENT 'las que tienen el mismo valor se contabilizan emparejadas', + `isActive` tinyint(2) NOT NULL DEFAULT '1', + `updated` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `transactionCode` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Código de Transacción de SAGE', `operationCode` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Código de operaciones de SAGE', `taxCode` int(4) DEFAULT NULL COMMENT 'Código de IVA SAGE', - `isIntracommunity` tinyint(2) DEFAULT 0, + `isIntracommunity` tinyint(2) DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `taxCode_dated_IDX` (`dated`,`taxTypeFk`,`type`,`link`) USING BTREE, KEY `iva_tipo_id` (`taxTypeFk`), @@ -36638,7 +36553,7 @@ DROP TABLE IF EXISTS `taxType`; CREATE TABLE `taxType` ( `id` tinyint(2) NOT NULL AUTO_INCREMENT, `nickname` varchar(6) COLLATE utf8_unicode_ci NOT NULL, - `isAccrued` tinyint(4) NOT NULL DEFAULT 0, + `isAccrued` tinyint(4) NOT NULL DEFAULT '0', `serial` char(1) COLLATE utf8_unicode_ci DEFAULT NULL, `TIPOOPE` varchar(1) COLLATE utf8_unicode_ci NOT NULL DEFAULT ' ' COMMENT 'respetar el nombre de la columna, se utiliza en contaplus', `description` varchar(100) COLLATE utf8_unicode_ci NOT NULL, @@ -36673,34 +36588,34 @@ DROP TABLE IF EXISTS `ticket`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ticket` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `clientFk` int(11) NOT NULL DEFAULT 0, - `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT 1, + `clientFk` int(11) NOT NULL DEFAULT '0', + `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT '1', `shipped` datetime NOT NULL, `nickname` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `notes` longtext COLLATE utf8_unicode_ci DEFAULT NULL, + `notes` longtext COLLATE utf8_unicode_ci, `refFk` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, `invoiceOutFk` int(10) unsigned DEFAULT NULL COMMENT 'eliminar', - `isBooked` tinyint(1) NOT NULL DEFAULT 0, - `addressFk` int(11) NOT NULL DEFAULT 0, + `isBooked` tinyint(1) NOT NULL DEFAULT '0', + `addressFk` int(11) NOT NULL DEFAULT '0', `workerFk` int(11) DEFAULT NULL, `observations` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'eliminar', - `isSigned` tinyint(1) NOT NULL DEFAULT 0, - `isLabeled` tinyint(1) NOT NULL DEFAULT 0, - `isPrinted` tinyint(1) NOT NULL DEFAULT 0, - `packages` smallint(10) unsigned DEFAULT 0, + `isSigned` tinyint(1) NOT NULL DEFAULT '0', + `isLabeled` tinyint(1) NOT NULL DEFAULT '0', + `isPrinted` tinyint(1) NOT NULL DEFAULT '0', + `packages` smallint(10) unsigned DEFAULT '0', `location` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, - `hour` int(11) DEFAULT 0, - `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), - `isBlocked` tinyint(1) NOT NULL DEFAULT 1, + `hour` int(11) DEFAULT '0', + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `isBlocked` tinyint(1) NOT NULL DEFAULT '1', `solution` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL, `routeFk` int(10) unsigned DEFAULT NULL, `priority` tinyint(3) unsigned DEFAULT NULL, - `hasPriority` tinyint(1) unsigned NOT NULL DEFAULT 1, - `companyFk` smallint(5) unsigned NOT NULL DEFAULT 442, + `hasPriority` tinyint(1) unsigned NOT NULL DEFAULT '1', + `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', `agencyModeFk` int(11) DEFAULT NULL, `landed` date DEFAULT NULL, - `isBoxed` tinyint(2) NOT NULL DEFAULT 0, - `isDeleted` tinyint(2) NOT NULL DEFAULT 0, + `isBoxed` tinyint(2) NOT NULL DEFAULT '0', + `isDeleted` tinyint(2) NOT NULL DEFAULT '0', `zoneFk` int(11) DEFAULT NULL, `collectionFk` int(11) DEFAULT NULL, `zonePrice` decimal(10,2) DEFAULT NULL, @@ -36887,6 +36802,11 @@ BEGIN `body` = CONCAT(account.myUserGetName(), ' ha modificado el ticket ', NEW.id); END IF; + + IF !(DATE(NEW.shipped) <=> DATE(OLD.shipped)) AND DATE(NEW.shipped) = CURDATE() THEN + INSERT INTO tmp.ticketDate_updated(ticketFk, oldShipped, newShipped, workerFk) + VALUES (NEW.id, OLD.shipped, NEW.shipped, vn.getUser()); + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -36927,16 +36847,51 @@ CREATE TABLE `ticketCollection` ( `id` int(11) NOT NULL AUTO_INCREMENT, `ticketFk` int(11) NOT NULL, `collectionFk` int(11) NOT NULL, - `created` timestamp NOT NULL DEFAULT current_timestamp(), + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `level` int(11) DEFAULT NULL, - `wagon` int(11) NOT NULL DEFAULT 0, + `wagon` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), - UNIQUE KEY `ticketCollection_fk2_idx` (`ticketFk`), KEY `ticketCollection_fk1_idx` (`collectionFk`), + KEY `ticketCollection_fk2_idx` (`ticketFk`), 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; /*!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 ticketCollection_AFTER_DELETE +AFTER DELETE +ON ticketCollection FOR EACH ROW +BEGIN + + DECLARE vTicketsInCollection INT; + + SELECT count(*) INTO vTicketsInCollection + FROM vn.ticketCollection tc + WHERE collectionFk = OLD.collectionFk + AND tc.id != OLD.id; + + IF vTicketsInCollection = 0 THEN + + DELETE FROM vn.collection WHERE id = OLD.collectionFk; + + END IF; + + -- CALL vn.ticketStateUpdate(OLD.ticketFk, 'OK'); + +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 `ticketConfig` @@ -37017,13 +36972,17 @@ DROP TABLE IF EXISTS `ticketDown`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ticketDown` ( `ticketFk` int(11) NOT NULL, - `created` timestamp NOT NULL DEFAULT current_timestamp(), - `selected` int(11) NOT NULL DEFAULT 0, - PRIMARY KEY (`ticketFk`), + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `selected` int(11) NOT NULL DEFAULT '0', + `collectionFk` int(11) NOT NULL, + `id` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`), KEY `created_idx` (`created`), KEY `selected_idx` (`selected`), + KEY `ticketDown_FK` (`collectionFk`), + CONSTRAINT `ticketDown_FK` FOREIGN KEY (`collectionFk`) REFERENCES `collection` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketDown_fk1` FOREIGN KEY (`selected`) REFERENCES `ticketDown_SelectionType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Cola de impresion para los tickets que se van a solicitar al altillo'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Cola de impresion para los tickets que se van a solicitar al altillo'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -37066,7 +37025,7 @@ DROP TABLE IF EXISTS `ticketLastState`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ticketLastState` ( - `ticketFk` int(11) NOT NULL DEFAULT 0, + `ticketFk` int(11) NOT NULL DEFAULT '0', `ticketTrackingFk` int(11) NOT NULL, `name` varchar(15) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`ticketFk`), @@ -37076,6 +37035,34 @@ CREATE TABLE `ticketLastState` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Temporary table structure for view `ticketLastUpdated` +-- + +DROP TABLE IF EXISTS `ticketLastUpdated`; +/*!50001 DROP VIEW IF EXISTS `ticketLastUpdated`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `ticketLastUpdated` ( + `ticketFk` tinyint NOT NULL, + `lastUpdated` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `ticketLastUpdatedList` +-- + +DROP TABLE IF EXISTS `ticketLastUpdatedList`; +/*!50001 DROP VIEW IF EXISTS `ticketLastUpdatedList`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `ticketLastUpdatedList` ( + `ticketFk` tinyint NOT NULL, + `created` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `ticketLog` -- @@ -37088,11 +37075,11 @@ CREATE TABLE `ticketLog` ( `originFk` int(11) NOT NULL, `userFk` int(10) unsigned DEFAULT NULL, `action` set('insert','update','delete','select') COLLATE utf8_unicode_ci NOT NULL, - `creationDate` timestamp NULL DEFAULT current_timestamp(), - `description` text CHARACTER SET utf8 DEFAULT NULL, + `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `description` text CHARACTER SET utf8, `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, + `oldInstance` text COLLATE utf8_unicode_ci, + `newInstance` text COLLATE utf8_unicode_ci, `changedModelId` int(11) DEFAULT NULL, `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), @@ -37150,7 +37137,7 @@ DROP TABLE IF EXISTS `ticketPackage`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ticketPackage` ( `ticket` int(11) NOT NULL, - `counter` int(10) unsigned NOT NULL DEFAULT 0, + `counter` int(10) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`ticket`), CONSTRAINT `ticketPackage_ticketFk` FOREIGN KEY (`ticket`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -37167,8 +37154,8 @@ CREATE TABLE `ticketPackaging` ( `id` int(11) NOT NULL AUTO_INCREMENT, `ticketFk` int(11) NOT NULL, `packagingFk` varchar(10) COLLATE utf8_unicode_ci NOT NULL, - `quantity` int(10) DEFAULT 0, - `created` timestamp NOT NULL DEFAULT current_timestamp(), + `quantity` int(10) DEFAULT '0', + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `pvp` double DEFAULT NULL, `workerFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), @@ -37214,7 +37201,7 @@ CREATE TABLE `ticketPackagingStartingStock` ( `itemFk` int(11) NOT NULL, `sent` int(11) DEFAULT NULL, `returned` int(11) DEFAULT NULL, - `isForgetable` tinyint(1) NOT NULL DEFAULT 0, + `isForgetable` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`clientFk`,`packagingFk`), KEY `ticketPackagingStartingStock_fk2_idx` (`packagingFk`), KEY `ticketPackagingStartingStock_fk3_idx` (`itemFk`), @@ -37235,7 +37222,7 @@ CREATE TABLE `ticketParking` ( `id` int(11) NOT NULL AUTO_INCREMENT, `ticketFk` int(11) NOT NULL, `parkingFk` int(11) NOT NULL, - `created` timestamp NOT NULL DEFAULT current_timestamp(), + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `workerFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `ticketParking_idx1` (`ticketFk`,`parkingFk`), @@ -37319,13 +37306,13 @@ CREATE TABLE `ticketRequest` ( `price__` double DEFAULT NULL, `itemFk` double DEFAULT NULL, `clientFk` int(11) DEFAULT NULL, - `response` longtext COLLATE utf8_unicode_ci DEFAULT NULL, - `ok__` tinyint(1) NOT NULL DEFAULT 0, + `response` longtext COLLATE utf8_unicode_ci, + `ok__` tinyint(1) NOT NULL DEFAULT '0', `total` int(11) DEFAULT NULL, `buyed` datetime DEFAULT NULL, - `ko__` tinyint(1) NOT NULL DEFAULT 0, + `ko__` tinyint(1) NOT NULL DEFAULT '0', `saleFk` int(11) DEFAULT NULL, - `created` timestamp NULL DEFAULT current_timestamp(), + `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `isOk` tinyint(1) DEFAULT NULL, `requesterFk` int(11) DEFAULT NULL, `attenderFk` int(11) DEFAULT NULL, @@ -37413,9 +37400,9 @@ DROP TABLE IF EXISTS `ticketService`; 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, - `taxClassFk` tinyint(3) unsigned NOT NULL DEFAULT 2, + `quantity` int(11) NOT NULL DEFAULT '0', + `price` decimal(10,2) unsigned NOT NULL DEFAULT '0.00', + `taxClassFk` tinyint(3) unsigned NOT NULL DEFAULT '2', `ticketFk` int(11) NOT NULL, `ticketServiceTypeFk` int(11) NOT NULL, PRIMARY KEY (`id`), @@ -37515,7 +37502,7 @@ DROP TABLE IF EXISTS `ticketTrolley`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ticketTrolley` ( `ticket` int(11) NOT NULL, - `labelCount` int(11) NOT NULL DEFAULT 0, + `labelCount` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`ticket`), CONSTRAINT `fk_ticketTrolley_vs_ticket` FOREIGN KEY (`ticket`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -37564,20 +37551,20 @@ DROP TABLE IF EXISTS `till`; CREATE TABLE `till` ( `id` int(11) NOT NULL AUTO_INCREMENT, `dated` date NOT NULL, - `isAccountable` tinyint(1) NOT NULL DEFAULT 0, + `isAccountable` tinyint(1) NOT NULL DEFAULT '0', `serie` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL, `number` int(11) DEFAULT NULL, `concept` varchar(50) COLLATE utf8_unicode_ci NOT NULL, `in` decimal(10,2) DEFAULT NULL, `out` decimal(10,2) DEFAULT NULL, - `bankFk` int(11) DEFAULT 1, + `bankFk` int(11) DEFAULT '1', `workerFk` int(11) DEFAULT NULL, - `companyFk` smallint(5) unsigned DEFAULT 442 COMMENT 'kakear', - `isLinked` tinyint(4) DEFAULT 0, - `created` timestamp NOT NULL DEFAULT current_timestamp(), - `isOk` tinyint(4) NOT NULL DEFAULT 0, - `warehouseFk` smallint(5) unsigned NOT NULL DEFAULT 1 COMMENT 'to kak\\n', - `isConciliate` tinyint(4) NOT NULL DEFAULT 0, + `companyFk` smallint(5) unsigned DEFAULT '442' COMMENT 'kakear', + `isLinked` tinyint(4) DEFAULT '0', + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `isOk` tinyint(4) NOT NULL DEFAULT '0', + `warehouseFk` smallint(5) unsigned NOT NULL DEFAULT '1' COMMENT 'to kak\\n', + `isConciliate` tinyint(4) NOT NULL DEFAULT '0', `supplierAccountFk` mediumint(8) unsigned NOT NULL, `calculatedCode` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `InForeignValue` decimal(10,2) DEFAULT NULL, @@ -37625,7 +37612,7 @@ DROP TABLE IF EXISTS `tillConfig`; CREATE TABLE `tillConfig` ( `id` int(11) NOT NULL, `openingBalance` decimal(10,2) NOT NULL, - `updated` timestamp NOT NULL DEFAULT current_timestamp(), + `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -37861,9 +37848,9 @@ CREATE TABLE `trainingCourse` ( `ended` datetime NOT NULL, `invoice` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `amount` double DEFAULT NULL, - `remark` longtext COLLATE utf8_unicode_ci DEFAULT NULL, - `hasDiscount` tinyint(1) NOT NULL DEFAULT 0, - `hasDiploma` tinyint(1) NOT NULL DEFAULT 0, + `remark` longtext COLLATE utf8_unicode_ci, + `hasDiscount` tinyint(1) NOT NULL DEFAULT '0', + `hasDiploma` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `frgnWorker_idx` (`workerFk`), KEY `frgnCenter_idx` (`centerFk`), @@ -37905,12 +37892,12 @@ CREATE TABLE `travel` ( `warehouseOutFk` smallint(6) unsigned DEFAULT NULL, `agencyFk` int(11) DEFAULT NULL, `ref` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - `isDelivered` tinyint(1) NOT NULL DEFAULT 0, - `isReceived` tinyint(1) NOT NULL DEFAULT 0, + `isDelivered` tinyint(1) NOT NULL DEFAULT '0', + `isReceived` tinyint(1) NOT NULL DEFAULT '0', `m3` decimal(10,2) unsigned DEFAULT NULL, `kg` decimal(10,0) unsigned DEFAULT NULL, `cargoSupplierFk` int(11) DEFAULT NULL, - `totalEntries` tinyint(4) unsigned DEFAULT 0, + `totalEntries` tinyint(4) unsigned DEFAULT '0', `appointment` datetime DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `shipment_2` (`shipped`,`landed`,`warehouseInFk`,`warehouseOutFk`,`agencyFk`,`ref`), @@ -38017,11 +38004,11 @@ CREATE TABLE `travelLog` ( `originFk` int(10) 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, + `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `description` text CHARACTER SET utf8, `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, + `oldInstance` text COLLATE utf8_unicode_ci, + `newInstance` text COLLATE utf8_unicode_ci, `changedModelId` int(11) DEFAULT NULL, `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), @@ -38044,7 +38031,7 @@ CREATE TABLE `travelObservation` ( `originFk` int(11) NOT NULL, `userFk` int(11) NOT NULL, `description` text COLLATE utf8_unicode_ci NOT NULL, - `created` timestamp NOT NULL DEFAULT current_timestamp(), + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Observaciones de travel'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -38100,7 +38087,7 @@ DROP TABLE IF EXISTS `trolley`; CREATE TABLE `trolley` ( `id` int(11) NOT NULL AUTO_INCREMENT, `workerFk` int(11) DEFAULT NULL, - `coupled` timestamp NOT NULL DEFAULT current_timestamp(), + `coupled` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `trolley_FK` (`workerFk`), CONSTRAINT `trolley_FK` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE SET NULL ON UPDATE CASCADE @@ -38137,8 +38124,8 @@ CREATE TABLE `userConfig` ( `userFk` int(10) unsigned NOT NULL, `warehouseFk` smallint(6) DEFAULT NULL, `companyFk` smallint(5) unsigned DEFAULT NULL, - `created` timestamp NULL DEFAULT current_timestamp(), - `updated` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `updated` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`userFk`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Configuración de usuario en Salix'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -38155,11 +38142,11 @@ CREATE TABLE `userLog` ( `originFk` int(10) 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, + `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `description` text CHARACTER SET utf8, `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, + `oldInstance` text COLLATE utf8_unicode_ci, + `newInstance` text COLLATE utf8_unicode_ci, `changedModelId` int(11) DEFAULT NULL, `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), @@ -38216,9 +38203,9 @@ CREATE TABLE `vehicle` ( `numberPlate` varchar(10) COLLATE utf8_unicode_ci NOT NULL, `model` varchar(20) COLLATE utf8_unicode_ci NOT NULL, `tradeMark` varchar(20) COLLATE utf8_unicode_ci NOT NULL, - `companyFk` smallint(5) unsigned NOT NULL DEFAULT 442, + `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', `m3` double DEFAULT NULL, - `isActive` tinyint(4) NOT NULL DEFAULT 1, + `isActive` tinyint(4) NOT NULL DEFAULT '1', `warehouseFk` smallint(6) unsigned DEFAULT NULL, `description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `deliveryPointFk` int(11) DEFAULT NULL, @@ -38254,7 +38241,7 @@ DROP TABLE IF EXISTS `wagon`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `wagon` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `volume` int(11) NOT NULL DEFAULT 150 COMMENT 'Volumen en litros', + `volume` int(11) NOT NULL DEFAULT '150' COMMENT 'Volumen en litros', `plate` varchar(10) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Matrícula', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -38269,10 +38256,10 @@ DROP TABLE IF EXISTS `wagonVolumetry`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `wagonVolumetry` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `level` int(10) unsigned NOT NULL DEFAULT 0, - `lines` int(10) unsigned NOT NULL DEFAULT 1, - `liters` int(10) unsigned NOT NULL DEFAULT 0, - `height` int(10) unsigned NOT NULL DEFAULT 20, + `level` int(10) unsigned NOT NULL DEFAULT '0', + `lines` int(10) unsigned NOT NULL DEFAULT '1', + `liters` int(10) unsigned NOT NULL DEFAULT '0', + `height` int(10) unsigned NOT NULL DEFAULT '20', `wagonFk` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `wagonVolumetry_FK` (`wagonFk`), @@ -38290,26 +38277,26 @@ DROP TABLE IF EXISTS `warehouse`; CREATE TABLE `warehouse` ( `id` smallint(6) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(20) COLLATE utf8_unicode_ci NOT NULL, - `isFeedStock` tinyint(1) unsigned NOT NULL DEFAULT 0, + `isFeedStock` tinyint(1) unsigned NOT NULL DEFAULT '0', `addressName` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `delay` double NOT NULL DEFAULT 0.004, - `hasAvailable` tinyint(4) NOT NULL DEFAULT 0, - `isForTicket` tinyint(2) unsigned zerofill NOT NULL DEFAULT 00, - `countryFk` mediumint(8) unsigned NOT NULL DEFAULT 1, - `labelZone` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'almacenes donde hay produccion', - `hasComission` tinyint(4) NOT NULL DEFAULT 0, - `isInventory` tinyint(2) NOT NULL DEFAULT 0, - `isComparative` tinyint(2) NOT NULL DEFAULT 0 COMMENT 'Si esta a true,en la comparativa muestra el stock de este almacen, cuando no se especifica almacen.', - `valuatedInventory` tinyint(2) NOT NULL DEFAULT 0 COMMENT 'Determina si se incluye en el informe de inventario valorado', - `isManaged` tinyint(2) NOT NULL DEFAULT 0 COMMENT 'Se añaden los cubos de expedition a la tabla ticketPackaging', - `hasConfectionTeam` tinyint(1) unsigned NOT NULL DEFAULT 0, - `hasStowaway` tinyint(1) NOT NULL DEFAULT 0, - `hasDms` tinyint(1) NOT NULL DEFAULT 0, + `delay` double NOT NULL DEFAULT '0.004', + `hasAvailable` tinyint(4) NOT NULL DEFAULT '0', + `isForTicket` tinyint(2) unsigned zerofill NOT NULL DEFAULT '00', + `countryFk` mediumint(8) unsigned NOT NULL DEFAULT '1', + `labelZone` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'almacenes donde hay produccion', + `hasComission` tinyint(4) NOT NULL DEFAULT '0', + `isInventory` tinyint(2) NOT NULL DEFAULT '0', + `isComparative` tinyint(2) NOT NULL DEFAULT '0' COMMENT 'Si esta a true,en la comparativa muestra el stock de este almacen, cuando no se especifica almacen.', + `valuatedInventory` tinyint(2) NOT NULL DEFAULT '0' COMMENT 'Determina si se incluye en el informe de inventario valorado', + `isManaged` tinyint(2) NOT NULL DEFAULT '0' COMMENT 'Se añaden los cubos de expedition a la tabla ticketPackaging', + `hasConfectionTeam` tinyint(1) unsigned NOT NULL DEFAULT '0', + `hasStowaway` tinyint(1) NOT NULL DEFAULT '0', + `hasDms` tinyint(1) NOT NULL DEFAULT '0', `pickUpAgencyModeFk` int(11) DEFAULT NULL, - `isBuyerToBeEmailed` tinyint(2) NOT NULL DEFAULT 0, + `isBuyerToBeEmailed` tinyint(2) NOT NULL DEFAULT '0', `aliasFk` smallint(5) unsigned DEFAULT NULL, `labelReport` int(11) DEFAULT NULL, - `hasUbications` tinyint(1) NOT NULL DEFAULT 1, + `hasUbications` tinyint(1) NOT NULL DEFAULT '1', PRIMARY KEY (`id`), UNIQUE KEY `name_UNIQUE` (`name`), KEY `Id_Paises` (`countryFk`), @@ -38387,7 +38374,7 @@ DROP TABLE IF EXISTS `workCenter`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workCenter` ( - `id` int(11) NOT NULL DEFAULT 0, + `id` int(11) NOT NULL DEFAULT '0', `name` varchar(255) DEFAULT NULL, `payrollCenterFk` int(11) DEFAULT NULL, `counter` bigint(20) DEFAULT NULL, @@ -38437,7 +38424,7 @@ CREATE TABLE `worker` ( `started__` datetime DEFAULT NULL, `ended__` datetime DEFAULT NULL, `notes__` varchar(254) COLLATE utf8_unicode_ci DEFAULT NULL, - `photo` blob DEFAULT NULL, + `photo` blob, `fi` varchar(9) COLLATE utf8_unicode_ci DEFAULT NULL, `address__` varchar(50) COLLATE utf8_unicode_ci NOT NULL, `birthed__` date NOT NULL, @@ -38445,10 +38432,12 @@ CREATE TABLE `worker` ( `phone` varchar(9) COLLATE utf8_unicode_ci NOT NULL, `clientFk__` int(11) DEFAULT NULL, `userFk` int(10) unsigned DEFAULT NULL, - `bossFk` int(11) NOT NULL DEFAULT 103, + `bossFk` int(11) NOT NULL DEFAULT '103', `fiDueDate` datetime DEFAULT NULL, - `hasMachineryAutorized` tinyint(2) DEFAULT 0, + `hasMachineryAutorized` tinyint(2) DEFAULT '0', `seniority` date DEFAULT NULL, + `isTodayRelative` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Para el F11. Calcula los problemas de visiblidad en funcion del dia actual', + `isF11Allowed` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Usuario autorizado para abrir el F11', PRIMARY KEY (`id`), UNIQUE KEY `CodigoTrabajador_UNIQUE` (`code`), UNIQUE KEY `user` (`user__`), @@ -38509,7 +38498,7 @@ CREATE TABLE `workerClockLog` ( `originFk` int(11) NOT NULL, `userFk` int(10) unsigned NOT NULL, `action` set('insert','update','delete','select') COLLATE utf8_unicode_ci NOT NULL, - `creationDate` timestamp NULL DEFAULT current_timestamp(), + `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `description` text COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`), KEY `logWorkerClockoriginFk` (`originFk`), @@ -38573,7 +38562,7 @@ CREATE TABLE `workerDocument` ( `id` int(11) NOT NULL AUTO_INCREMENT, `worker` int(10) unsigned DEFAULT NULL, `document` int(11) DEFAULT NULL, - `isReadableByWorker` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Indica si el empleado tiene permiso para acceder al documento', + `isReadableByWorker` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Indica si el empleado tiene permiso para acceder al documento', PRIMARY KEY (`id`), KEY `workerDocument_ibfk_1` (`worker`), KEY `workerDocument_ibfk_2` (`document`), @@ -38626,14 +38615,14 @@ CREATE TABLE `workerIrpf` ( `spouseNif` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `geographicMobilityDate` date DEFAULT NULL, `disabilityGradeFk` int(11) DEFAULT NULL, - `isDependend` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Acredita la necesidad de ayuda de terceras personas o movilidad reducida', + `isDependend` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Acredita la necesidad de ayuda de terceras personas o movilidad reducida', `familySituation` enum('1','2','3') COLLATE utf8_unicode_ci DEFAULT '1', `spousePension` decimal(10,2) DEFAULT NULL COMMENT 'Apartado 4 - Pensión compensatoria en favor del conyuge ', `childPension` decimal(10,2) DEFAULT NULL COMMENT 'Apartado 4 - Anualidades por alimentos en favor de los hijos', - `hasHousingPaymentBefore` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Apartado 5 - Pagos por adquisición o rehabilitación de la vivienda habitual utilizando financiación ajena, con derecho a deducción del IRPF', - `hasHousingPaymentAfter` tinyint(1) NOT NULL DEFAULT 0, - `hasExtendedWorking` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Aprtado 1 - prolongar la actividad laboral', - `updated` timestamp NULL DEFAULT current_timestamp(), + `hasHousingPaymentBefore` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Apartado 5 - Pagos por adquisición o rehabilitación de la vivienda habitual utilizando financiación ajena, con derecho a deducción del IRPF', + `hasHousingPaymentAfter` tinyint(1) NOT NULL DEFAULT '0', + `hasExtendedWorking` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Aprtado 1 - prolongar la actividad laboral', + `updated` timestamp NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`workerFk`), KEY `workerIrpf_disabilityGradeFk` (`disabilityGradeFk`), CONSTRAINT `workerIrpf_disabilityGradeFk` FOREIGN KEY (`disabilityGradeFk`) REFERENCES `disabilityGrade` (`id`) ON UPDATE CASCADE, @@ -38652,21 +38641,21 @@ CREATE TABLE `workerJourney` ( `id` int(11) NOT NULL AUTO_INCREMENT, `userFk` int(10) unsigned NOT NULL, `dated` date NOT NULL, - `total` decimal(5,2) NOT NULL DEFAULT 0.00, - `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, - `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, + `total` decimal(5,2) NOT NULL DEFAULT '0.00', + `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', + `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', `businessFk` int(11) DEFAULT NULL, - `isPaid` tinyint(1) NOT NULL DEFAULT 0, - `isUpdated` tinyint(1) NOT NULL DEFAULT 0, - `permission` decimal(5,2) NOT NULL DEFAULT 0.00, + `isPaid` tinyint(1) NOT NULL DEFAULT '0', + `isUpdated` tinyint(1) NOT NULL DEFAULT '0', + `permission` decimal(5,2) NOT NULL DEFAULT '0.00', PRIMARY KEY (`id`), UNIQUE KEY `userFk_UNIQUE` (`userFk`,`dated`), KEY `fk_workerJourney_user_idx` (`userFk`), @@ -38704,11 +38693,11 @@ CREATE TABLE `workerLog` ( `originFk` int(11) NOT NULL, `userFk` int(10) unsigned NOT NULL, `action` set('insert','update','delete') COLLATE utf8_unicode_ci NOT NULL, - `creationDate` timestamp NULL DEFAULT current_timestamp(), + `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `description` text COLLATE utf8_unicode_ci NOT 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, + `oldInstance` text COLLATE utf8_unicode_ci, + `newInstance` text COLLATE utf8_unicode_ci, `changedModelId` int(11) DEFAULT NULL, `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), @@ -38728,12 +38717,12 @@ DROP TABLE IF EXISTS `workerMana`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workerMana` ( `workerFk` int(11) NOT NULL, - `size` int(11) NOT NULL DEFAULT 300, - `amount` int(11) NOT NULL DEFAULT 0, - `pricesModifierRate` double NOT NULL DEFAULT 0, - `isPricesModifierActivated` tinyint(1) NOT NULL DEFAULT 1, - `minRate` decimal(3,2) NOT NULL DEFAULT -0.05, - `maxRate` decimal(3,2) NOT NULL DEFAULT 0.05, + `size` int(11) NOT NULL DEFAULT '300', + `amount` int(11) NOT NULL DEFAULT '0', + `pricesModifierRate` double NOT NULL DEFAULT '0', + `isPricesModifierActivated` tinyint(1) NOT NULL DEFAULT '1', + `minRate` decimal(3,2) NOT NULL DEFAULT '-0.05', + `maxRate` decimal(3,2) NOT NULL DEFAULT '0.05', PRIMARY KEY (`workerFk`), KEY `fk_mana_spellers_Trabajadores_idx` (`workerFk`), CONSTRAINT `fk_mana_spellers_Trabajadores` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE @@ -38797,13 +38786,13 @@ DROP TABLE IF EXISTS `workerRelatives`; CREATE TABLE `workerRelatives` ( `id` int(11) NOT NULL AUTO_INCREMENT, `workerFk` int(11) NOT NULL, - `isDescendant` tinyint(1) DEFAULT 1 COMMENT 'Descendientes - Ascendientes', + `isDescendant` tinyint(1) DEFAULT '1' COMMENT 'Descendientes - Ascendientes', `disabilityGradeFk` int(11) DEFAULT NULL, `birthed` int(4) NOT NULL, `adoptionYear` int(4) DEFAULT NULL COMMENT 'Solo en el caso de descendientes', - `isDependend` tinyint(1) DEFAULT 0, - `isJointCustody` tinyint(1) DEFAULT 0 COMMENT 'Solo en el caso de descendientes', - `updated` timestamp NULL DEFAULT current_timestamp(), + `isDependend` tinyint(1) DEFAULT '0', + `isJointCustody` tinyint(1) DEFAULT '0' COMMENT 'Solo en el caso de descendientes', + `updated` timestamp NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `workerRelatives_disabilityGradeFk` (`disabilityGradeFk`), KEY `workerRelatives_workerFk` (`workerFk`), @@ -38895,11 +38884,11 @@ CREATE TABLE `workerTimeControl` ( `id` int(11) NOT NULL AUTO_INCREMENT, `userFk` int(10) unsigned NOT NULL, `timed` datetime NOT NULL, - `manual` tinyint(4) NOT NULL DEFAULT 0, + `manual` tinyint(4) NOT NULL DEFAULT '0', `order` int(11) DEFAULT NULL, `warehouseFk` smallint(6) unsigned DEFAULT NULL, `direction` enum('in','out','middle') COLLATE utf8_unicode_ci DEFAULT 'middle', - `isSendMail` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'Fichadas generadas autómaticamente con el procedimiento vn.workerTimeControl_sendMail', + `isSendMail` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Fichadas generadas autómaticamente con el procedimiento vn.workerTimeControl_sendMail', PRIMARY KEY (`id`), UNIQUE KEY `userFk_Timed_uniq` (`userFk`,`timed`), KEY `warehouseFkfk1_idx` (`warehouseFk`), @@ -38935,7 +38924,7 @@ DROP TABLE IF EXISTS `workerTimeControlLog`; CREATE TABLE `workerTimeControlLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, `userFk` int(10) NOT NULL, - `created` datetime NOT NULL DEFAULT current_timestamp(), + `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Log de fichadas, se rellena cuando el fichador(tablet) no autoriza el fichaje (PROC:vn.workerTimeControl_check)'; @@ -38954,9 +38943,9 @@ CREATE TABLE `workerTimeControlMail` ( `year` int(4) NOT NULL, `week` int(2) NOT NULL, `state` enum('SENDED','CONFIRMED','REVISE') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'SENDED', - `updated` datetime NOT NULL DEFAULT current_timestamp() COMMENT 'Fecha/hora último cambio de estado', - `sendedCounter` int(3) NOT NULL DEFAULT 1 COMMENT 'Número de veces que se ha enviado el correo', - `emailResponse` text COLLATE utf8_unicode_ci DEFAULT NULL, + `updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Fecha/hora último cambio de estado', + `sendedCounter` int(3) NOT NULL DEFAULT '1' COMMENT 'Número de veces que se ha enviado el correo', + `emailResponse` text COLLATE utf8_unicode_ci, PRIMARY KEY (`id`), UNIQUE KEY `workerFk_UNIQUE` (`workerFk`,`year`,`week`), KEY `workerFk_idx` (`workerFk`), @@ -39105,8 +39094,8 @@ DROP TABLE IF EXISTS `workers20190711`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workers20190711` ( - `person_id` int(11) NOT NULL DEFAULT 0, - `business_id` int(11) NOT NULL DEFAULT 0, + `person_id` int(11) NOT NULL DEFAULT '0', + `business_id` int(11) NOT NULL DEFAULT '0', `Apellidos` varchar(60) CHARACTER SET utf8 NOT NULL, `Nombre` varchar(20) CHARACTER SET utf8 DEFAULT NULL, `nif` varchar(15) CHARACTER SET utf8 DEFAULT NULL, @@ -39131,7 +39120,7 @@ DROP TABLE IF EXISTS `workers20190711_FichadasAbril`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workers20190711_FichadasAbril` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `person_id` int(11) NOT NULL DEFAULT 0, + `person_id` int(11) NOT NULL DEFAULT '0', `nif` varchar(15) CHARACTER SET utf8 DEFAULT NULL, `Apellidos` varchar(60) CHARACTER SET utf8 NOT NULL, `Nombre` varchar(20) CHARACTER SET utf8 DEFAULT NULL, @@ -39139,7 +39128,7 @@ CREATE TABLE `workers20190711_FichadasAbril` ( `Hora` int(2) DEFAULT NULL, `Minuto` int(2) DEFAULT NULL, `sumable` double DEFAULT NULL, - `jornada` decimal(5,2) NOT NULL DEFAULT 8.00, + `jornada` decimal(5,2) NOT NULL DEFAULT '8.00', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -39153,7 +39142,7 @@ DROP TABLE IF EXISTS `workers20190711_FichadasJulio11`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workers20190711_FichadasJulio11` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `person_id` int(11) NOT NULL DEFAULT 0, + `person_id` int(11) NOT NULL DEFAULT '0', `nif` varchar(15) CHARACTER SET utf8 DEFAULT NULL, `Apellidos` varchar(60) CHARACTER SET utf8 NOT NULL, `Nombre` varchar(20) CHARACTER SET utf8 DEFAULT NULL, @@ -39161,7 +39150,7 @@ CREATE TABLE `workers20190711_FichadasJulio11` ( `Hora` int(2) DEFAULT NULL, `Minuto` int(2) DEFAULT NULL, `sumable` double DEFAULT NULL, - `jornada` decimal(5,2) NOT NULL DEFAULT 8.00, + `jornada` decimal(5,2) NOT NULL DEFAULT '8.00', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -39175,7 +39164,7 @@ DROP TABLE IF EXISTS `workers20190711_FichadasJunio`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workers20190711_FichadasJunio` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `person_id` int(11) NOT NULL DEFAULT 0, + `person_id` int(11) NOT NULL DEFAULT '0', `nif` varchar(15) CHARACTER SET utf8 DEFAULT NULL, `Apellidos` varchar(60) CHARACTER SET utf8 NOT NULL, `Nombre` varchar(20) CHARACTER SET utf8 DEFAULT NULL, @@ -39183,7 +39172,7 @@ CREATE TABLE `workers20190711_FichadasJunio` ( `Hora` int(2) DEFAULT NULL, `Minuto` int(2) DEFAULT NULL, `sumable` double DEFAULT NULL, - `jornada` decimal(5,2) NOT NULL DEFAULT 8.00, + `jornada` decimal(5,2) NOT NULL DEFAULT '8.00', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -39197,7 +39186,7 @@ DROP TABLE IF EXISTS `workers20190711_FichadasMayo`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workers20190711_FichadasMayo` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `person_id` int(11) NOT NULL DEFAULT 0, + `person_id` int(11) NOT NULL DEFAULT '0', `nif` varchar(15) CHARACTER SET utf8 DEFAULT NULL, `Apellidos` varchar(60) CHARACTER SET utf8 NOT NULL, `Nombre` varchar(20) CHARACTER SET utf8 DEFAULT NULL, @@ -39205,7 +39194,7 @@ CREATE TABLE `workers20190711_FichadasMayo` ( `Hora` int(2) DEFAULT NULL, `Minuto` int(2) DEFAULT NULL, `sumable` double DEFAULT NULL, - `jornada` decimal(5,2) NOT NULL DEFAULT 8.00, + `jornada` decimal(5,2) NOT NULL DEFAULT '8.00', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -39219,7 +39208,7 @@ DROP TABLE IF EXISTS `workers20190711_FichadasOctubre`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workers20190711_FichadasOctubre` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `person_id` int(11) NOT NULL DEFAULT 0, + `person_id` int(11) NOT NULL DEFAULT '0', `nif` varchar(15) CHARACTER SET utf8 DEFAULT NULL, `Apellidos` varchar(60) CHARACTER SET utf8 NOT NULL, `Nombre` varchar(20) CHARACTER SET utf8 DEFAULT NULL, @@ -39227,7 +39216,7 @@ CREATE TABLE `workers20190711_FichadasOctubre` ( `Hora` int(2) DEFAULT NULL, `Minuto` int(2) DEFAULT NULL, `sumable` double DEFAULT NULL, - `jornada` decimal(5,2) NOT NULL DEFAULT 8.00, + `jornada` decimal(5,2) NOT NULL DEFAULT '8.00', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -39241,7 +39230,7 @@ DROP TABLE IF EXISTS `workers20190711_Garrote`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `workers20190711_Garrote` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `person_id` int(11) NOT NULL DEFAULT 0, + `person_id` int(11) NOT NULL DEFAULT '0', `nif` varchar(15) CHARACTER SET utf8 DEFAULT NULL, `Apellidos` varchar(60) CHARACTER SET utf8 NOT NULL, `Nombre` varchar(20) CHARACTER SET utf8 DEFAULT NULL, @@ -39249,7 +39238,7 @@ CREATE TABLE `workers20190711_Garrote` ( `Hora` int(2) DEFAULT NULL, `Minuto` int(2) DEFAULT NULL, `sumable` double DEFAULT NULL, - `jornada` decimal(5,2) NOT NULL DEFAULT 8.00, + `jornada` decimal(5,2) NOT NULL DEFAULT '8.00', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -39307,11 +39296,11 @@ CREATE TABLE `zone` ( `hour` datetime NOT NULL, `warehouseFk__` smallint(6) unsigned DEFAULT NULL, `agencyModeFk` int(11) NOT NULL, - `travelingDays` int(11) NOT NULL DEFAULT 1, - `price` double NOT NULL DEFAULT 0, - `bonus` double NOT NULL DEFAULT 0, - `isVolumetric` tinyint(1) NOT NULL DEFAULT 0, - `inflation` decimal(5,2) NOT NULL DEFAULT 1.00, + `travelingDays` int(11) NOT NULL DEFAULT '1', + `price` double NOT NULL DEFAULT '0', + `bonus` double NOT NULL DEFAULT '0', + `isVolumetric` tinyint(1) NOT NULL DEFAULT '0', + `inflation` decimal(5,2) NOT NULL DEFAULT '1.00', `m3Max` decimal(10,2) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `fk_zone_1_idx` (`warehouseFk__`), @@ -39366,7 +39355,7 @@ DROP TABLE IF EXISTS `zoneConfig`; CREATE TABLE `zoneConfig` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `scope` int(10) unsigned NOT NULL, - `forwardDays` int(10) NOT NULL DEFAULT 7 COMMENT 'days forward to show zone_upcomingDeliveries', + `forwardDays` int(10) NOT NULL DEFAULT '7' COMMENT 'days forward to show zone_upcomingDeliveries', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -39450,7 +39439,7 @@ CREATE TABLE `zoneGeo` ( `path` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `lft` int(11) DEFAULT NULL, `rgt` int(11) DEFAULT NULL, - `depth` bigint(22) NOT NULL DEFAULT 0, + `depth` bigint(22) NOT NULL DEFAULT '0', `sons` decimal(10,0) DEFAULT NULL, PRIMARY KEY (`id`), KEY `lft_rgt_depth_idx` (`lft`,`rgt`,`depth`), @@ -39544,11 +39533,11 @@ CREATE TABLE `zoneLog` ( `originFk` int(10) 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, + `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `description` text CHARACTER SET utf8, `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, + `oldInstance` text COLLATE utf8_unicode_ci, + `newInstance` text COLLATE utf8_unicode_ci, `changedModelId` int(11) DEFAULT NULL, `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), @@ -39571,7 +39560,7 @@ CREATE TABLE `zonePromo` ( `zoneFk` int(11) NOT NULL, `dated` date NOT NULL, `amount` decimal(10,2) NOT NULL, - `isDone` tinyint(4) NOT NULL DEFAULT 0, + `isDone` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `zonePromo_fk1_idx` (`zoneFk`), CONSTRAINT `zonePromo_fk1` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE @@ -41045,7 +41034,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`z-developer`@`%` FUNCTION `ekt_getEntry`(vEktFk INT) RETURNS int(11) +CREATE DEFINER=`root`@`%` FUNCTION `ekt_getEntry`(vEktFk INT) RETURNS int(11) READS SQL DATA BEGIN DECLARE vTravelFk INT; @@ -42300,6 +42289,38 @@ BEGIN RETURN hasAnyNegativeBase; +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 `hasItemsInSector` */; +/*!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 `hasItemsInSector`(vTicketFk INT, vSectorFk INT) RETURNS tinyint(1) + DETERMINISTIC +BEGIN + + DECLARE vItemCount INT; + + SELECT count(*) INTO vItemCount + FROM vn.sale s + JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk + JOIN vn.shelving sh ON sh.code = ish.shelvingFk + JOIN vn.parking p ON p.id = sh.parkingFk + WHERE s.ticketFk = vTicketFk + AND p.sectorFk = vSectorFk; + + RETURN vItemCount; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -42784,6 +42805,38 @@ BEGIN RETURN vClosestParkingFk; +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 `itemsInSector_get` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` FUNCTION `itemsInSector_get`(vTicketFk INT, vSectorFk INT) RETURNS int(11) + READS SQL DATA +BEGIN + + DECLARE vItemCount INT; + + SELECT count(*) INTO vItemCount + FROM vn.sale s + JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk + JOIN vn.shelving sh ON sh.code = ish.shelvingFk + JOIN vn.parking p ON p.id = sh.parkingFk + WHERE s.ticketFk = vTicketFk + AND p.sectorFk = vSectorFk; + + RETURN vItemCount; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -44615,7 +44668,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`z-developer`@`%` PROCEDURE `agencyVolume`(vDated DATE, vAgency INT) +CREATE DEFINER=`root`@`%` PROCEDURE `agencyVolume`(vDated DATE, vAgency INT) BEGIN SELECT ELT(it.temperature + 1,'Calientes','Frios','Secos') AS Temp, @@ -46084,10 +46137,10 @@ proc: BEGIN AND t.addressFk = vAddressFk AND t.shipped = vShipped AND t.zoneFk = vZoneFk) sub ON sub.itemFk = i.id - WHERE i.supplyResponseFk + WHERE (i.supplyResponseFk AND ISNULL(sub.itemFk) AND IFNULL(v.visible,0) = 0 - AND vWarehouseFk = tl.warehouseFk; + AND vWarehouseFk = tl.warehouseFk); END IF; @@ -46479,7 +46532,7 @@ BEGIN DELETE FROM sms WHERE created < v18Month; DELETE FROM saleTracking WHERE created < vDateShort; DELETE tobs FROM ticketObservation tobs - JOIN ticket t ON tobs.ticketFk = t.id WHERE t.shipped < vDateShort; + JOIN ticket t ON tobs.ticketFk = t.id WHERE t.shipped < TIMESTAMPADD(YEAR,-2,CURDATE()); DELETE sc.* FROM saleCloned sc JOIN sale s ON s.id = sc.saleClonedFk JOIN ticket t ON t.id = s.ticketFk WHERE t.shipped < vOneYearAgo; DELETE FROM sharingCart where ended < vDateShort; DELETE FROM sharingClient where ended < vDateShort; @@ -47738,7 +47791,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`z-developer`@`%` PROCEDURE `client_RandomList`(vNumber INT) +CREATE DEFINER=`root`@`%` PROCEDURE `client_RandomList`(vNumber INT) BEGIN DECLARE i INT DEFAULT 0; @@ -48035,9 +48088,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 ;; @@ -48061,9 +48114,18 @@ BEGIN 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 - UNION ALL + 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 @@ -48081,10 +48143,10 @@ BEGIN 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 @@ -48167,7 +48229,6 @@ BEGIN WHERE w.aliasFk = vWarehouseAliasFk HAVING (iss.id AND st.saleFk) OR salePreviousPrepared IS NULL ; - -- select * from tmp.salePlacementList; DROP TEMPORARY TABLE IF EXISTS tmp.salePlacementList_2; CREATE TEMPORARY TABLE tmp.salePlacementList_2 @@ -48190,10 +48251,14 @@ BEGIN JOIN tmp.salePlacementList_3 s3 ON s3.saleFk = s1.saleFk SET s1.saleOrder = s3.saleOrder; + -- Nuevo campaña + UPDATE tmp.salePlacementList + SET saleOrder = `order`; + SELECT * FROM tmp.salePlacementList ORDER BY saleOrder, IF(isPreviousPrepared,2,1), IF(visible > 0 OR itemShelvingSaleFk,1,2),priority; - + DROP TEMPORARY TABLE tmp.sale, tmp.sale2, @@ -48218,30 +48283,55 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `collectionSale_get`(vCollectionFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `collectionSale_get`(vParam INT) BEGIN + DECLARE vItemPackingTypeFk VARCHAR(1); + DECLARE vCollectionFk INT; + DECLARE vTicketFk INT; + + IF (SELECT COUNT(*) FROM vn.ticket WHERE id = vParam AND id > 2000000) THEN + + SET vTicketFk = vParam; + + SELECT itemPackingTypeFk INTO vItemPackingTypeFk + FROM tmp.workerPackingType wpt + WHERE wpt.workerFk = account.myUser_getId(); + + SELECT c.id INTO vCollectionFk + FROM vn.collection c + JOIN vn.ticketCollection tc ON tc.collectionFk = c.id + WHERE tc.ticketFk = vTicketFk + ORDER BY c.itemPackingTypeFk = vItemPackingTypeFk DESC + LIMIT 1; + + IF IFNULL(vCollectionFk,0) = 0 THEN + + INSERT INTO vn.collection(workerFk, itemPackingTypeFk) + VALUES(vn.getUser(), vItemPackingTypeFk); + + SET vCollectionFk = LAST_INSERT_ID(); + + INSERT INTO vn.ticketCollection (collectionFk, ticketFk) + VALUES (vCollectionFk, vParam); + + END IF; + + ELSE + + SET vCollectionFk = vParam; + + END IF; + DROP TEMPORARY TABLE IF EXISTS tmp.ticket; CREATE TEMPORARY TABLE tmp.ticket - SELECT t.id, clientFk, id as showTicketFk - FROM vn.ticket t - WHERE id = vCollectionFk - AND shipped > '2020-01-01' - UNION ALL SELECT tc.ticketFk id, clientFk, tc.ticketFk as showTicketFk FROM vn.ticketCollection tc JOIN vn.ticket t ON t.id = tc.ticketFk - WHERE tc.collectionFk = vCollectionFk; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket2; - CREATE TEMPORARY TABLE tmp.ticket2 - SELECT sw.id, t.clientFk, sw.shipFk showTicketFk - FROM vn.stowaway sw - JOIN tmp.ticket t ON t.id = sw.shipFk; - - INSERT INTO tmp.ticket - SELECT * FROM tmp.ticket2; - + WHERE tc.collectionFk = vCollectionFk + AND IFNULL(vTicketFk, t.id) = t.id; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticket3; CREATE TEMPORARY TABLE tmp.ticket3 SELECT * FROM tmp.ticket; @@ -48279,14 +48369,14 @@ BEGIN FROM vn.sale s JOIN tmp.ticket t ON t.id = s.ticketFk JOIN vn.item i ON i.id = s.itemFk + JOIN vn.ticketCollection tc ON tc.ticketFk = t.id + 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 LEFT JOIN vn.itemColor ic ON ic.itemFk = s.itemFk LEFT JOIN vn.itemProductor ip ON ip.itemFk = s.itemFk LEFT JOIN vn.origin o ON o.id = i.originFk - LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = t.id - LEFT JOIN vn.collection c ON c.id = tc.collectionFk LEFT JOIN (SELECT st.saleFk, p.`code` as parkingCode FROM vn.saleTracking st JOIN vn.state s ON s.id = st.stateFk @@ -48297,115 +48387,15 @@ BEGIN WHERE st.isChecked AND s.semaphore = 1 GROUP BY st.saleFk) st ON st.saleFk = s.id + WHERE (i.itemPackingTypeFk = c.itemPackingTypeFk OR ISNULL(c.itemPackingTypeFk)) + AND tc.collectionFk = vCollectionFk GROUP BY s.id - /*HAVING quantity > 0 OR workerFk != vn.getUser()*/ + ; - - DROP TEMPORARY TABLE tmp.ticket; - DROP TEMPORARY TABLE tmp.ticket2; DROP TEMPORARY TABLE tmp.ticket3; - - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `collectionSale_get_gamma` */; -/*!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 `collectionSale_get_gamma`(vCollectionFk INT) -BEGIN - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket; - CREATE TEMPORARY TABLE tmp.ticket - SELECT t.id, clientFk, id as showTicketFk - FROM vn.ticket t - WHERE id = vCollectionFk - AND shipped > '2020-01-01' - UNION ALL - SELECT tc.ticketFk id, clientFk, tc.ticketFk as showTicketFk - FROM vn.ticketCollection tc - JOIN vn.ticket t ON t.id = tc.ticketFk - WHERE tc.collectionFk = vCollectionFk; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket2; - CREATE TEMPORARY TABLE tmp.ticket2 - SELECT sw.id, t.clientFk, sw.shipFk showTicketFk - FROM vn.stowaway sw - JOIN tmp.ticket t ON t.id = sw.shipFk; - - INSERT INTO tmp.ticket - SELECT * FROM tmp.ticket2; - - SELECT showTicketFk ticketFk, - s.id as saleFk, - s.itemFk, - s.quantity, - i.longName, - i.size, - s.reserved, - MAX(IF(st.semaphore <=> 1, TRUE, FALSE)) as isPreviousPrepared, - MAX(IF(st.semaphore <=> 2, TRUE, FALSE)) as isPrepared, - MAX(IF(st.semaphore <=> 3, TRUE, FALSE)) as isControlled, - ic.color, - ip.productor, - s.discount, - s.price, - i.stems, - i.category, - o.code AS origin, - t.clientFk, - s.originalQuantity, - TRIM(CONCAT(LPAD(i.longName,30,' '), ' ',RPAD(IFNULL(i.size,''),5,' '))) as line1, - 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 - c.workerFk, - IFNULL(SUM(iss.quantity),0) as pickedQuantity - FROM vn.sale s - JOIN tmp.ticket t ON t.id = s.ticketFk - JOIN vn.item i ON i.id = s.itemFk - 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 - LEFT JOIN vn.itemColor ic ON ic.itemFk = s.itemFk - LEFT JOIN vn.itemProductor ip ON ip.itemFk = s.itemFk - LEFT JOIN vn.origin o ON o.id = i.originFk - LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = t.id - LEFT JOIN vn.collection c ON c.id = tc.collectionFk - /* - LEFT JOIN (SELECT st.saleFk, p.`code` as parkingCode - FROM vn.saleTracking st - JOIN vn.state s ON s.id = st.stateFk - JOIN vn.sale sa ON sa.id = st.saleFk - JOIN vn.ticketParking tp ON tp.ticketFk = sa.ticketFk - JOIN vn.parking p ON p.id = tp.parkingFk - WHERE st.isChecked - AND s.semaphore = 1 - GROUP BY st.saleFk) st ON st.saleFk = s.id - */ - GROUP BY s.id - HAVING quantity > 0 OR workerFk != vn.getUser() - ; - - - - DROP TEMPORARY TABLE tmp.ticket; - DROP TEMPORARY TABLE tmp.ticket2; - - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -48425,6 +48415,50 @@ DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `collectionSticker_print`(vCollectionFk INT, vSectorFk INT) BEGIN + + DECLARE vLabelReport INT; + /* + UPDATE vn.ticket t + JOIN vn.ticketCollection tc ON tc.ticketFk = t.id + SET t.notes = CONCAT('COL ',vCollectionFk,'-',tc.`level`) + WHERE tc.collectionFk = vCollectionFk; + */ + SELECT labelReport INTO vLabelReport + FROM vn.sector + WHERE id = vSectorFk; + + IF vLabelReport THEN + + INSERT INTO vn.ticketTrolley(ticket, labelCount) + SELECT ticketFk, 1 + FROM vn.ticketCollection + WHERE collectionFk = vCollectionFk + ON DUPLICATE KEY UPDATE labelCount = labelCount + 1; + + INSERT INTO vn.printServerQueue(reportFk, param1, workerFk) + SELECT vLabelReport, vCollectionFk, getUser(); + + 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 `collectionSticker_print__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `collectionSticker_print__`(vCollectionFk INT, vSectorFk INT) +BEGIN + DECLARE vLabelReport INT; UPDATE vn.ticket t @@ -48443,13 +48477,16 @@ BEGIN FROM vn.ticketCollection WHERE collectionFk = vCollectionFk ON DUPLICATE KEY UPDATE labelCount = labelCount + 1; - - INSERT INTO vn.printServerQueue(reportFk, param1, workerFk,param2) + /* + INSERT INTO vn.printServerQueue(reportFk, param1, workerFk,param2) SELECT vLabelReport, tc.ticketFk, getUser(), tt.labelCount FROM vn.ticketCollection tc LEFT JOIN vn.ticketTrolley tt ON tt.ticket = tc.ticketFk - WHERE collectionFk = vCollectionFk; - + WHERE collectionFk = vCollectionFk; + */ + INSERT INTO vn.printServerQueue(reportFk, param1, workerFk) + SELECT vLabelReport, vCollectionFk, getUser(); + END IF; END ;; @@ -48462,393 +48499,136 @@ 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 `collectionTicket_get`(vCollectionFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `collectionTicket_get`(vParamFk INT) BEGIN - DROP TEMPORARY TABLE IF EXISTS tmp.ticket; - CREATE TEMPORARY TABLE tmp.ticket - SELECT t.id, t.clientFk, t.warehouseFk, t.zoneFk,t.observations + DECLARE vCollectionFk INT; + DECLARE vTicketFk INT; + DECLARE vAlertLevel INT; + DECLARE vItemPackingTypeFk VARCHAR(1); + + -- Si los sacadores son los de pruebas, pinta los colores + SELECT id, itemPackingTypeFk + INTO vCollectionFk, vItemPackingTypeFk + FROM vn.collection + WHERE id = vParamFk; + + IF !(vItemPackingTypeFk <=> 'V') THEN + + IF vCollectionFk THEN + + SELECT t.id ticketFk, + cc.code `level`, + am.name as agencyName, + t.warehouseFk , + w.id as salesPersonFk, + IFNULL(tob.description,'')as observaciones FROM vn.ticket t - WHERE id = vCollectionFk - AND t.shipped > '2020-01-01' - UNION ALL - SELECT t.id, t.clientFk, t.warehouseFk, t.zoneFk,t.observations - FROM vn.ticketCollection tc - JOIN vn.ticket t ON t.id = tc.ticketFk + 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 = vCollectionFk; - - SELECT t.id ticketFk, - IFNULL(tc.wagon * 100 + tc.level,0) `level`, - am.name as agencyName, - t.warehouseFk , - w.id as salesPersonFk, - IFNULL(tob.description,'')as observaciones - FROM tmp.ticket t - LEFT JOIN vn.ticketCollection tc ON t.id = tc.ticketFk - LEFT JOIN vn.zone z ON z.id = t.zoneFk - LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk - LEFT JOIN vn.client c ON c.id = t.clientFk - LEFT JOIN vn.worker w ON w.id = c.salesPersonFk - LEFT JOIN vn.ticketObservation tob ON tob.ticketFk = t.id AND tob.observationTypeFk = 1; - -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 `collectionTrain_new` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = 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 `collectionTrain_new`(vSectorFk INT, vWagons INT) -proc:BEGIN - - DECLARE vIsPreviousPrepared BOOLEAN; - DECLARE vCollectionFk INT; - DECLARE vWarehouseFk INT; - DECLARE vMaxTickets INT DEFAULT 4 * vWagons; - DECLARE vStateFk INT; - DECLARE vFirstTicketFk INT; - DECLARE vWorkerCode VARCHAR(3); - DECLARE vWagon INT; - DECLARE vWagonCounter INT; - DECLARE vShelve INT; - DECLARE vTicket INT; - DECLARE myUserIsSalesPersonRole BOOLEAN; - DECLARE vPrintedTickets INT; - DECLARE vMaxTicketPrinted INT DEFAULT 5 * vWagons; - - -- Establecemos el almacén y si es un sector de preparación previa, así como el estado para los tickets que se vayan preparando - SELECT isPreviousPrepared, warehouseFk - INTO vIsPreviousPrepared, vWarehouseFk - FROM vn.sector - WHERE id = vSectorFk; - - IF vIsPreviousPrepared THEN - - SELECT id INTO vStateFk - FROM vn.state - WHERE `code` = 'PREVIOUS_PREPARATION'; + + ELSE + + SET vTicketFk = vParamFk; + + SELECT t.id ticketFk, + cc.code `level`, + am.name as agencyName, + t.warehouseFk , + w.id as salesPersonFk, + IFNULL(tob.description,'')as 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 t.id = vTicketFk + LIMIT 1; + + SELECT s.alertLevel INTO vAlertLevel + FROM vn.state s + JOIN vn.ticketStateToday tst ON tst.state = s.id + WHERE tst.ticket = vTicketFk + LIMIT 1; + + IF vAlertLevel < 2 THEN + + CALL vn.ticketStateUpdate(vTicketFk, 'ON_CHECKING'); + + END IF; + + END IF; + ELSE - - SELECT id INTO vStateFk - FROM vn.state - WHERE `code` = 'ON_PREPARATION'; - - END IF; - - -- Averiguamos si es comercial el usuario - SELECT (r.name = 'salesPerson') - INTO myUserIsSalesPersonRole - FROM account.user u - JOIN account.role r ON r.id = u.role - WHERE u.id = vn.getUser(); - - -- Obtenemos el código del usuario - SELECT w.code - INTO vWorkerCode - FROM vn.worker w - WHERE w.id = account.myUser_getId(); - - -- Se obtiene nº de colección y el buffer con los pedidos preparables - INSERT INTO vn.collection - SET workerFk = account.myUser_getId(); - - SELECT LAST_INSERT_ID() INTO vCollectionFk; - CALL vn2008.production_control_source(vWarehouseFk, 0); - - SELECT COUNT(*) INTO vPrintedTickets - FROM tmp.production_buffer pb - JOIN vn.state s ON s.id = pb.state - WHERE pb.Fecha = CURDATE() - AND s.isPreparable; - - SET vMaxTicketPrinted = vMaxTicketPrinted - vPrintedTickets; - - -- AutoPRINT - - IF vMaxTicketPrinted > 0 THEN - - INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) - SELECT s2.id, pb.Id_Ticket, vn.getUser() - FROM tmp.production_buffer pb - JOIN vn.agency a ON a.id = pb.agency_id - JOIN vn.state s ON s.id = pb.state - JOIN vn.state s2 ON s2.code = 'PRINTED' - LEFT JOIN vn.route r ON r.id = pb.Id_Ruta - WHERE pb.Fecha = CURDATE() - AND NOT pb.problems - AND a.name != 'REC_SILLA' - AND (pb.ubicacion IS NOT NULL OR a.isOwn = FALSE) - AND s.isPrintable - AND (pb.m3 > 0.05 OR s.isOK) - ORDER BY (Hora - 1) * 60 + minuto > hour(now()) * 60 + minute(now()) , - s.order DESC, - Hora, - minuto, - IFNULL(r.priority,99999), - pb.m3 DESC - LIMIT vMaxTicketPrinted; - + IF vCollectionFk THEN + + SELECT t.id ticketFk, + CONCAT(SUBSTRING('ABCDEFGH',tc.wagon, 1),'-',tc.`level` ) `level`, + am.name as agencyName, + t.warehouseFk , + w.id as salesPersonFk, + IFNULL(tob.description,'')as observaciones + FROM vn.ticket t + JOIN vn.ticketCollection tc ON t.id = tc.ticketFk + LEFT JOIN vn.zone z ON z.id = t.zoneFk + LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk + LEFT JOIN vn.client c ON c.id = t.clientFk + LEFT JOIN vn.worker w ON w.id = c.salesPersonFk + LEFT JOIN vn.ticketObservation tob ON tob.ticketFk = t.id AND tob.observationTypeFk = 1 + WHERE tc.collectionFk = vCollectionFk; + + ELSE + + SET vTicketFk = vParamFk; + + SELECT t.id ticketFk, + CONCAT(SUBSTRING('ABCDEFGH',tc.wagon, 1),'-',tc.`level` ) `level`, + am.name as agencyName, + t.warehouseFk , + w.id as salesPersonFk, + IFNULL(tob.description,'')as observaciones + FROM vn.ticket t + JOIN vn.ticketCollection tc ON t.id = tc.ticketFk + LEFT JOIN vn.zone z ON z.id = t.zoneFk + LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk + LEFT JOIN vn.client c ON c.id = t.clientFk + LEFT JOIN vn.worker w ON w.id = c.salesPersonFk + LEFT JOIN vn.ticketObservation tob ON tob.ticketFk = t.id AND tob.observationTypeFk = 1 + WHERE t.id = vTicketFk + LIMIT 1; + + SELECT s.alertLevel INTO vAlertLevel + FROM vn.state s + JOIN vn.ticketStateToday tst ON tst.state = s.id + WHERE tst.ticket = vTicketFk + LIMIT 1; + + IF vAlertLevel < 2 THEN + + CALL vn.ticketStateUpdate(vTicketFk, 'ON_CHECKING'); + + END IF; + + END IF; + END IF; - - -- SELECT vMaxTicketPrinted; - -- Se seleccionan los primeros tickets, asignando colección para dejarlos bloqueados a otros sacadores. - - INSERT IGNORE INTO vn.ticketCollection(ticketFk, collectionFk) - SELECT pb.Id_Ticket, - vCollectionFk - FROM tmp.production_buffer pb - JOIN vn.state s ON s.id = pb.state - WHERE pb.collectionFk IS NULL - AND ( - (s.isPreparable AND NOT myUserIsSalesPersonRole AND pb.Agencia != 'REC_SILLA') - OR - (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) - ) - ORDER BY (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) DESC, pb.Hora, pb.Minuto - LIMIT vMaxTickets; - - - -- Creamos una tabla temporal con los datos que necesitamos para depurar la colección - DROP TEMPORARY TABLE IF EXISTS tmp.ticket; - CREATE TEMPORARY TABLE tmp.ticket - SELECT pb.Id_Ticket ticketFk, - pb.lines, - pb.m3 * 1000 liters, - 0 as height, - 0 as shelve, - 0 as wagon - FROM tmp.production_buffer pb - JOIN vn.ticketCollection tc ON tc.ticketFk = pb.Id_Ticket - WHERE tc.collectionFk = vCollectionFk; - /* El criterio para formar la colección es el siguiente: - * - * 1º.- Los tickets asignados son prioritarios, y por ello ya vienen ordenados en las primeras posiciones. - * - */ - - SELECT ticketFk - INTO vFirstTicketFk - FROM tmp.ticket - LIMIT 1; - - -- Establece altura máxima por pedido, porque las plantas no se pueden recostar. - UPDATE tmp.ticket t - JOIN - ( SELECT MAX(i.size) maxHeigth, - tc.ticketFk - FROM vn.ticketCollection tc - JOIN vn.sale s ON s.ticketFk = tc.ticketFk - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.itemCategory ic ON ic.id = it.categoryFk - WHERE ic.isReclining = FALSE - AND tc.collectionFk = vCollectionFk - GROUP BY tc.ticketFk) sub ON sub.ticketFk = t.ticketFk - SET t.height = sub.maxHeigth; - - -- Vamos a generar una tabla con todas las posibilidades de asignacion de pedido - DROP TEMPORARY TABLE IF EXISTS tmp.wagonsVolumetry; - CREATE TEMPORARY TABLE tmp.wagonsVolumetry - SELECT cv.`level` as shelve, - 1 as wagon, - cv.lines, - cv.liters, - cv.height - FROM vn.collectionVolumetry cv; - - SET vWagonCounter = 1; - - WHILE vWagonCounter < vWagons DO - - SET vWagonCounter = vWagonCounter + 1; - - INSERT INTO tmp.wagonsVolumetry(shelve, wagon, `lines`, liters, height) - SELECT cv.`level` as shelve, - vWagonCounter as wagon, - cv.lines, - cv.liters, - cv.height - FROM vn.collectionVolumetry cv; - - END WHILE; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketShelve; - CREATE TEMPORARY TABLE tmp.ticketShelve - SELECT ticketFk, shelve, wagon, linesDif, LitersDif, heightDif - FROM ( - SELECT t.ticketFk, - wv.shelve, - wv.wagon, - CAST(wv.lines AS SIGNED) - t.lines as linesDif, - CAST(wv.liters AS SIGNED) - t.liters as litersDif, - CAST(wv.height AS SIGNED) - t.height as heightDif - FROM tmp.wagonsVolumetry wv - JOIN tmp.ticket t - ORDER BY (t.ticketFk = vFirstTicketFk) DESC, linesDif - ) sub - WHERE linesDif >= 0 - AND litersDif >= 0 - AND heightDif >= 0 - ORDER BY linesDif; - - -- Insertamos una opcion virtual para carro completo. Todo ticket tiene que poder entrar en un carro completo.... - INSERT INTO tmp.ticketShelve(ticketFk, shelve, wagon, linesDif, LitersDif, heightDif) - SELECT t.ticketFk, 0, wv.wagon, 999, 999,999 - FROM tmp.ticket t - JOIN tmp.wagonsVolumetry wv - GROUP BY t.ticketFk, wv.wagon; - /* - DROP TEMPORARY TABLE IF EXISTS tmp.tsKKK; - - CREATE TEMPORARY TABLE tmp.tsKKK - SELECT t.ticketFk, - wv.shelve, - wv.wagon, - CAST(wv.lines AS SIGNED) - t.lines as linesDif, - CAST(wv.liters AS SIGNED) - t.liters as litersDif, - CAST(wv.height AS SIGNED) - t.height as heightDif - FROM tmp.wagonsVolumetry wv - JOIN tmp.ticket t - ORDER BY (t.ticketFk = vFirstTicketFk) DESC, linesDif; - - - DROP TEMPORARY TABLE IF EXISTS tmp.tsKK; - - CREATE TEMPORARY TABLE tmp.tsKK - SELECT * FROM tmp.ticketShelve; - - SELECT * FROM tmp.tsKK; - - SELECT * FROM tmp.ticket; - */ - SET vWagonCounter = 0; - - WHILE vWagonCounter < vWagons DO - - SET vWagonCounter = vWagonCounter + 1; - - -- Asignamos la primera balda util al primer pedido - IF vWagonCounter = 1 THEN - - SELECT shelve INTO vShelve - FROM tmp.ticketShelve - WHERE ticketFk = vFirstTicketFk - AND wagon = vWagonCounter - ORDER BY heightDif, litersDif, linesDif - LIMIT 1; - - ELSE - - SELECT shelve, ticketFk INTO vShelve, vFirstTicketFk - FROM tmp.ticketShelve - WHERE wagon = vWagonCounter - ORDER BY heightDif, litersDif, linesDif - LIMIT 1; - - END IF; - - IF vShelve > 0 THEN - - UPDATE tmp.ticket - SET shelve = vShelve, - wagon = vWagonCounter - WHERE ticketFk = vFirstTicketFk; - - DELETE FROM tmp.ticketShelve - WHERE ticketFk = vFirstTicketFk - OR (shelve = vShelve AND wagon = vWagonCounter); - - WHILE (SELECT COUNT(*) FROM tmp.ticketShelve WHERE wagon = vWagonCounter) DO - - SELECT ticketFk, shelve - INTO vTicket, vShelve - FROM tmp.ticketShelve - WHERE wagon = vWagonCounter - LIMIT 1; - - UPDATE tmp.ticket - SET shelve = vShelve, - wagon = vWagonCounter - WHERE ticketFk = vTicket; - - DELETE FROM tmp.ticketShelve - WHERE ticketFk = vTicket - OR (shelve = vShelve AND wagon = vWagonCounter); - - END WHILE; - - ELSE - - UPDATE tmp.ticket - SET shelve = 1, wagon = vWagonCounter - WHERE ticketFk = vFirstTicketFk; - - DELETE FROM tmp.ticketShelve - WHERE ticketFk = vFirstTicketFk - AND wagon != vWagonCounter; - - END IF; - - END WHILE; - - -- Eliminamos los que se han quedado sin balda - DELETE FROM tmp.ticket WHERE shelve = 0; - - -- Elimina los tickets bloqueados que no se van a preparar - DELETE tc.* - FROM vn.ticketCollection tc - LEFT JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk - WHERE tc.collectionFk = vCollectionFk - AND t.ticketFk IS NULL; - - -- Actualiza el estado de la colección - UPDATE vn.collection c - JOIN vn.state st ON st.code = 'ON_PREPARATION' - SET c.stateFk = st.id - WHERE c.id = vCollectionFk; - - -- Asigna las bandejas - UPDATE vn.ticketCollection tc - JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk - SET tc.level = t.shelve, tc.wagon = t.wagon; - - -- Actualiza el estado de los tickets - INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) - SELECT vStateFk, ticketFk, account.myUser_getId() - FROM vn.ticketCollection tc - WHERE tc.collectionFk = vCollectionFk; - - -- Avisa los preparados previos que hay que bajar del altillo imprimiendo etiqueta - INSERT IGNORE INTO vn.ticketDown(ticketFk) - SELECT DISTINCT tc.ticketFk - FROM vn.ticketCollection tc - JOIN vncontrol.inter vi ON vi.Id_Ticket = tc.ticketFk - JOIN vn.state st ON st.id = vi.state_id - JOIN vn.ticket t ON t.id = tc.ticketFk - JOIN vn.warehouse w ON w.id = t.warehouseFk - WHERE tc.collectionFk = vCollectionFk - AND w.name = 'Silla FV' - AND st.code = 'PREVIOUS_PREPARATION'; - - SELECT vCollectionFk; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -49060,57 +48840,65 @@ CREATE DEFINER=`root`@`%` PROCEDURE `collection_new`(vSectorFk INT) proc:BEGIN DECLARE vIsPreviousPrepared BOOLEAN; - DECLARE vCollectionFk INT; - DECLARE vWarehouseFk INT; - DECLARE vMaxTickets INT DEFAULT 4; - DECLARE vStateFk INT; - DECLARE vFirstTicketFk INT; - DECLARE vWorkerCode VARCHAR(3); - DECLARE vShelve INT; - DECLARE vTicket INT; - DECLARE myUserIsSalesPersonRole BOOLEAN; - DECLARE vPrintedTickets INT; - DECLARE vMaxTicketPrinted INT DEFAULT 30; - - - - -- Se comprueba si existe coleccion pendiente, en cuyo caso se devuelve esa colección - SELECT collectionFk INTO vCollectionFk - FROM - ( - SELECT tc.collectionFk, COUNT(*) as lineas, sum(IF(st.id,0,1)) as libres - FROM vn.collection c - JOIN vn.ticketCollection tc ON tc.collectionFk = c.id - JOIN vn.ticket t ON t.id = tc.ticketFk - JOIN vn.sale s ON s.ticketFk = t.id - LEFT JOIN vn.saleTracking st ON st.saleFk = s.id - WHERE c.workerFk = vn.getUser() - AND s.quantity - AND c.created > CURDATE() - GROUP BY c.id - HAVING libres = lineas) sub - LIMIT 1; - - IF vCollectionFk THEN - - SELECT vCollectionFk; - - LEAVE proc; - - END IF; - - IF /*vSectorFk = 37*/ FALSE THEN - - CALL vn.collectionTrain_new(9,3); - - ELSE - + DECLARE vCollectionFk INT; + DECLARE vWarehouseFk INT; + DECLARE vMaxTickets INT; + DECLARE vStateFk INT; + DECLARE vFirstTicketFk INT; + DECLARE vWorkerCode VARCHAR(3); + DECLARE vWagon INT; + DECLARE vWagonCounter INT; + DECLARE vShelve INT; + DECLARE vTicket INT; + DECLARE vTicketToSplit INT; + DECLARE myUserIsSalesPersonRole BOOLEAN; + DECLARE vPrintedTickets INT; + DECLARE vMaxTicketPrinted INT; + DECLARE vItemPackingTypeFk VARCHAR(1); + DECLARE vWagons INT DEFAULT 2; + DECLARE hasAssignedTickets BOOLEAN; + DECLARE vMaxNotReadyCollections INT DEFAULT 0; + DECLARE vNotReadyCollections INT; + DECLARE vSectorCode VARCHAR(20); + +-- Si hay colecciones sin terminar, sale del proceso + SELECT count(*) INTO vNotReadyCollections + FROM vn.collection c + JOIN vn.state s ON s.id = c.stateFk + WHERE c.workerFk = vn.getUser() + AND s.code = 'ON_PREPARATION' + AND c.created > TIMESTAMPADD(HOUR , -5,NOW()); + + IF vMaxNotReadyCollections < vNotReadyCollections THEN + + LEAVE proc; + + 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 - INTO vIsPreviousPrepared, vWarehouseFk + SELECT isPreviousPrepared, warehouseFk, itemPackingTypeFk, code + INTO vIsPreviousPrepared, vWarehouseFk, vItemPackingTypeFk, vSectorCode FROM vn.sector WHERE id = vSectorFk; + IF vSectorCode != 'V' THEN -- beta + + CALL vn.collection_new_beta(vSectorFk); + + LEAVE proc; + + END IF; + + 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 SELECT id INTO vStateFk @@ -49130,227 +48918,311 @@ proc:BEGIN FROM account.user u JOIN account.role r ON r.id = u.role WHERE u.id = vn.getUser(); - - -- Obtenemos el código del usuario - SELECT w.code - INTO vWorkerCode - FROM vn.worker w - WHERE w.id = account.myUser_getId(); - - IF vWorkerCode = 'ATM' THEN - - SET vMaxTickets = 8; - - END IF; -- Se obtiene nº de colección y el buffer con los pedidos preparables INSERT INTO vn.collection - SET workerFk = account.myUser_getId(); + SET workerFk = account.myUser_getId(), + itemPackingTypeFk = vItemPackingTypeFk; SELECT LAST_INSERT_ID() INTO vCollectionFk; - CALL vn2008.production_control_source(vWarehouseFk, 0); - - SELECT COUNT(*) INTO vPrintedTickets - FROM tmp.production_buffer pb - JOIN vn.state s ON s.id = pb.state - WHERE pb.Fecha = CURDATE() - AND s.isPreparable; - - SET vMaxTicketPrinted = vMaxTicketPrinted - vPrintedTickets; - - -- AutoPRINT - - IF vMaxTicketPrinted > 0 THEN - - INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) - SELECT s2.id, pb.Id_Ticket, vn.getUser() - FROM tmp.production_buffer pb - JOIN vn.agency a ON a.id = pb.agency_id - JOIN vn.warehouse w ON w.id = pb.warehouse_id - JOIN vn.state s ON s.id = pb.state - JOIN vn.state s2 ON s2.code = 'PRINTED_AUTO' - LEFT JOIN vn.route r ON r.id = pb.Id_Ruta - WHERE pb.Fecha = CURDATE() - AND NOT pb.problems - AND a.name != 'REC_SILLA' - AND (pb.ubicacion IS NOT NULL OR a.isOwn = FALSE ) - AND (r.id IS NOT NULL OR a.isOwn = FALSE OR a.name = 'REC_ALGEMESI') - AND s.isPrintable - AND (pb.m3 > 0.05 OR s.isOK) - ORDER BY (Hora - 1) * 60 + minuto > hour(now()) * 60 + minute(now()) , - s.order DESC, - Hora, - minuto, - IFNULL(r.priority,99999), - IFNULL(r.id,999999), - pb.m3 DESC - LIMIT vMaxTicketPrinted; - - END IF; - - -- SELECT vMaxTicketPrinted; - -- Se seleccionan los primeros tickets, asignando colección para dejarlos bloqueados a otros sacadores. - - INSERT IGNORE INTO vn.ticketCollection(ticketFk, collectionFk) - SELECT pb.Id_Ticket, - vCollectionFk - FROM tmp.production_buffer pb - JOIN vn.ticketStateToday tst ON tst.ticket = pb.Id_Ticket - JOIN vn.state s ON s.id = tst.state - LEFT JOIN vn.route r ON r.id = pb.Id_Ruta - WHERE pb.collectionFk IS NULL - AND ( - (s.isPreparable AND NOT myUserIsSalesPersonRole AND pb.Agencia != 'REC_SILLA') - OR - (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) - ) - ORDER BY (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) DESC, - pb.Hora, - pb.Minuto, - IF(IFNULL(r.priority,0) = 0, 999, r.priority), - IFNULL(r.id,99999) - /*, - pb.m3 DESC*/ - LIMIT vMaxTickets; + CALL vn.productionControl(vWarehouseFk, 0); + + -- 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 + FROM tmp.productionBuffer pb + JOIN vn.state s ON s.id = pb.state + WHERE s.code = 'PICKER_DESIGNED' + AND pb.workerCode = vWorkerCode; + + IF hasAssignedTickets THEN + + UPDATE vn.collection + SET itemPackingTypeFk = NULL + WHERE id = vCollectionFk; + DROP TEMPORARY TABLE IF EXISTS tmp.ticketToSplit; + CREATE TEMPORARY TABLE tmp.ticketToSplit + SELECT pb.ticketFk + FROM tmp.productionBuffer pb + JOIN vn.state s ON s.id = pb.state + WHERE s.code = 'PICKER_DESIGNED' + AND pb.workerCode = vWorkerCode + ORDER BY HH, + mm, + s.`order` DESC, + pb.m3 DESC; + + WHILE (SELECT COUNT(*) FROM tmp.ticketToSplit) DO + + SELECT MIN(ticketFk) INTO vTicketToSplit + FROM tmp.ticketToSplit; + + CALL vn.ticket_splitItemPackingType(vTicketToSplit); + + INSERT INTO vn.ticketCollection(ticketFk, collectionFk) + SELECT ticketFk, vCollectionFk + FROM tmp.ticketIPT; + + DELETE FROM tmp.ticketToSplit + WHERE ticketFk = vTicketToSplit; + + END WHILE; + + + ELSE + + SELECT COUNT(*) INTO vPrintedTickets + FROM tmp.productionBuffer pb + JOIN vn.state s ON s.id = pb.state + JOIN vn.agencyMode am ON am.id = pb.agencyModeFk + JOIN vn.agency a ON a.id = am.agencyFk + WHERE pb.shipped = CURDATE() + AND (pb.ubicacion IS NOT NULL OR a.isOwn = FALSE ) + AND s.isPreparable + AND (pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH) + OR pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV) + OR pb.F > 0 AND vItemPackingTypeFk = 'F' AND ISNULL(pb.collectionF) + OR pb.P > 0 AND vItemPackingTypeFk = 'P' AND ISNULL(pb.collectionP)); + + SET vMaxTicketPrinted = vMaxTicketPrinted - vPrintedTickets; + -- AutoPRINT + + IF vMaxTicketPrinted > 0 THEN + + INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) + 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 + JOIN vn.state s ON s.id = pb.state + JOIN vn.state s2 ON s2.code = 'PRINTED_AUTO' + WHERE pb.shipped = CURDATE() + AND LENGTH(pb.problem) = 0 + AND (pb.ubicacion IS NOT NULL OR a.isOwn = FALSE ) + AND s.isPrintable + AND (pb.m3 > 0.05 OR s.isOK) + AND (pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH) + OR pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV) + OR pb.F > 0 AND vItemPackingTypeFk = 'F' AND ISNULL(pb.collectionF) + OR pb.P > 0 AND vItemPackingTypeFk = 'P' AND ISNULL(pb.collectionP)) + ORDER BY HH, + mm, + s.`order` DESC, + pb.m3 DESC + LIMIT vMaxTicketPrinted; + + END IF; + + -- Se seleccionan los primeros tickets, asignando colección para dejarlos bloqueados a otros sacadores. + -- Se splitan los tickets preparables, para que solo tengan un tipo de empaquetado + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketToSplit; + CREATE TEMPORARY TABLE tmp.ticketToSplit + SELECT pb.ticketFk + FROM tmp.productionBuffer pb + JOIN vn.agencyMode am ON am.id = pb.agencyModeFk + JOIN vn.agency a ON a.id = am.agencyFk + JOIN vn.ticketStateToday tst ON tst.ticket = pb.ticketFk + JOIN vn.state s ON s.id = tst.state + WHERE ( pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH) + OR pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV) + OR pb.F > 0 AND vItemPackingTypeFk = 'F' AND ISNULL(pb.collectionF) + OR pb.P > 0 AND vItemPackingTypeFk = 'P' AND ISNULL(pb.collectionP)) + AND (pb.ubicacion IS NOT NULL OR a.isOwn = FALSE ) + AND LENGTH(pb.problem) = 0 + AND s.isPreparable + AND NOT myUserIsSalesPersonRole + ORDER BY pb.HH, pb.mm, s.`order` DESC + LIMIT vMaxTickets; + + WHILE (SELECT COUNT(*) FROM tmp.ticketToSplit) DO + + SELECT MIN(ticketFk) INTO vTicketToSplit + FROM tmp.ticketToSplit; + + CALL vn.ticket_splitItemPackingType(vTicketToSplit); + + INSERT INTO vn.ticketCollection(ticketFk, collectionFk) + SELECT ticketFk, vCollectionFk + FROM tmp.ticketIPT + WHERE itemPackingTypeFk = vItemPackingTypeFk; + + DELETE FROM tmp.ticketToSplit + WHERE ticketFk = vTicketToSplit; + + END WHILE; + + END IF; -- Creamos una tabla temporal con los datos que necesitamos para depurar la colección DROP TEMPORARY TABLE IF EXISTS tmp.ticket; CREATE TEMPORARY TABLE tmp.ticket - SELECT pb.Id_Ticket ticketFk, - pb.lines, + SELECT pb.ticketFk, + pb.`lines`, pb.m3 * 1000 liters, 0 as height, - 0 as shelve - FROM tmp.production_buffer pb - JOIN vn.ticketCollection tc ON tc.ticketFk = pb.Id_Ticket - WHERE tc.collectionFk = vCollectionFk; + 0 as shelve, + 0 as wagon, + pb.productionOrder + FROM tmp.productionBuffer pb + JOIN vn.ticketCollection tc ON tc.ticketFk = pb.ticketFk + WHERE tc.collectionFk = vCollectionFk + ORDER BY pb.productionOrder DESC, HH, mm + LIMIT vMaxTickets; + + /* + * + * Construccion del tren + * + */ SELECT ticketFk INTO vFirstTicketFk FROM tmp.ticket + ORDER BY productionOrder DESC LIMIT 1; - - IF (SELECT pb.Agencia FROM tmp.production_buffer pb WHERE Id_Ticket = vFirstTicketFk) = 'REC_SILLA' THEN - - DELETE FROM tmp.ticket WHERE ticketFk != vFirstTicketFk; - - UPDATE tmp.ticket SET shelve = 1; - -- Como sólo hay un ticket, se le asigna el nivel 1 y acabamos - - ELSE - - -- Eliminamos los de recogida, puesto que el primero sabemos que no es de rec_silla - DELETE t.* - FROM tmp.ticket t - JOIN tmp.production_buffer pb ON pb.Id_Ticket = t.ticketFk - WHERE pb.Agencia = 'REC_SILLA'; + + INSERT INTO tmp.log(ticketFk) VALUES(vFirstTicketFk); + + -- Establece altura máxima por pedido, porque las plantas no se pueden recostar. + UPDATE tmp.ticket t + JOIN + ( SELECT MAX(i.size) maxHeigth, + tc.ticketFk + FROM vn.ticketCollection tc + JOIN vn.sale s ON s.ticketFk = tc.ticketFk + JOIN vn.item i ON i.id = s.itemFk + WHERE i.itemPackingTypeFk = 'V' + AND tc.collectionFk = vCollectionFk + GROUP BY tc.ticketFk) sub ON sub.ticketFk = t.ticketFk + SET t.height = IFNULL(sub.maxHeigth,0); + + -- Vamos a generar una tabla con todas las posibilidades de asignacion de pedido + DROP TEMPORARY TABLE IF EXISTS tmp.wagonsVolumetry; + CREATE TEMPORARY TABLE tmp.wagonsVolumetry + SELECT cv.`level` as shelve, + 1 as wagon, + cv.`lines`, + cv.liters, + cv.height + FROM vn.collectionVolumetry cv; - -- Establece altura máxima por pedido, porque las plantas no se pueden recostar. - UPDATE tmp.ticket t - JOIN - ( SELECT MAX(i.size) maxHeigth, - tc.ticketFk - FROM vn.ticketCollection tc - JOIN vn.sale s ON s.ticketFk = tc.ticketFk - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.itemCategory ic ON ic.id = it.categoryFk - WHERE ic.isReclining = FALSE - AND tc.collectionFk = vCollectionFk - GROUP BY tc.ticketFk) sub ON sub.ticketFk = t.ticketFk - SET t.height = sub.maxHeigth; - - -- Vamos a generar una tabla con todas las posibilidades de asignacion de pedido - IF vWorkerCode = 'LOM' THEN + SET vWagonCounter = 1; - DROP TEMPORARY TABLE IF EXISTS tmp.ticketShelve; - CREATE TEMPORARY TABLE tmp.ticketShelve - SELECT ticketFk, shelve, linesDif, LitersDif, heightDif - FROM ( - SELECT t.ticketFk, - cv.`level` shelve, - CAST(cv.lines AS SIGNED) - t.lines as linesDif, - CAST(cv.liters AS SIGNED) - t.liters as litersDif, - CAST(cv.height AS SIGNED) - t.height as heightDif - FROM vn.collectionVolumetry_Paloma cv - JOIN tmp.ticket t - ORDER BY (t.ticketFk = vFirstTicketFk) DESC, linesDif - ) sub - WHERE linesDif >= 0 - AND litersDif >= 0 - AND heightDif >= 0 - ORDER BY linesDif; + WHILE vWagonCounter < vWagons DO - ELSE + SET vWagonCounter = vWagonCounter + 1; - DROP TEMPORARY TABLE IF EXISTS tmp.ticketShelve; - CREATE TEMPORARY TABLE tmp.ticketShelve - SELECT ticketFk, shelve, linesDif, LitersDif, heightDif - FROM ( - SELECT t.ticketFk, - cv.`level` shelve, - CAST(cv.lines AS SIGNED) - t.lines as linesDif, - CAST(cv.liters AS SIGNED) - t.liters as litersDif, - CAST(cv.height AS SIGNED) - t.height as heightDif - FROM vn.collectionVolumetry cv - JOIN tmp.ticket t - ORDER BY (t.ticketFk = vFirstTicketFk) DESC, linesDif - ) sub - WHERE linesDif >= 0 - AND litersDif >= 0 - AND heightDif >= 0 - ORDER BY linesDif; - - END IF; - + INSERT INTO tmp.wagonsVolumetry(shelve, wagon, `lines`, liters, height) + SELECT cv.`level` as shelve, + vWagonCounter as wagon, + cv.`lines`, + cv.liters, + cv.height + FROM vn.collectionVolumetry cv; + + END WHILE; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketShelve; + CREATE TEMPORARY TABLE tmp.ticketShelve + SELECT ticketFk, shelve, wagon, linesDif, LitersDif, heightDif + FROM ( + SELECT t.ticketFk, + wv.shelve, + wv.wagon, + t.productionOrder, + CAST(wv.`lines` AS SIGNED) - t.`lines` as linesDif, + CAST(wv.liters AS SIGNED) - t.liters as litersDif, + CAST(wv.height AS SIGNED) - t.height as heightDif + FROM tmp.wagonsVolumetry wv + JOIN tmp.ticket t + ) sub + WHERE linesDif >= 0 + AND litersDif >= 0 + AND heightDif >= 0 + ORDER BY productionOrder DESC, linesDif, LitersDif, heightDif ; + + -- Insertamos una opcion virtual para carro completo. Todo ticket tiene que poder entrar en un carro completo.... + INSERT INTO tmp.ticketShelve(ticketFk, shelve, wagon, linesDif, LitersDif, heightDif) + SELECT t.ticketFk, 0, wv.wagon, 999, 999,999 + FROM tmp.ticket t + JOIN tmp.wagonsVolumetry wv + GROUP BY t.ticketFk, wv.wagon; + + SET vWagonCounter = 0; + + WHILE vWagonCounter < vWagons DO + + SET vWagonCounter = vWagonCounter + 1; + -- Asignamos la primera balda util al primer pedido - SELECT IFNULL(shelve,0) INTO vShelve - FROM tmp.ticketShelve - WHERE ticketFk = vFirstTicketFk - ORDER BY heightDif, litersDif, linesDif - LIMIT 1; + IF vWagonCounter = 1 THEN - IF vShelve THEN + SELECT shelve INTO vShelve + FROM tmp.ticketShelve + WHERE ticketFk = vFirstTicketFk + AND wagon = vWagonCounter + ORDER BY heightDif, litersDif, linesDif + LIMIT 1; + + ELSE + + SELECT shelve, ticketFk INTO vShelve, vFirstTicketFk + FROM tmp.ticketShelve + WHERE wagon = vWagonCounter + ORDER BY heightDif, litersDif, linesDif + LIMIT 1; + + END IF; + IF vShelve > 0 THEN + UPDATE tmp.ticket - SET shelve = vShelve + SET shelve = vShelve, + wagon = vWagonCounter WHERE ticketFk = vFirstTicketFk; DELETE FROM tmp.ticketShelve WHERE ticketFk = vFirstTicketFk - OR shelve = vShelve; + OR (shelve = vShelve AND wagon = vWagonCounter); - WHILE (SELECT COUNT(*) FROM tmp.ticketShelve) DO + WHILE (SELECT COUNT(*) FROM tmp.ticketShelve WHERE wagon = vWagonCounter) DO - SELECT ticketFk, shelve + SELECT ticketFk, shelve INTO vTicket, vShelve FROM tmp.ticketShelve + WHERE wagon = vWagonCounter LIMIT 1; UPDATE tmp.ticket - SET shelve = vShelve + SET shelve = vShelve, + wagon = vWagonCounter WHERE ticketFk = vTicket; DELETE FROM tmp.ticketShelve WHERE ticketFk = vTicket - OR shelve = vShelve; + OR (shelve = vShelve AND wagon = vWagonCounter); END WHILE; - - ELSE - + + ELSE + UPDATE tmp.ticket - SET shelve = 1 + SET shelve = 1, wagon = vWagonCounter WHERE ticketFk = vFirstTicketFk; + DELETE FROM tmp.ticketShelve + WHERE ticketFk = vFirstTicketFk + AND wagon != vWagonCounter; + END IF; - END IF; - + END WHILE; + -- Eliminamos los que se han quedado sin balda - DELETE FROM tmp.ticket WHERE shelve = 0 ; + DELETE FROM tmp.ticket WHERE shelve = 0; -- Elimina los tickets bloqueados que no se van a preparar DELETE tc.* @@ -49358,7 +49230,8 @@ proc:BEGIN LEFT JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk WHERE tc.collectionFk = vCollectionFk AND t.ticketFk IS NULL; - + + -- Actualiza el estado de la colección UPDATE vn.collection c JOIN vn.state st ON st.code = 'ON_PREPARATION' @@ -49368,45 +49241,47 @@ proc:BEGIN -- Asigna las bandejas UPDATE vn.ticketCollection tc JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk - SET tc.level = t.shelve; + 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, account.myUser_getId() FROM vn.ticketCollection tc - WHERE tc.collectionFk = vCollectionFk - UNION ALL - SELECT vStateFk, sw.id, account.myUser_getId() - FROM vn.stowaway sw - JOIN vn.ticketCollection tc ON tc.ticketFk = sw.shipFk WHERE tc.collectionFk = vCollectionFk; - - -- Avisa los preparados previos que hay que bajar del altillo imprimiendo etiqueta - INSERT IGNORE INTO vn.ticketDown(ticketFk) - SELECT DISTINCT tc.ticketFk - FROM vn.ticketCollection tc - JOIN vncontrol.inter vi ON vi.Id_Ticket = tc.ticketFk - JOIN vn.state st ON st.id = vi.state_id - JOIN vn.ticket t ON t.id = tc.ticketFk - JOIN vn.warehouse w ON w.id = t.warehouseFk - WHERE tc.collectionFk = vCollectionFk - AND w.name = 'Silla FV' - AND st.code = 'PREVIOUS_PREPARATION'; - - IF (SELECT COUNT(*) FROM vn.ticketCollection WHERE collectionFk = vCollectionFk) THEN - - CALL vn.salesMerge_byCollection(vCollectionFk); - - SELECT vCollectionFk; - - ELSE - - DELETE FROM vn.collection WHERE id = vCollectionFk; - SELECT 0; - - END IF; + + -- Aviso para la preparacion previa + INSERT INTO vn.ticketDown(ticketFk, collectionFk) + SELECT tc.ticketFk, tc.collectionFk + FROM vn.ticketCollection tc + WHERE tc.collectionFk = vCollectionFk; + + IF (SELECT count(*) FROM vn.ticketCollection WHERE collectionFk = vCollectionFk) THEN + + CALL vn.salesMerge_byCollection(vCollectionFk); + + UPDATE vn.collection c + JOIN (SELECT count(*) saleTotalCount , + sum(s.isPicked != 0) salePickedCount + FROM vn.ticketCollection tc + JOIN vn.sale s ON s.ticketFk = tc.ticketFk + WHERE tc.collectionFk = vCollectionFk + AND s.quantity > 0 + ) sub + SET c.saleTotalCount = sub.saleTotalCount, + c.salePickedCount = sub.salePickedCount + WHERE c.id = vCollectionFk; + + SELECT vCollectionFk; + + ELSE + + DELETE FROM vn.collection WHERE id = vCollectionFk; + -- SELECT NULL; END IF; + + DROP TEMPORARY TABLE tmp.ticketIPT; + DROP TEMPORARY TABLE IF EXISTS tmp.ticketToSplit; END ;; DELIMITER ; @@ -49414,69 +49289,71 @@ 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_new_Basic` */; +/*!50003 DROP PROCEDURE IF EXISTS `collection_new_beta` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = 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 `collection_new_Basic`(vSectorFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `collection_new_beta`(vSectorFk INT) proc:BEGIN DECLARE vIsPreviousPrepared BOOLEAN; - DECLARE vCollectionFk INT; - DECLARE vWarehouseFk INT; - DECLARE vMaxTickets INT DEFAULT 4; - DECLARE vStateFk INT; - DECLARE vFirstTicketFk INT; - DECLARE vWorkerCode VARCHAR(3); - DECLARE vShelve INT; - DECLARE vTicket INT; - DECLARE myUserIsSalesPersonRole BOOLEAN; - DECLARE vPrintedTickets INT; - DECLARE vMaxTicketPrinted INT DEFAULT 10; - - -- Se comprueba si existe coleccion pendiente, en cuyo caso se devuelve esa colección - SELECT collectionFk INTO vCollectionFk - FROM - ( - SELECT tc.collectionFk, COUNT(*) as lineas, sum(IF(st.id,0,1)) as libres - FROM vn.collection c - JOIN vn.ticketCollection tc ON tc.collectionFk = c.id - JOIN vn.ticket t ON t.id = tc.ticketFk - JOIN vn.sale s ON s.ticketFk = t.id - LEFT JOIN vn.saleTracking st ON st.saleFk = s.id - WHERE c.workerFk = vn.getUser() - AND s.quantity - AND c.created > CURDATE() - GROUP BY c.id - HAVING libres = lineas) sub - LIMIT 1; - - IF vCollectionFk THEN - - SELECT vCollectionFk; - - LEAVE proc; - - END IF; - - IF /*vSectorFk = 37*/ FALSE THEN - - CALL vn.collectionTrain_new(9,3); - - ELSE - + DECLARE vCollectionFk INT; + DECLARE vWarehouseFk INT; + DECLARE vMaxTickets INT; + DECLARE vStateFk INT; + DECLARE vFirstTicketFk INT; + DECLARE vWorkerCode VARCHAR(3); + DECLARE vWagon INT; + DECLARE vWagonCounter INT; + DECLARE vShelve INT; + DECLARE vTicket INT; + DECLARE vTicketToSplit INT; + DECLARE myUserIsSalesPersonRole BOOLEAN; + DECLARE vPrintedTickets INT; + DECLARE vMaxTicketPrinted INT; + DECLARE vItemPackingTypeFk VARCHAR(1); + DECLARE vWagons INT DEFAULT 2; + DECLARE hasAssignedTickets BOOLEAN; + DECLARE vMaxNotReadyCollections INT DEFAULT 0; + DECLARE vNotReadyCollections INT; + DECLARE vSectorCode VARCHAR(20); + +-- Si hay colecciones sin terminar, sale del proceso + SELECT count(*) INTO vNotReadyCollections + FROM vn.collection c + JOIN vn.state s ON s.id = c.stateFk + WHERE c.workerFk = vn.getUser() + AND s.code = 'ON_PREPARATION' + AND c.created > TIMESTAMPADD(HOUR , -5,NOW()); + + IF vMaxNotReadyCollections < vNotReadyCollections THEN + + LEAVE proc; + + 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 - INTO vIsPreviousPrepared, vWarehouseFk + SELECT isPreviousPrepared, warehouseFk, itemPackingTypeFk, code + INTO vIsPreviousPrepared, vWarehouseFk, vItemPackingTypeFk, vSectorCode FROM vn.sector WHERE id = vSectorFk; + 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 SELECT id INTO vStateFk @@ -49505,187 +49382,736 @@ proc:BEGIN -- Se obtiene nº de colección y el buffer con los pedidos preparables INSERT INTO vn.collection - SET workerFk = account.myUser_getId(); + SET workerFk = account.myUser_getId(), + itemPackingTypeFk = vItemPackingTypeFk; SELECT LAST_INSERT_ID() INTO vCollectionFk; - CALL vn2008.production_control_source(vWarehouseFk, 0); - - SELECT COUNT(*) INTO vPrintedTickets - FROM tmp.production_buffer pb - JOIN vn.state s ON s.id = pb.state - WHERE pb.Fecha = CURDATE() - AND s.isPreparable; - - SET vMaxTicketPrinted = vMaxTicketPrinted - vPrintedTickets; - - -- AutoPRINT - - IF vMaxTicketPrinted > 0 THEN - - INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) - SELECT s2.id, pb.Id_Ticket, vn.getUser() - FROM tmp.production_buffer pb - JOIN vn.agency a ON a.id = pb.agency_id - JOIN vn.warehouse w ON w.id = pb.warehouse_id - JOIN vn.state s ON s.id = pb.state - JOIN vn.state s2 ON s2.code = 'PRINTED_AUTO' - LEFT JOIN vn.route r ON r.id = pb.Id_Ruta - WHERE pb.Fecha = CURDATE() - AND NOT pb.problems - AND a.name != 'REC_SILLA' - AND (pb.ubicacion IS NOT NULL OR a.isOwn = FALSE ) - AND s.isPrintable - AND (pb.m3 > 0.05 OR s.isOK) - ORDER BY - (Hora - 1) * 60 + minuto > hour(now()) * 60 + minute(now()) , - s.order DESC, - Hora, - minuto, - IFNULL(r.priority,99999), - IFNULL(r.id,999999), - pb.m3 DESC - LIMIT vMaxTicketPrinted; - - END IF; - - -- SELECT vMaxTicketPrinted; - -- Se seleccionan los primeros tickets, asignando colección para dejarlos bloqueados a otros sacadores. - - INSERT IGNORE INTO vn.ticketCollection(ticketFk, collectionFk) - SELECT pb.Id_Ticket, - vCollectionFk - FROM tmp.production_buffer pb - JOIN vn.ticketStateToday tst ON tst.ticket = pb.Id_Ticket - JOIN vn.state s ON s.id = tst.state - LEFT JOIN vn.route r ON r.id = pb.Id_Ruta - WHERE pb.collectionFk IS NULL - AND ( - (s.isPreparable AND NOT myUserIsSalesPersonRole AND pb.Agencia != 'REC_SILLA') - OR - (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) - ) - ORDER BY (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) DESC, - pb.Hora, - pb.Minuto, - IF(IFNULL(r.priority,0) = 0, 999, r.priority), - IFNULL(r.id,99999), - pb.m3 DESC - LIMIT vMaxTickets; + CALL vn.productionControl(vWarehouseFk, 0); + + -- 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 + FROM tmp.productionBuffer pb + JOIN vn.state s ON s.id = pb.state + WHERE s.code = 'PICKER_DESIGNED' + AND pb.workerCode = vWorkerCode; + + IF hasAssignedTickets THEN + + UPDATE vn.collection + SET itemPackingTypeFk = NULL + WHERE id = vCollectionFk; + DROP TEMPORARY TABLE IF EXISTS tmp.ticketToSplit; + CREATE TEMPORARY TABLE tmp.ticketToSplit + SELECT pb.ticketFk + FROM tmp.productionBuffer pb + JOIN vn.state s ON s.id = pb.state + WHERE s.code = 'PICKER_DESIGNED' + AND pb.workerCode = vWorkerCode + ORDER BY HH, + mm, + s.`order` DESC, + pb.m3 DESC; + + WHILE (SELECT COUNT(*) FROM tmp.ticketToSplit) DO + + SELECT MIN(ticketFk) INTO vTicketToSplit + FROM tmp.ticketToSplit; + + CALL vn.ticket_splitItemPackingType(vTicketToSplit); + + INSERT INTO vn.ticketCollection(ticketFk, collectionFk) + SELECT ticketFk, vCollectionFk + FROM tmp.ticketIPT; + + DELETE FROM tmp.ticketToSplit + WHERE ticketFk = vTicketToSplit; + + END WHILE; + + + ELSE + + SELECT COUNT(*) INTO vPrintedTickets + FROM tmp.productionBuffer pb + JOIN vn.state s ON s.id = pb.state + JOIN vn.agencyMode am ON am.id = pb.agencyModeFk + JOIN vn.agency a ON a.id = am.agencyFk + WHERE pb.shipped = CURDATE() + AND (pb.ubicacion IS NOT NULL OR a.isOwn = FALSE ) + AND s.isPreparable + AND (pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH) + OR pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV) + OR pb.F > 0 AND vItemPackingTypeFk = 'F' AND ISNULL(pb.collectionF) + OR pb.P > 0 AND vItemPackingTypeFk = 'P' AND ISNULL(pb.collectionP)); + + SET vMaxTicketPrinted = vMaxTicketPrinted - vPrintedTickets; + -- AutoPRINT + + IF vMaxTicketPrinted > 0 THEN + + INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) + 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 + JOIN vn.state s ON s.id = pb.state + JOIN vn.state s2 ON s2.code = 'PRINTED_AUTO' + WHERE pb.shipped = CURDATE() + AND LENGTH(pb.problem) = 0 + AND (pb.ubicacion IS NOT NULL OR a.isOwn = FALSE ) + AND s.isPrintable + AND (pb.m3 > 0.05 OR s.isOK) + AND (pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH) + OR pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV) + OR pb.F > 0 AND vItemPackingTypeFk = 'F' AND ISNULL(pb.collectionF) + OR pb.P > 0 AND vItemPackingTypeFk = 'P' AND ISNULL(pb.collectionP)) + ORDER BY HH, + mm, + s.`order` DESC, + pb.m3 DESC + LIMIT vMaxTicketPrinted; + + END IF; + + -- Se seleccionan los primeros tickets, asignando colección para dejarlos bloqueados a otros sacadores. + -- Se splitan los tickets preparables, para que solo tengan un tipo de empaquetado + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketToSplit; + CREATE TEMPORARY TABLE tmp.ticketToSplit + SELECT pb.ticketFk + FROM tmp.productionBuffer pb + JOIN vn.agencyMode am ON am.id = pb.agencyModeFk + JOIN vn.agency a ON a.id = am.agencyFk + JOIN vn.ticketStateToday tst ON tst.ticket = pb.ticketFk + JOIN vn.state s ON s.id = tst.state + WHERE ( pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH) + OR pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV) + OR pb.F > 0 AND vItemPackingTypeFk = 'F' AND ISNULL(pb.collectionF) + OR pb.P > 0 AND vItemPackingTypeFk = 'P' AND ISNULL(pb.collectionP)) + AND (pb.ubicacion IS NOT NULL OR a.isOwn = FALSE ) + AND LENGTH(pb.problem) = 0 + AND s.isPreparable + AND NOT myUserIsSalesPersonRole + ORDER BY pb.HH, pb.mm, s.`order` DESC + LIMIT vMaxTickets; + + WHILE (SELECT COUNT(*) FROM tmp.ticketToSplit) DO + + SELECT MIN(ticketFk) INTO vTicketToSplit + FROM tmp.ticketToSplit; + + CALL vn.ticket_splitItemPackingType(vTicketToSplit); + + INSERT INTO vn.ticketCollection(ticketFk, collectionFk) + SELECT ticketFk, vCollectionFk + FROM tmp.ticketIPT + WHERE itemPackingTypeFk = vItemPackingTypeFk; + + DELETE FROM tmp.ticketToSplit + WHERE ticketFk = vTicketToSplit; + + END WHILE; + + END IF; -- Creamos una tabla temporal con los datos que necesitamos para depurar la colección DROP TEMPORARY TABLE IF EXISTS tmp.ticket; CREATE TEMPORARY TABLE tmp.ticket - SELECT pb.Id_Ticket ticketFk, - pb.lines, + SELECT pb.ticketFk, + pb.`lines`, pb.m3 * 1000 liters, 0 as height, - 0 as shelve - FROM tmp.production_buffer pb - JOIN vn.ticketCollection tc ON tc.ticketFk = pb.Id_Ticket + 0 as shelve, + 0 as wagon, + pb.productionOrder + FROM tmp.productionBuffer pb + JOIN vn.ticketCollection tc ON tc.ticketFk = pb.ticketFk + WHERE tc.collectionFk = vCollectionFk + ORDER BY pb.productionOrder DESC, HH, mm + LIMIT vMaxTickets; + + /* + * + * Construccion del tren + * + */ + + SELECT ticketFk + INTO vFirstTicketFk + FROM tmp.ticket + ORDER BY productionOrder DESC + LIMIT 1; + + INSERT INTO tmp.log(ticketFk) VALUES(vFirstTicketFk); + + -- Establece altura máxima por pedido, porque las plantas no se pueden recostar. + UPDATE tmp.ticket t + JOIN + ( SELECT MAX(i.size) maxHeigth, + tc.ticketFk + FROM vn.ticketCollection tc + JOIN vn.sale s ON s.ticketFk = tc.ticketFk + JOIN vn.item i ON i.id = s.itemFk + WHERE i.itemPackingTypeFk = 'V' + AND tc.collectionFk = vCollectionFk + GROUP BY tc.ticketFk) sub ON sub.ticketFk = t.ticketFk + SET t.height = IFNULL(sub.maxHeigth,0); + + -- Vamos a generar una tabla con todas las posibilidades de asignacion de pedido + DROP TEMPORARY TABLE IF EXISTS tmp.wagonsVolumetry; + CREATE TEMPORARY TABLE tmp.wagonsVolumetry + SELECT cv.`level` as shelve, + 1 as wagon, + cv.`lines`, + cv.liters, + cv.height + FROM vn.collectionVolumetry_Paloma cv; -- beta + + SET vWagonCounter = 1; + + WHILE vWagonCounter < vWagons DO + + SET vWagonCounter = vWagonCounter + 1; + + INSERT INTO tmp.wagonsVolumetry(shelve, wagon, `lines`, liters, height) + SELECT cv.`level` as shelve, + vWagonCounter as wagon, + cv.`lines`, + cv.liters, + cv.height + FROM vn.collectionVolumetry_Paloma cv; -- beta + + END WHILE; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketShelve; + CREATE TEMPORARY TABLE tmp.ticketShelve + SELECT ticketFk, shelve, wagon, linesDif, LitersDif, heightDif + FROM ( + SELECT t.ticketFk, + wv.shelve, + wv.wagon, + t.productionOrder, + CAST(wv.`lines` AS SIGNED) - t.`lines` as linesDif, + CAST(wv.liters AS SIGNED) - t.liters as litersDif, + CAST(wv.height AS SIGNED) - t.height as heightDif + FROM tmp.wagonsVolumetry wv + JOIN tmp.ticket t + ) sub + WHERE linesDif >= 0 + AND litersDif >= 0 + AND heightDif >= 0 + ORDER BY productionOrder DESC, linesDif, LitersDif, heightDif ; + + -- Insertamos una opcion virtual para carro completo. Todo ticket tiene que poder entrar en un carro completo.... + INSERT INTO tmp.ticketShelve(ticketFk, shelve, wagon, linesDif, LitersDif, heightDif) + SELECT t.ticketFk, 0, wv.wagon, 999, 999,999 + FROM tmp.ticket t + JOIN tmp.wagonsVolumetry wv + GROUP BY t.ticketFk, wv.wagon; + + SET vWagonCounter = 0; + + WHILE vWagonCounter < vWagons DO + + SET vWagonCounter = vWagonCounter + 1; + + -- Asignamos la primera balda util al primer pedido + IF vWagonCounter = 1 THEN + + SELECT shelve INTO vShelve + FROM tmp.ticketShelve + WHERE ticketFk = vFirstTicketFk + AND wagon = vWagonCounter + ORDER BY heightDif, litersDif, linesDif + LIMIT 1; + + ELSE + + SELECT shelve, ticketFk INTO vShelve, vFirstTicketFk + FROM tmp.ticketShelve + WHERE wagon = vWagonCounter + ORDER BY heightDif, litersDif, linesDif + LIMIT 1; + + END IF; + + IF vShelve > 0 THEN + + UPDATE tmp.ticket + SET shelve = vShelve, + wagon = vWagonCounter + WHERE ticketFk = vFirstTicketFk; + + DELETE FROM tmp.ticketShelve + WHERE ticketFk = vFirstTicketFk + OR (shelve = vShelve AND wagon = vWagonCounter); + + WHILE (SELECT COUNT(*) FROM tmp.ticketShelve WHERE wagon = vWagonCounter) DO + + SELECT ticketFk, shelve + INTO vTicket, vShelve + FROM tmp.ticketShelve + WHERE wagon = vWagonCounter + LIMIT 1; + + UPDATE tmp.ticket + SET shelve = vShelve, + wagon = vWagonCounter + WHERE ticketFk = vTicket; + + DELETE FROM tmp.ticketShelve + WHERE ticketFk = vTicket + OR (shelve = vShelve AND wagon = vWagonCounter); + + END WHILE; + + ELSE + + UPDATE tmp.ticket + SET shelve = 1, wagon = vWagonCounter + WHERE ticketFk = vFirstTicketFk; + + DELETE FROM tmp.ticketShelve + WHERE ticketFk = vFirstTicketFk + AND wagon != vWagonCounter; + + END IF; + + END WHILE; + + -- Eliminamos los que se han quedado sin balda + DELETE FROM tmp.ticket WHERE shelve = 0; + + -- Elimina los tickets bloqueados que no se van a preparar + DELETE tc.* + FROM vn.ticketCollection tc + LEFT JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk + WHERE tc.collectionFk = vCollectionFk + AND t.ticketFk IS NULL; + + + -- Actualiza el estado de la colección + UPDATE vn.collection c + JOIN vn.state st ON st.code = 'ON_PREPARATION' + SET c.stateFk = st.id + WHERE c.id = vCollectionFk; + + -- Asigna las bandejas + UPDATE vn.ticketCollection tc + JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk + SET tc.level = t.shelve, tc.wagon = t.wagon; + + -- Actualiza el estado de los tickets + INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) + SELECT vStateFk, ticketFk, account.myUser_getId() + FROM vn.ticketCollection tc + WHERE tc.collectionFk = vCollectionFk; + + -- Aviso para la preparacion previa + INSERT INTO vn.ticketDown(ticketFk, collectionFk) + SELECT tc.ticketFk, tc.collectionFk + FROM vn.ticketCollection tc + WHERE tc.collectionFk = vCollectionFk; + + IF (SELECT count(*) FROM vn.ticketCollection WHERE collectionFk = vCollectionFk) THEN + + CALL vn.salesMerge_byCollection(vCollectionFk); + + UPDATE vn.collection c + JOIN (SELECT count(*) saleTotalCount , + sum(s.isPicked != 0) salePickedCount + FROM vn.ticketCollection tc + JOIN vn.sale s ON s.ticketFk = tc.ticketFk + WHERE tc.collectionFk = vCollectionFk + AND s.quantity > 0 + ) sub + SET c.saleTotalCount = sub.saleTotalCount, + c.salePickedCount = sub.salePickedCount + WHERE c.id = vCollectionFk; + + SELECT vCollectionFk; + + ELSE + + DELETE FROM vn.collection WHERE id = vCollectionFk; + -- SELECT NULL; + + END IF; + + DROP TEMPORARY TABLE tmp.ticketIPT; + DROP TEMPORARY TABLE IF EXISTS 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_new__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `collection_new__`(vSectorFk INT) +proc:BEGIN + + DECLARE vIsPreviousPrepared BOOLEAN; + DECLARE vCollectionFk INT; + DECLARE vWarehouseFk INT; + DECLARE vMaxTickets INT; + DECLARE vStateFk INT; + DECLARE vFirstTicketFk INT; + DECLARE vWorkerCode VARCHAR(3); + DECLARE vWagon INT; + DECLARE vWagonCounter INT; + DECLARE vShelve INT; + DECLARE vTicket INT; + DECLARE myUserIsSalesPersonRole BOOLEAN; + DECLARE vPrintedTickets INT; + DECLARE vMaxTicketPrinted INT; + DECLARE vSectorCode VARCHAR(1); + DECLARE vWagons INT DEFAULT 2; + DECLARE hasAssignedTickets BOOLEAN; + + + -- Si existe una coleccion sin finalizar, la devuelve + /* + SELECT MAX(c.id) INTO vCollectionFk + FROM vn.collection c + JOIN vn.state s ON s.id = c.stateFk + WHERE c.workerFk = vn.getUser() + AND s.code = 'ON_PREPARATION' + AND c.created > TIMESTAMPADD(HOUR , -5,NOW()); + + IF vCollectionFk THEN + + SELECT vCollectionFk; + + LEAVE proc; + + END IF; + */ + SET vMaxTicketPrinted = 15 * vWagons; + SET vMaxTickets = 5 * vWagons; + + -- 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, code + INTO vIsPreviousPrepared, vWarehouseFk, vSectorCode + FROM vn.sector + WHERE id = vSectorFk; + + IF vIsPreviousPrepared THEN + + SELECT id INTO vStateFk + FROM vn.state + WHERE `code` = 'PREVIOUS_PREPARATION'; + ELSE + + SELECT id INTO vStateFk + FROM vn.state + WHERE `code` = 'ON_PREPARATION'; + + END IF; + + -- Averiguamos si es comercial el usuario + SELECT (r.name = 'salesPerson') + INTO myUserIsSalesPersonRole + FROM account.user u + JOIN account.role r ON r.id = u.role + WHERE u.id = vn.getUser(); + + -- Obtenemos el código del usuario + SELECT w.code + INTO vWorkerCode + FROM vn.worker w + WHERE w.id = account.myUser_getId(); + + -- Se obtiene nº de colección y el buffer con los pedidos preparables + INSERT INTO vn.collection + SET workerFk = account.myUser_getId(), + itemPackingTypeFk = vSectorCode; + + SELECT LAST_INSERT_ID() INTO vCollectionFk; + + CALL vn.productionControl(vWarehouseFk, 0); + + -- 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 + FROM tmp.productionBuffer pb + JOIN vn.state s ON s.id = pb.state + WHERE s.code = 'PICKER_DESIGNED' + AND pb.workerCode = vWorkerCode + AND (pb.H > 0 AND ISNULL(pb.collectionH) + OR pb.V > 0 AND ISNULL(pb.collectionV) + OR pb.F > 0 AND ISNULL(pb.collectionF) + OR pb.P > 0 AND ISNULL(pb.collectionP)); + + IF hasAssignedTickets THEN + + UPDATE vn.collection + SET itemPackingTypeFk = NULL + WHERE id = vCollectionFk; + + INSERT INTO vn.ticketCollection(ticketFk, collectionFk) + SELECT pb.ticketFk, + vCollectionFk + FROM tmp.productionBuffer pb + JOIN vn.state s ON s.id = pb.state + JOIN vn.agencyMode am ON am.id = pb.agencyModeFk + JOIN vn.agency a ON a.id = am.agencyFk + WHERE s.code = 'PICKER_DESIGNED' + AND pb.workerCode = vWorkerCode + AND (pb.H > 0 AND ISNULL(pb.collectionH) + OR pb.V > 0 AND ISNULL(pb.collectionV) + OR pb.F > 0 AND ISNULL(pb.collectionF) + OR pb.P > 0 AND ISNULL(pb.collectionP)) + ORDER BY HH, + mm, + s.`order` DESC, + pb.m3 DESC; + + ELSE + + SELECT COUNT(*) INTO vPrintedTickets + FROM tmp.productionBuffer pb + JOIN vn.state s ON s.id = pb.state + JOIN vn.agencyMode am ON am.id = pb.agencyModeFk + JOIN vn.agency a ON a.id = am.agencyFk + WHERE pb.shipped = CURDATE() + AND (pb.ubicacion IS NOT NULL OR a.isOwn = FALSE ) + AND s.isPreparable + AND (pb.H > 0 AND vSectorCode = 'H' AND ISNULL(pb.collectionH) + OR pb.V > 0 AND vSectorCode = 'V' AND ISNULL(pb.collectionV) + OR pb.F > 0 AND vSectorCode = 'F' AND ISNULL(pb.collectionF) + OR pb.P > 0 AND vSectorCode = 'P' AND ISNULL(pb.collectionP)); + + SET vMaxTicketPrinted = vMaxTicketPrinted - vPrintedTickets; + + -- AutoPRINT + + IF vMaxTicketPrinted > vMaxTickets THEN + + INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) + 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 + JOIN vn.state s ON s.id = pb.state + JOIN vn.state s2 ON s2.code = 'PRINTED_AUTO' + WHERE pb.shipped = CURDATE() + AND LENGTH(pb.problem) = 0 + AND (pb.ubicacion IS NOT NULL OR a.isOwn = FALSE ) + AND (s.isPrintable OR s.isPreparable ) + AND (pb.m3 > 0.05 OR s.isOK) + AND (pb.H > 0 AND vSectorCode = 'H' AND ISNULL(pb.collectionH) + OR pb.V > 0 AND vSectorCode = 'V' AND ISNULL(pb.collectionV) + OR pb.F > 0 AND vSectorCode = 'F' AND ISNULL(pb.collectionF) + OR pb.P > 0 AND vSectorCode = 'P' AND ISNULL(pb.collectionP)) + ORDER BY HH, + mm, + s.`order` DESC, + pb.m3 DESC + LIMIT vMaxTicketPrinted; + + END IF; + + -- Se seleccionan los primeros tickets, asignando colección para dejarlos bloqueados a otros sacadores. + + INSERT INTO vn.ticketCollection(ticketFk, collectionFk) + SELECT pb.ticketFk, + vCollectionFk + FROM tmp.productionBuffer pb + JOIN vn.agencyMode am ON am.id = pb.agencyModeFk + JOIN vn.agency a ON a.id = am.agencyFk + JOIN vn.ticketStateToday tst ON tst.ticket = pb.ticketFk + JOIN vn.state s ON s.id = tst.state + WHERE ( pb.H > 0 AND vSectorCode = 'H' AND ISNULL(pb.collectionH) + OR pb.V > 0 AND vSectorCode = 'V' AND ISNULL(pb.collectionV) + OR pb.F > 0 AND vSectorCode = 'F' AND ISNULL(pb.collectionF) + OR pb.P > 0 AND vSectorCode = 'P' AND ISNULL(pb.collectionP)) + AND (pb.ubicacion IS NOT NULL OR a.isOwn = FALSE ) + AND LENGTH(pb.problem) = 0 + AND s.isPreparable + AND NOT myUserIsSalesPersonRole + ORDER BY pb.HH, pb.mm + LIMIT vMaxTickets; + + END IF; + +-- SELECT vMaxTicketPrinted , vMaxTickets, vPrintedTickets, myUserIsSalesPersonRole, vCollectionFk, vSectorCode; + +-- SELECT ticketFk, collectionFk FROM vn.ticketCollection tc WHERE tc.collectionFk = vCollectionFk; + + -- Creamos una tabla temporal con los datos que necesitamos para depurar la colección + DROP TEMPORARY TABLE IF EXISTS tmp.ticket; + CREATE TEMPORARY TABLE tmp.ticket + SELECT pb.ticketFk, + pb.`lines`, + pb.m3 * 1000 liters, + 0 as height, + 0 as shelve, + 0 as wagon + FROM tmp.productionBuffer pb + JOIN vn.ticketCollection tc ON tc.ticketFk = pb.ticketFk WHERE tc.collectionFk = vCollectionFk; + + /* + * + * Construccion del tren + * + */ SELECT ticketFk INTO vFirstTicketFk FROM tmp.ticket LIMIT 1; + + -- Establece altura máxima por pedido, porque las plantas no se pueden recostar. + UPDATE tmp.ticket t + JOIN + ( SELECT MAX(i.size) maxHeigth, + tc.ticketFk + FROM vn.ticketCollection tc + JOIN vn.sale s ON s.ticketFk = tc.ticketFk + JOIN vn.item i ON i.id = s.itemFk + WHERE i.itemPackingTypeFk = 'V' + AND tc.collectionFk = vCollectionFk + GROUP BY tc.ticketFk) sub ON sub.ticketFk = t.ticketFk + SET t.height = IFNULL(sub.maxHeigth,0); + + -- Vamos a generar una tabla con todas las posibilidades de asignacion de pedido + DROP TEMPORARY TABLE IF EXISTS tmp.wagonsVolumetry; + CREATE TEMPORARY TABLE tmp.wagonsVolumetry + SELECT cv.`level` as shelve, + 1 as wagon, + cv.`lines`, + cv.liters, + cv.height + FROM vn.collectionVolumetry cv; + + SET vWagonCounter = 1; - IF (SELECT pb.Agencia FROM tmp.production_buffer pb WHERE Id_Ticket = vFirstTicketFk) = 'REC_SILLA' THEN + WHILE vWagonCounter < vWagons DO - DELETE FROM tmp.ticket WHERE ticketFk != vFirstTicketFk; + SET vWagonCounter = vWagonCounter + 1; - UPDATE tmp.ticket SET shelve = 1; - -- Como sólo hay un ticket, se le asigna el nivel 1 y acabamos + INSERT INTO tmp.wagonsVolumetry(shelve, wagon, `lines`, liters, height) + SELECT cv.`level` as shelve, + vWagonCounter as wagon, + cv.`lines`, + cv.liters, + cv.height + FROM vn.collectionVolumetry cv; + + END WHILE; - ELSE + DROP TEMPORARY TABLE IF EXISTS tmp.ticketShelve; + CREATE TEMPORARY TABLE tmp.ticketShelve + SELECT ticketFk, shelve, wagon, linesDif, LitersDif, heightDif + FROM ( + SELECT t.ticketFk, + wv.shelve, + wv.wagon, + CAST(wv.`lines` AS SIGNED) - t.`lines` as linesDif, + CAST(wv.liters AS SIGNED) - t.liters as litersDif, + CAST(wv.height AS SIGNED) - t.height as heightDif + FROM tmp.wagonsVolumetry wv + JOIN tmp.ticket t + ORDER BY (t.ticketFk = vFirstTicketFk) DESC, linesDif + ) sub + WHERE linesDif >= 0 + AND litersDif >= 0 + AND heightDif >= 0 + ORDER BY linesDif; + + -- Insertamos una opcion virtual para carro completo. Todo ticket tiene que poder entrar en un carro completo.... + INSERT INTO tmp.ticketShelve(ticketFk, shelve, wagon, linesDif, LitersDif, heightDif) + SELECT t.ticketFk, 0, wv.wagon, 999, 999,999 + FROM tmp.ticket t + JOIN tmp.wagonsVolumetry wv + GROUP BY t.ticketFk, wv.wagon; + + SET vWagonCounter = 0; + + WHILE vWagonCounter < vWagons DO + + SET vWagonCounter = vWagonCounter + 1; - -- Eliminamos los de recogida, puesto que el primero sabemos que no es de rec_silla - DELETE t.* - FROM tmp.ticket t - JOIN tmp.production_buffer pb ON pb.Id_Ticket = t.ticketFk - WHERE pb.Agencia = 'REC_SILLA'; - - -- Establece altura máxima por pedido, porque las plantas no se pueden recostar. - UPDATE tmp.ticket t - JOIN - ( SELECT MAX(i.size) maxHeigth, - tc.ticketFk - FROM vn.ticketCollection tc - JOIN vn.sale s ON s.ticketFk = tc.ticketFk - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.itemCategory ic ON ic.id = it.categoryFk - WHERE ic.isReclining = FALSE - AND tc.collectionFk = vCollectionFk - GROUP BY tc.ticketFk) sub ON sub.ticketFk = t.ticketFk - SET t.height = sub.maxHeigth; - - -- Vamos a generar una tabla con todas las posibilidades de asignacion de pedido - DROP TEMPORARY TABLE IF EXISTS tmp.ticketShelve; - CREATE TEMPORARY TABLE tmp.ticketShelve - SELECT ticketFk, shelve, linesDif, LitersDif, heightDif - FROM ( - SELECT t.ticketFk, - cv.`level` shelve, - CAST(cv.lines AS SIGNED) - t.lines as linesDif, - CAST(cv.liters AS SIGNED) - t.liters as litersDif, - CAST(cv.height AS SIGNED) - t.height as heightDif - FROM vn.collectionVolumetry cv - JOIN tmp.ticket t - ORDER BY (t.ticketFk = vFirstTicketFk) DESC, linesDif - ) sub - WHERE linesDif >= 0 - AND litersDif >= 0 - AND heightDif >= 0 - ORDER BY linesDif; - -- Asignamos la primera balda util al primer pedido - SELECT IFNULL(shelve,0) INTO vShelve - FROM tmp.ticketShelve - WHERE ticketFk = vFirstTicketFk - ORDER BY heightDif, litersDif, linesDif - LIMIT 1; + IF vWagonCounter = 1 THEN - IF vShelve THEN + SELECT shelve INTO vShelve + FROM tmp.ticketShelve + WHERE ticketFk = vFirstTicketFk + AND wagon = vWagonCounter + ORDER BY heightDif, litersDif, linesDif + LIMIT 1; + + ELSE + + SELECT shelve, ticketFk INTO vShelve, vFirstTicketFk + FROM tmp.ticketShelve + WHERE wagon = vWagonCounter + ORDER BY heightDif, litersDif, linesDif + LIMIT 1; + + END IF; + IF vShelve > 0 THEN + UPDATE tmp.ticket - SET shelve = vShelve + SET shelve = vShelve, + wagon = vWagonCounter WHERE ticketFk = vFirstTicketFk; DELETE FROM tmp.ticketShelve WHERE ticketFk = vFirstTicketFk - OR shelve = vShelve; + OR (shelve = vShelve AND wagon = vWagonCounter); - WHILE (SELECT COUNT(*) FROM tmp.ticketShelve) DO + WHILE (SELECT COUNT(*) FROM tmp.ticketShelve WHERE wagon = vWagonCounter) DO - SELECT ticketFk, shelve + SELECT ticketFk, shelve INTO vTicket, vShelve FROM tmp.ticketShelve + WHERE wagon = vWagonCounter LIMIT 1; UPDATE tmp.ticket - SET shelve = vShelve + SET shelve = vShelve, + wagon = vWagonCounter WHERE ticketFk = vTicket; DELETE FROM tmp.ticketShelve WHERE ticketFk = vTicket - OR shelve = vShelve; + OR (shelve = vShelve AND wagon = vWagonCounter); END WHILE; - - ELSE - + + ELSE + UPDATE tmp.ticket - SET shelve = 1 + SET shelve = 1, wagon = vWagonCounter WHERE ticketFk = vFirstTicketFk; + DELETE FROM tmp.ticketShelve + WHERE ticketFk = vFirstTicketFk + AND wagon != vWagonCounter; + END IF; - END IF; + END WHILE; -- Eliminamos los que se han quedado sin balda - DELETE FROM tmp.ticket WHERE shelve = 0 ; + DELETE FROM tmp.ticket WHERE shelve = 0; -- Elimina los tickets bloqueados que no se van a preparar DELETE tc.* @@ -49703,43 +50129,42 @@ proc:BEGIN -- Asigna las bandejas UPDATE vn.ticketCollection tc JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk - SET tc.level = t.shelve; + 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, account.myUser_getId() FROM vn.ticketCollection tc - WHERE tc.collectionFk = vCollectionFk - UNION ALL - SELECT vStateFk, sw.id, account.myUser_getId() - FROM vn.stowaway sw - JOIN vn.ticketCollection tc ON tc.ticketFk = sw.shipFk WHERE tc.collectionFk = vCollectionFk; - - -- Avisa los preparados previos que hay que bajar del altillo imprimiendo etiqueta - INSERT IGNORE INTO vn.ticketDown(ticketFk) - SELECT DISTINCT tc.ticketFk - FROM vn.ticketCollection tc - JOIN vncontrol.inter vi ON vi.Id_Ticket = tc.ticketFk - JOIN vn.state st ON st.id = vi.state_id - JOIN vn.ticket t ON t.id = tc.ticketFk - JOIN vn.warehouse w ON w.id = t.warehouseFk - WHERE tc.collectionFk = vCollectionFk - AND w.name = 'Silla FV' - AND st.code = 'PREVIOUS_PREPARATION'; - - IF (SELECT COUNT(*) FROM vn.ticketCollection WHERE collectionFk = vCollectionFk) THEN - - CALL vn.salesMerge_byCollection(vCollectionFk); - - SELECT vCollectionFk; - - ELSE - - DELETE FROM vn.collection WHERE id = vCollectionFk; - SELECT 0; - - END IF; + + -- Aviso para la preparacion previa + INSERT INTO vn.ticketDown(ticketFk, collectionFk) + SELECT tc.ticketFk, tc.collectionFk + FROM vn.ticketCollection tc + WHERE tc.collectionFk = vCollectionFk; + + IF (SELECT count(*) FROM vn.ticketCollection WHERE collectionFk = vCollectionFk) THEN + + CALL vn.salesMerge_byCollection(vCollectionFk); + + UPDATE vn.collection c + JOIN (SELECT count(*) saleTotalCount + FROM vn.ticketCollection tc + JOIN vn.sale s ON s.ticketFk = tc.ticketFk + JOIN vn.item i ON i.id = s.itemFk + WHERE tc.collectionFk = vCollectionFk + AND s.quantity > 0 + AND (i.itemPackingTypeFk = vSectorCode OR ISNULL(vSectorCode)) + ) sub + SET c.saleTotalCount = sub.saleTotalCount + WHERE c.id = vCollectionFk; + + SELECT vCollectionFk; + + ELSE + + DELETE FROM vn.collection WHERE id = vCollectionFk; + SELECT NULL; END IF; @@ -49779,45 +50204,6 @@ SELECT quantity INTO vOriginalQuantity FROM vn.sale WHERE id = vSale; UPDATE vn.sale SET originalQuantity = vOriginalQuantity ,quantity = vQuantity WHERE 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 `collection_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 `collection_update`(vTicketFk INT) -BEGIN - - DECLARE vNumChecked INT; - DECLARE vCollectionFk INT; - - /*SI TODAS LOS TICKETS DE UNA COLECCIÓN ESTAN REVISADOS CAMBIADOS ESTADO COLECCIÓN*/ - SELECT collectionFk - INTO vCollectionFk - FROM vn.ticketCollection - WHERE ticketFk = vTicketFk; - - IF (SELECT COUNT(*) - FROM vn.ticketCollection tc - JOIN vn.ticketLastState tls ON tls.ticketFk = tc.ticketFk - WHERE tc.collectionFk = vCollectionFk - AND (name = 'Preparación' OR name = 'En Revisión' OR name = 'Impreso' OR name = 'Preparado') ) = 0 THEN - - UPDATE vn.collection - SET stateFk = (SELECT id FROM vn.state WHERE code = 'PREPARED') - WHERE id = vCollectionFk; - END IF; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -49875,17 +50261,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 `collection_updateState` */; +/*!50003 DROP PROCEDURE IF EXISTS `collection_updateState__` */; /*!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 `collection_updateState`(vTicketFk INT, vState VARCHAR(50)) +CREATE DEFINER=`root`@`%` PROCEDURE `collection_updateState__`(vTicketFk INT, vState VARCHAR(50)) BEGIN DECLARE vCollectionFk INT; @@ -49914,9 +50300,48 @@ IF vLastState <> 'Encajado' THEN WHERE tc.ticketFk = vTicketFk; -- Actualiza la colección - CALL vn.collection_update(vTicketFk); + CALL vn.collection_update__(vTicketFk); 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 `collection_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 = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `collection_update__`(vTicketFk INT) +BEGIN + + DECLARE vNumChecked INT; + DECLARE vCollectionFk INT; + + /*SI TODAS LOS TICKETS DE UNA COLECCIÓN ESTAN REVISADOS CAMBIADOS ESTADO COLECCIÓN*/ + SELECT collectionFk + INTO vCollectionFk + FROM vn.ticketCollection + WHERE ticketFk = vTicketFk; + + IF (SELECT COUNT(*) + FROM vn.ticketCollection tc + JOIN vn.ticketLastState tls ON tls.ticketFk = tc.ticketFk + WHERE tc.collectionFk = vCollectionFk + AND (name = 'Preparación' OR name = 'En Revisión' OR name = 'Impreso' OR name = 'Preparado') ) = 0 THEN + + UPDATE vn.collection + SET stateFk = (SELECT id FROM vn.state WHERE code = 'PREPARED') + WHERE id = vCollectionFk; + END IF; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -51363,7 +51788,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`z-developer`@`%` PROCEDURE `ediTables_Update`() +CREATE DEFINER=`root`@`%` PROCEDURE `ediTables_Update`() BEGIN INSERT IGNORE INTO vn.genus(name) @@ -52040,7 +52465,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`z-developer`@`%` PROCEDURE `entryVolume`(vEntryFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `entryVolume`(vEntryFk INT) BEGIN SELECT ELT(it.temperature + 1,'Calientes','Frios','Secos') AS Temp, @@ -54086,7 +54511,32 @@ BEGIN JOIN newInvoiceIn ni ON ii.id = ni.id SET ii.serialNumber = vSerialNumber, ii.isBooked = TRUE; - + + -- Problemas derivados de la precisión en los decimales al calcular los impuestos + UPDATE XDiario + SET EURODEBE = EURODEBE - + (SELECT IF(ABS(sub.difference) = 0.01, sub.difference, 0) + FROM(SELECT SUM(IFNULL(ROUND(EURODEBE, 2),0)) - SUM(IFNULL(ROUND(EUROHABER, 2), 0)) difference + FROM XDiario + WHERE ASIEN = vBookNumber + )sub + ) + WHERE ASIEN = vBookNumber + AND EURODEBE <> 0 + ORDER BY id DESC + LIMIT 1; + + /*UPDATE XDiario + SET EURODEBE = EURODEBE - + (SELECT SUM(IFNULL(ROUND(EURODEBE,2),0))- SUM(IFNULL(ROUND(EUROHABER,2),0)) difference + FROM XDiario + WHERE ASIEN = vBookNumber + HAVING ABS(difference) = 0.01) + WHERE ASIEN = vBookNumber + AND EURODEBE <> 0 + ORDER BY id DESC + LIMIT 1;*/ + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -54344,6 +54794,263 @@ BEGIN SET ii.serialNumber = vSerialNumber, ii.isBooked = 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 `invoiceInBookingMain___` */; +/*!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 `invoiceInBookingMain___`(vInvoiceInId INT) +BEGIN + DECLARE vTotalAmount,vTotalAmountDivisa DECIMAL(10,2); + DECLARE vBookNumber,vSerialNumber INT; + DECLARE vRate DECIMAL(10,4); + DECLARE vSerial VARCHAR(2); + + CALL invoiceInBookingCommon(vInvoiceInId,vSerialNumber); + + SELECT serial + INTO vSerial + FROM newInvoiceIn; + + SELECT SUM(iit.taxableBase * IF(vSerial = 'R' AND tc.`type` <> 'I', 1 +(tc.rate/100),1)), + SUM(iit.foreignValue * IF(vSerial = 'R', 1 +(tc.rate/100),1)), + iit.taxableBase/iit.foreignValue + INTO vTotalAmount, vTotalAmountDivisa, vRate + FROM newInvoiceIn i + JOIN invoiceInTax iit ON iit.invoiceInFk = i.id + JOIN taxCode tc ON iit.taxCodeFk = tc.id; + + CALL vn.ledger_next(vBookNumber); + + -- Apunte del proveedor + + INSERT INTO vn2008.XDiario( + ASIEN, + FECHA, + SUBCTA, + EUROHABER, + CONCEPTO, + CAMBIO, + HABERME, + NFACTICK, + CLAVE, + empresa_id) + SELECT + vBookNumber, + n.bookEntried, + s.supplierAccount, + vTotalAmount EUROHABER, + n.conceptWithSupplier, + vRate, + vTotalAmountDivisa, + n.invoicesCount, + vInvoiceInId, + n.companyFk + FROM newInvoiceIn n + JOIN newSupplier s; + + -- ----------------------------------------------------------- Linea de Gastos + INSERT INTO vn2008.XDiario (ASIEN, + FECHA, + SUBCTA, + CONTRA, + EURODEBE, + EUROHABER, + CONCEPTO, + CAMBIO, + DEBEME, + HABERME, + NFACTICK, + empresa_id + ) + SELECT vBookNumber ASIEN, + n.bookEntried FECHA, + IF(e.isWithheld , LPAD(RIGHT(s.supplierAccount,5),10,iit.expenceFk),iit.expenceFk) SUBCTA, + s.supplierAccount CONTRA, + IF(e.isWithheld AND iit.taxableBase < 0, NULL, ROUND(SUM(iit.taxableBase),2)) EURODEBE, + IF(e.isWithheld AND iit.taxableBase < 0,ROUND(SUM(-iit.taxableBase),2),NULL) EUROHABER, + n.conceptWithSupplier CONCEPTO, + vRate, + IF(e.isWithheld,NULL,ABS(ROUND(SUM(iit.foreignValue),2))) DEBEME, + IF(e.isWithheld,ABS(ROUND(SUM(iit.foreignValue),2)),NULL) HABERME, + n.invoicesCount NFACTICK, + n.companyFk empresa_id + FROM newInvoiceIn n + JOIN newSupplier s + JOIN invoiceInTax iit ON iit.invoiceInFk = n.id + JOIN taxCode tc ON tc.id = iit.taxCodeFk + JOIN expence e ON e.id = iit.expenceFk AND e.taxTypeFk = tc.taxTypeFk + WHERE iit.expenceFk != 5660000002 + GROUP BY iit.expenceFk; + + -- -------------------------------------------------------------------- + -- ------- Lineas de IVA --------------- + -- -------------------------------------------------------------------- + + INSERT INTO vn2008.XDiario( ASIEN, + FECHA, + SUBCTA, + CONTRA, + EURODEBE, + BASEEURO, + CONCEPTO, + FACTURA, + IVA, + AUXILIAR, + SERIE, + TIPOOPE, + FECHA_EX, + FECHA_OP, + NFACTICK, + FACTURAEX, + L340, + LRECT349, + TIPOCLAVE, + TIPOEXENCI, + TIPONOSUJE, + TIPOFACT, + TIPORECTIF, + TERIDNIF, + TERNIF, + TERNOM, + FECREGCON, + empresa_id + ) + SELECT vBookNumber ASIEN, + n.bookEntried FECHA, + tc.code SUBCTA, + s.supplierAccount CONTRA, + SUM(ROUND(tc.rate * it.taxableBase / 100 /* + 0.0001*/, 2)) EURODEBE, + SUM(it.taxableBase) BASEEURO, + GROUP_CONCAT(DISTINCT e.`name` SEPARATOR ', ') CONCEPTO, + vSerialNumber FACTURA, + tc.rate IVA, + IF(isUeeMember AND eWithheld.id IS NULL,'','*') AUXILIAR, + n.serial SERIE, + tt.TIPOOPE, + n.issued FECHA_EX, + n.operated FECHA_OP, + n.invoicesCount NFACTICK, + n.supplierRef FACTURAEX, + TRUE L340, + (isSameCountry OR NOT isUeeMember) LRECT349, + n.cplusTrascendency472Fk TIPOCLAVE, + n.cplusTaxBreakFk TIPOEXENCI, + n.cplusSubjectOpFk TIPONOSUJE, + n.cplusInvoiceType472Fk TIPOFACT, + n.cplusRectificationTypeFk TIPORECTIF, + iis.cplusTerIdNifFk TERIDNIF, + s.nif AS TERNIF, + s.name AS TERNOM, + n.booked FECREGCON, + n.companyFk + FROM newInvoiceIn n + JOIN newSupplier s + JOIN invoiceInTax it ON n.id = it.invoiceInFk + JOIN taxCode tc ON tc.id = it.taxCodeFk + JOIN taxType tt ON tt.id = tc.taxTypeFk + JOIN invoiceInSerial iis ON iis.code = tt.serial + JOIN expence e ON e.id = it.expenceFk + AND e.taxTypeFk = tc.taxTypeFk + LEFT JOIN (SELECT eWithheld.id + FROM invoiceInTax hold + JOIN expence eWithheld ON eWithheld.id = hold.expenceFk AND eWithheld.isWithheld + WHERE hold.invoiceInFk = vInvoiceInId LIMIT 1 + ) eWithheld ON TRUE + WHERE tc.type != '-' + AND tc.isActive + GROUP BY tc.rate, e.id; + + -- Linea iva inversor sujeto pasivo + + INSERT INTO vn2008.XDiario( ASIEN, + FECHA, + SUBCTA, + CONTRA, + EUROHABER, + BASEEURO, + CONCEPTO, + FACTURA, + IVA, + AUXILIAR, + SERIE, + TIPOOPE, + FECHA_EX, + FECHA_OP, + NFACTICK, + FACTURAEX, + L340, + LRECT349, + TIPOCLAVE, + TIPOEXENCI, + TIPONOSUJE, + TIPOFACT, + TIPORECTIF, + TERIDNIF, + TERNIF, + TERNOM, + empresa_id + ) + + SELECT vBookNumber ASIEN, + n.bookEntried FECHA, + tcLink.code SUBCTA, + s.supplierAccount CONTRA, + SUM(ROUND(tcLink.rate * it.taxableBase / 100,2)) EUROHABER, + ROUND(SUM(it.taxableBase),2) BASEEURO, + GROUP_CONCAT(DISTINCT e.`name` SEPARATOR ', ') CONCEPTO, + vSerialNumber FACTURA, + tcLink.rate IVA, + '*' AUXILIAR, + n.serial SERIE, + tt.TIPOOPE, + n.issued FECHA_EX, + n.operated FECHA_OP, + n.invoicesCount NFACTICK, + n.supplierRef FACTURAEX, + FALSE L340, + (isSameCountry OR NOT isUeeMember) LRECT349, + 1 TIPOCLAVE, + n.cplusTaxBreakFk TIPOEXENCI, + n.cplusSubjectOpFk TIPONOSUJE, + n.cplusInvoiceType472Fk TIPOFACT, + n.cplusRectificationTypeFk TIPORECTIF, + iis.cplusTerIdNifFk TERIDNIF, + s.nif AS TERNIF, + s.name AS TERNOM, + n.companyFk + FROM newInvoiceIn n + JOIN newSupplier s + JOIN invoiceInTax it ON n.id = it.invoiceInFk + JOIN taxCode tc ON tc.id = it.taxCodeFk + JOIN taxType tt ON tt.id = tc.taxTypeFk + JOIN invoiceInSerial iis ON iis.code = tt.serial + JOIN taxCode tcLink ON tcLink.link = tc.link + AND tc.id != tcLink.id + AND tc.link + JOIN expence e ON e.id = it.expenceFk + AND e.taxTypeFk = tc.taxTypeFk + WHERE tc.isActive + AND (tc.type in('S','I') OR MID(s.supplierAccount,4,1) = '1') + GROUP BY tcLink.rate, e.id; + + -- Actualización del registro original + UPDATE invoiceIn ii + JOIN newInvoiceIn ni ON ii.id = ni.id + SET ii.serialNumber = vSerialNumber, + ii.isBooked = TRUE; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -57286,22 +57993,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 `itemShelvingRadar`(vSectorFk INT) -BEGIN +proc:BEGIN - DECLARE vCalcVisibleFk INT; - DECLARE vCalcAvailableFk INT; - DECLARE hasFatherSector BOOLEAN; - DECLARE vBuyerFk INT DEFAULT 0; - DECLARE vWarehouseFk INT DEFAULT 0; - DECLARE vSonSectorFk INT; + DECLARE vCalcVisibleFk INT; + DECLARE vCalcAvailableFk INT; + DECLARE hasFatherSector BOOLEAN; + DECLARE vBuyerFk INT DEFAULT 0; + DECLARE vWarehouseFk INT DEFAULT 0; + DECLARE vSonSectorFk INT; + DECLARE vWorkerFk INT; + SELECT s.workerFk + INTO vWorkerFk + FROM vn.sector s + WHERE s.id = vSectorFk; + + IF IFNULL(vWorkerFk,0) THEN + + CALL vn.itemShelvingRadar_Urgent(vWorkerFk); + LEAVE proc; + + end if; + + SELECT w.id, s.warehouseFk INTO vBuyerFk, vWarehouseFk FROM vn.worker w JOIN vn.sector s ON s.code = w.code @@ -57311,17 +58032,8 @@ BEGIN FROM vn.sector s WHERE s.warehouseFk = vWarehouseFk AND s.isMain; - /* - IF vWarehouseFk = 1 THEN - - SET vSectorFk = 9; - - ELSEIF vWarehouseFk = 44 THEN - - SET vSectorFk = 6; - END IF; - */ + SELECT COUNT(*) INTO hasFatherSector FROM vn.sector WHERE sonFk = vSectorFk; @@ -57492,207 +58204,6 @@ BEGIN DROP TEMPORARY TABLE tmp.itemShelvingRadar; -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 `itemShelvingRadar_beta` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `itemShelvingRadar_beta`(vSectorFk INT) -BEGIN - - DECLARE vCalcVisibleFk INT; - DECLARE vCalcAvailableFk INT; - DECLARE hasFatherSector BOOLEAN; - DECLARE vBuyerFk INT DEFAULT 0; - DECLARE vWarehouseFk INT DEFAULT 0; - DECLARE vSonSectorFk INT; - - SELECT w.id, s.warehouseFk INTO vBuyerFk, vWarehouseFk - FROM vn.worker w - JOIN vn.sector s ON s.code = w.code - WHERE s.id = vSectorFk; - - SELECT s.id INTO vSectorFk - FROM vn.sector s - WHERE s.warehouseFk = vWarehouseFk - AND s.isMain; - - SELECT COUNT(*) INTO hasFatherSector - FROM vn.sector - WHERE sonFk = vSectorFk; - - SELECT warehouseFk, sonFk INTO vWarehouseFk, vSonSectorFk - FROM vn.sector - WHERE id = vSectorFk; - SELECT vSectorFk, vWarehouseFk, hasFatherSector , vSonSectorFk; - CALL cache.visible_refresh(vCalcVisibleFk, TRUE, vWarehouseFk); - CALL cache.available_refresh(vCalcAvailableFk, FALSE, vWarehouseFk, CURDATE()); - - DROP TEMPORARY TABLE IF EXISTS tmp.itemShelvingRadar; - - IF hasFatherSector THEN - - CREATE TEMPORARY TABLE tmp.itemShelvingRadar - (PRIMARY KEY (itemFk)) - ENGINE = MEMORY - SELECT * FROM ( - SELECT iss.itemFk, - i.longName, - i.size, - i.subName producer, - IFNULL(a.available,0) available, - SUM(IF(s.sonFk = vSectorFk, IFNULL(iss.visible,0), 0)) upstairs, - SUM(IF(iss.sectorFk = vSectorFk, IFNULL(iss.visible,0), 0)) downstairs, - IF(it.isPackaging, null, IFNULL(v.visible,0)) as visible, - vSectorFk as sectorFk - - FROM vn.itemShelvingStock iss - JOIN vn.sector s ON s.id = iss.sectorFk - JOIN vn.item i on i.id = iss.itemFk - JOIN vn.itemType it ON it.id = i.typeFk AND vBuyerFk IN (0,it.workerFk) - LEFT JOIN cache.available a ON a.item_id = iss.itemFk AND a.calc_id = vCalcAvailableFk - LEFT JOIN cache.visible v ON v.item_id = iss.itemFk AND v.calc_id = vCalcVisibleFk - WHERE vSectorFk IN (iss.sectorFk, s.sonFk) - AND it.workerFk != 3366 - - GROUP BY iss.itemFk - - UNION ALL - - SELECT v.item_id, - i.longName, - i.size, - i.subName producer, - IFNULL(a.available,0) as available, - 0 upstairs, - 0 downstairs, - IF(it.isPackaging, NULL, v.visible) visible, - vSectorFk as sectorFk - FROM cache.visible v - JOIN vn.item i on i.id = v.item_id - JOIN vn.itemType it ON it.id = i.typeFk AND vBuyerFk IN (0,it.workerFk) - LEFT JOIN vn.itemShelvingStock iss ON iss.itemFk = v.item_id AND iss.warehouseFk = vWarehouseFk - LEFT JOIN cache.available a ON a.item_id = v.item_id AND a.calc_id = vCalcAvailableFk - WHERE v.calc_id = vCalcVisibleFk - AND iss.itemFk IS NULL - AND it.isInventory - ) sub GROUP BY itemFk; - - SELECT ishr.*, - CAST(visible - upstairs - downstairs AS DECIMAL(10,0)) AS nicho, - CAST(downstairs - IFNULL(notPickedYed,0) AS DECIMAL(10,0)) as pendiente - FROM tmp.itemShelvingRadar ishr - JOIN vn.item i ON i.id = ishr.itemFk - LEFT JOIN (SELECT s.itemFk, sum(s.quantity) as notPickedYed - FROM vn.ticket t - JOIN vn.ticketStateToday tst ON tst.ticket = t.id - JOIN vn.sale s ON s.ticketFk = t.id - WHERE t.warehouseFk = vWarehouseFk - AND tst.alertLevel = 0 - GROUP BY s.itemFk - ) sub ON sub.itemFk = ishr.itemFk - ORDER BY i.typeFk, i.longName - ; - - - ELSE - - CREATE TEMPORARY TABLE tmp.itemShelvingRadar - (PRIMARY KEY (itemFk)) - ENGINE = MEMORY - SELECT iss.itemFk, - 0 `hour`, - 0 `minute`, - IFNULL(ip.`code`,'--') itemPlacementCode, - i.longName, - i.size, - i.subName producer, - i.upToDown, - IFNULL(a.available,0) available, - IFNULL(v.visible - iss.visible,0) dayEndVisible, - IFNULL(v.visible - iss.visible,0) firstNegative, - IFNULL(v.visible - iss.visible,0) itemPlacementVisible, - IFNULL(i.minimum * b.packing,0) itemPlacementSize, - ips.onTheWay, - iss.visible itemShelvingStock, - IFNULL(v.visible,0) visible, - b.isPickedOff, - iss.sectorFk - FROM vn.itemShelvingStock iss - JOIN vn.item i on i.id = iss.itemFk - LEFT JOIN vn.itemPlacement ip ON ip.itemFk = iss.itemFk AND ip.warehouseFk = vWarehouseFk - LEFT JOIN cache.last_buy lb ON lb.item_id = iss.itemFk AND lb.warehouse_id = vWarehouseFk - LEFT JOIN vn.buy b ON b.id = lb.buy_id - LEFT JOIN cache.available a ON a.item_id = iss.itemFk AND a.calc_id = vCalcAvailableFk - LEFT JOIN cache.visible v ON v.item_id = iss.itemFk AND v.calc_id = vCalcVisibleFk - LEFT JOIN (SELECT itemFk, sum(saldo) as onTheWay - FROM vn.itemPlacementSupplyList - WHERE saldo > 0 - GROUP BY itemFk - ) ips ON ips.itemFk = i.id - WHERE IFNULL(iss.sectorFk,0) IN (0, vSectorFk) - OR iss.sectorFk = vSectorFk; - - SELECT * FROM tmp.itemShelvingRadar; - - DROP TEMPORARY TABLE IF EXISTS tmp.itemOutTime; - CREATE TEMPORARY TABLE tmp.itemOutTime - SELECT *,SUM(amount) quantity - FROM - (SELECT item_id itemFk, - amount, - IF(HOUR(t.shipped), HOUR(t.shipped), HOUR(z.`hour`)) as hours, - IF(MINUTE(t.shipped), MINUTE(t.shipped), MINUTE(z.`hour`)) as minutes - FROM vn2008.item_out io - JOIN tmp.itemShelvingRadar isr ON isr.itemFk = io.item_id - JOIN vn.ticket t on t.id= io.ticketFk - JOIN vn.ticketState ts on ts.ticketFk = io.ticketFk - JOIN vn.state s ON s.id = ts.stateFk - LEFT JOIN vn.zone z ON z.id = t.zoneFk - LEFT JOIN (SELECT DISTINCT saleFk - FROM vn.saleTracking st - WHERE st.created > CURDATE() - AND st.isChecked - ) stPrevious ON `stPrevious`.`saleFk` = io.saleFk - WHERE t.warehouseFk = vWarehouseFk - AND s.isPicked = 0 - AND NOT io.Reservado - AND stPrevious.saleFk IS NULL - AND io.dat >= CURDATE() - AND io.dat < CURDATE()+1 - ) sub - GROUP BY itemFk, hours, minutes; - - INSERT INTO tmp.itemShelvingRadar (itemFk) - SELECT itemFk FROM tmp.itemOutTime - ON DUPLICATE KEY UPDATE dayEndVisible = dayEndVisible + quantity, - firstNegative = if (firstNegative < 0, firstNegative, firstNegative + quantity), - `hour` = ifnull(if (firstNegative > 0 , `hour`, hours),0), - `minute` = ifnull(if (firstNegative > 0, `minute`, minutes),0); -/* - UPDATE tmp.itemShelvingRadar - SET itemPlacementVisible = 0, - dayEndVisible = 0, - firstNegative = 0 - WHERE itemPlacementVisible = - itemShelvingStock; - */ - SELECT * FROM tmp.itemShelvingRadar; - - END IF; - - DROP TEMPORARY TABLE tmp.itemShelvingRadar; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -57809,6 +58320,180 @@ BEGIN DROP TEMPORARY TABLE tmp.item; DROP TEMPORARY TABLE tmp.item2; +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 `itemShelvingRadar_Urgent` */; +/*!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 `itemShelvingRadar_Urgent`(vWorkerFk INT) +BEGIN + + + + DECLARE vCalcVisibleFk INT; + DECLARE vWarehouseFk INT; + DECLARE vSectorFk INt; + DECLARE vFatherSectorFk INT; + + -- Eliminar cuando tengamos programador de Android + SET vSectorFk = 37; + SET vFatherSectorFk = 38; + + SELECT s.warehouseFk INTO vWarehouseFk + FROM vn.sector s + WHERE s.id = vSectorFk; + + CALL cache.visible_refresh(vCalcVisibleFk, TRUE, vWarehouseFk); + + SELECT * FROM ( + SELECT sub.itemFk, + sub.longName, + CONCAT('Hoy saldrán ', CAST(sub2.pendiente AS DECIMAL(10,0)), ' unidades.') `size`, + CONCAT(IF(sub2.itemFk, IF(sub2.pendiente > (sub.upstairs + sub.downstairs),'(1) ','(2) '),'(3) ' ),sub.producer) producer, + sub.upstairs, + sub.downstairs, + sub.visible, + sub.sectorFk, + CAST(visible - upstairs - downstairs AS DECIMAL(10,0)) AS nicho + FROM ( + SELECT iss.itemFk, + CONCAT(i.longName,' ',i.size,' ',IFNULL(i.subName,'') ) longName, + '' size, + CONCAT(iss.parkingCode , ' ', iss.shelvingFk) producer, + SUM(IF(s.id = vFatherSectorFk, IFNULL(iss.visible,0), 0)) upstairs, + SUM(IF(s.id = vSectorFk, IFNULL(iss.visible,0), 0)) downstairs, + IF(it.isPackaging, null, IFNULL(v.visible,0)) as visible, + vSectorFk as sectorFk + FROM vn.itemShelvingStock iss + JOIN vn.sector s ON s.id = iss.sectorFk + JOIN vn.item i on i.id = iss.itemFk + JOIN vn.itemType it ON it.id = i.typeFk + LEFT JOIN cache.visible v ON v.item_id = iss.itemFk AND v.calc_id = vCalcVisibleFk + WHERE iss.sectorFk IN (vSectorFk, vFatherSectorFk) + AND it.workerFk = vWorkerFk + GROUP BY itemFk + ) sub + LEFT JOIN (SELECT s.itemFk , sum(s.quantity) as pendiente + FROM vn.sale s + LEFT JOIN vn.saleTracking st ON st.saleFk = s.id + JOIN vn.ticket t ON t.id = s.ticketFk + JOIN vn.client c on c.id = t.clientFk + WHERE t.shipped BETWEEN CURDATE() AND util.dayend(CURDATE()) + AND ISNULL(st.saleFk) + AND c.isOfficial + GROUP BY s.itemFk) sub2 ON sub2.itemFk = sub.itemFk + ORDER BY producer) sub3 + WHERE nicho + ; + + + + + + /* + DECLARE vCalcVisibleFk INT; + DECLARE vCalcAvailableFk INT; + DECLARE vWarehouseFk INT; + DECLARE vSectorFk INt; + DECLARE vFatherSectorFk INT; + + -- Eliminar cuando tengamos programador de Android + SET vSectorFk = 37; + SET vFatherSectorFk = 38; + + SELECT s.warehouseFk INTO vWarehouseFk + FROM vn.sector s + WHERE s.id = vSectorFk; + + CALL cache.visible_refresh(vCalcVisibleFk, TRUE, vWarehouseFk); + + SELECT * FROM ( + SELECT sub.itemFk, + sub.longName, + CONCAT('Hoy saldrán ', CAST(sub2.pendiente AS DECIMAL(10,0)), ' unidades.') `size`, + CONCAT(IF(sub2.itemFk, IF(sub2.pendiente > (sub.upstairs + sub.downstairs),'(1) ','(2) '),'(3) ' ),sub.producer) producer, + sub.upstairs, + sub.downstairs, + sub.visible, + sub.sectorFk, + CAST(visible - upstairs - downstairs AS DECIMAL(10,0)) AS nicho + FROM ( + SELECT sub4.itemFk, + CONCAT(sub4.longName,' ',sub4.size,' ',IFNULL(sub4.subName,'') ) longName, + '' `size`, + CONCAT(sub4.parkingCode , ' ', sub4.shelvingFk) producer, + SUM(IF(sub4.sectorFk = vFatherSectorFk, IFNULL(sub4.visible,0), 0)) upstairs, + SUM(IF(sub4.sectorFk = vSectorFk, IFNULL(sub4.visible,0), 0)) downstairs, + IFNULL(sub4.visible,0) as visible, + sub4.sectorFk + FROM + ( + + SELECT iss.itemFk, + iss.parkingCode , + iss.shelvingFk , + iss.visible , + iss.sectorFk, + i.longName, + i.`size`, + i.subName + FROM vn.itemShelvingStock iss + JOIN vn.item i on i.id = iss.itemFk + JOIN vn.itemType it ON it.id = i.typeFk + LEFT JOIN cache.visible v ON v.item_id = iss.itemFk AND v.calc_id = vCalcVisibleFk + WHERE iss.sectorFk IN (vSectorFk, vFatherSectorFk) + AND it.workerFk = vWorkerFk + + UNION ALL + + SELECT v.item_id , + NULL, + NULL, + v.visible, + vSectorFk, + i.longName, + i.`size`, + i.subName + FROM cache.visible v + JOIN vn.item i on i.id = v.item_id + JOIN vn.itemType it ON it.id = i.typeFk + LEFT JOIN vn.itemShelvingStock iss ON iss.itemFk = v.item_id + WHERE v.calc_id = vCalcVisibleFk + AND iss.sectorFk IN (vSectorFk, vFatherSectorFk) + AND it.workerFk = vWorkerFk + AND iss.itemFk IS NULL + + ) sub4 + JOIN vn.sector s ON s.id = sub4.sectorFk + GROUP BY sub4.itemFk + ) sub + LEFT JOIN (SELECT s.itemFk , sum(s.quantity) as pendiente + FROM vn.sale s + LEFT JOIN vn.saleTracking st ON st.saleFk = s.id + JOIN vn.ticket t ON t.id = s.ticketFk + JOIN vn.client c on c.id = t.clientFk + WHERE t.shipped BETWEEN CURDATE() AND util.dayend(CURDATE()) + AND ISNULL(st.saleFk) + AND c.isOfficial + GROUP BY s.itemFk) sub2 ON sub2.itemFk = sub.itemFk + ORDER BY producer) sub3 + WHERE nicho + ; + */ + + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -58771,22 +59456,25 @@ BEGIN @currentLineFk := IF (@shipped < CURDATE() OR (@shipped = CURDATE() AND (isPicked OR alertLevel >= 2)), lineFk,@currentLineFk) lastPreparedLineFk, - isTicket, - lineFk,isPicked + isTicket, + lineFk, + isPicked, + clientType FROM - ( SELECT tr.landed as shipped, - b.quantity as `in`, - NULL as `out`, - al.alertLevel as alertLevel, + ( SELECT tr.landed AS shipped, + b.quantity AS `in`, + NULL AS `out`, + al.alertLevel AS alertLevel, st.name AS stateName, - s.name as name, - e.ref as reference, - e.id as origin, - s.id as clientFk, + s.name AS name, + e.ref AS reference, + e.id AS origin, + s.id AS clientFk, IF(al.alertLevel = 3, TRUE, FALSE) isPicked, FALSE AS isTicket, b.id lineFk, - NULL `order` + NULL `order`, + NULL AS clientType FROM buy b JOIN entry e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk @@ -58807,17 +59495,18 @@ BEGIN SELECT tr.shipped, NULL as `in`, - b.quantity as `out`, - al.alertLevel as alertLevel, + b.quantity AS `out`, + al.alertLevel AS alertLevel, st.name AS stateName, - s.name as name, - e.ref as reference, - e.id as origin, - s.id as clientFk, + s.name AS name, + e.ref AS reference, + e.id AS origin, + s.id AS clientFk, IF(al.alertLevel = 3, TRUE, FALSE) isPicked, FALSE AS isTicket, b.id, - NULL `order` + NULL `order`, + NULL AS clientType FROM buy b JOIN entry e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk @@ -58841,22 +59530,24 @@ BEGIN SELECT DATE(t.shipped), NULL as `in`, - s.quantity as `out`, - al.alertLevel as alertLevel, + s.quantity AS `out`, + al.alertLevel AS alertLevel, st.name AS stateName, - t.nickname as name, - t.refFk as reference, - t.id as origin, + t.nickname AS name, + t.refFk AS reference, + t.id AS origin, t.clientFk, - stk.id as isPicked, - TRUE as isTicket, + stk.id AS isPicked, + TRUE AS isTicket, s.id, - st.`order` + st.`order`, + ct.code AS clientType 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.alertLevel = CASE WHEN t.shipped < curdate() THEN 3 @@ -60109,7 +60800,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`z-developer`@`%` PROCEDURE `lungSize_generator`(vDate DATE) +CREATE DEFINER=`root`@`%` PROCEDURE `lungSize_generator`(vDate DATE) BEGIN SET @buildingOrder := 0; @@ -61352,7 +62043,7 @@ BEGIN SET vCode = CONCAT(vLetter,'-', LPAD(vRow,2,'0'),'-', i); INSERT IGNORE INTO vn.parking( sectorFk, `code`, pickingOrder) - VALUES (vSectorFk, vCode, vPickingOrder + ((vFromRow - vRow) * 100) + i ) + VALUES (vSectorFk, vCode, vPickingOrder + (i * 10)) ON DUPLICATE KEY UPDATE `code` = vCode; SET i = i + 1; @@ -61376,7 +62067,7 @@ BEGIN SET vCode = CONCAT(vLetter,'-', LPAD(vRow,2,'0'),'-', i); INSERT IGNORE INTO vn.parking( sectorFk, `code`, pickingOrder) - VALUES (vSectorFk, vCode, vPickingOrder + (vRow * 100) + i ) + VALUES (vSectorFk, vCode, vPickingOrder + (i * 10) ) ON DUPLICATE KEY UPDATE `code` = vCode; SET i = i + 1; @@ -61556,6 +62247,109 @@ BEGIN GROUP BY wj.userFk ORDER BY w.lastName, w.firstname; +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 `prepareClientList` */; +/*!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 `prepareClientList`() +BEGIN + + /* + * Require la tabla tmp.ticket(id,clientFk) + */ + + DROP TEMPORARY TABLE IF EXISTS tmp.client; + CREATE TEMPORARY TABLE tmp.client + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT DISTINCT clientFk id + FROM tmp.ticket; +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 `prepareTicketList` */; +/*!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 `prepareTicketList`(vStartingDate DATETIME, vEndingDate DATETIME) +BEGIN + + DROP TEMPORARY TABLE IF EXISTS tmp.productionTicket; + CREATE TEMPORARY TABLE tmp.productionTicket + (PRIMARY KEY (ticketFk)) + ENGINE = MEMORY + SELECT t.id ticketFk, t.clientFk + FROM vn.ticket t + LEFT JOIN vn.ticketState ts ON ts.ticket = t.id + JOIN vn.client c ON c.id = t.clientFk + WHERE c.typeFk IN ('normal','handMaking','internalUse') + AND ( + t.shipped BETWEEN CURDATE() AND vEndingDate + OR ( + ts.alertLevel < 3 + AND t.shipped >= vStartingDate + AND t.shipped < 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 `previousPreparationSticker_get` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `previousPreparationSticker_get`(vTicketFk INT) +BEGIN + + SELECT t.id ticketFk, + p.code as location, + t.observations, + IF(HOUR(t.shipped), HOUR(t.shipped), HOUR(z.`hour`)) shippingHour, + IF(MINUTE(t.shipped), MINUTE(t.shipped), MINUTE(z.`hour`)) shippingMinute , + i.itemPackingTypeFk , + count(*) items + FROM vn.ticket t + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemShelvingStock iss ON iss.itemFk = s.itemFk AND iss.sectorFk = 38 + LEFT JOIN vn.zone z ON z.id = t.zoneFk + LEFT JOIN vn.shelving sh ON sh.code = t.id + LEFT JOIN vn.parking p ON p.id = sh.parkingFk + WHERE t.id = vTicketFk + GROUP BY i.itemPackingTypeFk ; + + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -61610,6 +62404,470 @@ 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 `productionControl` */; +/*!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 `productionControl`(vWarehouseFk INT, vScopeDays INT) +proc: BEGIN + + DECLARE vEndingDate DATETIME DEFAULT TIMESTAMPADD(DAY,vScopeDays,util.dayEnd(CURDATE())); + + DECLARE vIsTodayRelative BOOLEAN; + + SELECT isTodayRelative INTO vIsTodayRelative + FROM vn.worker + WHERE userFk = vn.getUser(); + + CALL vn.prepareTicketList(TIMESTAMPADD(DAY,-1,CURDATE()), vEndingDate); + + DROP TEMPORARY TABLE IF EXISTS tmp.ticket; + CREATE TEMPORARY TABLE tmp.ticket + SELECT * FROM tmp.productionTicket; + + CALL vn.prepareClientList(); + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketGetProblems; + CREATE TEMPORARY TABLE tmp.ticketGetProblems + (INDEX (ticketFk)) ENGINE = MEMORY + SELECT tt.ticketFk, tt.clientFk, t.warehouseFk, t.shipped + FROM tmp.productionTicket tt + JOIN vn.ticket t ON t.id = tt.ticketFk; + + CALL vn.ticketGetProblems(vIsTodayRelative); + + DROP TEMPORARY TABLE IF EXISTS tmp.productionBuffer; + CREATE TEMPORARY TABLE tmp.productionBuffer + (PRIMARY KEY(ticketFk)) + ENGINE = MEMORY + SELECT tt.ticketFk + , tt.clientFk + , t.warehouseFk + , t.nickname + , t.packages + , IF(HOUR(t.shipped), HOUR(t.shipped), IFNULL(HOUR(zc.hour),HOUR(z.hour))) as HH + , IFNULL(HOUR(zc.hour),HOUR(z.hour)) as Departure + , MINUTE(t.shipped) as mm + , t.routeFk + , IF(am.deliveryMethodFk = 2,z.`id`,0) as zona + , a.nickname addressNickname + , a.postalCode + , a.city + , p.name province + , CONCAT(z.`name`,' ',IFNULL(RIGHT(t.routeFk,3),'')) agency + , am.id agencyModeFk + , 0 AS `lines` + , CAST( 0 AS DECIMAL(5,2)) AS m3 + , CAST( 0 AS DECIMAL(5,2)) AS preparationRate + , "" as problem + , IFNULL(tls.state,2) AS state + , w.code workerCode + , DATE(t.shipped) shipped + , wk.code AS salesPersonCode + , p.id provinceFk + , tls.productionOrder + , ifnull(tls.alertLevel,0) alertLevel + , t.isBoxed as palletized + , rg.deviceId ubicacion + , tlu.lastUpdated + -- , tls.updated lastUpdated + , ifnull(st.graphCategory,0) graphCategory + , pk.code as parking + , 0 AS H + , 0 AS V + , 0 AS F + , 0 AS P + , st.isOk + , ag.isOwn + FROM tmp.productionTicket tt + JOIN vn.ticket t on tt.ticketFk = t.id + LEFT JOIN vn.ticketStateToday tst ON tst.ticket = t.id + LEFT JOIN vn.state st ON st.id = tst.state + LEFT JOIN vn.client c ON c.id = t.clientFk + LEFT JOIN vn.worker wk ON wk.id = c.salesPersonFk + JOIN vn.address a on a.id = t.addressFk + LEFT JOIN vn.province p on p.id = a.provinceFk + JOIN vn.agencyMode am ON am.id = t.agencyModeFk + JOIN vn.agency ag ON ag.id = am.agencyFk + LEFT JOIN vn.ticketState tls on tls.ticket = tt.ticketFk + LEFT JOIN vn.ticketLastUpdated tlu ON tlu.ticketFk = tt.ticketFk + LEFT JOIN vn.worker w on w.id = tls.worker + LEFT JOIN vn.routeGate rg ON rg.routeFk = t.routeFk + LEFT JOIN vn.zone z ON z.id = t.zoneFk + LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk AND date(t.shipped) = zc.dated + LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id + LEFT JOIN vn.parking pk ON pk.id = tp.parkingFk + WHERE t.warehouseFk = vWarehouseFk + AND am.deliveryMethodFk IN (1,2,3); + + ALTER TABLE tmp.productionBuffer + CHANGE COLUMN `problem` `problem` VARCHAR(255), + ADD COLUMN `collectionH` INT, + ADD COLUMN `collectionV` INT, + ADD COLUMN `collectionF` INT, + ADD COLUMN `collectionP` INT; + + -- Líneas y volumen por ticket + UPDATE tmp.productionBuffer pb + JOIN ( + SELECT tt.ticketFk, + COUNT(*) as `lines`, + sum(sv.volume) as m3, + IFNULL(sum(IF(sv.isPicked,sv.volume,0)) / sum(sv.volume),0) as rate + FROM tmp.productionTicket tt + JOIN vn.saleVolume sv on sv.ticketFk = tt.ticketFk + GROUP BY tt.ticketFk + ) m on m.ticketFk = pb.ticketFk + SET pb.`lines` = m.`lines`, + pb.m3 = m.m3, + pb.preparationRate = m.rate; + + DELETE FROM tmp.productionBuffer + WHERE `lines`= 0; + + -- Lineas por linea de encajado + UPDATE tmp.productionBuffer pb + JOIN ( SELECT ticketFk, + sum(sub.H) H, + sum(sub.V) V, + sum(sub.F) F, + sum(sub.P) P + FROM ( + SELECT t.ticketFk, + sum(i.itemPackingTypeFk = 'H') H, + sum(i.itemPackingTypeFk = 'V') V, + sum(i.itemPackingTypeFk = 'F') F, + sum(i.itemPackingTypeFk = 'P') P + FROM tmp.productionTicket t + JOIN vn.sale s ON s.ticketFk = t.ticketFk + JOIN vn.item i ON i.id = s.itemFk + GROUP BY t.ticketFk, i.itemPackingTypeFk) sub + GROUP BY ticketFk + ) sub2 ON sub2.ticketFk = pb.ticketFk + SET pb.H = sub2.H, + pb.V = sub2.V, + pb.F = sub2.F, + pb.P = sub2.P; + + -- Colecciones segun tipo de encajado + UPDATE tmp.productionBuffer pb + JOIN vn.ticketCollection tc ON pb.ticketFk = tc.ticketFk + JOIN vn.collection c ON c.id = tc.collectionFk + SET pb.collectionH = c.id + WHERE pb.H AND (c.itemPackingTypeFk = 'H' OR ISNULL(c.itemPackingTypeFk)); + + UPDATE tmp.productionBuffer pb + JOIN vn.ticketCollection tc ON pb.ticketFk = tc.ticketFk + JOIN vn.collection c ON c.id = tc.collectionFk + SET pb.collectionV = c.id + WHERE pb.V AND (c.itemPackingTypeFk = 'V' OR ISNULL(c.itemPackingTypeFk)); + + UPDATE tmp.productionBuffer pb + JOIN vn.ticketCollection tc ON pb.ticketFk = tc.ticketFk + JOIN vn.collection c ON c.id = tc.collectionFk + SET pb.collectionF = c.id + WHERE pb.F AND (c.itemPackingTypeFk = 'F' OR ISNULL(c.itemPackingTypeFk)); + + UPDATE tmp.productionBuffer pb + JOIN vn.ticketCollection tc ON pb.ticketFk = tc.ticketFk + JOIN vn.collection c ON c.id = tc.collectionFk + SET pb.collectionP = c.id + WHERE pb.P AND (c.itemPackingTypeFk = 'P' OR ISNULL(c.itemPackingTypeFk)); + + -- Cajas + ALTER TABLE tmp.productionBuffer + ADD Cajas DOUBLE DEFAULT NULL; + + -- Problemas por ticket + UPDATE tmp.productionBuffer pb + JOIN tmp.ticketProblems tp ON tp.ticketFk = pb.ticketFk + SET pb.problem = CAST(CONCAT( IFNULL(tp.itemShortage,''), + IFNULL(tp.itemDelay,''), + IF(tp.isFreezed,' CONGELADO',''), + IF(tp.risk,' RIESGO',''), + IF(tp.hasTicketRequest, ' COD 100',''), + IF(tp.isTaxDataChecked, '',' FICHA INCOMPLETA') + ) as char(255)); + + -- Refresca la caché para el cierre dinámico de agencias + -- CALL cache.departure_timing(vWarehouseFk); +/* + -- Tickets de recogida + REPLACE tmp.productionBuffer( + shipped + , ticketFk + , agency + , clientFk + , addressNickname + , state + , workerCode + , alertLevel + , warehouseFk + ) + SELECT DATE(t.shipped) + , t.id + , am.name + , t.clientFk + , a.nickname + , s.id as state + , w.code + , ifnull(tls.alertLevel,0) alert_level + , vWarehouseFk + FROM vn.ticket t + JOIN vn.address a on a.id = t.addressFk + JOIN vn.agencyMode am ON am.id = t.agencyModeFk + LEFT JOIN vn2008.warehouse_pickup wp ON wp.agency_id = am.id + LEFT JOIN vn.ticketState tls on tls.ticket = t.id + LEFT JOIN vn.state s ON s.id = tls.state + LEFT JOIN vn.worker w on w.id = tls.worker + WHERE t.shipped between TIMESTAMPADD(WEEK,-1,CURDATE()) AND util.dayend(TIMESTAMPADD(DAY,-1,CURDATE())) + AND wp.warehouse_id = vWarehouseFk; +*/ + DROP TEMPORARY TABLE tmp.productionTicket; + DROP TEMPORARY TABLE tmp.ticket; + DROP TEMPORARY TABLE IF EXISTS tmp.risk; + +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 `productionControl__` */; +/*!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 `productionControl__`(vWarehouseFk INT, vScopeDays INT) +proc: BEGIN + + DECLARE vEndingDate DATETIME DEFAULT TIMESTAMPADD(DAY,vScopeDays,util.dayEnd(CURDATE())); + + CALL vn.prepareTicketList(TIMESTAMPADD(DAY,-1,CURDATE()), vEndingDate); + + DROP TEMPORARY TABLE IF EXISTS tmp.ticket; + CREATE TEMPORARY TABLE tmp.ticket + SELECT * FROM tmp.productionTicket; + + CALL vn.prepareClientList(); + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketGetProblems; + CREATE TEMPORARY TABLE tmp.ticketGetProblems + (INDEX (ticketFk)) ENGINE = MEMORY + SELECT tt.ticketFk, tt.clientFk, t.warehouseFk, t.shipped + FROM tmp.productionTicket tt + JOIN vn.ticket t ON t.id = tt.ticketFk; + + CALL vn.ticketGetProblems(); + + DROP TEMPORARY TABLE IF EXISTS tmp.productionBuffer; + CREATE TEMPORARY TABLE tmp.productionBuffer + (PRIMARY KEY(ticketFk)) + ENGINE = MEMORY + SELECT tt.ticketFk + , tt.clientFk + , t.warehouseFk + , t.nickname + , t.packages + , IF(HOUR(t.shipped), HOUR(t.shipped), IFNULL(HOUR(zc.hour),HOUR(z.hour))) as HH + , IFNULL(HOUR(zc.hour),HOUR(z.hour)) as Departure + , MINUTE(t.shipped) as mm + , t.routeFk + , IF(am.deliveryMethodFk = 2,z.`id`,0) as zona + , a.nickname addressNickname + , a.postalCode + , a.city + , p.name province + , CONCAT(z.`name`,' ',IFNULL(RIGHT(t.routeFk,3),'')) agency + , am.id agencyModeFk + , 0 AS `lines` + , CAST( 0 AS DECIMAL(5,2)) AS m3 + , CAST( 0 AS DECIMAL(5,2)) AS preparationRate + , "" as problem + , IFNULL(tls.state,2) AS state + , w.code workerCode + , DATE(t.shipped) shipped + , wk.code AS salesPersonCode + , p.id provinceFk + , tls.productionOrder + , ifnull(tls.alertLevel,0) alertLevel + , t.isBoxed as palletized + , rg.deviceId ubicacion + , tlu.lastUpdated + -- , tls.updated lastUpdated + , ifnull(st.graphCategory,0) graphCategory + , pk.code as parking + , 0 AS H + , 0 AS V + , 0 AS F + , 0 AS P + , st.isOk + , ag.isOwn + FROM tmp.productionTicket tt + JOIN vn.ticket t on tt.ticketFk = t.id + LEFT JOIN vn.ticketStateToday tst ON tst.ticket = t.id + LEFT JOIN vn.state st ON st.id = tst.state + LEFT JOIN vn.client c ON c.id = t.clientFk + LEFT JOIN vn.worker wk ON wk.id = c.salesPersonFk + JOIN vn.address a on a.id = t.addressFk + LEFT JOIN vn.province p on p.id = a.provinceFk + JOIN vn.agencyMode am ON am.id = t.agencyModeFk + JOIN vn.agency ag ON ag.id = am.agencyFk + LEFT JOIN vn.ticketState tls on tls.ticket = tt.ticketFk + LEFT JOIN vn.ticketLastUpdated tlu ON tlu.ticketFk = tt.ticketFk + LEFT JOIN vn.worker w on w.id = tls.worker + LEFT JOIN vn.routeGate rg ON rg.routeFk = t.routeFk + LEFT JOIN vn.zone z ON z.id = t.zoneFk + LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk AND date(t.shipped) = zc.dated + LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id + LEFT JOIN vn.parking pk ON pk.id = tp.parkingFk + WHERE t.warehouseFk = vWarehouseFk + AND am.deliveryMethodFk IN (1,2,3); + + ALTER TABLE tmp.productionBuffer + CHANGE COLUMN `problem` `problem` VARCHAR(255), + ADD COLUMN `collectionH` INT, + ADD COLUMN `collectionV` INT, + ADD COLUMN `collectionF` INT, + ADD COLUMN `collectionP` INT; + + -- Líneas y volumen por ticket + UPDATE tmp.productionBuffer pb + JOIN ( + SELECT tt.ticketFk, + COUNT(*) as `lines`, + sum(sv.volume) as m3, + IFNULL(sum(IF(sv.isPicked,sv.volume,0)) / sum(sv.volume),0) as rate + FROM tmp.productionTicket tt + JOIN vn.saleVolume sv on sv.ticketFk = tt.ticketFk + GROUP BY tt.ticketFk + ) m on m.ticketFk = pb.ticketFk + SET pb.`lines` = m.`lines`, + pb.m3 = m.m3, + pb.preparationRate = m.rate; + + DELETE FROM tmp.productionBuffer + WHERE `lines`= 0; + + -- Lineas por linea de encajado + UPDATE tmp.productionBuffer pb + JOIN ( SELECT ticketFk, + sum(sub.H) H, + sum(sub.V) V, + sum(sub.F) F, + sum(sub.P) P + FROM ( + SELECT t.ticketFk, + sum(i.itemPackingTypeFk = 'H') H, + sum(i.itemPackingTypeFk = 'V') V, + sum(i.itemPackingTypeFk = 'F') F, + sum(i.itemPackingTypeFk = 'P') P + FROM tmp.productionTicket t + JOIN vn.sale s ON s.ticketFk = t.ticketFk + JOIN vn.item i ON i.id = s.itemFk + GROUP BY t.ticketFk, i.itemPackingTypeFk) sub + GROUP BY ticketFk + ) sub2 ON sub2.ticketFk = pb.ticketFk + SET pb.H = sub2.H, + pb.V = sub2.V, + pb.F = sub2.F, + pb.P = sub2.P; + + -- Colecciones segun tipo de encajado + UPDATE tmp.productionBuffer pb + JOIN vn.ticketCollection tc ON pb.ticketFk = tc.ticketFk + JOIN vn.collection c ON c.id = tc.collectionFk + SET pb.collectionH = c.id + WHERE pb.H AND (c.itemPackingTypeFk = 'H' OR ISNULL(c.itemPackingTypeFk)); + + UPDATE tmp.productionBuffer pb + JOIN vn.ticketCollection tc ON pb.ticketFk = tc.ticketFk + JOIN vn.collection c ON c.id = tc.collectionFk + SET pb.collectionV = c.id + WHERE pb.V AND (c.itemPackingTypeFk = 'V' OR ISNULL(c.itemPackingTypeFk)); + + UPDATE tmp.productionBuffer pb + JOIN vn.ticketCollection tc ON pb.ticketFk = tc.ticketFk + JOIN vn.collection c ON c.id = tc.collectionFk + SET pb.collectionF = c.id + WHERE pb.F AND (c.itemPackingTypeFk = 'F' OR ISNULL(c.itemPackingTypeFk)); + + UPDATE tmp.productionBuffer pb + JOIN vn.ticketCollection tc ON pb.ticketFk = tc.ticketFk + JOIN vn.collection c ON c.id = tc.collectionFk + SET pb.collectionP = c.id + WHERE pb.P AND (c.itemPackingTypeFk = 'P' OR ISNULL(c.itemPackingTypeFk)); + + -- Cajas + ALTER TABLE tmp.productionBuffer + ADD Cajas DOUBLE DEFAULT NULL; + + -- Problemas por ticket + UPDATE tmp.productionBuffer pb + JOIN tmp.ticketProblems tp ON tp.ticketFk = pb.ticketFk + SET pb.problem = CAST(CONCAT( IFNULL(tp.itemShortage,''), + IFNULL(tp.itemDelay,''), + IF(tp.isFreezed,' CONGELADO',''), + IF(tp.risk,' RIESGO',''), + IF(tp.hasTicketRequest, ' COD 100',''), + IF(tp.isTaxDataChecked, '',' FICHA INCOMPLETA') + ) as char(255)); + + -- Refresca la caché para el cierre dinámico de agencias + -- CALL cache.departure_timing(vWarehouseFk); +/* + -- Tickets de recogida + REPLACE tmp.productionBuffer( + shipped + , ticketFk + , agency + , clientFk + , addressNickname + , state + , workerCode + , alertLevel + , warehouseFk + ) + SELECT DATE(t.shipped) + , t.id + , am.name + , t.clientFk + , a.nickname + , s.id as state + , w.code + , ifnull(tls.alertLevel,0) alert_level + , vWarehouseFk + FROM vn.ticket t + JOIN vn.address a on a.id = t.addressFk + JOIN vn.agencyMode am ON am.id = t.agencyModeFk + LEFT JOIN vn2008.warehouse_pickup wp ON wp.agency_id = am.id + LEFT JOIN vn.ticketState tls on tls.ticket = t.id + LEFT JOIN vn.state s ON s.id = tls.state + LEFT JOIN vn.worker w on w.id = tls.worker + WHERE t.shipped between TIMESTAMPADD(WEEK,-1,CURDATE()) AND util.dayend(TIMESTAMPADD(DAY,-1,CURDATE())) + AND wp.warehouse_id = vWarehouseFk; +*/ + DROP TEMPORARY TABLE tmp.productionTicket; + DROP TEMPORARY TABLE tmp.ticket; + DROP TEMPORARY TABLE IF EXISTS tmp.risk; + +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 `productionSectorList` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -62300,6 +63558,91 @@ 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 `reportLabelCollection_get` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `reportLabelCollection_get`(vCollectionFk INT) +BEGIN + + DECLARE vItemPackingTypeFk VARCHAR(1); + + -- Si los sacadores NO son de V, pinta los colores + SELECT c.itemPackingTypeFk INTO vItemPackingTypeFk + FROM vn.collection c + WHERE c.id = vCollectionFk; + + IF !(vItemPackingTypeFk <=> 'V') THEN + + SELECT CONCAT(tc.collectionFk,' ',LEFT(cc.code,4)) `level`, + tc.ticketFk, + LEFT(IF(t.routeFk IS null, am.name, zo.name ),12) agencyDescription, + am.name, + t.clientFk, + '' notes, + w.code workerCode, + tt.labelCount, + IF(HOUR(t.shipped),TIME(t.shipped),TIME(zo.HOUR)) as horaagencia, + t.shipped, + count(*) AS urgente + FROM vn.ticket t + JOIN vn.ticketCollection tc ON tc.ticketFk = t.id + JOIN vn.collectionColors cc ON cc.shelve = tc.`level` AND cc.wagon = tc.wagon + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.collection c ON c.id = tc.collectionFk + JOIN vn.worker w ON w.id = c.workerFk + JOIN vn.agencyMode am on am.id = t.agencyModeFk + 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.agencyMode agm on r.agencyModeFk =agm.id + LEFT JOIN vn.zone zo ON t.zoneFk = zo.id + WHERE tc.collectionFk = vCollectionFk + GROUP BY t.id; + + ELSE + + SELECT CONCAT(tc.collectionFk,' ', SUBSTRING('ABCDEFGH',tc.wagon, 1), '-',tc.level) `level`, + tc.ticketFk, + LEFT(IF(t.routeFk IS null, am.name, zo.name ),12) agencyDescription, + am.name, + t.clientFk, + '' notes, + w.code workerCode, + tt.labelCount, + IF(HOUR(t.shipped),TIME(t.shipped),TIME(zo.HOUR)) as horaagencia, + t.shipped, + count(*) AS urgente + FROM vn.ticket t + JOIN vn.ticketCollection tc ON tc.ticketFk = t.id + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.collection c ON c.id = tc.collectionFk + JOIN vn.worker w ON w.id = c.workerFk + JOIN vn.agencyMode am on am.id = t.agencyModeFk + 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.agencyMode agm on r.agencyModeFk =agm.id + LEFT JOIN vn.zone zo ON t.zoneFk = zo.id + WHERE tc.collectionFk = vCollectionFk + GROUP BY t.id; + + 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 `riskAllClients` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -62354,7 +63697,7 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `routeGateAsign`(vDevice VARCHAR(30), vRouteFk INT) BEGIN - + /* UPDATE routeGate SET displayText = NULL, routeFk = NULL, @@ -62365,16 +63708,24 @@ BEGIN pallets = NULL, lastScanned = NULL WHERE routeFk = vRouteFk; - - UPDATE routeGate - SET routeFk = vRouteFk - WHERE deviceId = vDevice COLLATE utf8_general_ci; - + */ + IF ISNULL(vDevice) THEN + + DELETE FROM routeGate + WHERE routeFk = vRouteFk; + + ELSE + + REPLACE routeGate(routeFk, deviceId) + VALUES(vRouteFk, vDevice); + + END IF; + /* UPDATE vn.route r JOIN vn.beach b ON b.name = vDevice SET r.beachFk = b.id WHERE r.id = vRouteFk; - + */ END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -62469,7 +63820,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`z-developer`@`%` PROCEDURE `routeInfo`(vRouteFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `routeInfo`(vRouteFk INT) BEGIN DECLARE vPackages INT; @@ -66241,9 +67592,13 @@ DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `ticketCollection_get`(vTicketFk INT) BEGIN - SELECT collectionFk - FROM vn.ticketCollection - WHERE ticketFk = vTicketFk; + SELECT tc.collectionFk + FROM vn.ticketCollection tc + JOIN vn.collection c ON c.id = tc.collectionFk + JOIN tmp.workerPackingType wpt ON wpt.workerFk = account.myUser_getId() + WHERE ticketFk = vTicketFk + AND c.itemPackingTypeFk = wpt.itemPackingTypeFk + ; END ;; DELIMITER ; @@ -66973,7 +68328,7 @@ BEGIN * @return Listado de tickets */ CALL ticketGetTotal(); - CALL ticketGetProblems(); + CALL ticketGetProblems(FALSE); DROP TEMPORARY TABLE IF EXISTS tmp.ticketFilter; CREATE TEMPORARY TABLE tmp.ticketFilter ENGINE = MEMORY @@ -67002,20 +68357,19 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ticketGetProblems`() +CREATE DEFINER=`root`@`%` PROCEDURE `ticketGetProblems`(vIsTodayRelative BOOLEAN) BEGIN DECLARE vWarehouse INT; DECLARE vDate DATE; DECLARE vAvailableCache INT; - DECLARE vVisibleCache INT; DECLARE vDone INT DEFAULT 0; DECLARE vCursor CURSOR FOR - SELECT DISTINCT tt.warehouseFk, date(tt.shipped) + SELECT DISTINCT tt.warehouseFk, IF(vIsTodayRelative, CURDATE(), date(tt.shipped)) FROM tmp.ticketGetProblems tt WHERE DATE(tt.shipped) BETWEEN CURDATE() - AND TIMESTAMPADD(DAY, 1.9, CURDATE()); + AND TIMESTAMPADD(DAY, IF(vIsTodayRelative, 9.9, 1.9), CURDATE()); DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = 1; @@ -67026,7 +68380,9 @@ BEGIN risk DECIMAL(10,2) DEFAULT 0, hasTicketRequest INTEGER(1) DEFAULT 0, isAvailable INTEGER(1) DEFAULT 1, - isTaxDataChecked INTEGER(1) DEFAULT 1 + itemShortage VARCHAR(250), + isTaxDataChecked INTEGER(1) DEFAULT 1, + itemDelay VARCHAR(250) ) ENGINE = MEMORY; DROP TEMPORARY TABLE IF EXISTS tmp.ticketList; @@ -67036,8 +68392,7 @@ BEGIN SELECT tp.ticketFk, c.id clientFk FROM tmp.ticketGetProblems tp JOIN vn.client c ON c.id = tp.clientFk; - - + INSERT INTO tmp.ticketProblems(ticketFk, isFreezed) SELECT DISTINCT tl.ticketFk, 1 FROM tmp.ticketList tl @@ -67053,7 +68408,6 @@ BEGIN CALL clientGetDebt(CURDATE()); - INSERT INTO tmp.ticketProblems(ticketFk, risk) SELECT DISTINCT tl.ticketFk, r.risk FROM tmp.ticketList tl @@ -67061,7 +68415,8 @@ BEGIN 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 - WHERE r.risk > c.credit + 10 + JOIN vn.clientConfig cc + WHERE r.risk - cc.riskTolerance > c.credit + 10 AND a.isRiskFree = FALSE ON DUPLICATE KEY UPDATE risk = r.risk; @@ -67080,21 +68435,19 @@ BEGIN DO FETCH vCursor INTO vWarehouse, vDate; - CALL cache.visible_refresh(vVisibleCache, FALSE, vWarehouse); CALL cache.available_refresh(vAvailableCache, FALSE, vWarehouse, vDate); - INSERT INTO tmp.ticketProblems(ticketFk, isAvailable) SELECT tl.ticketFk, 0 FROM tmp.ticketList tl JOIN vn.ticket t ON t.id = tl.ticketFk - LEFT JOIN vn.sale s ON s.ticketFk = t.id + 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 categoryFk != 6 + AND it.categoryFk != 6 AND IFNULL(av.available, 0) < 0 AND s.isPicked = FALSE AND NOT i.generic @@ -67103,28 +68456,53 @@ BEGIN ON DUPLICATE KEY UPDATE isAvailable = 0; - INSERT INTO tmp.ticketProblems(ticketFk, isAvailable) - SELECT tl.ticketFk, 0 + INSERT INTO tmp.ticketProblems(ticketFk, itemShortage) + SELECT ticketFk, problem + FROM ( + SELECT tl.ticketFk, CONCAT('F: ',GROUP_CONCAT(i.id, ' ', i.longName, ' ')) problem FROM tmp.ticketList tl JOIN vn.ticket t ON t.id = tl.ticketFk - LEFT JOIN vn.sale s ON s.ticketFk = t.id + 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.visible v ON i.id = v.item_id AND v.calc_id = vVisibleCache + 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(v.visible, 0) + 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 date(t.shipped) = vDate + AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate) AND NOT i.generic AND CURDATE() = vDate AND t.warehouseFk = vWarehouse - GROUP BY tl.ticketFk + GROUP BY tl.ticketFk) sub ON DUPLICATE KEY UPDATE - isAvailable = 0; + itemShortage = sub.problem; + INSERT INTO tmp.ticketProblems(ticketFk, itemDelay) + SELECT ticketFk, problem + FROM ( + SELECT tl.ticketFk, GROUP_CONCAT('I: ',i.id, ' ', i.longName, ' ') problem + FROM tmp.ticketList 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) sub + ON DUPLICATE KEY UPDATE + itemDelay = sub.problem; END WHILE; CLOSE vCursor; @@ -67137,9 +68515,6 @@ BEGIN ON DUPLICATE KEY UPDATE isTaxDataChecked = FALSE; - - -- SELECT * FROM tmp.ticketProblems; - DROP TEMPORARY TABLE tmp.clientGetDebt, tmp.ticketList; @@ -67154,9 +68529,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 ;; @@ -67183,7 +68558,10 @@ BEGIN isFreezed INTEGER(1) DEFAULT 0, risk DECIMAL(10,2) DEFAULT 0, hasTicketRequest INTEGER(1) DEFAULT 0, - isAvailable INTEGER(1) DEFAULT 1 + isAvailable INTEGER(1) DEFAULT 1, + itemShortage VARCHAR(250), + isTaxDataChecked INTEGER(1) DEFAULT 1, + itemDelay VARCHAR(250) ) ENGINE = MEMORY; DROP TEMPORARY TABLE IF EXISTS tmp.ticketList; @@ -67193,8 +68571,7 @@ BEGIN SELECT tp.ticketFk, c.id clientFk FROM tmp.ticketGetProblems tp JOIN vn.client c ON c.id = tp.clientFk; - - + INSERT INTO tmp.ticketProblems(ticketFk, isFreezed) SELECT DISTINCT tl.ticketFk, 1 FROM tmp.ticketList tl @@ -67210,7 +68587,6 @@ BEGIN CALL clientGetDebt(CURDATE()); - INSERT INTO tmp.ticketProblems(ticketFk, risk) SELECT DISTINCT tl.ticketFk, r.risk FROM tmp.ticketList tl @@ -67218,8 +68594,9 @@ BEGIN 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 - WHERE r.risk > c.credit + 10 - AND a.deliveryMethodFk != 3 + JOIN vn.clientConfig cc + WHERE r.risk - cc.riskTolerance > c.credit + 10 + AND a.isRiskFree = FALSE ON DUPLICATE KEY UPDATE risk = r.risk; @@ -67240,18 +68617,17 @@ BEGIN CALL cache.visible_refresh(vVisibleCache, FALSE, vWarehouse); CALL cache.available_refresh(vAvailableCache, FALSE, vWarehouse, vDate); - INSERT INTO tmp.ticketProblems(ticketFk, isAvailable) SELECT tl.ticketFk, 0 FROM tmp.ticketList tl JOIN vn.ticket t ON t.id = tl.ticketFk - LEFT JOIN vn.sale s ON s.ticketFk = t.id + 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 categoryFk != 6 + AND it.categoryFk != 6 AND IFNULL(av.available, 0) < 0 AND s.isPicked = FALSE AND NOT i.generic @@ -67260,17 +68636,20 @@ BEGIN ON DUPLICATE KEY UPDATE isAvailable = 0; - INSERT INTO tmp.ticketProblems(ticketFk, isAvailable) - SELECT tl.ticketFk, 0 + INSERT INTO tmp.ticketProblems(ticketFk, itemShortage) + SELECT ticketFk, problem + FROM ( + SELECT tl.ticketFk, CONCAT('F: ',GROUP_CONCAT(i.id, ' ', i.longName, ' ')) problem FROM tmp.ticketList tl JOIN vn.ticket t ON t.id = tl.ticketFk - LEFT JOIN vn.sale s ON s.ticketFk = t.id + 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.visible v ON i.id = v.item_id AND v.calc_id = vVisibleCache LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache - WHERE IFNULL(av.available, 0) >= 0 + WHERE IFNULL(av.available, 0) < 0 AND s.quantity > IFNULL(v.visible, 0) + AND s.quantity > 0 AND s.isPicked = FALSE AND s.reserved = FALSE AND it.categoryFk != 6 @@ -67278,15 +68657,45 @@ BEGIN AND NOT i.generic AND CURDATE() = vDate AND t.warehouseFk = vWarehouse - GROUP BY tl.ticketFk + GROUP BY tl.ticketFk) sub ON DUPLICATE KEY UPDATE - isAvailable = 0; + itemShortage = sub.problem; + INSERT INTO tmp.ticketProblems(ticketFk, itemDelay) + SELECT ticketFk, problem + FROM ( + SELECT tl.ticketFk, CONCAT('R: ',GROUP_CONCAT(i.id, ' ', i.longName, ' ')) problem + FROM tmp.ticketList 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.visible v ON i.id = v.item_id AND v.calc_id = vVisibleCache + 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(v.visible, 0) + AND s.quantity > 0 + AND s.isPicked = FALSE + AND s.reserved = FALSE + AND it.categoryFk != 6 + AND date(t.shipped) = vDate + AND NOT i.generic + AND CURDATE() = vDate + AND t.warehouseFk = vWarehouse + GROUP BY tl.ticketFk) sub + ON DUPLICATE KEY UPDATE + itemDelay = sub.problem; END WHILE; CLOSE vCursor; - - SELECT * FROM tmp.ticketProblems; + + INSERT INTO tmp.ticketProblems(ticketFk, isTaxDataChecked) + SELECT DISTINCT tl.ticketFk, FALSE + FROM tmp.ticketList 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, @@ -67709,7 +69118,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`z-developer`@`%` PROCEDURE `ticketManaToPromo`(vTicketFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `ticketManaToPromo`(vTicketFk INT) BEGIN DECLARE vManaComponent INT; @@ -67739,9 +69148,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 ;; @@ -67756,7 +69165,8 @@ BEGIN SELECT IFNULL(`level`,0), IFNULL(collectionFk,0) INTO vLevel, vCollectionFk FROM vn.ticketCollection - WHERE ticketFk = vTicketFk; + WHERE ticketFk = vTicketFk + LIMIT 1; SELECT created, parkingFk INTO vParked, vParkingFk @@ -67790,9 +69200,6 @@ BEGIN AND tp.created < vParked AND t.packages <=> 0); - - - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -67902,6 +69309,83 @@ 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 `ticketParking_findSkipped` */; +/*!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 `ticketParking_findSkipped`(vTicketFk INT, vItemPackingTypeFk VARCHAR(1)) +BEGIN + +/** + * Averigua los tickets que se han saltado por un error en el proceso encajado + * @param vTicketFk Ticket + * @param vItemPackingTypeFk Modo de encajado + * @return un select con los tickets afectados + */ + + DECLARE vParkingFk INT; + DECLARE vParked DATETIME; + DECLARE vLevel INT; + DECLARE vWagon INT; + DECLARE vCollectionFk INT; + + SELECT IFNULL(`level`,0), IFNULL(`wagon`,0),IFNULL(collectionFk,0) + INTO vLevel, vWagon, vCollectionFk + FROM vn.ticketCollection tc + JOIN vn.collection c ON c.id = tc.collectionFk AND c.itemPackingTypeFk = vItemPackingTypeFk + WHERE ticketFk = vTicketFk + ORDER BY c.id DESC + LIMIT 1; + + SELECT created, parkingFk + INTO vParked, vParkingFk + FROM vn.ticketParking tp + JOIN vn.parking p ON p.id = tp.parkingFk + JOIN vn.sector s ON s.id = p.sectorFk + WHERE ticketFk = vTicketFk + AND s.itemPackingTypeFk = vItemPackingTypeFk + AND s.isPackagingArea ; + + SELECT tp.ticketFk, CONCAT(tc.collectionFk, ' ', tc.wagon, ' - ', tc.level) coleccion, tp.created, p.code, am.name as Agencia + FROM vn.ticketParking tp + JOIN vn.parking p ON p.id = tp.parkingFk + JOIN vn.sector sc ON sc.id = p.sectorFk + LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = tp.ticketFk + JOIN vn.ticketStateToday tst ON tst.ticket = tp.ticketFk + JOIN vn.ticket t ON t.id = tp.ticketFk + JOIN vn.zone z ON z.id = t.zoneFk + JOIN vn.agencyMode am ON am.id = z.agencyModeFk + JOIN vn.state s ON s.id = tst.state + WHERE (s.alertLevel < 2 + AND tp.parkingFk = vParkingFk + AND sc.isPackagingArea + AND ( + ( IFNULL(tc.collectionFk,-1) != IFNULL(@vCollectionFk,0) AND tp.created < vParked ) + OR + ( tc.collectionFk = vCollectionFk + AND (LEFT(tc.wagon,1) < LEFT(vWagon,1) + OR (LEFT(tc.wagon,1) = LEFT(vWagon,1) AND LEFT(tc.level,1) < LEFT(vLevel,1))) + ) + ) + ) -- Etiquetas que no se han escaneado y ya estamos con una posterior + OR + (s.alertLevel > 1 + AND tp.parkingFk = vParkingFk + AND sc.isPackagingArea + AND tp.created < vParked + AND t.packages <=> 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 `ticketRequest_Add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -68037,15 +69521,26 @@ 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 `ticketStateUpdate`(vTicketFk INT, vStateCode VARCHAR(45)) +CREATE DEFINER=`root`@`%` PROCEDURE `ticketStateUpdate`(vTicketFk INT, vStateCode VARCHAR(45)) BEGIN + + DECLARE vAlertLevel INT; - INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) - SELECT id, vTicketFk, account.myUser_getId() - FROM vn.state - WHERE `code` = vStateCode collate utf8_unicode_ci; + SELECT s.alertLevel INTO vAlertLevel + FROM vn.state s + JOIN vn.ticketState ts ON ts.stateFk = s.id + WHERE ts.ticketFk = vTicketFk; + + IF !(vStateCode = 'ON_CHECKING' AND vAlertLevel > 1) THEN + + INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) + SELECT id, vTicketFk, account.myUser_getId() + FROM vn.state + WHERE `code` = vStateCode collate utf8_unicode_ci; + + END IF; END ;; DELIMITER ; @@ -68225,25 +69720,208 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `ticketToPrePrepare`(IN vIdTicket INT, IN viewAll BOOL, IN vSectorFk INT) +BEGIN + +/* Tickets de preparacion previa (artificial) 21/03/2021 PAK +*/ + + DECLARE vIsResetCode BOOLEAN; + +IF viewAll IS true THEN + + SELECT (vIdTicket = 2000000) INTO vIsResetCode; + + IF vIsResetCode THEN + + UPDATE vn.saleTracking st + JOIN vn.state s ON s.code = 'OK PREVIOUS' + JOIN vncontrol.accion a ON a.accion_id = st.actionFk + JOIN vn.state s2 ON s2.id = st.stateFk + SET st.stateFk = s.id + WHERE workerFk = vn.getUser() + AND (a.accion = 'PRESACAR') + AND st.created > TIMESTAMPADD(HOUR, -10, NOW()); + + ELSE + + UPDATE vn.saleTracking st + JOIN vn.salesToPrePrepare stpp ON stpp.Id_Movimiento_mark = st.id + SET workerFk = vn.getUser() + WHERE stpp.Id_Ticket = vIdTicket + AND stpp.isChecked = FALSE; + + SELECT stpp.Id_Ticket, + stpp.Id_Movimiento, + stpp.Id_Movimiento_mark, + stpp.Id_Trabjador, + stpp.Id_Article, + CONCAT('(', i.itemPackingTypeFk,') ', stpp.Concepte) Concepte, + stpp.subName, + stpp.Cantidad, + stpp.original_quantity, + stpp.Hora, + stpp.Departure, + stpp.Minuto, + stpp.agency_id, + stpp.warehouse_id, + stpp.province_id, + stpp.picked, + stpp.trabajador, + ispss.created, + ispss.sectorFk + FROM vn.salesToPrePrepare stpp + JOIN vn.worker w ON w.code = stpp.trabajador + LEFT JOIN vn.itemShelvingPlacementSupplyStock ispss + ON ispss.itemShelvingFk = ( SELECT itemShelvingFk + FROM vn.itemShelvingPlacementSupplyStock + WHERE itemFk = stpp.Id_Article + AND sectorFk = vSectorFk + ORDER BY parking ASC + LIMIT 1) + LEFT JOIN vn.parking p ON p.id = ispss.parkingFk + LEFT JOIN vn.item i ON i.id = stpp.Id_Article + JOIN vn.state s ON s.id = stpp.stateFk + WHERE w.id = vn.getUser() + AND stpp.created > CURDATE() + AND s.code = 'PREVIOUS_PREPARATION' + ORDER BY p.pickingOrder, p.column ASC; + + END IF;/* +ELSE + SELECT * + FROM vn.ticketToPrepare ttp + WHERE ttp.Id_Ticket = vIdTicket; +*/ +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 `ticketToPrePrepare_beta` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8 */ ; /*!50003 SET character_set_results = utf8 */ ; /*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ticketToPrePrepare`(IN vIdTicket INT, IN viewAll BOOL, IN vSectorFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `ticketToPrePrepare_beta`(IN vIdTicket INT, IN viewAll BOOL, IN vSectorFk INT) +BEGIN + +/* Tickets de artificial +*/ +IF viewAll IS true THEN + + UPDATE vn.saleTracking st + JOIN vn.salesToPrePrepare stpp ON stpp.Id_Movimiento_mark = st.id + SET workerFk = vn.getUser() + WHERE s.ticketFk = vIdTicket + AND stpp.isChecked = FALSE; + + SELECT stpp.Id_Ticket, + stpp.Id_Movimiento, + stpp.Id_Movimiento_mark, + stpp.Id_Trabjador, + stpp.Id_Article, + CONCAT('(', i.itemPackingTypeFk,') ', stpp.Concepte) Concepte, + stpp.subName, + stpp.Cantidad, + stpp.original_quantity, + stpp.Hora, + stpp.Departure, + stpp.Minuto, + stpp.agency_id, + stpp.warehouse_id, + stpp.province_id, + stpp.picked, + stpp.trabajador, + ispss.created, + ispss.sectorFk + FROM vn.salesToPrePrepare stpp + JOIN vn.worker w ON w.code = stpp.trabajador + LEFT JOIN vn.itemShelvingPlacementSupplyStock ispss + ON ispss.itemShelvingFk = ( SELECT itemShelvingFk + FROM vn.itemShelvingPlacementSupplyStock + WHERE itemFk = stpp.Id_Article + AND sectorFk = vSectorFk + ORDER BY parking ASC + LIMIT 1) + LEFT JOIN vn.parking p ON p.id = ispss.parkingFk + LEFT JOIN vn.item i ON i.id = stpp.Id_Article + WHERE w.id = vn.getUser() + AND (stpp.isChecked = FALSE) + ORDER BY p.pickingOrder, p.column ASC; +ELSE + SELECT * + FROM vn.ticketToPrepare ttp + WHERE ttp.Id_Ticket = vIdTicket; + +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 `ticketToPrePrepare__` */; +/*!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 `ticketToPrePrepare__`(IN vIdTicket INT, IN viewAll BOOL, IN vSectorFk INT) BEGIN /* Tickets con estado 26 para preaprar en altillo */ IF viewAll IS true THEN - SELECT stpp.*,ispss.created,ispss.sectorFk + SELECT stpp.Id_Ticket, + stpp.Id_Movimiento, + stpp.Id_Movimiento_mark, + stpp.Id_Trabjador, + stpp.Id_Article, + CONCAT('(', i.itemPackingTypeFk,') ', stpp.Concepte) Concepte, + stpp.subName, + stpp.Cantidad, + stpp.original_quantity, + stpp.Hora, + stpp.Departure, + stpp.Minuto, + stpp.agency_id, + stpp.warehouse_id, + stpp.province_id, + stpp.picked, + stpp.trabajador, + ispss.created, + ispss.sectorFk FROM vn.salesToPrePrepare stpp - LEFT JOIN vn.itemShelvingPlacementSupplyStock ispss - ON ispss.itemShelvingFk = (SELECT itemShelvingFk FROM vn.itemShelvingPlacementSupplyStock WHERE itemFk = stpp.Id_Article AND sectorFk = vSectorFk ORDER BY parking ASC LIMIT 1) - LEFT JOIN vn.parking p ON p.id = ispss.parkingFk + LEFT JOIN vn.itemShelvingPlacementSupplyStock ispss + ON ispss.itemShelvingFk = ( SELECT itemShelvingFk + FROM vn.itemShelvingPlacementSupplyStock + WHERE itemFk = stpp.Id_Article + AND sectorFk = vSectorFk + ORDER BY parking ASC + LIMIT 1) + LEFT JOIN vn.parking p ON p.id = ispss.parkingFk + LEFT JOIN vn.item i ON i.id = stpp.Id_Article WHERE stpp.Id_Ticket = vIdTicket - ORDER BY p.column ASC; + ORDER BY p.pickingOrder, p.column ASC; ELSE SELECT * FROM vn.ticketToPrepare ttp @@ -68401,9 +70079,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 ;; @@ -68413,8 +70091,8 @@ BEGIN /** * Comprueba que los tickets entre un rango de fechas tienen componentes * - * @param vDatedFrom Id del ticket - * @param vIsTicketEditable si no se quiere forzar llamar con NULL + * @param vShippedFrom rango inicial de fecha + * @param vShippedTo rango final de fecha */ DECLARE v_done BOOL DEFAULT FALSE; DECLARE vSaleFk INTEGER; @@ -68427,7 +70105,7 @@ BEGIN 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 t.shipped >= vDatedFrom AND t.shipped <= vDatedTo + WHERE t.shipped >= vShippedFrom AND t.shipped <= vShippedTo AND c.id IS NULL AND clt.isActive != 0 AND ic.merchandise != 0 @@ -68451,7 +70129,7 @@ BEGIN 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 - WHERE t.shipped >= vDatedFrom + WHERE t.shipped >= vShippedFrom AND ic.merchandise != 0; OPEN vCur; @@ -68479,14 +70157,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 ;; CREATE DEFINER=`root`@`%` PROCEDURE `ticket_Clone`(vOriginalTicket INT, OUT vNewTicket INT) BEGIN + + DECLARE vStateFk INT; + INSERT INTO ticket ( clientFk, shipped, @@ -68498,7 +70179,8 @@ BEGIN landed, zoneFk, zonePrice, - zoneBonus + zoneBonus, + routeFk ) SELECT clientFk, @@ -68511,7 +70193,8 @@ BEGIN landed, zoneFk, zonePrice, - zoneBonus + zoneBonus, + routeFk FROM ticket WHERE id = vOriginalTicket; @@ -68522,11 +70205,19 @@ BEGIN FROM addressObservation ao JOIN ticket t ON t.addressFk = ao.addressFk WHERE t.id = vNewTicket; - + INSERT INTO ticketLog SET originFk = vNewTicket, userFk = account.myUser_getId(), `action` = 'insert', description = CONCAT('Ha creado el ticket:', ' ', vNewTicket, ' clonando el ', vOriginalTicket); + INSERT INTO vncontrol.inter(Id_Ticket, state_id, Id_Trabajador, odbc_date) + SELECT vNewTicket, state_id, Id_Trabajador , odbc_date + FROM vncontrol.inter + WHERE Id_Ticket = vOriginalTicket + ORDER BY odbc_date; + + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -69196,8 +70887,10 @@ BEGIN t.id = vTicketFk; IF vHasToBeUnrouted THEN - UPDATE ticket t SET t.routeFk = NULL - WHERE t.id = vTicketFk; + UPDATE ticket t + SET t.routeFk = NULL, + t.shipped = TIMESTAMP(DATE(t.shipped), 0) + WHERE t.id = vTicketFk; END IF; IF vOption <> 8 THEN @@ -69206,7 +70899,9 @@ BEGIN (PRIMARY KEY (saleFk)) ENGINE = MEMORY SELECT id AS saleFk, vWarehouseFk warehouseFk - FROM sale s WHERE s.ticketFk = vTicketFk; + FROM sale s + LEFT JOIN vn.saleCloned sc ON sc.saleClonedFk = s.id + WHERE s.ticketFk = vTicketFk AND sc.saleClonedFk IS NULL; DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent; CREATE TEMPORARY TABLE tmp.ticketComponent @@ -70284,6 +71979,80 @@ proc: BEGIN END IF; INSERT IGNORE INTO ticketRecalc SET ticketFk = 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_splitItemPackingType` */; +/*!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 `ticket_splitItemPackingType`(vTicketFk INT) +BEGIN + + /* + * Clona y reparte las ventas de un ticket en funcion del tipo de empaquetado + * + */ + + DECLARE vNewItemPackingTypeFk VARCHAR(1); + DECLARE vNewTicketFk INT; + DECLARE vCollectionFk INT; + DECLARE vSplittedLines INT; + DECLARE vPickedLines INT; + + SELECT collectionFk INTO vCollectionFk + FROM vn.ticketCollection tc + WHERE tc.ticketFk = vTicketFk + LIMIT 1; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketIPT; + CREATE TEMPORARY TABLE tmp.ticketIPT + SELECT DISTINCT s.ticketFk, i.itemPackingTypeFk + FROM vn.sale s + JOIN vn.item i ON i.id = s.itemFk + WHERE s.ticketFk = vTicketFk; + + WHILE (SELECT count(*) FROM tmp.ticketIPT WHERE ticketFk = vTicketFk ) > 1 DO + + SELECT MIN(itemPackingTypeFk) INTO vNewItemPackingTypeFk + FROM tmp.ticketIPT + WHERE ticketFk = vTicketFk; + + CALL vn.ticket_Clone(vTicketFk, vNewTicketFk); + + UPDATE tmp.ticketIPT + SET ticketFk = vNewTicketFk + WHERE itemPackingTypeFk = vNewItemPackingTypeFk; + + SELECT count(*), sum(isPicked != 0) INTO vSplittedLines, vPickedLines + FROM vn.sale s + JOIN vn.item i ON i.id = s.itemFk + WHERE s.ticketFk = vTicketFk + AND i.itemPackingTypeFk = vNewItemPackingTypeFk; + + UPDATE vn.sale s + JOIN vn.item i ON i.id = s.itemFk + SET s.ticketFk = vNewTicketFk + WHERE s.ticketFk = vTicketFk + AND i.itemPackingTypeFk = vNewItemPackingTypeFk; + + UPDATE vn.collection + SET saleTotalCount = saleTotalCount - vSplittedLines, + salePickedCount = salePickedCount - vPickedLines + WHERE id = vCollectionFk; + + END WHILE; + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -71016,7 +72785,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`z-developer`@`%` PROCEDURE `travelVolume`(vTravelFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `travelVolume`(vTravelFk INT) BEGIN SELECT w1.name AS ORI, @@ -77203,9 +78972,9 @@ DROP TABLE IF EXISTS `inter`; CREATE TABLE `inter` ( `inter_id` int(11) NOT NULL AUTO_INCREMENT, `state_id` tinyint(3) unsigned NOT NULL, - `fallo_id` int(10) unsigned NOT NULL DEFAULT 21, + `fallo_id` int(10) unsigned NOT NULL DEFAULT '21', `nota` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `odbc_date` timestamp NULL DEFAULT current_timestamp(), + `odbc_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `Id_Ticket` int(11) DEFAULT NULL, `Id_Trabajador` int(11) DEFAULT NULL, `Id_Supervisor` int(11) DEFAULT NULL, @@ -77434,7 +79203,7 @@ USE `account`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `accountDovecot` AS select `u`.`name` AS `name`,`u`.`password` AS `password` from (`user` `u` join `account` `a` on(`a`.`id` = `u`.`id`)) where `u`.`active` <> 0 */; +/*!50001 VIEW `accountDovecot` AS select `u`.`name` AS `name`,`u`.`password` AS `password` from (`user` `u` join `account` `a` on((`a`.`id` = `u`.`id`))) where `u`.`active` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -77472,7 +79241,7 @@ USE `account`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `myRole` AS select `r`.`inheritsFrom` AS `id` from (`roleRole` `r` join `user` `u` on(`u`.`role` = `r`.`role`)) where `u`.`id` = `myUser_getId`() */; +/*!50001 VIEW `myRole` AS select `r`.`inheritsFrom` AS `id` from (`roleRole` `r` join `user` `u` on((`u`.`role` = `r`.`role`))) where (`u`.`id` = `myUser_getId`()) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -77491,7 +79260,7 @@ USE `account`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `myUser` AS select `u`.`id` AS `id`,`u`.`name` AS `name`,`u`.`active` AS `active`,`u`.`email` AS `email`,`u`.`nickname` AS `nickname`,`u`.`lang` AS `lang`,`u`.`role` AS `role`,`u`.`recoverPass` AS `recoverPass` from `user` `u` where `u`.`name` = `myUserGetName`() */ +/*!50001 VIEW `myUser` AS select `u`.`id` AS `id`,`u`.`name` AS `name`,`u`.`active` AS `active`,`u`.`email` AS `email`,`u`.`nickname` AS `nickname`,`u`.`lang` AS `lang`,`u`.`role` AS `role`,`u`.`recoverPass` AS `recoverPass` from `user` `u` where (`u`.`name` = `myUserGetName`()) */ /*!50002 WITH CASCADED CHECK OPTION */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -77517,7 +79286,7 @@ USE `bs`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `bajasLaborales` AS select `p`.`firstname` AS `firstname`,`p`.`name` AS `name`,`b`.`business_id` AS `business_id`,max(`ce`.`date`) AS `lastDate`,max(ifnull(`b`.`date_end`,curdate())) AS `endContract`,`cs`.`type` AS `type`,cast(count(0) as decimal(10,0)) AS `dias`,`w`.`userFk` AS `userFk` from (((((`postgresql`.`calendar_employee` `ce` join `postgresql`.`business` `b` on(`b`.`business_id` = `ce`.`business_id`)) join `postgresql`.`profile` `pr` on(`pr`.`profile_id` = `b`.`client_id`)) join `postgresql`.`person` `p` on(`p`.`person_id` = `pr`.`person_id`)) join `postgresql`.`calendar_state` `cs` on(`cs`.`calendar_state_id` = `ce`.`calendar_state_id`)) join `vn`.`worker` `w` on(`w`.`id` = `p`.`id_trabajador`)) where `ce`.`date` >= curdate() + interval -1 year and `cs`.`type` not in ('Vacaciones','Vacaciones 1/2 día','Compensar','Festivo') group by `p`.`firstname`,`p`.`name`,`cs`.`type` having `endContract` >= curdate() */; +/*!50001 VIEW `bajasLaborales` AS select `p`.`firstname` AS `firstname`,`p`.`name` AS `name`,`b`.`business_id` AS `business_id`,max(`ce`.`date`) AS `lastDate`,max(ifnull(`b`.`date_end`,curdate())) AS `endContract`,`cs`.`type` AS `type`,cast(count(0) as decimal(10,0)) AS `dias`,`w`.`userFk` AS `userFk` from (((((`postgresql`.`calendar_employee` `ce` join `postgresql`.`business` `b` on((`b`.`business_id` = `ce`.`business_id`))) join `postgresql`.`profile` `pr` on((`pr`.`profile_id` = `b`.`client_id`))) join `postgresql`.`person` `p` on((`p`.`person_id` = `pr`.`person_id`))) join `postgresql`.`calendar_state` `cs` on((`cs`.`calendar_state_id` = `ce`.`calendar_state_id`))) join `vn`.`worker` `w` on((`w`.`id` = `p`.`id_trabajador`))) where ((`ce`.`date` >= (curdate() + interval -(1) year)) and (`cs`.`type` not in ('Vacaciones','Vacaciones 1/2 día','Compensar','Festivo'))) group by `p`.`firstname`,`p`.`name`,`cs`.`type` having (`endContract` >= curdate()) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -77536,7 +79305,7 @@ USE `bs`; /*!50001 SET collation_connection = utf8_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 */; @@ -77555,7 +79324,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 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 */; @@ -77574,7 +79343,7 @@ USE `bs`; /*!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 `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 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -77669,7 +79438,7 @@ USE `bs`; /*!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` <> 0 or `c`.`id` in (200,400)) */; +/*!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 */; @@ -77688,7 +79457,7 @@ USE `bs`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `v_ventas__` AS select `bs`.`ventas`.`importe` * `Movimientos`.`Cantidad` AS `importe`,`bs`.`ventas`.`recargo` AS `recargo`,`time`.`year` AS `year`,`time`.`month` AS `month`,`time`.`week` AS `week`,`time`.`day` AS `day` from ((`bs`.`ventas` join `vn2008`.`time` on(`time`.`date` = `bs`.`ventas`.`fecha`)) join `vn2008`.`Movimientos` on(`bs`.`ventas`.`Id_Movimiento` = `Movimientos`.`Id_Movimiento`)) group by `time`.`date` */; +/*!50001 VIEW `v_ventas__` AS select (`bs`.`ventas`.`importe` * `Movimientos`.`Cantidad`) AS `importe`,`bs`.`ventas`.`recargo` AS `recargo`,`time`.`year` AS `year`,`time`.`month` AS `month`,`time`.`week` AS `week`,`time`.`day` AS `day` from ((`bs`.`ventas` join `vn2008`.`time` on((`time`.`date` = `bs`.`ventas`.`fecha`))) join `vn2008`.`Movimientos` on((`bs`.`ventas`.`Id_Movimiento` = `Movimientos`.`Id_Movimiento`))) group by `time`.`date` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -77744,7 +79513,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `mainAccountBank` AS select `e`.`name` AS `name`,`a`.`iban` AS `iban` from ((`hedera`.`mainAccount` `c` join `vn`.`supplierAccount` `a` on(`a`.`id` = `c`.`accountFk`)) join `vn`.`bankEntity` `e` on(`e`.`id` = `a`.`bankEntityFk`)) */; +/*!50001 VIEW `mainAccountBank` AS select `e`.`name` AS `name`,`a`.`iban` AS `iban` from ((`hedera`.`mainAccount` `c` join `vn`.`supplierAccount` `a` on((`a`.`id` = `c`.`accountFk`))) join `vn`.`bankEntity` `e` on((`e`.`id` = `a`.`bankEntityFk`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -77763,7 +79532,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `myAddress` AS select `t`.`id` AS `id`,`t`.`clientFk` AS `clientFk`,`t`.`street` AS `street`,`t`.`city` AS `city`,`t`.`postalCode` AS `postalCode`,`t`.`provinceFk` AS `provinceFk`,`t`.`nickname` AS `nickname`,`t`.`isDefaultAddress` AS `isDefaultAddress`,`t`.`isActive` AS `isActive`,`t`.`longitude` AS `longitude`,`t`.`latitude` AS `latitude`,`t`.`warehouseFk` AS `warehouseFk`,`t`.`agencyModeFk` AS `agencyModeFk` from `vn`.`address` `t` where `t`.`clientFk` = `account`.`myUser_getId`() */ +/*!50001 VIEW `myAddress` AS select `t`.`id` AS `id`,`t`.`clientFk` AS `clientFk`,`t`.`street` AS `street`,`t`.`city` AS `city`,`t`.`postalCode` AS `postalCode`,`t`.`provinceFk` AS `provinceFk`,`t`.`nickname` AS `nickname`,`t`.`isDefaultAddress` AS `isDefaultAddress`,`t`.`isActive` AS `isActive`,`t`.`longitude` AS `longitude`,`t`.`latitude` AS `latitude`,`t`.`warehouseFk` AS `warehouseFk`,`t`.`agencyModeFk` AS `agencyModeFk` from `vn`.`address` `t` where (`t`.`clientFk` = `account`.`myUser_getId`()) */ /*!50002 WITH CASCADED CHECK OPTION */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -77783,7 +79552,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `myBasket` AS select `o`.`id` AS `id`,`o`.`date_make` AS `made`,`o`.`date_send` AS `sent`,`o`.`customer_id` AS `clientFk`,`o`.`delivery_method_id` AS `deliveryMethodFk`,`o`.`agency_id` AS `agencyModeFk`,`o`.`address_id` AS `addressFk`,`o`.`company_id` AS `companyFk`,`o`.`note` AS `notes` from `hedera`.`order` `o` where `o`.`id` = `MYBASKET_GETID`() */ +/*!50001 VIEW `myBasket` AS select `o`.`id` AS `id`,`o`.`date_make` AS `made`,`o`.`date_send` AS `sent`,`o`.`customer_id` AS `clientFk`,`o`.`delivery_method_id` AS `deliveryMethodFk`,`o`.`agency_id` AS `agencyModeFk`,`o`.`address_id` AS `addressFk`,`o`.`company_id` AS `companyFk`,`o`.`note` AS `notes` from `hedera`.`order` `o` where (`o`.`id` = `MYBASKET_GETID`()) */ /*!50002 WITH CASCADED CHECK OPTION */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -77803,7 +79572,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `myBasketDefaults` AS select coalesce(`dm`.`code`,`cm`.`code`) AS `deliveryMethod`,coalesce(`ad`.`agencyModeFk`,`oc`.`defaultAgencyFk`) AS `agencyModeFk`,`c`.`defaultAddressFk` AS `addressFk`,`oc`.`defaultAgencyFk` AS `defaultAgencyFk` from ((((((`hedera`.`orderConfig` `oc` join `vn`.`agencyMode` `ca` on(`ca`.`id` = `oc`.`defaultAgencyFk`)) join `vn`.`deliveryMethod` `cm` on(`cm`.`id` = `ca`.`deliveryMethodFk`)) left join `vn`.`client` `c` on(`c`.`id` = `account`.`myUser_getId`())) left join `vn`.`address` `ad` on(`ad`.`id` = `c`.`defaultAddressFk`)) left join `vn`.`agencyMode` `a` on(`a`.`id` = `ad`.`agencyModeFk`)) left join `vn`.`deliveryMethod` `dm` on(`dm`.`id` = `a`.`deliveryMethodFk`)) */; +/*!50001 VIEW `myBasketDefaults` AS select coalesce(`dm`.`code`,`cm`.`code`) AS `deliveryMethod`,coalesce(`ad`.`agencyModeFk`,`oc`.`defaultAgencyFk`) AS `agencyModeFk`,`c`.`defaultAddressFk` AS `addressFk`,`oc`.`defaultAgencyFk` AS `defaultAgencyFk` from ((((((`hedera`.`orderConfig` `oc` join `vn`.`agencyMode` `ca` on((`ca`.`id` = `oc`.`defaultAgencyFk`))) join `vn`.`deliveryMethod` `cm` on((`cm`.`id` = `ca`.`deliveryMethodFk`))) left join `vn`.`client` `c` on((`c`.`id` = `account`.`myUser_getId`()))) left join `vn`.`address` `ad` on((`ad`.`id` = `c`.`defaultAddressFk`))) left join `vn`.`agencyMode` `a` on((`a`.`id` = `ad`.`agencyModeFk`))) left join `vn`.`deliveryMethod` `dm` on((`dm`.`id` = `a`.`deliveryMethodFk`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -77822,7 +79591,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `myBasketItem` AS select `r`.`id` AS `id`,`r`.`orderFk` AS `orderFk`,`r`.`warehouseFk` AS `warehouseFk`,`r`.`itemFk` AS `itemFk`,`r`.`amount` AS `amount`,`r`.`price` AS `price` from `hedera`.`orderRow` `r` where `r`.`orderFk` = `MYBASKET_GETID`() */ +/*!50001 VIEW `myBasketItem` AS select `r`.`id` AS `id`,`r`.`orderFk` AS `orderFk`,`r`.`warehouseFk` AS `warehouseFk`,`r`.`itemFk` AS `itemFk`,`r`.`amount` AS `amount`,`r`.`price` AS `price` from `hedera`.`orderRow` `r` where (`r`.`orderFk` = `MYBASKET_GETID`()) */ /*!50002 WITH CASCADED CHECK OPTION */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -77842,7 +79611,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `myClient` AS select `c`.`id` AS `id`,`c`.`isToBeMailed` AS `isToBeMailed`,`c`.`defaultAddressFk` AS `defaultAddressFk`,`c`.`credit` AS `credit` from `vn`.`client` `c` where `c`.`id` = `account`.`myUser_getId`() */ +/*!50001 VIEW `myClient` AS select `c`.`id` AS `id`,`c`.`isToBeMailed` AS `isToBeMailed`,`c`.`defaultAddressFk` AS `defaultAddressFk`,`c`.`credit` AS `credit` from `vn`.`client` `c` where (`c`.`id` = `account`.`myUser_getId`()) */ /*!50002 WITH CASCADED CHECK OPTION */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -77862,7 +79631,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `myInvoice` AS select `i`.`id` AS `id`,`i`.`ref` AS `ref`,`i`.`issued` AS `issued`,`i`.`amount` AS `amount`,`i`.`hasPdf` AS `hasPdf` from `vn`.`invoiceOut` `i` where `i`.`clientFk` = `account`.`myUser_getId`() */; +/*!50001 VIEW `myInvoice` AS select `i`.`id` AS `id`,`i`.`ref` AS `ref`,`i`.`issued` AS `issued`,`i`.`amount` AS `amount`,`i`.`hasPdf` AS `hasPdf` from `vn`.`invoiceOut` `i` where (`i`.`clientFk` = `account`.`myUser_getId`()) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -77881,7 +79650,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `myMenu` AS select `t`.`id` AS `id`,`t`.`path` AS `path`,`t`.`description` AS `description`,`t`.`parentFk` AS `parentFk` from (`hedera`.`menu` `t` join `account`.`myRole` `r` on(`r`.`id` = `t`.`roleFk`)) order by `t`.`parentFk`,`t`.`displayOrder`,`t`.`id` */; +/*!50001 VIEW `myMenu` AS select `t`.`id` AS `id`,`t`.`path` AS `path`,`t`.`description` AS `description`,`t`.`parentFk` AS `parentFk` from (`hedera`.`menu` `t` join `account`.`myRole` `r` on((`r`.`id` = `t`.`roleFk`))) order by `t`.`parentFk`,`t`.`displayOrder`,`t`.`id` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -77900,7 +79669,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `myOrder` AS select `o`.`id` AS `id`,`o`.`date_send` AS `landed`,`o`.`customer_id` AS `clientFk`,`o`.`delivery_method_id` AS `deliveryMethodFk`,`o`.`agency_id` AS `agencyModeFk`,`o`.`address_id` AS `addressFk`,`o`.`company_id` AS `companyFk`,`o`.`note` AS `note`,`o`.`source_app` AS `sourceApp`,`o`.`confirmed` AS `isConfirmed`,`o`.`date_make` AS `created`,`o`.`first_row_stamp` AS `firstRowStamp`,`o`.`confirm_date` AS `confirmed` from `hedera`.`order` `o` where `o`.`customer_id` = `account`.`myUser_getId`() */; +/*!50001 VIEW `myOrder` AS select `o`.`id` AS `id`,`o`.`date_send` AS `landed`,`o`.`customer_id` AS `clientFk`,`o`.`delivery_method_id` AS `deliveryMethodFk`,`o`.`agency_id` AS `agencyModeFk`,`o`.`address_id` AS `addressFk`,`o`.`company_id` AS `companyFk`,`o`.`note` AS `note`,`o`.`source_app` AS `sourceApp`,`o`.`confirmed` AS `isConfirmed`,`o`.`date_make` AS `created`,`o`.`first_row_stamp` AS `firstRowStamp`,`o`.`confirm_date` AS `confirmed` from `hedera`.`order` `o` where (`o`.`customer_id` = `account`.`myUser_getId`()) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -77919,7 +79688,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `myOrderRow` AS select `orw`.`id` AS `id`,`orw`.`order_id` AS `Fk`,`orw`.`item_id` AS `itemFk`,`orw`.`warehouse_id` AS `warehouseFk`,`orw`.`shipment` AS `shipped`,`orw`.`amount` AS `amount`,`orw`.`price` AS `price`,`orw`.`rate` AS `rate`,`orw`.`created` AS `created`,`orw`.`Id_Movimiento` AS `saleFk` from (`hedera`.`order_row` `orw` join `hedera`.`myOrder` `o` on(`o`.`id` = `orw`.`order_id`)) */ +/*!50001 VIEW `myOrderRow` AS select `orw`.`id` AS `id`,`orw`.`order_id` AS `Fk`,`orw`.`item_id` AS `itemFk`,`orw`.`warehouse_id` AS `warehouseFk`,`orw`.`shipment` AS `shipped`,`orw`.`amount` AS `amount`,`orw`.`price` AS `price`,`orw`.`rate` AS `rate`,`orw`.`created` AS `created`,`orw`.`Id_Movimiento` AS `saleFk` from (`hedera`.`order_row` `orw` join `hedera`.`myOrder` `o` on((`o`.`id` = `orw`.`order_id`))) */ /*!50002 WITH CASCADED CHECK OPTION */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -77939,7 +79708,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `myOrderTicket` AS select `o`.`id` AS `orderFk`,`ot`.`ticketFk` AS `ticketFk` from (`hedera`.`myOrder` `o` join `hedera`.`orderTicket` `ot` on(`ot`.`orderFk` = `o`.`id`)) */; +/*!50001 VIEW `myOrderTicket` AS select `o`.`id` AS `orderFk`,`ot`.`ticketFk` AS `ticketFk` from (`hedera`.`myOrder` `o` join `hedera`.`orderTicket` `ot` on((`ot`.`orderFk` = `o`.`id`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -77958,7 +79727,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `myTicket` AS select `t`.`id` AS `id`,`t`.`clientFk` AS `clientFk`,`t`.`warehouseFk` AS `warehouseFk`,`t`.`shipped` AS `shipped`,`t`.`landed` AS `landed`,`t`.`nickname` AS `nickname`,`t`.`agencyModeFk` AS `agencyModeFk`,`t`.`refFk` AS `refFk`,`t`.`addressFk` AS `addressFk`,`t`.`location` AS `location`,`t`.`companyFk` AS `companyFk` from `vn`.`ticket` `t` where `t`.`clientFk` = `account`.`myUser_getId`() */; +/*!50001 VIEW `myTicket` AS select `t`.`id` AS `id`,`t`.`clientFk` AS `clientFk`,`t`.`warehouseFk` AS `warehouseFk`,`t`.`shipped` AS `shipped`,`t`.`landed` AS `landed`,`t`.`nickname` AS `nickname`,`t`.`agencyModeFk` AS `agencyModeFk`,`t`.`refFk` AS `refFk`,`t`.`addressFk` AS `addressFk`,`t`.`location` AS `location`,`t`.`companyFk` AS `companyFk` from `vn`.`ticket` `t` where (`t`.`clientFk` = `account`.`myUser_getId`()) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -77977,7 +79746,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `myTicketRow` AS select `s`.`id` AS `id`,`s`.`itemFk` AS `itemFk`,`s`.`ticketFk` AS `ticketFk`,`s`.`concept` AS `concept`,`s`.`quantity` AS `quantity`,`s`.`price` AS `price`,`s`.`discount` AS `discount`,`s`.`reserved` AS `reserved`,`s`.`isPicked` AS `isPicked` from (`vn`.`sale` `s` join `hedera`.`myTicket` `t` on(`s`.`ticketFk` = `t`.`id`)) */ +/*!50001 VIEW `myTicketRow` AS select `s`.`id` AS `id`,`s`.`itemFk` AS `itemFk`,`s`.`ticketFk` AS `ticketFk`,`s`.`concept` AS `concept`,`s`.`quantity` AS `quantity`,`s`.`price` AS `price`,`s`.`discount` AS `discount`,`s`.`reserved` AS `reserved`,`s`.`isPicked` AS `isPicked` from (`vn`.`sale` `s` join `hedera`.`myTicket` `t` on((`s`.`ticketFk` = `t`.`id`))) */ /*!50002 WITH CASCADED CHECK OPTION */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -77997,7 +79766,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `myTicketService` AS select `s`.`id` AS `id`,`s`.`description` AS `description`,`s`.`quantity` AS `quantity`,`s`.`price` AS `price`,`s`.`taxClassFk` AS `taxClassFk`,`s`.`ticketFk` AS `ticketFk`,`s`.`ticketServiceTypeFk` AS `ticketServiceTypeFk` from (`vn`.`ticketService` `s` join `hedera`.`myTicket` `t` on(`s`.`ticketFk` = `t`.`id`)) */ +/*!50001 VIEW `myTicketService` AS select `s`.`id` AS `id`,`s`.`description` AS `description`,`s`.`quantity` AS `quantity`,`s`.`price` AS `price`,`s`.`taxClassFk` AS `taxClassFk`,`s`.`ticketFk` AS `ticketFk`,`s`.`ticketServiceTypeFk` AS `ticketServiceTypeFk` from (`vn`.`ticketService` `s` join `hedera`.`myTicket` `t` on((`s`.`ticketFk` = `t`.`id`))) */ /*!50002 WITH CASCADED CHECK OPTION */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -78017,7 +79786,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `myTicketState` AS select `t`.`id` AS `id`,`t`.`clientFk` AS `clientFk`,`t`.`warehouseFk` AS `warehouseFk`,`t`.`shipped` AS `shipped`,`t`.`landed` AS `landed`,`t`.`nickname` AS `nickname`,`t`.`agencyModeFk` AS `agencyModeFk`,`t`.`refFk` AS `refFk`,`t`.`addressFk` AS `addressFk`,`t`.`location` AS `location`,`t`.`companyFk` AS `companyFk`,`ts`.`alertLevel` AS `alertLevel`,`ts`.`code` AS `code` from (`vn`.`ticket` `t` left join `vn`.`ticketState` `ts` on(`ts`.`ticketFk` = `t`.`id`)) where `t`.`clientFk` = `account`.`myUser_getId`() */; +/*!50001 VIEW `myTicketState` AS select `t`.`id` AS `id`,`t`.`clientFk` AS `clientFk`,`t`.`warehouseFk` AS `warehouseFk`,`t`.`shipped` AS `shipped`,`t`.`landed` AS `landed`,`t`.`nickname` AS `nickname`,`t`.`agencyModeFk` AS `agencyModeFk`,`t`.`refFk` AS `refFk`,`t`.`addressFk` AS `addressFk`,`t`.`location` AS `location`,`t`.`companyFk` AS `companyFk`,`ts`.`alertLevel` AS `alertLevel`,`ts`.`code` AS `code` from (`vn`.`ticket` `t` left join `vn`.`ticketState` `ts` on((`ts`.`ticketFk` = `t`.`id`))) where (`t`.`clientFk` = `account`.`myUser_getId`()) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78036,7 +79805,7 @@ USE `hedera`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `myTpvTransaction` AS select `t`.`id` AS `id`,`t`.`merchantFk` AS `merchantFk`,`t`.`clientFk` AS `clientFk`,`t`.`receiptFk` AS `receiptFk`,`t`.`amount` AS `amount`,`t`.`response` AS `response`,`t`.`status` AS `status`,`t`.`created` AS `created` from `hedera`.`tpvTransaction` `t` where `t`.`clientFk` = `account`.`myUser_getId`() */; +/*!50001 VIEW `myTpvTransaction` AS select `t`.`id` AS `id`,`t`.`merchantFk` AS `merchantFk`,`t`.`clientFk` AS `clientFk`,`t`.`receiptFk` AS `receiptFk`,`t`.`amount` AS `amount`,`t`.`response` AS `response`,`t`.`status` AS `status`,`t`.`created` AS `created` from `hedera`.`tpvTransaction` `t` where (`t`.`clientFk` = `account`.`myUser_getId`()) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78181,7 +79950,7 @@ USE `pbx`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `queueConf` AS select `q`.`name` AS `name`,`c`.`strategy` AS `strategy`,`c`.`timeout` AS `timeout`,`c`.`retry` AS `retry`,`c`.`weight` AS `weight`,`c`.`maxLen` AS `maxlen`,`c`.`ringInUse` AS `ringinuse` from (`queue` `q` join `queueConfig` `c` on(`q`.`config` = `c`.`id`)) */; +/*!50001 VIEW `queueConf` AS select `q`.`name` AS `name`,`c`.`strategy` AS `strategy`,`c`.`timeout` AS `timeout`,`c`.`retry` AS `retry`,`c`.`weight` AS `weight`,`c`.`maxLen` AS `maxlen`,`c`.`ringInUse` AS `ringinuse` from (`queue` `q` join `queueConfig` `c` on((`q`.`config` = `c`.`id`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78219,7 +79988,7 @@ USE `pbx`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `sipConf` AS select `s`.`user_id` AS `id`,`s`.`extension` AS `name`,NULL AS `callbackextension`,`s`.`md5Secret` AS `md5secret`,`u`.`nickname` AS `callerid`,`c`.`host` AS `host`,`c`.`deny` AS `deny`,`c`.`permit` AS `permit`,`c`.`type` AS `type`,`c`.`context` AS `context`,`c`.`incomingLimit` AS `incominglimit`,`c`.`pickupGroup` AS `pickupgroup`,`c`.`careInvite` AS `careinvite`,`c`.`insecure` AS `insecure`,`c`.`transport` AS `transport`,`c`.`nat` AS `nat`,`r`.`ipAddr` AS `ipaddr`,`r`.`regSeconds` AS `regseconds`,`r`.`port` AS `port`,`r`.`defaultUser` AS `defaultuser`,`r`.`userAgent` AS `useragent`,`r`.`lastMs` AS `lastms`,`r`.`fullContact` AS `fullcontact`,`r`.`regServer` AS `regserver` from (((`pbx`.`sip` `s` join `account`.`user` `u` on(`u`.`id` = `s`.`user_id`)) left join `pbx`.`sipReg` `r` on(`s`.`user_id` = `r`.`userId`)) join `pbx`.`sipConfig` `c`) */; +/*!50001 VIEW `sipConf` AS select `s`.`user_id` AS `id`,`s`.`extension` AS `name`,NULL AS `callbackextension`,`s`.`md5Secret` AS `md5secret`,`u`.`nickname` AS `callerid`,`c`.`host` AS `host`,`c`.`deny` AS `deny`,`c`.`permit` AS `permit`,`c`.`type` AS `type`,`c`.`context` AS `context`,`c`.`incomingLimit` AS `incominglimit`,`c`.`pickupGroup` AS `pickupgroup`,`c`.`careInvite` AS `careinvite`,`c`.`insecure` AS `insecure`,`c`.`transport` AS `transport`,`c`.`nat` AS `nat`,`r`.`ipAddr` AS `ipaddr`,`r`.`regSeconds` AS `regseconds`,`r`.`port` AS `port`,`r`.`defaultUser` AS `defaultuser`,`r`.`userAgent` AS `useragent`,`r`.`lastMs` AS `lastms`,`r`.`fullContact` AS `fullcontact`,`r`.`regServer` AS `regserver` from (((`pbx`.`sip` `s` join `account`.`user` `u` on((`u`.`id` = `s`.`user_id`))) left join `pbx`.`sipReg` `r` on((`s`.`user_id` = `r`.`userId`))) join `pbx`.`sipConfig` `c`) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78269,7 +80038,7 @@ USE `sage`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `invoiceInList` AS select `vn`.`invoiceIn`.`id` AS `id`,`vn`.`invoiceIn`.`supplierRef` AS `supplierRef`,`vn`.`invoiceIn`.`serial` AS `serial`,`vn`.`invoiceIn`.`supplierFk` AS `supplierFk`,`vn`.`invoiceIn`.`issued` AS `issued`,`vn`.`invoiceIn`.`isVatDeductible` AS `isVatDeductible`,`vn`.`invoiceIn`.`serialNumber` AS `serialNumber` from `vn`.`invoiceIn` where `vn`.`invoiceIn`.`issued` >= date_format(curdate(),'%Y-01-01') + interval -1 year union all select `vn`.`dua`.`id` AS `id`,`vn`.`dua`.`code` AS `code`,'D' AS `D`,442 AS `442`,`vn`.`dua`.`issued` AS `issued`,0 AS `FALSE`,`vn`.`dua`.`id` AS `serialNumber` from `vn`.`dua` */; +/*!50001 VIEW `invoiceInList` AS select `vn`.`invoiceIn`.`id` AS `id`,`vn`.`invoiceIn`.`supplierRef` AS `supplierRef`,`vn`.`invoiceIn`.`serial` AS `serial`,`vn`.`invoiceIn`.`supplierFk` AS `supplierFk`,`vn`.`invoiceIn`.`issued` AS `issued`,`vn`.`invoiceIn`.`isVatDeductible` AS `isVatDeductible`,`vn`.`invoiceIn`.`serialNumber` AS `serialNumber` from `vn`.`invoiceIn` where (`vn`.`invoiceIn`.`issued` >= (date_format(curdate(),'%Y-01-01') + interval -(1) year)) union all select `vn`.`dua`.`id` AS `id`,`vn`.`dua`.`code` AS `code`,'D' AS `D`,442 AS `442`,`vn`.`dua`.`issued` AS `issued`,0 AS `FALSE`,`vn`.`dua`.`id` AS `serialNumber` from `vn`.`dua` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78332,7 +80101,7 @@ USE `salix`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `RoleMapping` AS select `u`.`id` * 1000 + `r`.`inheritsFrom` AS `id`,'USER' AS `principalType`,`u`.`id` AS `principalId`,`r`.`inheritsFrom` AS `roleId` from (`account`.`user` `u` join `account`.`roleRole` `r` on(`r`.`role` = `u`.`role`)) */; +/*!50001 VIEW `RoleMapping` AS select ((`u`.`id` * 1000) + `r`.`inheritsFrom`) AS `id`,'USER' AS `principalType`,`u`.`id` AS `principalId`,`r`.`inheritsFrom` AS `roleId` from (`account`.`user` `u` join `account`.`roleRole` `r` on((`r`.`role` = `u`.`role`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78521,7 +80290,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `buyer` AS select distinct `u`.`id` AS `userFk`,`u`.`nickname` AS `nickname` from (`account`.`user` `u` join `vn`.`itemType` `it` on(`it`.`workerFk` = `u`.`id`)) where `u`.`active` <> 0 order by `u`.`nickname` */; +/*!50001 VIEW `buyer` AS select distinct `u`.`id` AS `userFk`,`u`.`nickname` AS `nickname` from (`account`.`user` `u` join `vn`.`itemType` `it` on((`it`.`workerFk` = `u`.`id`))) where `u`.`active` order by `u`.`nickname` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78540,7 +80309,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `buyerSales` AS select `v`.`importe` AS `importe`,`w`.`code` AS `comprador`,`t`.`year` AS `año`,`t`.`week` AS `semana` from (((`bs`.`ventas` `v` join `vn`.`time` `t` on(`t`.`dated` = `v`.`fecha`)) join `vn`.`itemType` `it` on(`it`.`id` = `v`.`tipo_id`)) join `vn`.`worker` `w` on(`w`.`id` = `it`.`workerFk`)) */; +/*!50001 VIEW `buyerSales` AS select `v`.`importe` AS `importe`,`w`.`code` AS `comprador`,`t`.`year` AS `año`,`t`.`week` AS `semana` from (((`bs`.`ventas` `v` join `vn`.`time` `t` on((`t`.`dated` = `v`.`fecha`))) join `vn`.`itemType` `it` on((`it`.`id` = `v`.`tipo_id`))) join `vn`.`worker` `w` on((`w`.`id` = `it`.`workerFk`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78635,7 +80404,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `cmr_list` AS select `cmr`.`id` AS `cmrFk`,`cmr`.`ticketFk` AS `ticketFk`,`cmr`.`truckPlate` AS `truckPlate`,`cmr`.`observations` AS `observations`,`cmr`.`senderInstruccions` AS `senderInstruccions`,`cmr`.`paymentInstruccions` AS `paymentInstruccions`,`cmr`.`specialAgreements` AS `specialAgreements`,`cmr`.`created` AS `created`,`cmr`.`packagesList` AS `packagesList`,`aTo`.`nickname` AS `clientName`,`aTo`.`postalCode` AS `clientPostalCode`,`aTo`.`street` AS `clientStreet`,`aTo`.`city` AS `clientCity`,`pTo`.`name` AS `clientProvince`,`cTo`.`country` AS `clientCountry`,`su`.`name` AS `companyName`,`su`.`street` AS `companyStreet`,`su`.`postCode` AS `companyPostCode`,`su`.`city` AS `companyCity`,`cSu`.`country` AS `companyCountry`,concat(`aFrom`.`street`,' ',`aFrom`.`postalCode`,' ',`aFrom`.`city`,' (',`cFrom`.`country`,')') AS `warehouseAddress`,`cmr`.`created` AS `shipped`,`aTo`.`nickname` AS `clientOficialName`,`cmr`.`supplierFk` AS `supplierFk`,`aSu`.`name` AS `carrierName`,`aSu`.`street` AS `carrierStreet`,`aSu`.`postCode` AS `carrierPostCode`,`aSu`.`city` AS `carrierCity`,`cAs`.`country` AS `carrierCountry`,ifnull(`aTo`.`phone`,`client`.`phone`) AS `phone`,ifnull(`aTo`.`mobile`,`client`.`mobile`) AS `mobile`,`aTo`.`id` AS `addressFk` from (((((((((((`cmr` left join `address` `aTo` on(`aTo`.`id` = `cmr`.`addressToFk`)) left join `province` `pTo` on(`pTo`.`id` = `aTo`.`provinceFk`)) left join `country` `cTo` on(`cTo`.`id` = `pTo`.`countryFk`)) left join `client` on(`client`.`id` = `aTo`.`clientFk`)) left join `supplier` `su` on(`su`.`id` = `cmr`.`companyFk`)) left join `country` `cSu` on(`cSu`.`id` = `su`.`countryFk`)) left join `address` `aFrom` on(`aFrom`.`id` = `cmr`.`addressFromFk`)) left join `province` `pFrom` on(`pFrom`.`id` = `aFrom`.`provinceFk`)) left join `country` `cFrom` on(`cFrom`.`id` = `pFrom`.`countryFk`)) left join `supplier` `aSu` on(`aSu`.`id` = `cmr`.`supplierFk`)) left join `country` `cAs` on(`cAs`.`id` = `aSu`.`countryFk`)) */; +/*!50001 VIEW `cmr_list` AS select `cmr`.`id` AS `cmrFk`,`cmr`.`ticketFk` AS `ticketFk`,`cmr`.`truckPlate` AS `truckPlate`,`cmr`.`observations` AS `observations`,`cmr`.`senderInstruccions` AS `senderInstruccions`,`cmr`.`paymentInstruccions` AS `paymentInstruccions`,`cmr`.`specialAgreements` AS `specialAgreements`,`cmr`.`created` AS `created`,`cmr`.`packagesList` AS `packagesList`,`aTo`.`nickname` AS `clientName`,`aTo`.`postalCode` AS `clientPostalCode`,`aTo`.`street` AS `clientStreet`,`aTo`.`city` AS `clientCity`,`pTo`.`name` AS `clientProvince`,`cTo`.`country` AS `clientCountry`,`su`.`name` AS `companyName`,`su`.`street` AS `companyStreet`,`su`.`postCode` AS `companyPostCode`,`su`.`city` AS `companyCity`,`cSu`.`country` AS `companyCountry`,concat(`aFrom`.`street`,' ',`aFrom`.`postalCode`,' ',`aFrom`.`city`,' (',`cFrom`.`country`,')') AS `warehouseAddress`,`cmr`.`created` AS `shipped`,`aTo`.`nickname` AS `clientOficialName`,`cmr`.`supplierFk` AS `supplierFk`,`aSu`.`name` AS `carrierName`,`aSu`.`street` AS `carrierStreet`,`aSu`.`postCode` AS `carrierPostCode`,`aSu`.`city` AS `carrierCity`,`cAs`.`country` AS `carrierCountry`,ifnull(`aTo`.`phone`,`client`.`phone`) AS `phone`,ifnull(`aTo`.`mobile`,`client`.`mobile`) AS `mobile`,`aTo`.`id` AS `addressFk` from (((((((((((`cmr` left join `address` `aTo` on((`aTo`.`id` = `cmr`.`addressToFk`))) left join `province` `pTo` on((`pTo`.`id` = `aTo`.`provinceFk`))) left join `country` `cTo` on((`cTo`.`id` = `pTo`.`countryFk`))) left join `client` on((`client`.`id` = `aTo`.`clientFk`))) left join `supplier` `su` on((`su`.`id` = `cmr`.`companyFk`))) left join `country` `cSu` on((`cSu`.`id` = `su`.`countryFk`))) left join `address` `aFrom` on((`aFrom`.`id` = `cmr`.`addressFromFk`))) left join `province` `pFrom` on((`pFrom`.`id` = `aFrom`.`provinceFk`))) left join `country` `cFrom` on((`cFrom`.`id` = `pFrom`.`countryFk`))) left join `supplier` `aSu` on((`aSu`.`id` = `cmr`.`supplierFk`))) left join `country` `cAs` on((`cAs`.`id` = `aSu`.`countryFk`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78654,7 +80423,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `collectionReportSource` AS select `tc`.`collectionFk` AS `collectionFk`,`tc`.`ticketFk` AS `ticketFk`,`s`.`itemFk` AS `itemFk`,`s`.`concept` AS `concept`,`i`.`size` AS `size`,`s`.`quantity` AS `quantity`,`ip`.`code` AS `nicho`,`tc`.`level` AS `level` from (((((`collection` `c` join `ticketCollection` `tc` on(`tc`.`collectionFk` = `c`.`id`)) join `ticket` `t` on(`t`.`id` = `tc`.`ticketFk`)) join `sale` `s` on(`s`.`ticketFk` = `t`.`id`)) join `item` `i` on(`i`.`id` = `s`.`itemFk`)) left join `itemPlacement` `ip` on(`ip`.`itemFk` = `s`.`itemFk` and `ip`.`warehouseFk` = `t`.`warehouseFk`)) */; +/*!50001 VIEW `collectionReportSource` AS select `tc`.`collectionFk` AS `collectionFk`,`tc`.`ticketFk` AS `ticketFk`,`s`.`itemFk` AS `itemFk`,`s`.`concept` AS `concept`,`i`.`size` AS `size`,`s`.`quantity` AS `quantity`,`ip`.`code` AS `nicho`,`tc`.`level` AS `level` from (((((`collection` `c` join `ticketCollection` `tc` on((`tc`.`collectionFk` = `c`.`id`))) join `ticket` `t` on((`t`.`id` = `tc`.`ticketFk`))) join `sale` `s` on((`s`.`ticketFk` = `t`.`id`))) join `item` `i` on((`i`.`id` = `s`.`itemFk`))) left join `itemPlacement` `ip` on(((`ip`.`itemFk` = `s`.`itemFk`) and (`ip`.`warehouseFk` = `t`.`warehouseFk`)))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78768,7 +80537,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `departmentTree` AS select `node`.`id` AS `id`,concat(repeat(repeat(' ',5),count(`parent`.`id`) - 1),`node`.`name`) AS `dep` from (`department` `node` join `department` `parent`) where `node`.`lft` between `parent`.`lft` and `parent`.`rgt` group by `node`.`id` order by `node`.`lft` */; +/*!50001 VIEW `departmentTree` AS select `node`.`id` AS `id`,concat(repeat(repeat(' ',5),(count(`parent`.`id`) - 1)),`node`.`name`) AS `dep` from (`department` `node` join `department` `parent`) where (`node`.`lft` between `parent`.`lft` and `parent`.`rgt`) group by `node`.`id` order by `node`.`lft` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78825,7 +80594,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 3 day)),`tr`.`landed` desc,`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 */; @@ -78844,7 +80613,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `exchangeInsuranceEntry` AS select max(`tr`.`landed`) AS `dated`,cast(sum((`b`.`buyingValue` + `b`.`freightValue`) * `b`.`quantity`) as decimal(10,2)) AS `Dolares`,cast(sum((`b`.`buyingValue` + `b`.`freightValue`) * `b`.`quantity`) / sum((100 + `e`.`commission`) / 100 * (`b`.`buyingValue` + `b`.`freightValue`) * `b`.`quantity`) as decimal(10,4)) AS `rate` from ((`entry` `e` join `buy` `b` on(`e`.`id` = `b`.`entryFk`)) join `travel` `tr` on(`tr`.`id` = `e`.`travelFk`)) where `tr`.`landed` between '2016-01-31' and curdate() and `e`.`commission` < 0 and `e`.`currencyFk` = 2 group by month(`tr`.`landed`),year(`tr`.`landed`) */; +/*!50001 VIEW `exchangeInsuranceEntry` AS select max(`tr`.`landed`) AS `dated`,cast(sum(((`b`.`buyingValue` + `b`.`freightValue`) * `b`.`quantity`)) as decimal(10,2)) AS `Dolares`,cast((sum(((`b`.`buyingValue` + `b`.`freightValue`) * `b`.`quantity`)) / sum(((((100 + `e`.`commission`) / 100) * (`b`.`buyingValue` + `b`.`freightValue`)) * `b`.`quantity`))) as decimal(10,4)) AS `rate` from ((`entry` `e` join `buy` `b` on((`e`.`id` = `b`.`entryFk`))) join `travel` `tr` on((`tr`.`id` = `e`.`travelFk`))) where ((`tr`.`landed` between '2016-01-31' and curdate()) and (`e`.`commission` < 0) and (`e`.`currencyFk` = 2)) group by month(`tr`.`landed`),year(`tr`.`landed`) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78863,7 +80632,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `exchangeInsuranceIn` AS select `exchangeInsuranceInPrevious`.`dated` AS `dated`,sum(`exchangeInsuranceInPrevious`.`amount`) AS `amount`,cast(sum(`exchangeInsuranceInPrevious`.`amount` * `exchangeInsuranceInPrevious`.`rate`) / sum(`exchangeInsuranceInPrevious`.`amount`) as decimal(10,4)) AS `rate` from `vn`.`exchangeInsuranceInPrevious` group by `exchangeInsuranceInPrevious`.`dated` */; +/*!50001 VIEW `exchangeInsuranceIn` AS select `exchangeInsuranceInPrevious`.`dated` AS `dated`,sum(`exchangeInsuranceInPrevious`.`amount`) AS `amount`,cast((sum((`exchangeInsuranceInPrevious`.`amount` * `exchangeInsuranceInPrevious`.`rate`)) / sum(`exchangeInsuranceInPrevious`.`amount`)) as decimal(10,4)) AS `rate` from `vn`.`exchangeInsuranceInPrevious` group by `exchangeInsuranceInPrevious`.`dated` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78882,7 +80651,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `exchangeInsuranceOut` AS select `p`.`received` AS `received`,sum(`p`.`divisa`) AS `divisa`,sum(`p`.`divisa`) / sum(`p`.`amount`) AS `rate` from (`payment` `p` join `bank` `b` on(`b`.`id` = `p`.`bankFk`)) where `p`.`currencyFk` = 2 and `b`.`cash` = 0 and `p`.`supplierFk` <> 2213 group by `p`.`received` */; +/*!50001 VIEW `exchangeInsuranceOut` AS select `p`.`received` AS `received`,sum(`p`.`divisa`) AS `divisa`,(sum(`p`.`divisa`) / sum(`p`.`amount`)) AS `rate` from (`payment` `p` join `bank` `b` on((`b`.`id` = `p`.`bankFk`))) where ((`p`.`currencyFk` = 2) and (`b`.`cash` = 0) and (`p`.`supplierFk` <> 2213)) group by `p`.`received` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78920,7 +80689,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionCommon` AS select `et`.`id` AS `truckFk`,`et`.`ETD` AS `etd`,ifnull(ucase(`et`.`description`),'SIN ESCANEAR') AS `description`,`es`.`palletFk` AS `palletFk`,`t`.`routeFk` AS `routeFk`,`es`.`id` AS `scanFk`,`e`.`id` AS `expeditionFk`,`r`.`expeditionTruckFk` AS `expeditionTruckFk`,`t`.`warehouseFk` AS `warehouseFk`,`e`.`created` AS `lastPacked`,`t`.`id` AS `ticketFk` from (((((`vn`.`ticket` `t` left join `vn`.`expedition` `e` on(`t`.`id` = `e`.`ticketFk`)) left join `vn`.`expeditionScan` `es` on(`e`.`id` = `es`.`expeditionFk`)) left join `vn`.`expeditionPallet` `ep` on(`es`.`palletFk` = `ep`.`id`)) left join `vn`.`routesMonitor` `r` on(`r`.`routeFk` = `t`.`routeFk`)) left join `vn`.`expeditionTruck` `et` on(`et`.`id` = `r`.`expeditionTruckFk`)) where `t`.`shipped` >= curdate() and `t`.`routeFk` <> 0 */; +/*!50001 VIEW `expeditionCommon` AS select `et`.`id` AS `truckFk`,`et`.`ETD` AS `etd`,ifnull(ucase(`et`.`description`),'SIN ESCANEAR') AS `description`,`es`.`palletFk` AS `palletFk`,`t`.`routeFk` AS `routeFk`,`es`.`id` AS `scanFk`,`e`.`id` AS `expeditionFk`,`r`.`expeditionTruckFk` AS `expeditionTruckFk`,`t`.`warehouseFk` AS `warehouseFk`,`e`.`created` AS `lastPacked`,`t`.`id` AS `ticketFk` from (((((`vn`.`ticket` `t` left join `vn`.`expedition` `e` on((`t`.`id` = `e`.`ticketFk`))) left join `vn`.`expeditionScan` `es` on((`e`.`id` = `es`.`expeditionFk`))) left join `vn`.`expeditionPallet` `ep` on((`es`.`palletFk` = `ep`.`id`))) left join `vn`.`routesMonitor` `r` on((`r`.`routeFk` = `t`.`routeFk`))) left join `vn`.`expeditionTruck` `et` on((`et`.`id` = `r`.`expeditionTruckFk`))) where ((`t`.`shipped` >= curdate()) and (`t`.`routeFk` <> 0)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78939,7 +80708,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionPallet_Print` AS select `et2`.`description` AS `truck`,`t`.`routeFk` AS `routeFk`,`r`.`description` AS `zone`,count(`es`.`id`) AS `eti`,`ep`.`id` AS `palletFk`,`et`.`id` <=> `rm`.`expeditionTruckFk` AS `isMatch`,`t`.`warehouseFk` AS `warehouseFk` from (((((((`vn`.`expeditionTruck` `et` join `vn`.`expeditionPallet` `ep` on(`ep`.`truckFk` = `et`.`id`)) join `vn`.`expeditionScan` `es` on(`es`.`palletFk` = `ep`.`id`)) join `vn`.`expedition` `e` on(`e`.`id` = `es`.`expeditionFk`)) join `vn`.`ticket` `t` on(`t`.`id` = `e`.`ticketFk`)) join `vn`.`route` `r` on(`r`.`id` = `t`.`routeFk`)) left join `vn2008`.`Rutas_monitor` `rm` on(`rm`.`Id_Ruta` = `r`.`id`)) left join `vn`.`expeditionTruck` `et2` on(`et2`.`id` = `rm`.`expeditionTruckFk`)) where `ep`.`isPrint` = 0 group by `ep`.`id`,`t`.`routeFk` */; +/*!50001 VIEW `expeditionPallet_Print` AS select `et2`.`description` AS `truck`,`t`.`routeFk` AS `routeFk`,`r`.`description` AS `zone`,count(`es`.`id`) AS `eti`,`ep`.`id` AS `palletFk`,(`et`.`id` <=> `rm`.`expeditionTruckFk`) AS `isMatch`,`t`.`warehouseFk` AS `warehouseFk` from (((((((`vn`.`expeditionTruck` `et` join `vn`.`expeditionPallet` `ep` on((`ep`.`truckFk` = `et`.`id`))) join `vn`.`expeditionScan` `es` on((`es`.`palletFk` = `ep`.`id`))) join `vn`.`expedition` `e` on((`e`.`id` = `es`.`expeditionFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `e`.`ticketFk`))) join `vn`.`route` `r` on((`r`.`id` = `t`.`routeFk`))) left join `vn2008`.`Rutas_monitor` `rm` on((`rm`.`Id_Ruta` = `r`.`id`))) left join `vn`.`expeditionTruck` `et2` on((`et2`.`id` = `rm`.`expeditionTruckFk`))) where (`ep`.`isPrint` = 0) group by `ep`.`id`,`t`.`routeFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78958,7 +80727,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionRoute_Monitor` AS select `r`.`id` AS `routeFk`,count(distinct if(`e`.`id` is null,`t`.`id`,NULL)) AS `tickets`,count(distinct `e`.`id`) AS `expeditions`,count(distinct `es`.`id`) AS `scanned`,max(`e`.`created`) AS `lastPacked` from ((((((`vn`.`route` `r` join `vn`.`routesMonitor` `rm` on(`r`.`id` = `rm`.`routeFk`)) join `vn`.`expeditionTruck` `et` on(`et`.`id` = `rm`.`expeditionTruckFk`)) join `vn`.`ticket` `t` on(`t`.`routeFk` = `r`.`id`)) left join `vn`.`expedition` `e` on(`e`.`ticketFk` = `t`.`id`)) left join `vn`.`expeditionScan` `es` on(`es`.`expeditionFk` = `e`.`id`)) left join `vn`.`stowaway` `st` on(`st`.`id` = `t`.`id`)) where `et`.`ETD` >= curdate() and `st`.`id` is null group by `r`.`id` */; +/*!50001 VIEW `expeditionRoute_Monitor` AS select `r`.`id` AS `routeFk`,count(distinct if(isnull(`e`.`id`),`t`.`id`,NULL)) AS `tickets`,count(distinct `e`.`id`) AS `expeditions`,count(distinct `es`.`id`) AS `scanned`,max(`e`.`created`) AS `lastPacked` from ((((((`vn`.`route` `r` join `vn`.`routesMonitor` `rm` on((`r`.`id` = `rm`.`routeFk`))) join `vn`.`expeditionTruck` `et` on((`et`.`id` = `rm`.`expeditionTruckFk`))) join `vn`.`ticket` `t` on((`t`.`routeFk` = `r`.`id`))) left join `vn`.`expedition` `e` on((`e`.`ticketFk` = `t`.`id`))) left join `vn`.`expeditionScan` `es` on((`es`.`expeditionFk` = `e`.`id`))) left join `vn`.`stowaway` `st` on((`st`.`id` = `t`.`id`))) where ((`et`.`ETD` >= curdate()) and isnull(`st`.`id`)) group by `r`.`id` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78977,7 +80746,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionRoute_freeTickets` AS select `t`.`routeFk` AS `routeFk`,`tss`.`ticket` AS `ticket`,`s`.`name` AS `code`,`w`.`name` AS `almacen`,`tss`.`updated` AS `updated` from ((((`vn`.`ticketStateToday` `tss` join `vn`.`ticket` `t` on(`t`.`id` = `tss`.`ticket`)) join `vn`.`warehouse` `w` on(`w`.`id` = `t`.`warehouseFk`)) join `vn`.`state` `s` on(`s`.`id` = `tss`.`state`)) left join `vn`.`stowaway` `st` on(`st`.`id` = `t`.`id`)) where ifnull(`t`.`packages`,0) = 0 and `st`.`id` is null */; +/*!50001 VIEW `expeditionRoute_freeTickets` AS select `t`.`routeFk` AS `routeFk`,`tss`.`ticket` AS `ticket`,`s`.`name` AS `code`,`w`.`name` AS `almacen`,`tss`.`updated` AS `updated` from ((((`vn`.`ticketStateToday` `tss` join `vn`.`ticket` `t` on((`t`.`id` = `tss`.`ticket`))) join `vn`.`warehouse` `w` on((`w`.`id` = `t`.`warehouseFk`))) join `vn`.`state` `s` on((`s`.`id` = `tss`.`state`))) left join `vn`.`stowaway` `st` on((`st`.`id` = `t`.`id`))) where ((ifnull(`t`.`packages`,0) = 0) and isnull(`st`.`id`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -78996,7 +80765,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionScan_Monitor` AS select `et`.`id` AS `truckFk`,`et`.`ETD` AS `ETD`,`et`.`description` AS `description`,`ep`.`id` AS `palletFk`,`ep`.`position` AS `position`,`ep`.`built` AS `built`,`es`.`id` AS `scanFk`,`es`.`expeditionFk` AS `expeditionFk`,`es`.`scanned` AS `scanned` from ((`expeditionTruck` `et` left join `expeditionPallet` `ep` on(`ep`.`truckFk` = `et`.`id`)) left join `expeditionScan` `es` on(`es`.`palletFk` = `ep`.`id`)) */; +/*!50001 VIEW `expeditionScan_Monitor` AS select `et`.`id` AS `truckFk`,`et`.`ETD` AS `ETD`,`et`.`description` AS `description`,`ep`.`id` AS `palletFk`,`ep`.`position` AS `position`,`ep`.`built` AS `built`,`es`.`id` AS `scanFk`,`es`.`expeditionFk` AS `expeditionFk`,`es`.`scanned` AS `scanned` from ((`expeditionTruck` `et` left join `expeditionPallet` `ep` on((`ep`.`truckFk` = `et`.`id`))) left join `expeditionScan` `es` on((`es`.`palletFk` = `ep`.`id`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79015,7 +80784,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionTimeExpended` AS select `e`.`ticketFk` AS `ticketFk`,min(`e`.`created`) AS `started`,max(`e`.`created`) AS `finished`,max(`e`.`counter`) AS `cajas`,`w`.`code` AS `code`,`t`.`warehouseFk` AS `warehouseFk` from ((`expedition` `e` join `worker` `w` on(`w`.`id` = `e`.`workerFk`)) join `ticket` `t` on(`t`.`id` = `e`.`ticketFk`)) where `e`.`created` > curdate() group by `e`.`ticketFk` */; +/*!50001 VIEW `expeditionTimeExpended` AS select `e`.`ticketFk` AS `ticketFk`,min(`e`.`created`) AS `started`,max(`e`.`created`) AS `finished`,max(`e`.`counter`) AS `cajas`,`w`.`code` AS `code`,`t`.`warehouseFk` AS `warehouseFk` from ((`expedition` `e` join `worker` `w` on((`w`.`id` = `e`.`workerFk`))) join `ticket` `t` on((`t`.`id` = `e`.`ticketFk`))) where (`e`.`created` > curdate()) group by `e`.`ticketFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79034,7 +80803,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionTruck_Control` AS select `e`.`truckFk` AS `id`,`e`.`etd` AS `ETD`,`e`.`description` AS `description`,count(distinct if(`e`.`expeditionFk` is null,`e`.`ticketFk`,NULL)) AS `ticketsSinBultos`,count(distinct `e`.`palletFk`) AS `pallets`,count(distinct `e`.`routeFk`) AS `routes`,count(distinct `e`.`scanFk`) AS `scans`,count(distinct `e`.`expeditionFk`) AS `expeditions`,sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`,max(`e`.`lastPacked`) AS `lastPacked` from `vn`.`expeditionCommon` `e` group by `e`.`truckFk` order by sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) desc,`e`.`etd` */; +/*!50001 VIEW `expeditionTruck_Control` AS select `e`.`truckFk` AS `id`,`e`.`etd` AS `ETD`,`e`.`description` AS `description`,count(distinct if(isnull(`e`.`expeditionFk`),`e`.`ticketFk`,NULL)) AS `ticketsSinBultos`,count(distinct `e`.`palletFk`) AS `pallets`,count(distinct `e`.`routeFk`) AS `routes`,count(distinct `e`.`scanFk`) AS `scans`,count(distinct `e`.`expeditionFk`) AS `expeditions`,sum((`e`.`truckFk` <> `e`.`expeditionTruckFk`)) AS `fallos`,max(`e`.`lastPacked`) AS `lastPacked` from `vn`.`expeditionCommon` `e` group by `e`.`truckFk` order by `fallos` desc,`e`.`etd` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79053,7 +80822,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionTruck_Control_Detail` AS select `e`.`truckFk` AS `id`,`e`.`etd` AS `ETD`,`e`.`description` AS `destino`,`e`.`palletFk` AS `pallet`,count(distinct `e`.`routeFk`) AS `routes`,count(distinct `e`.`scanFk`) AS `scans`,count(distinct `e`.`expeditionTruckFk`) AS `destinos`,sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`,max(`e`.`lastPacked`) AS `lastPacked` from `vn`.`expeditionCommon` `e` group by `e`.`truckFk`,`e`.`palletFk` order by sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) desc,`e`.`etd`,`e`.`truckFk` */; +/*!50001 VIEW `expeditionTruck_Control_Detail` AS select `e`.`truckFk` AS `id`,`e`.`etd` AS `ETD`,`e`.`description` AS `destino`,`e`.`palletFk` AS `pallet`,count(distinct `e`.`routeFk`) AS `routes`,count(distinct `e`.`scanFk`) AS `scans`,count(distinct `e`.`expeditionTruckFk`) AS `destinos`,sum((`e`.`truckFk` <> `e`.`expeditionTruckFk`)) AS `fallos`,max(`e`.`lastPacked`) AS `lastPacked` from `vn`.`expeditionCommon` `e` group by `e`.`truckFk`,`e`.`palletFk` order by `fallos` desc,`e`.`etd`,`e`.`truckFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79072,7 +80841,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionTruck_Control_Detail_Pallet` AS select `e`.`truckFk` AS `id`,`e`.`etd` AS `ETD`,`e`.`description` AS `destino`,`e`.`palletFk` AS `pallet`,`e`.`routeFk` AS `route`,count(distinct `e`.`scanFk`) AS `scans`,`et`.`description` AS `destinos`,sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`,`e`.`expeditionTruckFk` AS `expeditionTruckFk`,max(`e`.`lastPacked`) AS `lastPacked` from (`vn`.`expeditionCommon` `e` left join `vn`.`expeditionTruck` `et` on(`et`.`id` = `e`.`expeditionTruckFk`)) group by `e`.`truckFk`,`e`.`palletFk`,`e`.`routeFk` order by sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) desc,`e`.`palletFk` */; +/*!50001 VIEW `expeditionTruck_Control_Detail_Pallet` AS select `e`.`truckFk` AS `id`,`e`.`etd` AS `ETD`,`e`.`description` AS `destino`,`e`.`palletFk` AS `pallet`,`e`.`routeFk` AS `route`,count(distinct `e`.`scanFk`) AS `scans`,`et`.`description` AS `destinos`,sum((`e`.`truckFk` <> `e`.`expeditionTruckFk`)) AS `fallos`,`e`.`expeditionTruckFk` AS `expeditionTruckFk`,max(`e`.`lastPacked`) AS `lastPacked` from (`vn`.`expeditionCommon` `e` left join `vn`.`expeditionTruck` `et` on((`et`.`id` = `e`.`expeditionTruckFk`))) group by `e`.`truckFk`,`e`.`palletFk`,`e`.`routeFk` order by `fallos` desc,`e`.`palletFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79091,7 +80860,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `firstTicketShipped` AS select min(`ticket`.`shipped`) AS `shipped`,`ticket`.`clientFk` AS `clientFk` from `ticket` where `ticket`.`shipped` > '2001-01-01' group by `ticket`.`clientFk` */; +/*!50001 VIEW `firstTicketShipped` AS select min(`ticket`.`shipped`) AS `shipped`,`ticket`.`clientFk` AS `clientFk` from `ticket` where (`ticket`.`shipped` > '2001-01-01') group by `ticket`.`clientFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79110,7 +80879,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `floraHollandBuyedItems` AS select `b`.`itemFk` AS `itemFk`,`i`.`longName` AS `longName`,`b`.`quantity` AS `quantity`,`b`.`buyingValue` AS `buyingValue`,`tr`.`landed` AS `landed`,`e`.`companyFk` AS `companyFk` from (((((`buy` `b` join `item` `i` on(`b`.`itemFk` = `i`.`id`)) join `itemType` `it` on(`it`.`id` = `i`.`typeFk`)) join `itemCategory` `ic` on(`ic`.`id` = `it`.`categoryFk`)) join `entry` `e` on(`e`.`id` = `b`.`entryFk`)) join `travel` `tr` on(`tr`.`id` = `e`.`travelFk` and `ic`.`id` not in (8,6) and `b`.`buyingValue` <> 0 and `b`.`quantity` <> 0 and `e`.`supplierFk` in (1664,1665,1666,1465,1433))) */; +/*!50001 VIEW `floraHollandBuyedItems` AS select `b`.`itemFk` AS `itemFk`,`i`.`longName` AS `longName`,`b`.`quantity` AS `quantity`,`b`.`buyingValue` AS `buyingValue`,`tr`.`landed` AS `landed`,`e`.`companyFk` AS `companyFk` from (((((`buy` `b` join `item` `i` on((`b`.`itemFk` = `i`.`id`))) join `itemType` `it` on((`it`.`id` = `i`.`typeFk`))) join `itemCategory` `ic` on((`ic`.`id` = `it`.`categoryFk`))) join `entry` `e` on((`e`.`id` = `b`.`entryFk`))) join `travel` `tr` on(((`tr`.`id` = `e`.`travelFk`) and (`ic`.`id` not in (8,6)) and (`b`.`buyingValue` <> 0) and (`b`.`quantity` <> 0) and (`e`.`supplierFk` in (1664,1665,1666,1465,1433))))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79205,7 +80974,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `inkL10n` AS select `k`.`id` AS `id`,ifnull(`i`.`name`,`k`.`name`) AS `name` from (`ink` `k` left join `inkI18n` `i` on(`i`.`inkFk` = `k`.`id` and `i`.`lang` = `util`.`lang`())) */; +/*!50001 VIEW `inkL10n` AS select `k`.`id` AS `id`,ifnull(`i`.`name`,`k`.`name`) AS `name` from (`ink` `k` left join `inkI18n` `i` on(((`i`.`inkFk` = `k`.`id`) and (`i`.`lang` = `util`.`lang`())))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79224,7 +80993,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`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79338,7 +81107,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`,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 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79357,7 +81126,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemCategoryL10n` AS select `c`.`id` AS `id`,ifnull(`i`.`name`,`c`.`name`) AS `name` from (`itemCategory` `c` left join `itemCategoryI18n` `i` on(`i`.`categoryFk` = `c`.`id` and `i`.`lang` = `util`.`lang`())) */; +/*!50001 VIEW `itemCategoryL10n` AS select `c`.`id` AS `id`,ifnull(`i`.`name`,`c`.`name`) AS `name` from (`itemCategory` `c` left join `itemCategoryI18n` `i` on(((`i`.`categoryFk` = `c`.`id`) and (`i`.`lang` = `util`.`lang`())))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79376,7 +81145,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemColor` AS select `it`.`itemFk` AS `itemFk`,`it`.`value` AS `color` from (`itemTag` `it` join `tag` `t` on(`t`.`id` = `it`.`tagFk`)) where `t`.`code` = 'COLOR' */; +/*!50001 VIEW `itemColor` AS select `it`.`itemFk` AS `itemFk`,`it`.`value` AS `color` from (`itemTag` `it` join `tag` `t` on((`t`.`id` = `it`.`tagFk`))) where (`t`.`code` = 'COLOR') */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79395,7 +81164,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemEntryIn` AS select `t`.`warehouseInFk` AS `warehouseInFk`,`t`.`landed` AS `landed`,`b`.`itemFk` AS `itemFk`,`b`.`quantity` AS `quantity`,`t`.`isReceived` AS `isReceived`,`e`.`isRaid` AS `isVirtualStock`,`e`.`id` AS `entryFk` from ((`buy` `b` join `entry` `e` on(`b`.`entryFk` = `e`.`id`)) join `travel` `t` on(`e`.`travelFk` = `t`.`id`)) where `e`.`isInventory` = 0 and `b`.`quantity` <> 0 */; +/*!50001 VIEW `itemEntryIn` AS select `t`.`warehouseInFk` AS `warehouseInFk`,`t`.`landed` AS `landed`,`b`.`itemFk` AS `itemFk`,`b`.`quantity` AS `quantity`,`t`.`isReceived` AS `isReceived`,`e`.`isRaid` AS `isVirtualStock`,`e`.`id` AS `entryFk` from ((`buy` `b` join `entry` `e` on((`b`.`entryFk` = `e`.`id`))) join `travel` `t` on((`e`.`travelFk` = `t`.`id`))) where ((`e`.`isInventory` = 0) and (`b`.`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 */; @@ -79414,7 +81183,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemEntryOut` AS select `t`.`warehouseOutFk` AS `warehouseOutFk`,`t`.`shipped` AS `shipped`,`b`.`itemFk` AS `itemFk`,-`b`.`quantity` AS `quantity`,`t`.`isDelivered` AS `isDelivered`,`e`.`id` AS `entryFk` from ((`buy` `b` join `entry` `e` on(`b`.`entryFk` = `e`.`id`)) join `travel` `t` on(`e`.`travelFk` = `t`.`id`)) where `e`.`isInventory` = 0 and `e`.`isRaid` = 0 and `b`.`quantity` <> 0 */; +/*!50001 VIEW `itemEntryOut` AS select `t`.`warehouseOutFk` AS `warehouseOutFk`,`t`.`shipped` AS `shipped`,`b`.`itemFk` AS `itemFk`,-(`b`.`quantity`) AS `quantity`,`t`.`isDelivered` AS `isDelivered`,`e`.`id` AS `entryFk` from ((`buy` `b` join `entry` `e` on((`b`.`entryFk` = `e`.`id`))) join `travel` `t` on((`e`.`travelFk` = `t`.`id`))) where ((`e`.`isInventory` = 0) and (`e`.`isRaid` = 0) and (`b`.`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 */; @@ -79433,7 +81202,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemPlacementSupplyList` AS select `ips`.`id` AS `id`,`ips`.`itemFk` AS `itemFk`,`ips`.`quantity` AS `quantity`,`ips`.`priority` AS `priority`,ifnull(`isps`.`created`,`ips`.`created`) AS `created`,`ips`.`userFk` AS `userFk`,`ips`.`repoUserFk` AS `repoUserFk`,`ips`.`quantity` - sum(ifnull(`isps`.`quantity`,0)) AS `saldo`,concat(`i`.`longName`,' ',`i`.`size`) AS `longName`,`i`.`subName` AS `subName`,`i`.`size` AS `size`,`w`.`code` AS `workerCode`,`rw`.`code` AS `repoCode`,`ips`.`sectorFk` AS `sectorFk` from ((((`itemPlacementSupply` `ips` join `item` `i` on(`i`.`id` = `ips`.`itemFk`)) left join `worker` `w` on(`w`.`userFk` = `ips`.`userFk`)) left join `worker` `rw` on(`rw`.`userFk` = `ips`.`repoUserFk`)) left join `itemShelvingPlacementSupply` `isps` on(`isps`.`itemPlacementSupplyFk` = `ips`.`id`)) where `ips`.`created` >= curdate() group by `ips`.`priority`,`ips`.`id`,`ips`.`sectorFk` */; +/*!50001 VIEW `itemPlacementSupplyList` AS select `ips`.`id` AS `id`,`ips`.`itemFk` AS `itemFk`,`ips`.`quantity` AS `quantity`,`ips`.`priority` AS `priority`,ifnull(`isps`.`created`,`ips`.`created`) AS `created`,`ips`.`userFk` AS `userFk`,`ips`.`repoUserFk` AS `repoUserFk`,(`ips`.`quantity` - sum(ifnull(`isps`.`quantity`,0))) AS `saldo`,concat(`i`.`longName`,' ',`i`.`size`) AS `longName`,`i`.`subName` AS `subName`,`i`.`size` AS `size`,`w`.`code` AS `workerCode`,`rw`.`code` AS `repoCode`,`ips`.`sectorFk` AS `sectorFk` from ((((`itemPlacementSupply` `ips` join `item` `i` on((`i`.`id` = `ips`.`itemFk`))) left join `worker` `w` on((`w`.`userFk` = `ips`.`userFk`))) left join `worker` `rw` on((`rw`.`userFk` = `ips`.`repoUserFk`))) left join `itemShelvingPlacementSupply` `isps` on((`isps`.`itemPlacementSupplyFk` = `ips`.`id`))) where (`ips`.`created` >= curdate()) group by `ips`.`priority`,`ips`.`id`,`ips`.`sectorFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79452,7 +81221,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemProductor` AS select `it`.`itemFk` AS `itemFk`,`it`.`value` AS `productor` from (`itemTag` `it` join `tag` `t` on(`t`.`id` = `it`.`tagFk`)) where `t`.`code` = 'PRODUCER' */; +/*!50001 VIEW `itemProductor` AS select `it`.`itemFk` AS `itemFk`,`it`.`value` AS `productor` from (`itemTag` `it` join `tag` `t` on((`t`.`id` = `it`.`tagFk`))) where (`t`.`code` = 'PRODUCER') */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79471,7 +81240,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemShelvingAvailable` AS select `s`.`id` AS `saleFk`,`tst`.`updated` AS `Modificado`,`s`.`ticketFk` AS `ticketFk`,0 AS `isPicked`,`s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`i`.`size` AS `size`,`st`.`name` AS `Estado`,`st`.`sectorProdPriority` AS `sectorProdPriority`,`stock`.`visible` AS `available`,`stock`.`sectorFk` AS `sectorFk`,`stock`.`shelvingFk` AS `matricula`,`stock`.`parkingFk` AS `parking`,`stock`.`itemShelvingFk` AS `itemShelving`,`am`.`name` AS `Agency`,`t`.`shipped` AS `shipped`,`stock`.`grouping` AS `grouping`,`stock`.`packing` AS `packing`,`z`.`hour` AS `hour`,`st`.`isPreviousPreparable` AS `isPreviousPreparable`,`sv`.`physicalVolume` AS `physicalVolume`,`t`.`warehouseFk` AS `warehouseFk` from (((((((((`vn`.`sale` `s` join `vn`.`ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) join `vn`.`agencyMode` `am` on(`am`.`id` = `t`.`agencyModeFk`)) join `vn`.`ticketStateToday` `tst` on(`tst`.`ticket` = `t`.`id`)) join `vn`.`state` `st` on(`st`.`id` = `tst`.`state`)) join `vn`.`item` `i` on(`i`.`id` = `s`.`itemFk`)) join `vn`.`itemShelvingStock` `stock` on(`stock`.`itemFk` = `i`.`id`)) left join `vn`.`saleTracking` `stk` on(`stk`.`saleFk` = `s`.`id`)) left join `vn`.`zone` `z` on(`z`.`id` = `t`.`zoneFk`)) left join `vn`.`saleVolume` `sv` on(`sv`.`saleFk` = `s`.`id`)) where `t`.`shipped` between `util`.`yesterday`() and `util`.`dayend`(curdate()) and `stk`.`id` is null and `stock`.`visible` > 0 and `stk`.`saleFk` is null and `st`.`isPreviousPreparable` <> 0 */; +/*!50001 VIEW `itemShelvingAvailable` AS select `s`.`id` AS `saleFk`,`tst`.`updated` AS `Modificado`,`s`.`ticketFk` AS `ticketFk`,0 AS `isPicked`,`s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`i`.`size` AS `size`,`st`.`name` AS `Estado`,`st`.`sectorProdPriority` AS `sectorProdPriority`,`stock`.`visible` AS `available`,`stock`.`sectorFk` AS `sectorFk`,`stock`.`shelvingFk` AS `matricula`,`stock`.`parkingFk` AS `parking`,`stock`.`itemShelvingFk` AS `itemShelving`,`am`.`name` AS `Agency`,`t`.`shipped` AS `shipped`,`stock`.`grouping` AS `grouping`,`stock`.`packing` AS `packing`,`z`.`hour` AS `hour`,`st`.`isPreviousPreparable` AS `isPreviousPreparable`,`sv`.`physicalVolume` AS `physicalVolume`,`t`.`warehouseFk` AS `warehouseFk` from (((((((((`vn`.`sale` `s` join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`agencyMode` `am` on((`am`.`id` = `t`.`agencyModeFk`))) join `vn`.`ticketStateToday` `tst` on((`tst`.`ticket` = `t`.`id`))) join `vn`.`state` `st` on((`st`.`id` = `tst`.`state`))) join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`itemShelvingStock` `stock` on((`stock`.`itemFk` = `i`.`id`))) left join `vn`.`saleTracking` `stk` on((`stk`.`saleFk` = `s`.`id`))) left join `vn`.`zone` `z` on((`z`.`id` = `t`.`zoneFk`))) left join `vn`.`saleVolume` `sv` on((`sv`.`saleFk` = `s`.`id`))) where ((`t`.`shipped` between `util`.`yesterday`() and `util`.`dayend`(curdate())) and isnull(`stk`.`id`) and (`stock`.`visible` > 0) and isnull(`stk`.`saleFk`) and `st`.`isPreviousPreparable`) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79490,7 +81259,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemShelvingList` AS select `ish`.`shelvingFk` AS `shelvingFk`,`ish`.`visible` AS `visible`,`ish`.`created` AS `created`,`pk`.`code` AS `parking`,`ish`.`itemFk` AS `itemFk`,`i`.`longName` AS `longName`,`i`.`size` AS `size`,`i`.`subName` AS `subName`,`sh`.`parked` AS `parked` from (((`itemShelving` `ish` join `shelving` `sh` on(`sh`.`code` = `ish`.`shelvingFk`)) join `item` `i` on(`i`.`id` = `ish`.`itemFk`)) left join `parking` `pk` on(`pk`.`id` = `sh`.`parkingFk`)) order by `ish`.`created` */; +/*!50001 VIEW `itemShelvingList` AS select `ish`.`shelvingFk` AS `shelvingFk`,`ish`.`visible` AS `visible`,`ish`.`created` AS `created`,`pk`.`code` AS `parking`,`ish`.`itemFk` AS `itemFk`,`i`.`longName` AS `longName`,`i`.`size` AS `size`,`i`.`subName` AS `subName`,`sh`.`parked` AS `parked` from (((`itemShelving` `ish` join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) join `item` `i` on((`i`.`id` = `ish`.`itemFk`))) left join `parking` `pk` on((`pk`.`id` = `sh`.`parkingFk`))) order by `ish`.`created` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79509,7 +81278,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemShelvingPlacementSupplyStock` AS select `ish`.`id` AS `itemShelvingFk`,`ish`.`itemFk` AS `itemFk`,`ish`.`quantity` AS `quantity`,`ish`.`packing` AS `packing`,`ish`.`visible` AS `stock`,`i`.`longName` AS `longName`,`i`.`size` AS `size`,`i`.`subName` AS `subName`,`sh`.`code` AS `shelving`,`p`.`code` AS `parking`,`ish`.`created` AS `created`,ifnull(`sh`.`priority`,1) AS `priority`,`p`.`id` AS `parkingFk`,`p`.`sectorFk` AS `sectorFk` from (((`itemShelving` `ish` join `shelving` `sh` on(`sh`.`code` = `ish`.`shelvingFk`)) left join `parking` `p` on(`p`.`id` = `sh`.`parkingFk`)) join `item` `i` on(`i`.`id` = `ish`.`itemFk`)) group by `ish`.`id` */; +/*!50001 VIEW `itemShelvingPlacementSupplyStock` AS select `ish`.`id` AS `itemShelvingFk`,`ish`.`itemFk` AS `itemFk`,`ish`.`quantity` AS `quantity`,`ish`.`packing` AS `packing`,`ish`.`visible` AS `stock`,`i`.`longName` AS `longName`,`i`.`size` AS `size`,`i`.`subName` AS `subName`,`sh`.`code` AS `shelving`,`p`.`code` AS `parking`,`ish`.`created` AS `created`,ifnull(`sh`.`priority`,1) AS `priority`,`p`.`id` AS `parkingFk`,`p`.`sectorFk` AS `sectorFk` from (((`itemShelving` `ish` join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) left join `parking` `p` on((`p`.`id` = `sh`.`parkingFk`))) join `item` `i` on((`i`.`id` = `ish`.`itemFk`))) 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 */; @@ -79528,7 +81297,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemShelvingPlacementSupplyStock__` AS select `ish`.`id` AS `itemShelvingFk`,`ish`.`itemFk` AS `itemFk`,`ish`.`quantity` AS `quantity`,`ish`.`packing` AS `packing`,`ish`.`visible` AS `stock`,`i`.`longName` AS `longName`,`i`.`size` AS `size`,`i`.`subName` AS `subName`,`sh`.`code` AS `shelving`,`p`.`code` AS `parking`,`ish`.`created` AS `created`,ifnull(`sh`.`priority`,1) AS `priority` from (((((`itemShelving` `ish` join `shelving` `sh` on(`sh`.`code` = `ish`.`shelvingFk`)) left join `parking` `p` on(`p`.`id` = `sh`.`parkingFk`)) join `item` `i` on(`i`.`id` = `ish`.`itemFk`)) left join `itemShelvingSale` `iss` on(`iss`.`itemShelvingFk` = `ish`.`id`)) left join `itemShelvingPlacementSupply` `isps` on(`isps`.`itemShelvingFk` = `ish`.`id`)) group by `ish`.`id` */; +/*!50001 VIEW `itemShelvingPlacementSupplyStock__` AS select `ish`.`id` AS `itemShelvingFk`,`ish`.`itemFk` AS `itemFk`,`ish`.`quantity` AS `quantity`,`ish`.`packing` AS `packing`,`ish`.`visible` AS `stock`,`i`.`longName` AS `longName`,`i`.`size` AS `size`,`i`.`subName` AS `subName`,`sh`.`code` AS `shelving`,`p`.`code` AS `parking`,`ish`.`created` AS `created`,ifnull(`sh`.`priority`,1) AS `priority` from (((((`itemShelving` `ish` join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) left join `parking` `p` on((`p`.`id` = `sh`.`parkingFk`))) join `item` `i` on((`i`.`id` = `ish`.`itemFk`))) 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 */; @@ -79547,7 +81316,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemShelvingSaleSum` AS select `iss`.`id` AS `id`,`iss`.`itemShelvingFk` AS `itemShelvingFk`,`iss`.`saleFk` AS `saleFk`,sum(`iss`.`quantity`) AS `quantity`,`iss`.`created` AS `created`,`p`.`sectorFk` AS `sectorFk` from (((`itemShelvingSale` `iss` join `itemShelving` `ish` on(`ish`.`id` = `iss`.`itemShelvingFk`)) join `shelving` `sh` on(`sh`.`code` = `ish`.`shelvingFk`)) join `parking` `p` on(`p`.`id` = `sh`.`parkingFk`)) group by `iss`.`saleFk` */; +/*!50001 VIEW `itemShelvingSaleSum` AS select `iss`.`id` AS `id`,`iss`.`itemShelvingFk` AS `itemShelvingFk`,`iss`.`saleFk` AS `saleFk`,sum(`iss`.`quantity`) AS `quantity`,`iss`.`created` AS `created`,`p`.`sectorFk` AS `sectorFk` from (((`itemShelvingSale` `iss` join `itemShelving` `ish` on((`ish`.`id` = `iss`.`itemShelvingFk`))) join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) join `parking` `p` on((`p`.`id` = `sh`.`parkingFk`))) group by `iss`.`saleFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79566,7 +81335,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_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` <> 0 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`,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 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79585,7 +81354,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemShelvingStockFull` AS select `ish`.`itemFk` AS `itemFk`,`ish`.`visible` AS `quantity`,`ish`.`packing` AS `packing`,`ish`.`grouping` AS `grouping`,`s`.`description` AS `sector`,`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` join `shelving` `sh` on(`sh`.`code` = `ish`.`shelvingFk`)) join `parking` `p` on(`p`.`id` = `sh`.`parkingFk`)) join `sector` `s` on(`s`.`id` = `p`.`sectorFk`)) left join `itemShelvingStockRemoved` `issr` on(`issr`.`itemShelvingFk` = `ish`.`id`)) */; +/*!50001 VIEW `itemShelvingStockFull` AS select `ish`.`itemFk` AS `itemFk`,`ish`.`visible` AS `quantity`,`ish`.`packing` AS `packing`,`ish`.`grouping` AS `grouping`,`s`.`description` AS `sector`,`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` join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) join `parking` `p` on((`p`.`id` = `sh`.`parkingFk`))) join `sector` `s` on((`s`.`id` = `p`.`sectorFk`))) left join `itemShelvingStockRemoved` `issr` on((`issr`.`itemShelvingFk` = `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 */; @@ -79604,7 +81373,26 @@ USE `vn`; /*!50001 SET collation_connection = utf8_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`,(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 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 `itemShelvingStock_byWarehouse` +-- + +/*!50001 DROP TABLE IF EXISTS `itemShelvingStock_byWarehouse`*/; +/*!50001 DROP VIEW IF EXISTS `itemShelvingStock_byWarehouse`*/; +/*!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 `itemShelvingStock_byWarehouse` AS select `ish`.`itemFk` AS `itemFk`,sum(`ish`.`visible`) AS `visible`,`s`.`warehouseFk` AS `warehouseFk` from (((`itemShelving` `ish` join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) join `parking` `p` on((`p`.`id` = `sh`.`parkingFk`))) join `sector` `s` on((`s`.`id` = `p`.`sectorFk`))) group by `ish`.`itemFk`,`s`.`warehouseFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79642,7 +81430,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemTicketOut` AS select `t`.`warehouseFk` AS `warehouseFk`,`t`.`shipped` AS `shipped`,`s`.`itemFk` AS `itemFk`,-`s`.`quantity` AS `quantity`,`s`.`isPicked` AS `isPicked`,`s`.`reserved` AS `reserved`,`t`.`refFk` AS `refFk`,`s`.`id` AS `saleFk`,`s`.`ticketFk` AS `ticketFk` from (`sale` `s` join `ticket` `t` on(`s`.`ticketFk` = `t`.`id`)) where `s`.`quantity` <> 0 */; +/*!50001 VIEW `itemTicketOut` AS select `t`.`warehouseFk` AS `warehouseFk`,`t`.`shipped` AS `shipped`,`s`.`itemFk` AS `itemFk`,-(`s`.`quantity`) AS `quantity`,`s`.`isPicked` AS `isPicked`,`s`.`reserved` AS `reserved`,`t`.`refFk` AS `refFk`,`s`.`id` AS `saleFk`,`s`.`ticketFk` AS `ticketFk` from (`sale` `s` join `ticket` `t` on((`s`.`ticketFk` = `t`.`id`))) where (`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 */; @@ -79661,7 +81449,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemTypeL10n` AS select `t`.`id` AS `id`,ifnull(`i`.`name`,`t`.`name`) AS `name` from (`itemType` `t` left join `itemTypeI18n` `i` on(`i`.`typeFk` = `t`.`id` and `i`.`lang` = `util`.`LANG`())) */; +/*!50001 VIEW `itemTypeL10n` AS select `t`.`id` AS `id`,ifnull(`i`.`name`,`t`.`name`) AS `name` from (`itemType` `t` left join `itemTypeI18n` `i` on(((`i`.`typeFk` = `t`.`id`) and (`i`.`lang` = `util`.`LANG`())))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79680,7 +81468,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `item_Free_Id` AS select `i1`.`id` + 1 AS `newId` from (`item` `i1` left join `item` `i2` on(`i1`.`id` + 1 = `i2`.`id`)) where `i2`.`id` is null and `i1`.`id` > 400000 */; +/*!50001 VIEW `item_Free_Id` AS select (`i1`.`id` + 1) AS `newId` from (`item` `i1` left join `item` `i2` on(((`i1`.`id` + 1) = `i2`.`id`))) where (isnull(`i2`.`id`) and (`i1`.`id` > 400000)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79699,7 +81487,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `labelInfo` AS select `i`.`id` AS `itemId`,`i`.`name` AS `itemName`,`b`.`stickers` AS `stickers`,`b`.`printedStickers` AS `life`,`i`.`inkFk` AS `colorCode`,`i`.`stems` AS `stems`,`i`.`category` AS `category`,`i`.`subName` AS `productor`,`b`.`packing` AS `packing`,`clb`.`warehouse_id` AS `warehouse_id`,`i`.`size` AS `size`,`b`.`isPickedOff` AS `isPickedOff`,`e`.`evaNotes` AS `notes`,`w`.`name` AS `wh_in`,`e`.`id` AS `entryId`,`b`.`id` AS `buyId` from (((((`vn`.`buy` `b` join `vn`.`item` `i` on(`i`.`id` = `b`.`itemFk`)) join `cache`.`last_buy` `clb` on(`clb`.`item_id` = `i`.`id`)) join `vn`.`entry` `e` on(`e`.`id` = `b`.`entryFk`)) left join `vn`.`travel` `tr` on(`tr`.`id` = `e`.`travelFk`)) join `vn`.`warehouse` `w` on(`w`.`id` = `tr`.`warehouseInFk`)) */; +/*!50001 VIEW `labelInfo` AS select `i`.`id` AS `itemId`,`i`.`name` AS `itemName`,`b`.`stickers` AS `stickers`,`b`.`printedStickers` AS `life`,`i`.`inkFk` AS `colorCode`,`i`.`stems` AS `stems`,`i`.`category` AS `category`,`i`.`subName` AS `productor`,`b`.`packing` AS `packing`,`clb`.`warehouse_id` AS `warehouse_id`,`i`.`size` AS `size`,`b`.`isPickedOff` AS `isPickedOff`,`e`.`evaNotes` AS `notes`,`w`.`name` AS `wh_in`,`e`.`id` AS `entryId`,`b`.`id` AS `buyId` from (((((`vn`.`buy` `b` join `vn`.`item` `i` on((`i`.`id` = `b`.`itemFk`))) join `cache`.`last_buy` `clb` on((`clb`.`item_id` = `i`.`id`))) join `vn`.`entry` `e` on((`e`.`id` = `b`.`entryFk`))) left join `vn`.`travel` `tr` on((`tr`.`id` = `e`.`travelFk`))) join `vn`.`warehouse` `w` on((`w`.`id` = `tr`.`warehouseInFk`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79718,7 +81506,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `lastHourProduction` AS select `t`.`warehouseFk` AS `warehouseFk`,greatest(10,cast(sum(`sv`.`volume`) as decimal(5,1))) AS `m3` from (((((((`vn`.`saleTracking` `st` join `vn`.`saleVolume` `sv` on(`sv`.`saleFk` = `st`.`saleFk`)) join `vn`.`ticket` `t` on(`t`.`id` = `sv`.`ticketFk`)) join `vn`.`state` `s` on(`s`.`id` = `st`.`stateFk`)) join `account`.`user` `u` on(`u`.`id` = `st`.`workerFk`)) join `account`.`role` `r` on(`r`.`id` = `u`.`role`)) join `vn`.`warehouse` `w` on(`w`.`id` = `t`.`warehouseFk`)) join `vn`.`warehouseAlias` `wa` on(`wa`.`id` = `w`.`aliasFk`)) where `st`.`created` > current_timestamp() + interval -1 hour and `s`.`code` = 'CHECKED' and `r`.`name` <> 'salesPerson' and `wa`.`name` = 'Silla' */; +/*!50001 VIEW `lastHourProduction` AS select `t`.`warehouseFk` AS `warehouseFk`,greatest(10,cast(sum(`sv`.`volume`) as decimal(5,1))) AS `m3` from (((((((`vn`.`saleTracking` `st` join `vn`.`saleVolume` `sv` on((`sv`.`saleFk` = `st`.`saleFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `sv`.`ticketFk`))) join `vn`.`state` `s` on((`s`.`id` = `st`.`stateFk`))) join `account`.`user` `u` on((`u`.`id` = `st`.`workerFk`))) join `account`.`role` `r` on((`r`.`id` = `u`.`role`))) join `vn`.`warehouse` `w` on((`w`.`id` = `t`.`warehouseFk`))) join `vn`.`warehouseAlias` `wa` on((`wa`.`id` = `w`.`aliasFk`))) where ((`st`.`created` > (now() + interval -(1) hour)) and (`s`.`code` = 'CHECKED') and (`r`.`name` <> 'salesPerson') and (`wa`.`name` = 'Silla')) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79737,7 +81525,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `lastTopClaims` AS select `s`.`itemFk` AS `itemFk`,`i`.`longName` AS `itemName`,`it`.`name` AS `itemTypeName`,count(0) AS `claimsNumber`,round(sum(`cb`.`quantity` * `s`.`price` * (1 - (`c`.`responsibility` - 1) / 4) * (100 - `s`.`discount`) / 100),2) AS `claimedAmount`,round(sum(`cb`.`quantity` * `s`.`price` * (100 - `s`.`discount`) / 100),2) AS `totalAmount` from ((((`claim` `c` join `claimBeginning` `cb` on(`cb`.`claimFk` = `c`.`id`)) join `sale` `s` on(`s`.`id` = `cb`.`saleFk`)) join `item` `i` on(`i`.`id` = `s`.`itemFk`)) join `itemType` `it` on(`it`.`id` = `i`.`typeFk`)) where `c`.`created` >= curdate() + interval -1 week group by `s`.`itemFk` having `claimedAmount` > 100 and `claimsNumber` > 2 or `claimsNumber` > 4 order by count(0) desc */; +/*!50001 VIEW `lastTopClaims` AS select `s`.`itemFk` AS `itemFk`,`i`.`longName` AS `itemName`,`it`.`name` AS `itemTypeName`,count(0) AS `claimsNumber`,round(sum(((((`cb`.`quantity` * `s`.`price`) * (1 - ((`c`.`responsibility` - 1) / 4))) * (100 - `s`.`discount`)) / 100)),2) AS `claimedAmount`,round(sum((((`cb`.`quantity` * `s`.`price`) * (100 - `s`.`discount`)) / 100)),2) AS `totalAmount` from ((((`claim` `c` join `claimBeginning` `cb` on((`cb`.`claimFk` = `c`.`id`))) join `sale` `s` on((`s`.`id` = `cb`.`saleFk`))) join `item` `i` on((`i`.`id` = `s`.`itemFk`))) join `itemType` `it` on((`it`.`id` = `i`.`typeFk`))) where (`c`.`created` >= (curdate() + interval -(1) week)) group by `s`.`itemFk` having (((`claimedAmount` > 100) and (`claimsNumber` > 2)) or (`claimsNumber` > 4)) order by `claimsNumber` desc */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79756,7 +81544,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `mistake` AS select `wr`.`code` AS `revisador`,`s`.`concept` AS `concept`,`w`.`code` AS `sacador`,`w`.`firstName` AS `firstName`,`w`.`lastName` AS `lastName`,`mt`.`description` AS `description`,cast(`iss`.`created` as date) AS `created`,`w`.`id` AS `workerFk` from (((((`saleMistake` `sm` join `mistakeType` `mt` on(`mt`.`id` = `sm`.`typeFk`)) join `worker` `wr` on(`wr`.`id` = `sm`.`userFk`)) join `sale` `s` on(`s`.`id` = `sm`.`saleFk`)) join `itemShelvingSale` `iss` on(`iss`.`saleFk` = `sm`.`saleFk`)) join `worker` `w` on(`w`.`id` = `iss`.`userFk`)) */; +/*!50001 VIEW `mistake` AS select `wr`.`code` AS `revisador`,`s`.`concept` AS `concept`,`w`.`code` AS `sacador`,`w`.`firstName` AS `firstName`,`w`.`lastName` AS `lastName`,`mt`.`description` AS `description`,cast(`iss`.`created` as date) AS `created`,`w`.`id` AS `workerFk` from (((((`saleMistake` `sm` join `mistakeType` `mt` on((`mt`.`id` = `sm`.`typeFk`))) join `worker` `wr` on((`wr`.`id` = `sm`.`userFk`))) join `sale` `s` on((`s`.`id` = `sm`.`saleFk`))) join `itemShelvingSale` `iss` on((`iss`.`saleFk` = `sm`.`saleFk`))) join `worker` `w` on((`w`.`id` = `iss`.`userFk`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79775,7 +81563,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `mistakeRatio` AS select `wr`.`code` AS `revisador`,`w`.`code` AS `sacador`,`w`.`firstName` AS `firstName`,`w`.`lastName` AS `lastName`,`mt`.`description` AS `description`,cast(`iss`.`created` as date) AS `created`,`w`.`id` AS `workerFk`,`sm`.`saleFk` AS `saleFk` from ((((`itemShelvingSale` `iss` join `worker` `w` on(`w`.`id` = `iss`.`userFk`)) left join `saleMistake` `sm` on(`iss`.`saleFk` = `sm`.`saleFk`)) left join `mistakeType` `mt` on(`mt`.`id` = `sm`.`typeFk`)) left join `worker` `wr` on(`wr`.`id` = `sm`.`userFk`)) */; +/*!50001 VIEW `mistakeRatio` AS select `wr`.`code` AS `revisador`,`w`.`code` AS `sacador`,`w`.`firstName` AS `firstName`,`w`.`lastName` AS `lastName`,`mt`.`description` AS `description`,cast(`iss`.`created` as date) AS `created`,`w`.`id` AS `workerFk`,`sm`.`saleFk` AS `saleFk` from ((((`itemShelvingSale` `iss` join `worker` `w` on((`w`.`id` = `iss`.`userFk`))) left join `saleMistake` `sm` on((`iss`.`saleFk` = `sm`.`saleFk`))) left join `mistakeType` `mt` on((`mt`.`id` = `sm`.`typeFk`))) left join `worker` `wr` on((`wr`.`id` = `sm`.`userFk`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79794,7 +81582,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `newBornSales` AS select `v`.`importe` AS `amount`,`v`.`Id_Cliente` AS `clientFk`,`c`.`salesPersonFk` AS `userFk`,`v`.`fecha` AS `dated`,`cn`.`firstShipped` AS `firstShipped` from ((((`bs`.`clientNewBorn` `cn` join `bs`.`ventas` `v` on(`cn`.`firstShipped` + interval 1 year > `v`.`fecha` and `v`.`Id_Cliente` = `cn`.`clientFk`)) join `vn`.`client` `c` on(`c`.`id` = `v`.`Id_Cliente`)) join `account`.`user` `u` on(`u`.`id` = `c`.`salesPersonFk`)) join `account`.`role` `r` on(`r`.`id` = `u`.`role`)) where `r`.`name` = 'salesPerson' and `u`.`name` not in ('ismaelalcolea','ruben') */; +/*!50001 VIEW `newBornSales` AS select `v`.`importe` AS `amount`,`v`.`Id_Cliente` AS `clientFk`,`c`.`salesPersonFk` AS `userFk`,`v`.`fecha` AS `dated`,`cn`.`firstShipped` AS `firstShipped` from ((((`bs`.`clientNewBorn` `cn` join `bs`.`ventas` `v` on((((`cn`.`firstShipped` + interval 1 year) > `v`.`fecha`) and (`v`.`Id_Cliente` = `cn`.`clientFk`)))) join `vn`.`client` `c` on((`c`.`id` = `v`.`Id_Cliente`))) join `account`.`user` `u` on((`u`.`id` = `c`.`salesPersonFk`))) join `account`.`role` `r` on((`r`.`id` = `u`.`role`))) where ((`r`.`name` = 'salesPerson') and (`u`.`name` not in ('ismaelalcolea','ruben'))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79813,7 +81601,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `newBornSales__` AS select `v`.`importe` AS `amount`,`v`.`Id_Cliente` AS `clientFk`,`c`.`salesPersonFk` AS `userFk`,`v`.`fecha` AS `dated`,`cn`.`firstShipped` AS `firstShipped` from (((`bs`.`clientNewBorn` `cn` join `bs`.`ventas` `v` on(`cn`.`firstShipped` + interval 1 year > `v`.`fecha` and `v`.`Id_Cliente` = `cn`.`clientFk`)) join `vn`.`client` `c` on(`c`.`id` = `v`.`Id_Cliente`)) join `account`.`user` `u` on(`u`.`id` = `c`.`salesPersonFk`)) where `u`.`role` = 18 and `u`.`name` not in ('ismaelalcolea','ruben') */; +/*!50001 VIEW `newBornSales__` AS select `v`.`importe` AS `amount`,`v`.`Id_Cliente` AS `clientFk`,`c`.`salesPersonFk` AS `userFk`,`v`.`fecha` AS `dated`,`cn`.`firstShipped` AS `firstShipped` from (((`bs`.`clientNewBorn` `cn` join `bs`.`ventas` `v` on((((`cn`.`firstShipped` + interval 1 year) > `v`.`fecha`) and (`v`.`Id_Cliente` = `cn`.`clientFk`)))) join `vn`.`client` `c` on((`c`.`id` = `v`.`Id_Cliente`))) join `account`.`user` `u` on((`u`.`id` = `c`.`salesPersonFk`))) where ((`u`.`role` = 18) and (`u`.`name` not in ('ismaelalcolea','ruben'))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79832,7 +81620,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `originL10n` AS select `o`.`id` AS `id`,ifnull(`i`.`name`,`o`.`name`) AS `name` from (`origin` `o` left join `originI18n` `i` on(`i`.`originFk` = `o`.`id` and `i`.`lang` = `util`.`lang`())) */; +/*!50001 VIEW `originL10n` AS select `o`.`id` AS `id`,ifnull(`i`.`name`,`o`.`name`) AS `name` from (`origin` `o` left join `originI18n` `i` on(((`i`.`originFk` = `o`.`id`) and (`i`.`lang` = `util`.`lang`())))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79851,7 +81639,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `packageEquivalentItem` AS select `i`.`itemFk` AS `itemFk`,`ie`.`itemFk` AS `equivalentFk` from ((`packageEquivalent` `pe` join `packaging` `i` on(`i`.`id` = `pe`.`packageFk`)) join `packaging` `ie` on(`ie`.`id` = `pe`.`equivalentFk`)) */; +/*!50001 VIEW `packageEquivalentItem` AS select `i`.`itemFk` AS `itemFk`,`ie`.`itemFk` AS `equivalentFk` from ((`packageEquivalent` `pe` join `packaging` `i` on((`i`.`id` = `pe`.`packageFk`))) join `packaging` `ie` on((`ie`.`id` = `pe`.`equivalentFk`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79889,7 +81677,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `personMedia` AS select `p`.`id_trabajador` AS `workerFk`,`m`.`value` AS `mediaValue` from ((((`postgresql`.`person` `p` join `postgresql`.`profile` `po` on(`po`.`person_id` = `p`.`person_id`)) join `postgresql`.`profile_media` `pom` on(`pom`.`profile_id` = `po`.`profile_id`)) join `postgresql`.`media` `m` on(`m`.`media_id` = `pom`.`media_id`)) join `postgresql`.`media_type` `mt` on(`mt`.`media_type_id` = `m`.`media_type_id`)) where `mt`.`name` = 'movil personal' */; +/*!50001 VIEW `personMedia` AS select `p`.`id_trabajador` AS `workerFk`,`m`.`value` AS `mediaValue` from ((((`postgresql`.`person` `p` join `postgresql`.`profile` `po` on((`po`.`person_id` = `p`.`person_id`))) join `postgresql`.`profile_media` `pom` on((`pom`.`profile_id` = `po`.`profile_id`))) join `postgresql`.`media` `m` on((`m`.`media_id` = `pom`.`media_id`))) join `postgresql`.`media_type` `mt` on((`mt`.`media_type_id` = `m`.`media_type_id`))) where (`mt`.`name` = 'movil personal') */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79908,7 +81696,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `productionVolume` AS select hour(`e`.`created`) AS `hora`,minute(`e`.`created`) AS `minuto`,ifnull(`p`.`volume`,ifnull(`p`.`width` * `p`.`height` * `p`.`depth`,94500)) AS `cm3`,`t`.`warehouseFk` AS `warehouseFk`,`e`.`created` AS `created` from (((`expedition` `e` left join `packaging` `p` on(`p`.`itemFk` = `e`.`itemFk`)) join `ticket` `t` on(`t`.`id` = `e`.`ticketFk`)) join `client` `c` on(`c`.`id` = `t`.`clientFk`)) where `e`.`created` between curdate() and `util`.`dayend`(curdate()) and `c`.`isRelevant` <> 0 */; +/*!50001 VIEW `productionVolume` AS select hour(`e`.`created`) AS `hora`,minute(`e`.`created`) AS `minuto`,ifnull(`p`.`volume`,ifnull(((`p`.`width` * `p`.`height`) * `p`.`depth`),94500)) AS `cm3`,`t`.`warehouseFk` AS `warehouseFk`,`e`.`created` AS `created` from (((`expedition` `e` left join `packaging` `p` on((`p`.`itemFk` = `e`.`itemFk`))) join `ticket` `t` on((`t`.`id` = `e`.`ticketFk`))) join `client` `c` on((`c`.`id` = `t`.`clientFk`))) where ((`e`.`created` between curdate() and `util`.`dayend`(curdate())) and `c`.`isRelevant`) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79927,7 +81715,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `productionVolume_LastHour` AS select cast(sum(`productionVolume`.`cm3` / 1000000) as decimal(10,0)) AS `m3`,`productionVolume`.`warehouseFk` AS `warehouseFk` from `productionVolume` where `productionVolume`.`created` > current_timestamp() + interval -1 hour and `productionVolume`.`warehouseFk` in (1,44,60) group by `productionVolume`.`warehouseFk` */; +/*!50001 VIEW `productionVolume_LastHour` AS select cast(sum((`productionVolume`.`cm3` / 1000000)) as decimal(10,0)) AS `m3`,`productionVolume`.`warehouseFk` AS `warehouseFk` from `productionVolume` where ((`productionVolume`.`created` > (now() + interval -(1) hour)) and (`productionVolume`.`warehouseFk` in (1,44,60))) group by `productionVolume`.`warehouseFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79946,7 +81734,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `rankingNewBornByQuarter__` AS select sum(`v`.`importe`) AS `total`,`u`.`name` AS `name`,current_timestamp() AS `time_sec`,`u`.`id` AS `userFk` from (((`bs`.`clientNewBorn` `cn` join `bs`.`ventas` `v` on(`cn`.`firstShipped` + interval 1 year > `v`.`fecha` and `v`.`Id_Cliente` = `cn`.`clientFk`)) join `vn`.`client` `c` on(`c`.`id` = `v`.`Id_Cliente`)) join `account`.`user` `u` on(`u`.`id` = `c`.`salesPersonFk`)) where `v`.`fecha` >= '2020-07-01' and `cn`.`firstShipped` >= '2019-07-01' and `u`.`role` = 18 and `u`.`name` not in ('ismaelalcolea','ruben') group by `u`.`id` order by sum(`v`.`importe`) desc limit 20 */; +/*!50001 VIEW `rankingNewBornByQuarter__` AS select sum(`v`.`importe`) AS `total`,`u`.`name` AS `name`,now() AS `time_sec`,`u`.`id` AS `userFk` from (((`bs`.`clientNewBorn` `cn` join `bs`.`ventas` `v` on((((`cn`.`firstShipped` + interval 1 year) > `v`.`fecha`) and (`v`.`Id_Cliente` = `cn`.`clientFk`)))) join `vn`.`client` `c` on((`c`.`id` = `v`.`Id_Cliente`))) join `account`.`user` `u` on((`u`.`id` = `c`.`salesPersonFk`))) where ((`v`.`fecha` >= '2020-07-01') and (`cn`.`firstShipped` >= '2019-07-01') and (`u`.`role` = 18) and (`u`.`name` not in ('ismaelalcolea','ruben'))) group by `u`.`id` order by sum(`v`.`importe`) desc limit 20 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -79965,7 +81753,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `rankingSellingByQuarter__` AS select sum(`v`.`importe`) AS `importe`,`u`.`name` AS `name`,`u`.`id` AS `userFk`,current_timestamp() AS `time_sec` from (`bs`.`vendedores` `v` join `account`.`user` `u` on(`u`.`id` = `v`.`Id_Trabajador`)) where `v`.`año` = year(curdate()) and quarter(concat(year(curdate()),'-',`v`.`mes`,'-01')) = quarter(curdate()) and `u`.`name` not in ('ismaelalcolea','ruben') group by `v`.`Id_Trabajador` order by sum(`v`.`importe`) desc limit 15 */; +/*!50001 VIEW `rankingSellingByQuarter__` AS select sum(`v`.`importe`) AS `importe`,`u`.`name` AS `name`,`u`.`id` AS `userFk`,now() AS `time_sec` from (`bs`.`vendedores` `v` join `account`.`user` `u` on((`u`.`id` = `v`.`Id_Trabajador`))) where ((`v`.`año` = year(curdate())) and (quarter(concat(year(curdate()),'-',`v`.`mes`,'-01')) = quarter(curdate())) and (`u`.`name` not in ('ismaelalcolea','ruben'))) group by `v`.`Id_Trabajador` order by sum(`v`.`importe`) desc limit 15 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80041,7 +81829,7 @@ USE `vn`; /*!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 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 */; @@ -80060,7 +81848,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleMistakeList` AS select `st`.`saleFk` AS `saleFk`,`st`.`workerFk` AS `workerFk`,concat(`w2`.`firstName`,' ',`w2`.`lastName`) AS `sacador`,`st`.`created` AS `created`,concat(`w`.`firstName`,' ',`w`.`lastName`) AS `revisador`,`mt`.`description` AS `description`,`sm`.`created` AS `controlled` from (((((`vn`.`saleTracking` `st` join `vn`.`worker` `w2` on(`w2`.`id` = `st`.`workerFk`)) join `vncontrol`.`accion` `a` on(`a`.`accion_id` = `st`.`actionFk` and `a`.`accion` = 'SACAR')) left join `vn`.`saleMistake` `sm` on(`st`.`saleFk` = `sm`.`saleFk`)) left join `vn`.`mistakeType` `mt` on(`mt`.`id` = `sm`.`typeFk`)) left join `vn`.`worker` `w` on(`w`.`id` = `sm`.`userFk`)) */; +/*!50001 VIEW `saleMistakeList` AS select `st`.`saleFk` AS `saleFk`,`st`.`workerFk` AS `workerFk`,concat(`w2`.`firstName`,' ',`w2`.`lastName`) AS `sacador`,`st`.`created` AS `created`,concat(`w`.`firstName`,' ',`w`.`lastName`) AS `revisador`,`mt`.`description` AS `description`,`sm`.`created` AS `controlled` from (((((`vn`.`saleTracking` `st` join `vn`.`worker` `w2` on((`w2`.`id` = `st`.`workerFk`))) join `vncontrol`.`accion` `a` on(((`a`.`accion_id` = `st`.`actionFk`) and (`a`.`accion` = 'SACAR')))) left join `vn`.`saleMistake` `sm` on((`st`.`saleFk` = `sm`.`saleFk`))) left join `vn`.`mistakeType` `mt` on((`mt`.`id` = `sm`.`typeFk`))) left join `vn`.`worker` `w` on((`w`.`id` = `sm`.`userFk`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80078,8 +81866,8 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`z-developer`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleMistake_list__` AS select `st`.`saleFk` AS `saleFk`,concat(`w2`.`firstName`,' ',`w2`.`lastName`) AS `sacador`,`st`.`created` AS `created`,concat(`w`.`firstName`,' ',`w`.`lastName`) AS `revisador`,`mt`.`description` AS `description`,`sm`.`created` AS `controlled` from (((((`vn`.`saleTracking` `st` join `vn`.`worker` `w2` on(`w2`.`id` = `st`.`workerFk`)) join `vncontrol`.`accion` `a` on(`a`.`accion_id` = `st`.`actionFk` and `a`.`accion` = 'SACAR')) left join `vn`.`saleMistake` `sm` on(`st`.`saleFk` = `sm`.`saleFk`)) left join `vn`.`mistakeType` `mt` on(`mt`.`id` = `sm`.`typeFk`)) left join `vn`.`worker` `w` on(`w`.`id` = `sm`.`userFk`)) where `st`.`created` > '2020-10-01' */; +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `saleMistake_list__` AS select `st`.`saleFk` AS `saleFk`,concat(`w2`.`firstName`,' ',`w2`.`lastName`) AS `sacador`,`st`.`created` AS `created`,concat(`w`.`firstName`,' ',`w`.`lastName`) AS `revisador`,`mt`.`description` AS `description`,`sm`.`created` AS `controlled` from (((((`vn`.`saleTracking` `st` join `vn`.`worker` `w2` on((`w2`.`id` = `st`.`workerFk`))) join `vncontrol`.`accion` `a` on(((`a`.`accion_id` = `st`.`actionFk`) and (`a`.`accion` = 'SACAR')))) left join `vn`.`saleMistake` `sm` on((`st`.`saleFk` = `sm`.`saleFk`))) left join `vn`.`mistakeType` `mt` on((`mt`.`id` = `sm`.`typeFk`))) left join `vn`.`worker` `w` on((`w`.`id` = `sm`.`userFk`))) where (`st`.`created` > '2020-10-01') */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80098,7 +81886,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleMistake_list__2` AS select `st`.`saleFk` AS `saleFk`,`st`.`workerFk` AS `workerFk`,concat(`w2`.`firstName`,' ',`w2`.`lastName`) AS `sacador`,`st`.`created` AS `created`,concat(`w`.`firstName`,' ',`w`.`lastName`) AS `revisador`,`mt`.`description` AS `description`,`sm`.`created` AS `controlled` from (((((`vn`.`saleTracking` `st` join `vn`.`worker` `w2` on(`w2`.`id` = `st`.`workerFk`)) join `vncontrol`.`accion` `a` on(`a`.`accion_id` = `st`.`actionFk` and `a`.`accion` = 'SACAR')) left join `vn`.`saleMistake` `sm` on(`st`.`saleFk` = `sm`.`saleFk`)) left join `vn`.`mistakeType` `mt` on(`mt`.`id` = `sm`.`typeFk`)) left join `vn`.`worker` `w` on(`w`.`id` = `sm`.`userFk`)) */; +/*!50001 VIEW `saleMistake_list__2` AS select `st`.`saleFk` AS `saleFk`,`st`.`workerFk` AS `workerFk`,concat(`w2`.`firstName`,' ',`w2`.`lastName`) AS `sacador`,`st`.`created` AS `created`,concat(`w`.`firstName`,' ',`w`.`lastName`) AS `revisador`,`mt`.`description` AS `description`,`sm`.`created` AS `controlled` from (((((`vn`.`saleTracking` `st` join `vn`.`worker` `w2` on((`w2`.`id` = `st`.`workerFk`))) join `vncontrol`.`accion` `a` on(((`a`.`accion_id` = `st`.`actionFk`) and (`a`.`accion` = 'SACAR')))) left join `vn`.`saleMistake` `sm` on((`st`.`saleFk` = `sm`.`saleFk`))) left join `vn`.`mistakeType` `mt` on((`mt`.`id` = `sm`.`typeFk`))) left join `vn`.`worker` `w` on((`w`.`id` = `sm`.`userFk`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80117,7 +81905,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleValue` AS select `wh`.`name` AS `warehouse`,`c`.`name` AS `client`,`c`.`typeFk` AS `clientTypeFk`,`u`.`name` AS `buyer`,`it`.`name` AS `family`,`s`.`itemFk` AS `itemFk`,`s`.`concept` AS `concept`,`s`.`quantity` AS `quantity`,`b`.`buyingValue` + `b`.`freightValue` + `b`.`comissionValue` + `b`.`packageValue` AS `cost`,(`b`.`buyingValue` + `b`.`freightValue` + `b`.`comissionValue` + `b`.`packageValue`) * `s`.`quantity` AS `value`,`tm`.`year` AS `year`,`tm`.`week` AS `week` from (((((((((`vn`.`sale` `s` join `vn`.`item` `i` on(`i`.`id` = `s`.`itemFk`)) join `vn`.`itemType` `it` on(`it`.`id` = `i`.`typeFk`)) join `account`.`user` `u` on(`u`.`id` = `it`.`workerFk`)) join `vn`.`ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) join `vn`.`client` `c` on(`c`.`id` = `t`.`clientFk`)) join `vn`.`warehouse` `wh` on(`wh`.`id` = `t`.`warehouseFk`)) join `vn`.`time` `tm` on(`tm`.`dated` = cast(`t`.`shipped` as date))) join `cache`.`last_buy` `lb` on(`lb`.`item_id` = `i`.`id` and `lb`.`warehouse_id` = `wh`.`id`)) join `vn`.`buy` `b` on(`b`.`id` = `lb`.`buy_id`)) where `wh`.`isManaged` <> 0 */; +/*!50001 VIEW `saleValue` AS select `wh`.`name` AS `warehouse`,`c`.`name` AS `client`,`c`.`typeFk` AS `clientTypeFk`,`u`.`name` AS `buyer`,`it`.`name` AS `family`,`s`.`itemFk` AS `itemFk`,`s`.`concept` AS `concept`,`s`.`quantity` AS `quantity`,(((`b`.`buyingValue` + `b`.`freightValue`) + `b`.`comissionValue`) + `b`.`packageValue`) AS `cost`,((((`b`.`buyingValue` + `b`.`freightValue`) + `b`.`comissionValue`) + `b`.`packageValue`) * `s`.`quantity`) AS `value`,`tm`.`year` AS `year`,`tm`.`week` AS `week` from (((((((((`vn`.`sale` `s` join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`itemType` `it` on((`it`.`id` = `i`.`typeFk`))) join `account`.`user` `u` on((`u`.`id` = `it`.`workerFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`client` `c` on((`c`.`id` = `t`.`clientFk`))) join `vn`.`warehouse` `wh` on((`wh`.`id` = `t`.`warehouseFk`))) join `vn`.`time` `tm` on((`tm`.`dated` = cast(`t`.`shipped` as date)))) join `cache`.`last_buy` `lb` on(((`lb`.`item_id` = `i`.`id`) and (`lb`.`warehouse_id` = `wh`.`id`)))) join `vn`.`buy` `b` on((`b`.`id` = `lb`.`buy_id`))) where `wh`.`isManaged` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80136,7 +81924,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleVolume` AS select `s`.`ticketFk` AS `ticketFk`,`s`.`id` AS `saleFk`,round(`ic`.`cm3delivery` * `s`.`quantity` / 1000,0) AS `litros`,`t`.`routeFk` AS `routeFk`,`t`.`shipped` AS `shipped`,`t`.`landed` AS `landed`,`s`.`quantity` * `ic`.`cm3delivery` / 1000000 AS `volume`,`s`.`quantity` * `ic`.`grams` / 1000 AS `physicalWeight`,`s`.`quantity` * `ic`.`cm3delivery` * greatest(`i`.`density`,167) / 1000000 AS `weight`,`s`.`quantity` * `ic`.`cm3delivery` / 1000000 AS `physicalVolume`,`s`.`quantity` * `ic`.`cm3delivery` * ifnull(`t`.`zonePrice`,`z`.`price`) / `cb`.`volume` AS `freight`,`t`.`zoneFk` AS `zoneFk`,`t`.`clientFk` AS `clientFk`,`s`.`isPicked` AS `isPicked` from (((((`sale` `s` join `item` `i` on(`i`.`id` = `s`.`itemFk`)) join `ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) join `zone` `z` on(`z`.`id` = `t`.`zoneFk`)) join `packaging` `cb` on(`cb`.`id` = '94')) join `itemCost` `ic` on(`ic`.`itemFk` = `s`.`itemFk` and `ic`.`warehouseFk` = `t`.`warehouseFk`)) */; +/*!50001 VIEW `saleVolume` AS select `s`.`ticketFk` AS `ticketFk`,`s`.`id` AS `saleFk`,round(((`ic`.`cm3delivery` * `s`.`quantity`) / 1000),0) AS `litros`,`t`.`routeFk` AS `routeFk`,`t`.`shipped` AS `shipped`,`t`.`landed` AS `landed`,((`s`.`quantity` * `ic`.`cm3delivery`) / 1000000) AS `volume`,((`s`.`quantity` * `ic`.`grams`) / 1000) AS `physicalWeight`,(((`s`.`quantity` * `ic`.`cm3delivery`) * greatest(`i`.`density`,167)) / 1000000) AS `weight`,((`s`.`quantity` * `ic`.`cm3delivery`) / 1000000) AS `physicalVolume`,(((`s`.`quantity` * `ic`.`cm3delivery`) * ifnull(`t`.`zonePrice`,`z`.`price`)) / `cb`.`volume`) AS `freight`,`t`.`zoneFk` AS `zoneFk`,`t`.`clientFk` AS `clientFk`,`s`.`isPicked` AS `isPicked` from (((((`sale` `s` join `item` `i` on((`i`.`id` = `s`.`itemFk`))) join `ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `zone` `z` on((`z`.`id` = `t`.`zoneFk`))) join `packaging` `cb` on((`cb`.`id` = '94'))) join `itemCost` `ic` on(((`ic`.`itemFk` = `s`.`itemFk`) and (`ic`.`warehouseFk` = `t`.`warehouseFk`)))) where (`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 */; @@ -80154,8 +81942,8 @@ USE `vn`; /*!50001 SET character_set_results = utf8 */; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`z-developer`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleVolume_Today_VNH` AS select `t`.`nickname` AS `Cliente`,`p`.`name` AS `Provincia`,`c`.`country` AS `Pais`,cast(sum(`sv`.`volume`) as decimal(5,1)) AS `volume` from (((((`saleVolume` `sv` join `ticket` `t` on(`t`.`id` = `sv`.`ticketFk`)) join `address` `a` on(`a`.`id` = `t`.`addressFk`)) join `province` `p` on(`p`.`id` = `a`.`provinceFk`)) join `country` `c` on(`c`.`id` = `p`.`countryFk`)) join `warehouse` `w` on(`w`.`id` = `t`.`warehouseFk`)) where `w`.`name` = 'VNH' and `t`.`shipped` between curdate() and `util`.`dayend`(curdate()) group by `t`.`nickname`,`p`.`name` */; +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `saleVolume_Today_VNH` AS select `t`.`nickname` AS `Cliente`,`p`.`name` AS `Provincia`,`c`.`country` AS `Pais`,cast(sum(`sv`.`volume`) as decimal(5,1)) AS `volume` from (((((`saleVolume` `sv` join `ticket` `t` on((`t`.`id` = `sv`.`ticketFk`))) join `address` `a` on((`a`.`id` = `t`.`addressFk`))) join `province` `p` on((`p`.`id` = `a`.`provinceFk`))) join `country` `c` on((`c`.`id` = `p`.`countryFk`))) join `warehouse` `w` on((`w`.`id` = `t`.`warehouseFk`))) where ((`w`.`name` = 'VNH') and (`t`.`shipped` between curdate() and `util`.`dayend`(curdate()))) group by `t`.`nickname`,`p`.`name` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80174,7 +81962,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `sale_freightComponent` AS select `t`.`id` AS `ticketFk`,`sc`.`value` * `s`.`quantity` AS `amount`,`t`.`shipped` AS `shipped` from ((((`ticket` `t` straight_join `sale` `s` on(`t`.`id` = `s`.`ticketFk`)) join `saleComponent` `sc` on(`sc`.`saleFk` = `s`.`id`)) join `component` `c` on(`c`.`id` = `sc`.`componentFk`)) join `componentType` `ct` on(`ct`.`id` = `c`.`typeFk` and `ct`.`type` = 'agencia')) */; +/*!50001 VIEW `sale_freightComponent` AS select `t`.`id` AS `ticketFk`,(`sc`.`value` * `s`.`quantity`) AS `amount`,`t`.`shipped` AS `shipped` from ((((`ticket` `t` straight_join `sale` `s` on((`t`.`id` = `s`.`ticketFk`))) join `saleComponent` `sc` on((`sc`.`saleFk` = `s`.`id`))) join `component` `c` on((`c`.`id` = `sc`.`componentFk`))) join `componentType` `ct` on(((`ct`.`id` = `c`.`typeFk`) and (`ct`.`type` = 'agencia')))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80193,7 +81981,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `salesPersonSince` AS select `p`.`id_trabajador` AS `workerFk`,min(`b`.`date_start`) AS `started` from ((((`postgresql`.`person` `p` join `postgresql`.`profile` `pr` on(`pr`.`person_id` = `p`.`person_id`)) left join `postgresql`.`business` `b` on(`pr`.`profile_id` = `b`.`client_id`)) left join `postgresql`.`business_labour` `bl` on(`b`.`business_id` = `bl`.`business_id`)) join `postgresql`.`professional_category` `pc` on(`pc`.`professional_category_id` = `bl`.`professional_category_id`)) where `pc`.`category_name` = 'Aux ventas' group by `p`.`id_trabajador` */; +/*!50001 VIEW `salesPersonSince` AS select `p`.`id_trabajador` AS `workerFk`,min(`b`.`date_start`) AS `started` from ((((`postgresql`.`person` `p` join `postgresql`.`profile` `pr` on((`pr`.`person_id` = `p`.`person_id`))) left join `postgresql`.`business` `b` on((`pr`.`profile_id` = `b`.`client_id`))) left join `postgresql`.`business_labour` `bl` on((`b`.`business_id` = `bl`.`business_id`))) join `postgresql`.`professional_category` `pc` on((`pc`.`professional_category_id` = `bl`.`professional_category_id`))) where (`pc`.`category_name` = 'Aux ventas') group by `p`.`id_trabajador` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80212,7 +82000,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `salesPreparedLastHour` AS select `t`.`warehouseFk` AS `warehouseFk`,`st`.`saleFk` AS `saleFk`,`st`.`isChecked` AS `isChecked`,`st`.`originalQuantity` AS `originalQuantity`,`a`.`accion` AS `accion`,`st`.`created` AS `created`,`e`.`code` AS `code`,`w`.`firstName` AS `firstname`,`w`.`lastName` AS `lastName`,`w`.`code` AS `workerCode`,`ic`.`cm3delivery` * `s`.`quantity` / 1000 AS `litros`,`s`.`concept` AS `concept`,`d`.`name` AS `departmentName` from (((((((((`vn`.`saleTracking` `st` left join `vn`.`salesPreviousPreparated` `prevPrepSales` on(`prevPrepSales`.`saleFk` = `st`.`saleFk`)) join `vn`.`sale` `s` on(`s`.`id` = `st`.`saleFk`)) join `vn`.`ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) join `vn`.`itemCost` `ic` on(`ic`.`warehouseFk` = `t`.`warehouseFk` and `ic`.`itemFk` = `s`.`itemFk`)) join `vn`.`worker` `w` on(`w`.`id` = `st`.`workerFk`)) join `vn`.`state` `e` on(`e`.`id` = `st`.`stateFk`)) join `vncontrol`.`accion` `a` on(`a`.`accion_id` = `st`.`actionFk`)) join `vn`.`workerDepartment` `wd` on(`wd`.`workerFk` = `st`.`workerFk`)) join `vn`.`department` `d` on(`d`.`id` = `wd`.`departmentFk`)) where `st`.`created` > current_timestamp() + interval -1 hour and `prevPrepSales`.`saleFk` is null and `d`.`name` not like 'EQUIPO%' */; +/*!50001 VIEW `salesPreparedLastHour` AS select `t`.`warehouseFk` AS `warehouseFk`,`st`.`saleFk` AS `saleFk`,`st`.`isChecked` AS `isChecked`,`st`.`originalQuantity` AS `originalQuantity`,`a`.`accion` AS `accion`,`st`.`created` AS `created`,`e`.`code` AS `code`,`w`.`firstName` AS `firstname`,`w`.`lastName` AS `lastName`,`w`.`code` AS `workerCode`,((`ic`.`cm3delivery` * `s`.`quantity`) / 1000) AS `litros`,`s`.`concept` AS `concept`,`d`.`name` AS `departmentName` from (((((((((`vn`.`saleTracking` `st` left join `vn`.`salesPreviousPreparated` `prevPrepSales` on((`prevPrepSales`.`saleFk` = `st`.`saleFk`))) join `vn`.`sale` `s` on((`s`.`id` = `st`.`saleFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`itemCost` `ic` on(((`ic`.`warehouseFk` = `t`.`warehouseFk`) and (`ic`.`itemFk` = `s`.`itemFk`)))) join `vn`.`worker` `w` on((`w`.`id` = `st`.`workerFk`))) join `vn`.`state` `e` on((`e`.`id` = `st`.`stateFk`))) join `vncontrol`.`accion` `a` on((`a`.`accion_id` = `st`.`actionFk`))) join `vn`.`workerDepartment` `wd` on((`wd`.`workerFk` = `st`.`workerFk`))) join `vn`.`department` `d` on((`d`.`id` = `wd`.`departmentFk`))) where ((`st`.`created` > (now() + interval -(1) hour)) and isnull(`prevPrepSales`.`saleFk`) and (not((`d`.`name` like 'EQUIPO%')))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80231,7 +82019,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `salesPreviousPreparated` AS select `st`.`saleFk` AS `saleFk` from (`saleTracking` `st` join `state` `e` on(`e`.`id` = `st`.`stateFk`)) where `st`.`created` > curdate() and `e`.`code` like 'PREVIOUS_PREPARATION' */; +/*!50001 VIEW `salesPreviousPreparated` AS select `st`.`saleFk` AS `saleFk` from (`saleTracking` `st` join `state` `e` on((`e`.`id` = `st`.`stateFk`))) where ((`st`.`created` > curdate()) and (`e`.`code` like 'PREVIOUS_PREPARATION')) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80250,7 +82038,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `supplierPackaging` AS select `e`.`supplierFk` AS `supplierFk`,`b`.`itemFk` AS `itemFk`,`i`.`longName` AS `longName`,`s`.`name` AS `supplier`,`b`.`entryFk` AS `entryFk`,`tr`.`landed` AS `landed`,-least(`b`.`quantity`,0) AS `out`,greatest(`b`.`quantity`,0) AS `in`,`w`.`name` AS `almacen` from ((((((`buy` `b` join `item` `i` on(`i`.`id` = `b`.`itemFk`)) join `packaging` `p` on(`p`.`itemFk` = `i`.`id`)) join `entry` `e` on(`e`.`id` = `b`.`entryFk`)) join `supplier` `s` on(`s`.`id` = `e`.`supplierFk`)) join `travel` `tr` on(`tr`.`id` = `e`.`travelFk`)) join `warehouse` `w` on(`w`.`id` = `tr`.`warehouseInFk`)) where `p`.`isPackageReturnable` <> 0 */; +/*!50001 VIEW `supplierPackaging` AS select `e`.`supplierFk` AS `supplierFk`,`b`.`itemFk` AS `itemFk`,`i`.`longName` AS `longName`,`s`.`name` AS `supplier`,`b`.`entryFk` AS `entryFk`,`tr`.`landed` AS `landed`,-(least(`b`.`quantity`,0)) AS `out`,greatest(`b`.`quantity`,0) AS `in`,`w`.`name` AS `almacen` from ((((((`buy` `b` join `item` `i` on((`i`.`id` = `b`.`itemFk`))) join `packaging` `p` on((`p`.`itemFk` = `i`.`id`))) join `entry` `e` on((`e`.`id` = `b`.`entryFk`))) join `supplier` `s` on((`s`.`id` = `e`.`supplierFk`))) join `travel` `tr` on((`tr`.`id` = `e`.`travelFk`))) join `warehouse` `w` on((`w`.`id` = `tr`.`warehouseInFk`))) where `p`.`isPackageReturnable` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80269,7 +82057,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `tagL10n` AS select `t`.`id` AS `id`,ifnull(`i`.`name`,`t`.`name`) AS `name` from (`tag` `t` left join `tagI18n` `i` on(`i`.`tagFk` = `t`.`id` and `i`.`lang` = `util`.`LANG`())) */; +/*!50001 VIEW `tagL10n` AS select `t`.`id` AS `id`,ifnull(`i`.`name`,`t`.`name`) AS `name` from (`tag` `t` left join `tagI18n` `i` on(((`i`.`tagFk` = `t`.`id`) and (`i`.`lang` = `util`.`LANG`())))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80288,7 +82076,45 @@ USE `vn`; /*!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 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 `ticketLastUpdated` +-- + +/*!50001 DROP TABLE IF EXISTS `ticketLastUpdated`*/; +/*!50001 DROP VIEW IF EXISTS `ticketLastUpdated`*/; +/*!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 `ticketLastUpdated` AS select `ticketLastUpdatedList`.`ticketFk` AS `ticketFk`,max(`ticketLastUpdatedList`.`created`) AS `lastUpdated` from `vn`.`ticketLastUpdatedList` group by `ticketLastUpdatedList`.`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 `ticketLastUpdatedList` +-- + +/*!50001 DROP TABLE IF EXISTS `ticketLastUpdatedList`*/; +/*!50001 DROP VIEW IF EXISTS `ticketLastUpdatedList`*/; +/*!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 `ticketLastUpdatedList` AS select `s`.`ticketFk` AS `ticketFk`,`st`.`created` AS `created` from (`vn`.`saleTracking` `st` join `vn`.`sale` `s` on((`s`.`id` = `st`.`saleFk`))) where (`st`.`created` > curdate()) union all select `i`.`Id_Ticket` AS `Id_Ticket`,`i`.`odbc_date` AS `odbc_date` from `vncontrol`.`inter` `i` where (`i`.`odbc_date` > curdate()) union all select `s`.`ticketFk` AS `ticketFk`,`iss`.`created` AS `created` from (`vn`.`itemShelvingSale` `iss` join `vn`.`sale` `s` on((`s`.`id` = `iss`.`saleFk`))) where (`iss`.`created` > curdate()) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80307,7 +82133,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketNotInvoiced` AS select `t`.`companyFk` AS `companyFk`,`cm`.`code` AS `companyCode`,`t`.`clientFk` AS `clientFk`,`c`.`name` AS `clientName`,`t`.`shipped` AS `shipped`,cast(sum(`s`.`quantity` * `s`.`price` * (100 - `s`.`discount`) / 100) as decimal(10,2)) AS `value` from (((`ticket` `t` join `sale` `s` on(`s`.`ticketFk` = `t`.`id`)) join `client` `c` on(`c`.`id` = `t`.`clientFk`)) join `company` `cm` on(`cm`.`id` = `t`.`companyFk`)) where `t`.`refFk` is null and `t`.`shipped` > '2017-01-01' group by `t`.`id` */; +/*!50001 VIEW `ticketNotInvoiced` AS select `t`.`companyFk` AS `companyFk`,`cm`.`code` AS `companyCode`,`t`.`clientFk` AS `clientFk`,`c`.`name` AS `clientName`,`t`.`shipped` AS `shipped`,cast(sum((((`s`.`quantity` * `s`.`price`) * (100 - `s`.`discount`)) / 100)) as decimal(10,2)) AS `value` from (((`ticket` `t` join `sale` `s` on((`s`.`ticketFk` = `t`.`id`))) join `client` `c` on((`c`.`id` = `t`.`clientFk`))) join `company` `cm` on((`cm`.`id` = `t`.`companyFk`))) where (isnull(`t`.`refFk`) and (`t`.`shipped` > '2017-01-01')) group by `t`.`id` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80326,7 +82152,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketPreviousPreparingList` AS select `t`.`id` AS `ticketFk`,`w`.`code` AS `code`,count(`st`.`id`) AS `saleLines`,sum(`st`.`isChecked` <> 0) AS `alreadyMadeSaleLines`,sum(`st`.`isChecked` <> 0) / count(`st`.`id`) AS `madeRate`,`st`.`created` AS `created`,`i`.`sectorFk` AS `sectorFk`,`p`.`code` AS `parking` from (((((((`ticket` `t` join `sale` `s` on(`s`.`ticketFk` = `t`.`id`)) join `item` `i` on(`i`.`id` = `s`.`itemFk`)) join `saleTracking` `st` on(`st`.`saleFk` = `s`.`id`)) join `state` on(`state`.`id` = `st`.`stateFk`)) left join `worker` `w` on(`w`.`id` = `st`.`workerFk`)) left join `ticketParking` `tp` on(`tp`.`ticketFk` = `t`.`id`)) left join `parking` `p` on(`p`.`id` = `tp`.`parkingFk`)) where `state`.`code` = 'PREVIOUS_PREPARATION' and `t`.`shipped` >= curdate() + interval -1 day group by `s`.`ticketFk`,`i`.`sectorFk` */; +/*!50001 VIEW `ticketPreviousPreparingList` AS select `t`.`id` AS `ticketFk`,`w`.`code` AS `code`,count(`st`.`id`) AS `saleLines`,sum((`st`.`isChecked` <> 0)) AS `alreadyMadeSaleLines`,(sum((`st`.`isChecked` <> 0)) / count(`st`.`id`)) AS `madeRate`,`st`.`created` AS `created`,`i`.`sectorFk` AS `sectorFk`,`p`.`code` AS `parking` from (((((((`ticket` `t` join `sale` `s` on((`s`.`ticketFk` = `t`.`id`))) join `item` `i` on((`i`.`id` = `s`.`itemFk`))) join `saleTracking` `st` on((`st`.`saleFk` = `s`.`id`))) join `state` on((`state`.`id` = `st`.`stateFk`))) left join `worker` `w` on((`w`.`id` = `st`.`workerFk`))) left join `ticketParking` `tp` on((`tp`.`ticketFk` = `t`.`id`))) left join `parking` `p` on((`p`.`id` = `tp`.`parkingFk`))) where ((`state`.`code` = 'PREVIOUS_PREPARATION') and (`t`.`shipped` >= (curdate() + interval -(1) day))) group by `s`.`ticketFk`,`i`.`sectorFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80345,7 +82171,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketState` AS select `i`.`odbc_date` AS `updated`,`i`.`state_id` AS `stateFk`,`i`.`Id_Trabajador` AS `workerFk`,`tls`.`ticketFk` AS `ticketFk`,`s`.`id` AS `state`,`s`.`order` AS `productionOrder`,`s`.`alertLevel` AS `alertLevel`,`s`.`code` AS `code`,`tls`.`ticketFk` AS `ticket`,`i`.`Id_Trabajador` AS `worker`,`s`.`isPreviousPreparable` AS `isPreviousPreparable`,`s`.`isPicked` AS `isPicked` from ((`vn`.`ticketLastState` `tls` join `vncontrol`.`inter` `i` on(`i`.`inter_id` = `tls`.`ticketTrackingFk`)) join `vn`.`state` `s` on(`s`.`id` = `i`.`state_id`)) */; +/*!50001 VIEW `ticketState` AS select `i`.`odbc_date` AS `updated`,`i`.`state_id` AS `stateFk`,`i`.`Id_Trabajador` AS `workerFk`,`tls`.`ticketFk` AS `ticketFk`,`s`.`id` AS `state`,`s`.`order` AS `productionOrder`,`s`.`alertLevel` AS `alertLevel`,`s`.`code` AS `code`,`tls`.`ticketFk` AS `ticket`,`i`.`Id_Trabajador` AS `worker`,`s`.`isPreviousPreparable` AS `isPreviousPreparable`,`s`.`isPicked` AS `isPicked` from ((`vn`.`ticketLastState` `tls` join `vncontrol`.`inter` `i` on((`i`.`inter_id` = `tls`.`ticketTrackingFk`))) join `vn`.`state` `s` on((`s`.`id` = `i`.`state_id`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80364,7 +82190,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketStateToday` AS select `ts`.`ticket` AS `ticket`,`ts`.`state` AS `state`,`ts`.`productionOrder` AS `productionOrder`,`ts`.`alertLevel` AS `alertLevel`,`ts`.`worker` AS `worker`,`ts`.`code` AS `code`,`ts`.`updated` AS `updated`,`ts`.`isPicked` AS `isPicked` from (`vn`.`ticketState` `ts` join `vn`.`ticket` `t` on(`t`.`id` = `ts`.`ticket`)) where `t`.`shipped` between curdate() and `MIDNIGHT`(curdate()) */; +/*!50001 VIEW `ticketStateToday` AS select `ts`.`ticket` AS `ticket`,`ts`.`state` AS `state`,`ts`.`productionOrder` AS `productionOrder`,`ts`.`alertLevel` AS `alertLevel`,`ts`.`worker` AS `worker`,`ts`.`code` AS `code`,`ts`.`updated` AS `updated`,`ts`.`isPicked` AS `isPicked` from (`vn`.`ticketState` `ts` join `vn`.`ticket` `t` on((`t`.`id` = `ts`.`ticket`))) where (`t`.`shipped` between curdate() and `MIDNIGHT`(curdate())) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80459,7 +82285,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerCalendar` AS select `ce`.`business_id` AS `businessFk`,`p`.`id_trabajador` AS `workerFk`,`ce`.`calendar_state_id` AS `absenceTypeFk`,`ce`.`date` AS `dated` from (((`postgresql`.`person` `p` join `postgresql`.`profile` `pr` on(`pr`.`person_id` = `p`.`person_id`)) join `postgresql`.`business` `b` on(`b`.`client_id` = `pr`.`profile_id`)) join `postgresql`.`calendar_employee` `ce` on(`ce`.`business_id` = `b`.`business_id`)) */; +/*!50001 VIEW `workerCalendar` AS select `ce`.`business_id` AS `businessFk`,`p`.`id_trabajador` AS `workerFk`,`ce`.`calendar_state_id` AS `absenceTypeFk`,`ce`.`date` AS `dated` from (((`postgresql`.`person` `p` join `postgresql`.`profile` `pr` on((`pr`.`person_id` = `p`.`person_id`))) join `postgresql`.`business` `b` on((`b`.`client_id` = `pr`.`profile_id`))) join `postgresql`.`calendar_employee` `ce` on((`ce`.`business_id` = `b`.`business_id`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80478,7 +82304,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerDepartment` AS select `p`.`id_trabajador` AS `workerFk`,`d`.`id` AS `departmentFk` from (((`postgresql`.`person` `p` join `postgresql`.`profile` `pr` on(`pr`.`person_id` = `p`.`person_id`)) left join (`postgresql`.`business` `b` left join `postgresql`.`business_labour` `bl` on(`b`.`business_id` = `bl`.`business_id`)) on(`pr`.`profile_id` = `b`.`client_id`)) join `vn`.`department` `d` on(`d`.`id` = `bl`.`department_id`)) where `b`.`date_end` is null and `b`.`date_start` <= curdate() or `b`.`date_end` >= curdate() and `b`.`date_start` <= curdate() */; +/*!50001 VIEW `workerDepartment` AS select `p`.`id_trabajador` AS `workerFk`,`d`.`id` AS `departmentFk` from (((`postgresql`.`person` `p` join `postgresql`.`profile` `pr` on((`pr`.`person_id` = `p`.`person_id`))) left join (`postgresql`.`business` `b` left join `postgresql`.`business_labour` `bl` on((`b`.`business_id` = `bl`.`business_id`))) on((`pr`.`profile_id` = `b`.`client_id`))) join `vn`.`department` `d` on((`d`.`id` = `bl`.`department_id`))) where ((isnull(`b`.`date_end`) and (`b`.`date_start` <= curdate())) or ((`b`.`date_end` >= curdate()) and (`b`.`date_start` <= curdate()))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80497,7 +82323,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerLabour` AS select `b`.`business_id` AS `businessFk`,`p`.`id_trabajador` AS `workerFk`,`bl`.`workcenter_id` AS `workCenterFk`,`b`.`date_start` AS `started`,`b`.`date_end` AS `ended`,`d`.`id` AS `departmentFk` from ((((`postgresql`.`person` `p` join `postgresql`.`profile` `pr` on(`pr`.`person_id` = `p`.`person_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`)) order by `b`.`date_start` desc */; +/*!50001 VIEW `workerLabour` AS select `b`.`business_id` AS `businessFk`,`p`.`id_trabajador` AS `workerFk`,`bl`.`workcenter_id` AS `workCenterFk`,`b`.`date_start` AS `started`,`b`.`date_end` AS `ended`,`d`.`id` AS `departmentFk` from ((((`postgresql`.`person` `p` join `postgresql`.`profile` `pr` on((`pr`.`person_id` = `p`.`person_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`))) order by `b`.`date_start` desc */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80535,7 +82361,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerMedia` AS select `p`.`id_trabajador` AS `workerFk`,`m`.`value` AS `mediaValue` from ((((`postgresql`.`person` `p` join `postgresql`.`profile` `po` on(`po`.`person_id` = `p`.`person_id`)) join `postgresql`.`profile_media` `pom` on(`pom`.`profile_id` = `po`.`profile_id`)) join `postgresql`.`media` `m` on(`m`.`media_id` = `pom`.`media_id`)) join `postgresql`.`media_type` `mt` on(`mt`.`media_type_id` = `m`.`media_type_id`)) where `mt`.`name` = 'movil empresa' */; +/*!50001 VIEW `workerMedia` AS select `p`.`id_trabajador` AS `workerFk`,`m`.`value` AS `mediaValue` from ((((`postgresql`.`person` `p` join `postgresql`.`profile` `po` on((`po`.`person_id` = `p`.`person_id`))) join `postgresql`.`profile_media` `pom` on((`pom`.`profile_id` = `po`.`profile_id`))) join `postgresql`.`media` `m` on((`m`.`media_id` = `pom`.`media_id`))) join `postgresql`.`media_type` `mt` on((`mt`.`media_type_id` = `m`.`media_type_id`))) where (`mt`.`name` = 'movil empresa') */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80554,7 +82380,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerSpeedExpedition` AS select `sv`.`ticketFk` AS `ticketFk`,sum(`sv`.`litros`) AS `litros`,sum(if(`sub`.`started` > current_timestamp() + interval -1 hour,`sv`.`litros`,0)) AS `literLastHour`,cast(60 * sum(`sv`.`litros`) / time_to_sec(timediff(max(`sub`.`finished`),min(`sub`.`started`))) as decimal(10,1)) AS `litersByMinute`,`sub`.`code` AS `workerCode`,`sub`.`cajas` AS `cajas`,`sub`.`warehouseFk` AS `warehouseFk` from (`saleVolume` `sv` join `expeditionTimeExpended` `sub` on(`sub`.`ticketFk` = `sv`.`ticketFk`)) group by `sub`.`code` */; +/*!50001 VIEW `workerSpeedExpedition` AS select `sv`.`ticketFk` AS `ticketFk`,sum(`sv`.`litros`) AS `litros`,sum(if((`sub`.`started` > (now() + interval -(1) hour)),`sv`.`litros`,0)) AS `literLastHour`,cast(((60 * sum(`sv`.`litros`)) / time_to_sec(timediff(max(`sub`.`finished`),min(`sub`.`started`)))) as decimal(10,1)) AS `litersByMinute`,`sub`.`code` AS `workerCode`,`sub`.`cajas` AS `cajas`,`sub`.`warehouseFk` AS `warehouseFk` from (`saleVolume` `sv` join `expeditionTimeExpended` `sub` on((`sub`.`ticketFk` = `sv`.`ticketFk`))) group by `workerCode` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80573,7 +82399,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerSpeedSaleTracking` AS select `salesPreparedLastHour`.`warehouseFk` AS `warehouseFk`,`salesPreparedLastHour`.`accion` AS `accion`,`salesPreparedLastHour`.`workerCode` AS `workerCode`,sum(`salesPreparedLastHour`.`litros`) AS `sumaLitros`,min(`salesPreparedLastHour`.`created`) AS `started`,max(`salesPreparedLastHour`.`created`) AS `finished`,sum(if(`salesPreparedLastHour`.`created` >= current_timestamp() + interval -1 hour,`salesPreparedLastHour`.`litros`,0)) AS `sumaLitrosLastHour`,cast(60 * sum(`salesPreparedLastHour`.`litros`) / time_to_sec(timediff(max(`salesPreparedLastHour`.`created`),min(`salesPreparedLastHour`.`created`))) as decimal(10,1)) AS `litersByMinute`,`salesPreparedLastHour`.`departmentName` AS `departmentName` from `vn`.`salesPreparedLastHour` group by `salesPreparedLastHour`.`warehouseFk`,`salesPreparedLastHour`.`accion`,`salesPreparedLastHour`.`workerCode` */; +/*!50001 VIEW `workerSpeedSaleTracking` AS select `salesPreparedLastHour`.`warehouseFk` AS `warehouseFk`,`salesPreparedLastHour`.`accion` AS `accion`,`salesPreparedLastHour`.`workerCode` AS `workerCode`,sum(`salesPreparedLastHour`.`litros`) AS `sumaLitros`,min(`salesPreparedLastHour`.`created`) AS `started`,max(`salesPreparedLastHour`.`created`) AS `finished`,sum(if((`salesPreparedLastHour`.`created` >= (now() + interval -(1) hour)),`salesPreparedLastHour`.`litros`,0)) AS `sumaLitrosLastHour`,cast(((60 * sum(`salesPreparedLastHour`.`litros`)) / time_to_sec(timediff(max(`salesPreparedLastHour`.`created`),min(`salesPreparedLastHour`.`created`)))) as decimal(10,1)) AS `litersByMinute`,`salesPreparedLastHour`.`departmentName` AS `departmentName` from `vn`.`salesPreparedLastHour` group by `salesPreparedLastHour`.`warehouseFk`,`salesPreparedLastHour`.`accion`,`salesPreparedLastHour`.`workerCode` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80592,7 +82418,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerTeamCollegues` AS select distinct `w`.`workerFk` AS `workerFk`,`t`.`workerFk` AS `collegueFk` from (`workerTeam` `w` join `workerTeam` `t` on(`w`.`team` = `t`.`team`)) */; +/*!50001 VIEW `workerTeamCollegues` AS select distinct `w`.`workerFk` AS `workerFk`,`t`.`workerFk` AS `collegueFk` from (`workerTeam` `w` join `workerTeam` `t` on((`w`.`team` = `t`.`team`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80611,7 +82437,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerTimeControlUserInfo` AS select `u`.`id` AS `userFk`,`w`.`firstName` AS `name`,`w`.`lastName` AS `surname`,`u`.`name` AS `user`,`u`.`password` AS `password`,`u`.`bcryptPassword` AS `bcryptPassword`,`wd`.`departmentFk` AS `departmentFk`,left(`w`.`fi`,8) AS `dni` from ((`account`.`user` `u` join `vn`.`worker` `w` on(`w`.`userFk` = `u`.`id`)) left join `vn`.`workerDepartment` `wd` on(`wd`.`workerFk` = `w`.`id`)) */; +/*!50001 VIEW `workerTimeControlUserInfo` AS select `u`.`id` AS `userFk`,`w`.`firstName` AS `name`,`w`.`lastName` AS `surname`,`u`.`name` AS `user`,`u`.`password` AS `password`,`u`.`bcryptPassword` AS `bcryptPassword`,`wd`.`departmentFk` AS `departmentFk`,left(`w`.`fi`,8) AS `dni` from ((`account`.`user` `u` join `vn`.`worker` `w` on((`w`.`userFk` = `u`.`id`))) left join `vn`.`workerDepartment` `wd` on((`wd`.`workerFk` = `w`.`id`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80630,7 +82456,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerTimeControlWorking` AS select `wtc`.`userFk` AS `userFk`,`wtc`.`timed` AS `timed`,`w`.`firstName` AS `name`,`w`.`lastName` AS `surname`,`pm`.`mediaValue` AS `phone`,`wm`.`mediaValue` AS `workerPhone`,`d`.`name` AS `department`,`wc`.`name` AS `workerCenter`,count(`wtc`.`order`) AS `maxOrder` from (((((((`vn`.`workerTimeControl` `wtc` join `vn`.`worker` `w` on(`w`.`userFk` = `wtc`.`userFk`)) left join `vn`.`personMedia` `pm` on(`pm`.`workerFk` = `w`.`id`)) left join `vn`.`workerMedia` `wm` on(`wm`.`workerFk` = `w`.`id`)) left join `vn`.`workerDepartment` `wd` on(`wd`.`workerFk` = `w`.`id`)) left join `vn`.`department` `d` on(`d`.`id` = `wd`.`departmentFk`)) left join `vn`.`workerLabour` `wl` on(`wl`.`businessFk` = (select `wl2`.`businessFk` from `vn`.`workerLabour` `wl2` where `wl2`.`workerFk` = `w`.`id` order by `wl2`.`started` desc limit 1))) left join `vn`.`workCenter` `wc` on(`wc`.`id` = `wl`.`workCenterFk`)) where cast(`wtc`.`timed` as date) = curdate() group by `wtc`.`userFk` having `maxOrder` MOD 2 = 1 order by `wtc`.`timed` desc */; +/*!50001 VIEW `workerTimeControlWorking` AS select `wtc`.`userFk` AS `userFk`,`wtc`.`timed` AS `timed`,`w`.`firstName` AS `name`,`w`.`lastName` AS `surname`,`pm`.`mediaValue` AS `phone`,`wm`.`mediaValue` AS `workerPhone`,`d`.`name` AS `department`,`wc`.`name` AS `workerCenter`,count(`wtc`.`order`) AS `maxOrder` from (((((((`vn`.`workerTimeControl` `wtc` join `vn`.`worker` `w` on((`w`.`userFk` = `wtc`.`userFk`))) left join `vn`.`personMedia` `pm` on((`pm`.`workerFk` = `w`.`id`))) left join `vn`.`workerMedia` `wm` on((`wm`.`workerFk` = `w`.`id`))) left join `vn`.`workerDepartment` `wd` on((`wd`.`workerFk` = `w`.`id`))) left join `vn`.`department` `d` on((`d`.`id` = `wd`.`departmentFk`))) left join `vn`.`workerLabour` `wl` on((`wl`.`businessFk` = (select `wl2`.`businessFk` from `vn`.`workerLabour` `wl2` where (`wl2`.`workerFk` = `w`.`id`) order by `wl2`.`started` desc limit 1)))) left join `vn`.`workCenter` `wc` on((`wc`.`id` = `wl`.`workCenterFk`))) where (cast(`wtc`.`timed` as date) = curdate()) group by `wtc`.`userFk` having ((`maxOrder` % 2) = 1) order by `wtc`.`timed` desc */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80649,7 +82475,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerTimeControl_Journey__` AS select `wtc`.`userFk` AS `userFk`,cast(`wtc`.`timed` as date) AS `dated`,cast(sum(if(`wtc`.`order` MOD 2,-1,1) * (hour(`wtc`.`timed`) + minute(`wtc`.`timed`) / 60)) as decimal(10,2)) AS `Journey`,dayname(`wtc`.`timed`) AS `dayName`,`w`.`lastName` AS `name`,`w`.`firstName` AS `firstname` from (`workerTimeControl` `wtc` join `worker` `w` on(`w`.`userFk` = `wtc`.`userFk`)) group by cast(`wtc`.`timed` as date),`wtc`.`userFk` */; +/*!50001 VIEW `workerTimeControl_Journey__` AS select `wtc`.`userFk` AS `userFk`,cast(`wtc`.`timed` as date) AS `dated`,cast(sum((if((`wtc`.`order` % 2),-(1),1) * (hour(`wtc`.`timed`) + (minute(`wtc`.`timed`) / 60)))) as decimal(10,2)) AS `Journey`,dayname(`wtc`.`timed`) AS `dayName`,`w`.`lastName` AS `name`,`w`.`firstName` AS `firstname` from (`workerTimeControl` `wtc` join `worker` `w` on((`w`.`userFk` = `wtc`.`userFk`))) group by cast(`wtc`.`timed` as date),`wtc`.`userFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80668,7 +82494,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerTimeJourneyNG` AS select `wtc`.`userFk` AS `userFk`,cast(`wtc`.`timed` as date) AS `dated`,if(`wtc`.`order` MOD 2,-1,1) * (hour(`wtc`.`timed`) + minute(`wtc`.`timed`) / 60) AS `Journey`,dayname(`wtc`.`timed`) AS `dayName`,`w`.`lastName` AS `name`,`w`.`firstName` AS `firstname` from (`workerTimeControl` `wtc` join `worker` `w` on(`w`.`userFk` = `wtc`.`userFk`)) */; +/*!50001 VIEW `workerTimeJourneyNG` AS select `wtc`.`userFk` AS `userFk`,cast(`wtc`.`timed` as date) AS `dated`,(if((`wtc`.`order` % 2),-(1),1) * (hour(`wtc`.`timed`) + (minute(`wtc`.`timed`) / 60))) AS `Journey`,dayname(`wtc`.`timed`) AS `dayName`,`w`.`lastName` AS `name`,`w`.`firstName` AS `firstname` from (`workerTimeControl` `wtc` join `worker` `w` on((`w`.`userFk` = `wtc`.`userFk`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80687,7 +82513,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `zoneEstimatedDelivery` AS select `t`.`zoneFk` AS `zoneFk`,cast(curdate() + interval hour(`zc`.`hour`) * 60 + minute(`zc`.`hour`) minute as time) AS `hourTheoretical`,cast(sum(`sv`.`volume`) as decimal(5,1)) AS `totalVolume`,cast(sum(if(`s`.`alertLevel` < 2,`sv`.`volume`,0)) as decimal(5,1)) AS `remainingVolume`,greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0)) AS `speed`,cast(`zc`.`hour` + interval -sum(if(`s`.`alertLevel` < 2,`sv`.`volume`,0)) * 60 / greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0)) minute as time) AS `hourEffective`,floor(-sum(if(`s`.`alertLevel` < 2,`sv`.`volume`,0)) * 60 / greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0))) AS `minutesLess`,cast(`zc`.`hour` + interval -sum(if(`s`.`alertLevel` < 2,`sv`.`volume`,0)) * 60 / greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0)) minute as time) AS `etc` from ((((((((`vn`.`ticket` `t` join `vn`.`ticketStateToday` `tst` on(`tst`.`ticket` = `t`.`id`)) join `vn`.`state` `s` on(`s`.`id` = `tst`.`state`)) join `vn`.`saleVolume` `sv` on(`sv`.`ticketFk` = `t`.`id`)) left join `vn`.`lastHourProduction` `lhp` on(`lhp`.`warehouseFk` = `t`.`warehouseFk`)) join `vn`.`warehouse` `w` on(`w`.`id` = `t`.`warehouseFk`)) join `vn`.`warehouseAlias` `wa` on(`wa`.`id` = `w`.`aliasFk`)) left join `vn`.`zoneClosure` `zc` on(`zc`.`zoneFk` = `t`.`zoneFk` and `zc`.`dated` = curdate())) left join `cache`.`departure_limit` `dl` on(`dl`.`warehouse_id` = `t`.`warehouseFk` and `dl`.`fecha` = curdate())) where `w`.`hasConfectionTeam` = 1 and cast(`t`.`shipped` as date) = curdate() group by `t`.`zoneFk` */; +/*!50001 VIEW `zoneEstimatedDelivery` AS select `t`.`zoneFk` AS `zoneFk`,cast((curdate() + interval ((hour(`zc`.`hour`) * 60) + minute(`zc`.`hour`)) minute) as time) AS `hourTheoretical`,cast(sum(`sv`.`volume`) as decimal(5,1)) AS `totalVolume`,cast(sum(if((`s`.`alertLevel` < 2),`sv`.`volume`,0)) as decimal(5,1)) AS `remainingVolume`,greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0)) AS `speed`,cast((`zc`.`hour` + interval ((-(sum(if((`s`.`alertLevel` < 2),`sv`.`volume`,0))) * 60) / greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0))) minute) as time) AS `hourEffective`,floor(((-(sum(if((`s`.`alertLevel` < 2),`sv`.`volume`,0))) * 60) / greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0)))) AS `minutesLess`,cast((`zc`.`hour` + interval ((-(sum(if((`s`.`alertLevel` < 2),`sv`.`volume`,0))) * 60) / greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0))) minute) as time) AS `etc` from ((((((((`vn`.`ticket` `t` join `vn`.`ticketStateToday` `tst` on((`tst`.`ticket` = `t`.`id`))) join `vn`.`state` `s` on((`s`.`id` = `tst`.`state`))) join `vn`.`saleVolume` `sv` on((`sv`.`ticketFk` = `t`.`id`))) left join `vn`.`lastHourProduction` `lhp` on((`lhp`.`warehouseFk` = `t`.`warehouseFk`))) join `vn`.`warehouse` `w` on((`w`.`id` = `t`.`warehouseFk`))) join `vn`.`warehouseAlias` `wa` on((`wa`.`id` = `w`.`aliasFk`))) left join `vn`.`zoneClosure` `zc` on(((`zc`.`zoneFk` = `t`.`zoneFk`) and (`zc`.`dated` = curdate())))) left join `cache`.`departure_limit` `dl` on(((`dl`.`warehouse_id` = `t`.`warehouseFk`) and (`dl`.`fecha` = curdate())))) where ((`w`.`hasConfectionTeam` = 1) and (cast(`t`.`shipped` as date) = curdate())) group by `t`.`zoneFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -80726,4 +82552,4 @@ USE `vncontrol`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-03-04 8:02:58 +-- Dump completed on 2021-03-30 12:16:04 diff --git a/db/export-structure.sh b/db/export-structure.sh index 9c5ca6177..c5c65ef34 100755 --- a/db/export-structure.sh +++ b/db/export-structure.sh @@ -86,6 +86,8 @@ IGNORETABLES=( --ignore-table=vn.warehouseJoined --ignore-table=vn.workerTeam__ --ignore-table=vn.XDiario__ + --ignore-table=sage.movConta + --ignore-table=sage.movContaCopia ) mysqldump \ --defaults-file=config.production.ini \ diff --git a/e2e/paths/14-account/01_create_and_basic_data.spec.js b/e2e/paths/14-account/01_create_and_basic_data.spec.js index d1b825a0a..1b1823628 100644 --- a/e2e/paths/14-account/01_create_and_basic_data.spec.js +++ b/e2e/paths/14-account/01_create_and_basic_data.spec.js @@ -59,6 +59,6 @@ describe('Account create and basic data path', () => { await page.accessToSection('account.card.roles'); const rolesCount = await page.countElement(selectors.accountRoles.anyResult); - expect(rolesCount).toEqual(3); + expect(rolesCount).toEqual(4); }); }); diff --git a/e2e/paths/14-account/03_role_create_and_basic_data.spec.js b/e2e/paths/14-account/03_role_create_and_basic_data.spec.js index 18b85ea32..c2c5645ef 100644 --- a/e2e/paths/14-account/03_role_create_and_basic_data.spec.js +++ b/e2e/paths/14-account/03_role_create_and_basic_data.spec.js @@ -81,6 +81,6 @@ describe('Account Role create and basic data path', () => { await page.accessToSection('account.role.card.inherited'); const rolesCount = await page.countElement(selectors.accountRoleInheritance.anyResult); - expect(rolesCount).toEqual(6); + expect(rolesCount).toEqual(7); }); }); diff --git a/modules/ticket/back/methods/ticket/specs/filter.spec.js b/modules/ticket/back/methods/ticket/specs/filter.spec.js index 8716a7630..2ca8bcf44 100644 --- a/modules/ticket/back/methods/ticket/specs/filter.spec.js +++ b/modules/ticket/back/methods/ticket/specs/filter.spec.js @@ -1,7 +1,6 @@ const app = require('vn-loopback/server/server'); -// #2868 Excluded until database export -xdescribe('ticket filter()', () => { +describe('ticket filter()', () => { it('should return the tickets matching the filter', async() => { const ctx = {req: {accessToken: {userId: 9}}, args: {}}; const filter = {order: 'id DESC'}; @@ -24,7 +23,7 @@ xdescribe('ticket filter()', () => { const filter = {}; const result = await app.models.Ticket.filter(ctx, filter); - expect(result.length).toEqual(4); + expect(result.length).toEqual(3); }); it('should return the tickets matching the problems on false', async() => { @@ -42,7 +41,7 @@ xdescribe('ticket filter()', () => { const filter = {}; const result = await app.models.Ticket.filter(ctx, filter); - expect(result.length).toEqual(10); + expect(result.length).toEqual(7); }); it('should return the tickets matching the problems on null', async() => {