From 6bdcdbb13ca48e3508c7b94faca9a133aa4d9a9e Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Mon, 2 May 2022 10:57:13 +0200 Subject: [PATCH] DB structure & data export Hedera tables added to data export --- db/dump/dumpedFixtures.sql | 168 +- db/dump/structure.sql | 5027 +++++++++++++++++------------------- db/export-data.sh | 14 +- 3 files changed, 2542 insertions(+), 2667 deletions(-) diff --git a/db/dump/dumpedFixtures.sql b/db/dump/dumpedFixtures.sql index 60e568e8d..64c048142 100644 --- a/db/dump/dumpedFixtures.sql +++ b/db/dump/dumpedFixtures.sql @@ -22,9 +22,29 @@ USE `util`; LOCK TABLES `config` WRITE; /*!40000 ALTER TABLE `config` DISABLE KEYS */; -INSERT INTO `config` VALUES (1,'10411',0,'production',NULL); +INSERT INTO `config` VALUES (1,'10450',0,'production',NULL); /*!40000 ALTER TABLE `config` ENABLE KEYS */; UNLOCK TABLES; + +-- +-- Dumping data for table `version` +-- + +LOCK TABLES `version` WRITE; +/*!40000 ALTER TABLE `version` DISABLE KEYS */; +INSERT INTO `version` VALUES ('salix','10230','53f69ae8e526a4a5d827c237a5b076d38507b392','2020-11-09 11:06:43',NULL),('vn-database','10118','1d6101514fea3d96a8a91de884f3ad978e230fe6','2022-05-01 10:54:59','10126'); +/*!40000 ALTER TABLE `version` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `versionLog` +-- + +LOCK TABLES `versionLog` WRITE; +/*!40000 ALTER TABLE `versionLog` DISABLE KEYS */; +INSERT INTO `versionLog` VALUES ('vn-database','00001','00-test.sql','juan@10.5.1.3','2022-01-31 10:12:26',NULL,NULL),('vn-database','00003','00-sage.sql','juan@10.5.1.3','2022-01-31 10:12:26',NULL,NULL),('vn-database','10008','00-alterRoleConfig.sql','juan@10.5.1.3','2022-01-31 10:12:26',NULL,NULL),('vn-database','10014','00-rolePrefix.sql','jenkins@10.0.2.68','2022-02-11 00:13:25',NULL,NULL),('vn-database','10017','01-firstScript.sql','jenkins@10.0.2.70','2022-03-09 11:36:54',NULL,NULL),('vn-database','10021','00-bankAccount.sql','jenkins@10.0.2.69','2022-03-16 14:11:22',NULL,NULL),('vn-database','10023','00-firstScript.sql','jenkins@10.0.2.69','2022-03-16 15:05:29',NULL,NULL),('vn-database','10026','00-invoiceInIntrastat.sql','jenkins@10.0.2.69','2022-03-21 15:10:53',NULL,NULL),('vn-database','10027','00-Clientes_cedidos.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10028','00-item_last_buy_.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10029','00-bankToViewAccountingToTable.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10030','00-KkejarNiche.sql','jenkins@10.0.2.69','2022-03-22 15:58:12',NULL,NULL),('vn-database','10036','00-updateBuyConfig.sql','jenkins@10.0.2.69','2022-03-29 12:36:54',NULL,NULL),('vn-database','10037','00-firstScript.sql','jenkins@10.0.2.69','2022-03-28 11:14:26',NULL,NULL),('vn-database','10038','00-printServerQueue.sql','jenkins@10.0.2.69','2022-03-29 08:13:24',NULL,NULL),('vn-database','10048','00-firstScript.sql','jenkins@10.0.2.69','2022-03-30 12:29:06',NULL,NULL),('vn-database','10058','00-vehicleAddFields.sql','jenkins@10.0.2.69','2022-04-06 08:48:34',NULL,NULL),('vn-database','10060','00-firstScript.sql','jenkins@10.0.2.69','2022-04-07 08:50:11',NULL,NULL),('vn-database','10062','00-firstScript.sql','jenkins@10.0.2.69','2022-04-06 10:51:45',NULL,NULL),('vn-database','10064','00-firstScript.sql','jenkins@10.0.2.69','2022-04-06 13:57:11',NULL,NULL),('vn-database','10066','00-firstScript.sql','jenkins@10.0.2.69','2022-04-07 08:50:12',NULL,NULL),('vn-database','10067','00-firstScript.sql','jenkins@10.0.2.69','2022-04-08 10:18:20',NULL,NULL),('vn-database','10071','00-packingSiteLog.sql','jenkins@10.0.2.69','2022-04-08 09:37:30',NULL,NULL),('vn-database','10072','00-firstScript.sql','jenkins@10.0.2.69','2022-04-08 11:01:46',NULL,NULL),('vn-database','10073','00-firstScript.sql','jenkins@10.0.2.69','2022-04-08 13:40:56',NULL,NULL),('vn-database','10074','00-firstScript.sql','jenkins@10.0.2.69','2022-04-10 13:15:05',NULL,NULL),('vn-database','10077','00-firstScript.sql','jenkins@10.0.2.69','2022-04-12 08:07:15',NULL,NULL),('vn-database','10078','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 07:44:21',NULL,NULL),('vn-database','10079','00-firstScript.sql','jenkins@10.0.2.69','2022-04-12 12:01:37',NULL,NULL),('vn-database','10086','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 08:58:34',NULL,NULL),('vn-database','10087','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 09:39:49',NULL,NULL),('vn-database','10088','00-firstScript.sql','jenkins@10.0.2.69','2022-04-13 15:05:12',NULL,NULL),('vn-database','10089','00-firstScript.sql','jenkins@10.0.2.69','2022-04-18 14:12:52',NULL,NULL),('vn-database','10090','00-firstScript.sql','jenkins@10.0.2.69','2022-04-18 14:34:46',NULL,NULL),('vn-database','10092','00-firstScript.sql','jenkins@10.0.2.69','2022-04-19 14:45:46',NULL,NULL),('vn-database','10094','00-firstScript.sql','jenkins@10.0.2.69','2022-04-20 10:57:30',NULL,NULL),('vn-database','10099','00-firstScript.sql','jenkins@10.0.2.69','2022-04-20 14:35:27',NULL,NULL),('vn-database','10100','00-firstScript.sql','jenkins@10.0.2.69','2022-04-20 14:35:27',NULL,NULL),('vn-database','10101','00-firstScript.sql','jenkins@10.0.2.69','2022-04-21 14:59:31',NULL,NULL),('vn-database','10107','00-firstScript.sql','jenkins@10.0.2.69','2022-04-23 10:53:53',NULL,NULL),('vn-database','10114','00-updateConfig.sql','jenkins@10.0.2.69','2022-04-27 13:37:25',NULL,NULL),('vn-database','10116','00-firstScript.sql','jenkins@10.0.2.69','2022-04-28 11:10:14',NULL,NULL),('vn-database','10118','00-firstScript.sql','jenkins@10.0.2.69','2022-04-29 08:10:15',NULL,NULL); +/*!40000 ALTER TABLE `versionLog` ENABLE KEYS */; +UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; @@ -34,7 +54,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2022-03-28 9:44:13 +-- Dump completed on 2022-05-02 10:56:20 USE `account`; -- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64) -- @@ -120,7 +140,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2022-03-28 9:44:14 +-- Dump completed on 2022-05-02 10:56:20 USE `salix`; -- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64) -- @@ -144,7 +164,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'),(51,'ItemTag','*','READ','ALLOW','ROLE','employee'),(53,'Item','*','READ','ALLOW','ROLE','employee'),(54,'Item','*','WRITE','ALLOW','ROLE','buyer'),(55,'Recovery','*','READ','ALLOW','ROLE','trainee'),(56,'Recovery','*','WRITE','ALLOW','ROLE','administrative'),(58,'CreditClassification','*','*','ALLOW','ROLE','insurance'),(60,'CreditInsurance','*','*','ALLOW','ROLE','insurance'),(61,'InvoiceOut','*','READ','ALLOW','ROLE','employee'),(62,'Ticket','*','*','ALLOW','ROLE','employee'),(63,'TicketObservation','*','*','ALLOW','ROLE','employee'),(64,'Route','*','READ','ALLOW','ROLE','employee'),(65,'Sale','*','READ','ALLOW','ROLE','employee'),(66,'TicketTracking','*','READ','ALLOW','ROLE','employee'),(68,'TicketPackaging','*','*','ALLOW','ROLE','employee'),(69,'Packaging','*','READ','ALLOW','ROLE','employee'),(70,'Packaging','*','WRITE','ALLOW','ROLE','logistic'),(71,'SaleChecked','*','READ','ALLOW','ROLE','employee'),(72,'SaleComponent','*','READ','ALLOW','ROLE','employee'),(73,'Expedition','*','READ','ALLOW','ROLE','employee'),(74,'Expedition','*','WRITE','ALLOW','ROLE','deliveryBoss'),(75,'Expedition','*','WRITE','ALLOW','ROLE','production'),(76,'AnnualAverageInvoiced','*','READ','ALLOW','ROLE','employee'),(77,'WorkerMana','*','READ','ALLOW','ROLE','employee'),(78,'TicketTracking','*','WRITE','ALLOW','ROLE','production'),(79,'TicketTracking','changeState','*','ALLOW','ROLE','employee'),(80,'Sale','deleteSales','*','ALLOW','ROLE','employee'),(81,'Sale','moveToTicket','*','ALLOW','ROLE','employee'),(82,'Sale','updateQuantity','*','ALLOW','ROLE','employee'),(83,'Sale','updatePrice','*','ALLOW','ROLE','employee'),(84,'Sale','updateDiscount','*','ALLOW','ROLE','employee'),(85,'SaleTracking','*','READ','ALLOW','ROLE','employee'),(86,'Order','*','*','ALLOW','ROLE','employee'),(87,'OrderRow','*','*','ALLOW','ROLE','employee'),(88,'ClientContact','*','*','ALLOW','ROLE','employee'),(89,'Sale','moveToNewTicket','*','ALLOW','ROLE','employee'),(90,'Sale','reserve','*','ALLOW','ROLE','employee'),(91,'TicketWeekly','*','READ','ALLOW','ROLE','employee'),(94,'Agency','landsThatDay','*','ALLOW','ROLE','employee'),(96,'ClaimEnd','*','READ','ALLOW','ROLE','employee'),(97,'ClaimEnd','*','WRITE','ALLOW','ROLE','claimManager'),(98,'ClaimBeginning','*','*','ALLOW','ROLE','employee'),(99,'ClaimDevelopment','*','READ','ALLOW','ROLE','employee'),(100,'ClaimDevelopment','*','WRITE','ALLOW','ROLE','claimManager'),(101,'Claim','*','*','ALLOW','ROLE','employee'),(102,'Claim','createFromSales','*','ALLOW','ROLE','employee'),(103,'ClaimEnd','importTicketSales','WRITE','ALLOW','ROLE','claimManager'),(104,'Item','*','WRITE','ALLOW','ROLE','marketingBoss'),(105,'ItemBarcode','*','WRITE','ALLOW','ROLE','marketingBoss'),(106,'ItemBotanical','*','WRITE','ALLOW','ROLE','marketingBoss'),(108,'ItemPlacement','*','WRITE','ALLOW','ROLE','marketingBoss'),(109,'UserConfig','*','*','ALLOW','ROLE','employee'),(110,'Bank','*','READ','ALLOW','ROLE','trainee'),(111,'ClientLog','*','READ','ALLOW','ROLE','trainee'),(112,'Defaulter','*','READ','ALLOW','ROLE','employee'),(113,'ClientRisk','*','READ','ALLOW','ROLE','trainee'),(114,'Receipt','*','READ','ALLOW','ROLE','trainee'),(115,'Receipt','*','WRITE','ALLOW','ROLE','administrative'),(116,'BankEntity','*','*','ALLOW','ROLE','employee'),(117,'ClientSample','*','*','ALLOW','ROLE','employee'),(118,'WorkerTeam','*','*','ALLOW','ROLE','salesPerson'),(119,'Travel','*','READ','ALLOW','ROLE','employee'),(120,'Travel','*','WRITE','ALLOW','ROLE','buyer'),(121,'Item','regularize','*','ALLOW','ROLE','employee'),(122,'TicketRequest','*','*','ALLOW','ROLE','employee'),(123,'Worker','*','*','ALLOW','ROLE','employee'),(124,'Client','confirmTransaction','WRITE','ALLOW','ROLE','administrative'),(125,'Agency','getAgenciesWithWarehouse','*','ALLOW','ROLE','employee'),(126,'Client','activeWorkersWithRole','*','ALLOW','ROLE','employee'),(127,'TicketLog','*','READ','ALLOW','ROLE','employee'),(129,'TicketService','*','*','ALLOW','ROLE','employee'),(130,'Expedition','*','WRITE','ALLOW','ROLE','packager'),(131,'CreditInsurance','*','READ','ALLOW','ROLE','trainee'),(132,'CreditClassification','*','READ','ALLOW','ROLE','trainee'),(133,'ItemTag','*','WRITE','ALLOW','ROLE','marketingBoss'),(135,'ZoneGeo','*','READ','ALLOW','ROLE','employee'),(136,'ZoneCalendar','*','READ','ALLOW','ROLE','employee'),(137,'ZoneIncluded','*','READ','ALLOW','ROLE','employee'),(138,'LabourHoliday','*','READ','ALLOW','ROLE','employee'),(139,'LabourHolidayLegend','*','READ','ALLOW','ROLE','employee'),(140,'LabourHolidayType','*','READ','ALLOW','ROLE','employee'),(141,'Zone','*','*','ALLOW','ROLE','deliveryBoss'),(142,'ZoneCalendar','*','WRITE','ALLOW','ROLE','deliveryBoss'),(143,'ZoneIncluded','*','*','ALLOW','ROLE','deliveryBoss'),(144,'Stowaway','*','*','ALLOW','ROLE','employee'),(145,'Ticket','getPossibleStowaways','READ','ALLOW','ROLE','employee'),(147,'UserConfigView','*','*','ALLOW','ROLE','employee'),(148,'UserConfigView','*','*','ALLOW','ROLE','employee'),(149,'Sip','*','READ','ALLOW','ROLE','employee'),(150,'Sip','*','WRITE','ALLOW','ROLE','hr'),(151,'Department','*','READ','ALLOW','ROLE','employee'),(152,'Department','*','WRITE','ALLOW','ROLE','hr'),(153,'Route','*','READ','ALLOW','ROLE','employee'),(154,'Route','*','WRITE','ALLOW','ROLE','delivery'),(155,'Calendar','*','READ','ALLOW','ROLE','hr'),(156,'WorkerLabour','*','READ','ALLOW','ROLE','hr'),(157,'Calendar','absences','READ','ALLOW','ROLE','employee'),(158,'ItemTag','*','WRITE','ALLOW','ROLE','accessory'),(160,'TicketServiceType','*','READ','ALLOW','ROLE','employee'),(161,'TicketConfig','*','READ','ALLOW','ROLE','employee'),(162,'InvoiceOut','delete','WRITE','ALLOW','ROLE','invoicing'),(163,'InvoiceOut','book','WRITE','ALLOW','ROLE','invoicing'),(165,'TicketDms','*','*','ALLOW','ROLE','employee'),(167,'Worker','isSubordinate','READ','ALLOW','ROLE','employee'),(168,'Worker','mySubordinates','READ','ALLOW','ROLE','employee'),(169,'WorkerTimeControl','filter','READ','ALLOW','ROLE','employee'),(170,'WorkerTimeControl','addTime','WRITE','ALLOW','ROLE','employee'),(171,'TicketServiceType','*','WRITE','ALLOW','ROLE','administrative'),(172,'Sms','*','READ','ALLOW','ROLE','employee'),(173,'Sms','send','WRITE','ALLOW','ROLE','employee'),(174,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(175,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(176,'Device','*','*','ALLOW','ROLE','employee'),(177,'Device','*','*','ALLOW','ROLE','employee'),(178,'WorkerTimeControl','*','*','ALLOW','ROLE','employee'),(179,'ItemLog','*','READ','ALLOW','ROLE','employee'),(180,'RouteLog','*','READ','ALLOW','ROLE','employee'),(181,'Dms','removeFile','WRITE','ALLOW','ROLE','employee'),(182,'Dms','uploadFile','WRITE','ALLOW','ROLE','employee'),(183,'Dms','downloadFile','READ','ALLOW','ROLE','employee'),(184,'Client','uploadFile','WRITE','ALLOW','ROLE','employee'),(185,'ClientDms','removeFile','WRITE','ALLOW','ROLE','employee'),(186,'ClientDms','*','READ','ALLOW','ROLE','trainee'),(187,'Ticket','uploadFile','WRITE','ALLOW','ROLE','employee'),(190,'Route','updateVolume','WRITE','ALLOW','ROLE','deliveryBoss'),(191,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(192,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(194,'Postcode','*','WRITE','ALLOW','ROLE','deliveryBoss'),(195,'Ticket','addSale','WRITE','ALLOW','ROLE','employee'),(196,'Dms','updateFile','WRITE','ALLOW','ROLE','employee'),(197,'Dms','*','READ','ALLOW','ROLE','trainee'),(198,'ClaimDms','removeFile','WRITE','ALLOW','ROLE','employee'),(199,'ClaimDms','*','READ','ALLOW','ROLE','employee'),(200,'Claim','uploadFile','WRITE','ALLOW','ROLE','employee'),(201,'Sale','updateConcept','WRITE','ALLOW','ROLE','employee'),(202,'Claim','updateClaimAction','WRITE','ALLOW','ROLE','claimManager'),(203,'UserPhone','*','*','ALLOW','ROLE','employee'),(204,'WorkerDms','removeFile','WRITE','ALLOW','ROLE','hr'),(205,'WorkerDms','*','READ','ALLOW','ROLE','hr'),(206,'Chat','*','*','ALLOW','ROLE','employee'),(207,'Chat','sendMessage','*','ALLOW','ROLE','employee'),(208,'Sale','recalculatePrice','WRITE','ALLOW','ROLE','employee'),(209,'Ticket','recalculateComponents','WRITE','ALLOW','ROLE','employee'),(211,'TravelLog','*','READ','ALLOW','ROLE','buyer'),(212,'Thermograph','*','*','ALLOW','ROLE','buyer'),(213,'TravelThermograph','*','WRITE','ALLOW','ROLE','buyer'),(214,'Entry','*','*','ALLOW','ROLE','buyer'),(215,'TicketWeekly','*','WRITE','ALLOW','ROLE','buyer'),(216,'TravelThermograph','*','READ','ALLOW','ROLE','employee'),(218,'Intrastat','*','*','ALLOW','ROLE','buyer'),(219,'Account','acl','READ','ALLOW','ROLE','account'),(220,'Account','getCurrentUserData','READ','ALLOW','ROLE','account'),(221,'UserConfig','getUserConfig','READ','ALLOW','ROLE','account'),(222,'Client','*','READ','ALLOW','ROLE','trainee'),(226,'ClientObservation','*','READ','ALLOW','ROLE','trainee'),(227,'Address','*','READ','ALLOW','ROLE','trainee'),(228,'AddressObservation','*','READ','ALLOW','ROLE','trainee'),(230,'ClientCredit','*','READ','ALLOW','ROLE','trainee'),(231,'ClientContact','*','READ','ALLOW','ROLE','trainee'),(232,'ClientSample','*','READ','ALLOW','ROLE','trainee'),(233,'EntryLog','*','READ','ALLOW','ROLE','buyer'),(234,'WorkerLog','*','READ','ALLOW','ROLE','salesAssistant'),(235,'CustomsAgent','*','*','ALLOW','ROLE','employee'),(236,'Buy','*','*','ALLOW','ROLE','buyer'),(237,'WorkerDms','filter','*','ALLOW','ROLE','employee'),(238,'Town','*','WRITE','ALLOW','ROLE','deliveryBoss'),(239,'Province','*','WRITE','ALLOW','ROLE','deliveryBoss'),(240,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(241,'SupplierContact','*','WRITE','ALLOW','ROLE','administrative'),(242,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(244,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(246,'Account','changePassword','*','ALLOW','ROLE','account'),(247,'UserAccount','exists','*','ALLOW','ROLE','account'),(248,'RoleMapping','*','READ','ALLOW','ROLE','account'),(249,'UserPassword','*','READ','ALLOW','ROLE','account'),(250,'Town','*','WRITE','ALLOW','ROLE','deliveryBoss'),(251,'Province','*','WRITE','ALLOW','ROLE','deliveryBoss'),(252,'Supplier','*','READ','ALLOW','ROLE','employee'),(253,'Supplier','*','WRITE','ALLOW','ROLE','administrative'),(254,'SupplierLog','*','READ','ALLOW','ROLE','employee'),(256,'Image','*','WRITE','ALLOW','ROLE','employee'),(257,'FixedPrice','*','*','ALLOW','ROLE','buyer'),(258,'PayDem','*','READ','ALLOW','ROLE','employee'),(259,'Client','createReceipt','*','ALLOW','ROLE','salesAssistant'),(260,'PrintServerQueue','*','WRITE','ALLOW','ROLE','employee'),(261,'SupplierAccount','*','*','ALLOW','ROLE','administrative'),(262,'Entry','*','*','ALLOW','ROLE','administrative'),(263,'InvoiceIn','*','*','ALLOW','ROLE','administrative'),(264,'StarredModule','*','*','ALLOW','ROLE','employee'),(265,'ItemBotanical','*','WRITE','ALLOW','ROLE','logisticBoss'),(266,'ZoneLog','*','READ','ALLOW','ROLE','employee'),(267,'Genus','*','WRITE','ALLOW','ROLE','logisticBoss'),(268,'Specie','*','WRITE','ALLOW','ROLE','logisticBoss'),(269,'InvoiceOut','createPdf','WRITE','ALLOW','ROLE','employee'),(270,'SupplierAddress','*','*','ALLOW','ROLE','employee'),(271,'SalesMonitor','*','*','ALLOW','ROLE','employee'),(272,'InvoiceInLog','*','*','ALLOW','ROLE','employee'),(273,'InvoiceInTax','*','*','ALLOW','ROLE','administrative'),(274,'InvoiceInLog','*','READ','ALLOW','ROLE','administrative'),(275,'InvoiceOut','createManualInvoice','WRITE','ALLOW','ROLE','invoicing'),(276,'InvoiceOut','globalInvoicing','WRITE','ALLOW','ROLE','invoicing'),(277,'Role','*','*','ALLOW','ROLE','it'),(278,'RoleInherit','*','WRITE','ALLOW','ROLE','grant'),(279,'MailAlias','*','*','ALLOW','ROLE','marketing'),(282,'UserAccount','*','WRITE','ALLOW','ROLE','it'),(283,'EntryObservation','*','*','ALLOW','ROLE','buyer'),(284,'LdapConfig','*','*','ALLOW','ROLE','sysadmin'),(285,'SambaConfig','*','*','ALLOW','ROLE','sysadmin'),(286,'ACL','*','*','ALLOW','ROLE','developer'),(287,'AccessToken','*','*','ALLOW','ROLE','developer'),(288,'MailAliasAccount','*','*','ALLOW','ROLE','marketing'),(289,'MailAliasAccount','*','*','ALLOW','ROLE','hr'),(290,'MailAlias','*','*','ALLOW','ROLE','hr'),(291,'MailForward','*','*','ALLOW','ROLE','marketing'),(292,'MailForward','*','*','ALLOW','ROLE','hr'),(293,'RoleInherit','*','*','ALLOW','ROLE','it'),(294,'RoleRole','*','*','ALLOW','ROLE','it'),(295,'AccountConfig','*','*','ALLOW','ROLE','sysadmin'),(296,'Collection','*','READ','ALLOW','ROLE','employee'),(297,'Sale','payBack','WRITE','ALLOW','ROLE','employee'),(298,'InvoiceInDueDay','*','*','ALLOW','ROLE','administrative'); +INSERT INTO `ACL` VALUES (1,'Account','*','*','ALLOW','ROLE','employee'),(3,'Address','*','*','ALLOW','ROLE','employee'),(5,'AgencyService','*','READ','ALLOW','ROLE','employee'),(7,'Client','*','*','ALLOW','ROLE','employee'),(9,'ClientObservation','*','*','ALLOW','ROLE','employee'),(11,'ContactChannel','*','READ','ALLOW','ROLE','trainee'),(13,'Employee','*','READ','ALLOW','ROLE','employee'),(14,'PayMethod','*','READ','ALLOW','ROLE','trainee'),(16,'FakeProduction','*','READ','ALLOW','ROLE','employee'),(17,'Warehouse','* ','READ','ALLOW','ROLE','trainee'),(18,'State','*','READ','ALLOW','ROLE','employee'),(20,'TicketState','*','*','ALLOW','ROLE','employee'),(24,'Delivery','*','READ','ALLOW','ROLE','employee'),(25,'Zone','*','READ','ALLOW','ROLE','employee'),(26,'ClientCredit','*','*','ALLOW','ROLE','employee'),(27,'ClientCreditLimit','*','READ','ALLOW','ROLE','trainee'),(30,'GreugeType','*','READ','ALLOW','ROLE','trainee'),(31,'Mandate','*','READ','ALLOW','ROLE','trainee'),(32,'MandateType','*','READ','ALLOW','ROLE','trainee'),(33,'Company','*','READ','ALLOW','ROLE','trainee'),(34,'Greuge','*','READ','ALLOW','ROLE','trainee'),(35,'AddressObservation','*','*','ALLOW','ROLE','employee'),(36,'ObservationType','*','*','ALLOW','ROLE','employee'),(37,'Greuge','*','WRITE','ALLOW','ROLE','employee'),(38,'AgencyMode','*','READ','ALLOW','ROLE','employee'),(39,'ItemTag','*','WRITE','ALLOW','ROLE','buyer'),(40,'ItemBotanical','*','WRITE','ALLOW','ROLE','buyer'),(41,'ItemBotanical','*','READ','ALLOW','ROLE','employee'),(42,'ItemPlacement','*','WRITE','ALLOW','ROLE','buyer'),(43,'ItemPlacement','*','WRITE','ALLOW','ROLE','replenisher'),(44,'ItemPlacement','*','READ','ALLOW','ROLE','employee'),(45,'ItemBarcode','*','READ','ALLOW','ROLE','employee'),(46,'ItemBarcode','*','WRITE','ALLOW','ROLE','buyer'),(47,'ItemBarcode','*','WRITE','ALLOW','ROLE','replenisher'),(51,'ItemTag','*','READ','ALLOW','ROLE','employee'),(53,'Item','*','READ','ALLOW','ROLE','employee'),(54,'Item','*','WRITE','ALLOW','ROLE','buyer'),(55,'Recovery','*','READ','ALLOW','ROLE','trainee'),(56,'Recovery','*','WRITE','ALLOW','ROLE','administrative'),(58,'CreditClassification','*','*','ALLOW','ROLE','insurance'),(60,'CreditInsurance','*','*','ALLOW','ROLE','insurance'),(61,'InvoiceOut','*','READ','ALLOW','ROLE','employee'),(62,'Ticket','*','*','ALLOW','ROLE','employee'),(63,'TicketObservation','*','*','ALLOW','ROLE','employee'),(64,'Route','*','READ','ALLOW','ROLE','employee'),(65,'Sale','*','READ','ALLOW','ROLE','employee'),(66,'TicketTracking','*','READ','ALLOW','ROLE','employee'),(68,'TicketPackaging','*','*','ALLOW','ROLE','employee'),(69,'Packaging','*','READ','ALLOW','ROLE','employee'),(70,'Packaging','*','WRITE','ALLOW','ROLE','logistic'),(71,'SaleChecked','*','READ','ALLOW','ROLE','employee'),(72,'SaleComponent','*','READ','ALLOW','ROLE','employee'),(73,'Expedition','*','READ','ALLOW','ROLE','employee'),(74,'Expedition','*','WRITE','ALLOW','ROLE','deliveryBoss'),(75,'Expedition','*','WRITE','ALLOW','ROLE','production'),(76,'AnnualAverageInvoiced','*','READ','ALLOW','ROLE','employee'),(77,'WorkerMana','*','READ','ALLOW','ROLE','employee'),(78,'TicketTracking','*','WRITE','ALLOW','ROLE','production'),(79,'TicketTracking','changeState','*','ALLOW','ROLE','employee'),(80,'Sale','deleteSales','*','ALLOW','ROLE','employee'),(81,'Sale','moveToTicket','*','ALLOW','ROLE','employee'),(82,'Sale','updateQuantity','*','ALLOW','ROLE','employee'),(83,'Sale','updatePrice','*','ALLOW','ROLE','employee'),(84,'Sale','updateDiscount','*','ALLOW','ROLE','employee'),(85,'SaleTracking','*','READ','ALLOW','ROLE','employee'),(86,'Order','*','*','ALLOW','ROLE','employee'),(87,'OrderRow','*','*','ALLOW','ROLE','employee'),(88,'ClientContact','*','*','ALLOW','ROLE','employee'),(89,'Sale','moveToNewTicket','*','ALLOW','ROLE','employee'),(90,'Sale','reserve','*','ALLOW','ROLE','employee'),(91,'TicketWeekly','*','READ','ALLOW','ROLE','employee'),(94,'Agency','landsThatDay','*','ALLOW','ROLE','employee'),(96,'ClaimEnd','*','READ','ALLOW','ROLE','employee'),(97,'ClaimEnd','*','WRITE','ALLOW','ROLE','claimManager'),(98,'ClaimBeginning','*','*','ALLOW','ROLE','employee'),(99,'ClaimDevelopment','*','READ','ALLOW','ROLE','employee'),(100,'ClaimDevelopment','*','WRITE','ALLOW','ROLE','claimManager'),(101,'Claim','*','*','ALLOW','ROLE','employee'),(102,'Claim','createFromSales','*','ALLOW','ROLE','employee'),(104,'Item','*','WRITE','ALLOW','ROLE','marketingBoss'),(105,'ItemBarcode','*','WRITE','ALLOW','ROLE','marketingBoss'),(106,'ItemBotanical','*','WRITE','ALLOW','ROLE','marketingBoss'),(108,'ItemPlacement','*','WRITE','ALLOW','ROLE','marketingBoss'),(109,'UserConfig','*','*','ALLOW','ROLE','employee'),(110,'Bank','*','READ','ALLOW','ROLE','trainee'),(111,'ClientLog','*','READ','ALLOW','ROLE','trainee'),(112,'Defaulter','*','READ','ALLOW','ROLE','employee'),(113,'ClientRisk','*','READ','ALLOW','ROLE','trainee'),(114,'Receipt','*','READ','ALLOW','ROLE','trainee'),(115,'Receipt','*','WRITE','ALLOW','ROLE','administrative'),(116,'BankEntity','*','*','ALLOW','ROLE','employee'),(117,'ClientSample','*','*','ALLOW','ROLE','employee'),(118,'WorkerTeam','*','*','ALLOW','ROLE','salesPerson'),(119,'Travel','*','READ','ALLOW','ROLE','employee'),(120,'Travel','*','WRITE','ALLOW','ROLE','buyer'),(121,'Item','regularize','*','ALLOW','ROLE','employee'),(122,'TicketRequest','*','*','ALLOW','ROLE','employee'),(123,'Worker','*','*','ALLOW','ROLE','employee'),(124,'Client','confirmTransaction','WRITE','ALLOW','ROLE','administrative'),(125,'Agency','getAgenciesWithWarehouse','*','ALLOW','ROLE','employee'),(126,'Client','activeWorkersWithRole','*','ALLOW','ROLE','employee'),(127,'TicketLog','*','READ','ALLOW','ROLE','employee'),(129,'TicketService','*','*','ALLOW','ROLE','employee'),(130,'Expedition','*','WRITE','ALLOW','ROLE','packager'),(131,'CreditInsurance','*','READ','ALLOW','ROLE','trainee'),(132,'CreditClassification','*','READ','ALLOW','ROLE','trainee'),(133,'ItemTag','*','WRITE','ALLOW','ROLE','marketingBoss'),(135,'ZoneGeo','*','READ','ALLOW','ROLE','employee'),(136,'ZoneCalendar','*','READ','ALLOW','ROLE','employee'),(137,'ZoneIncluded','*','READ','ALLOW','ROLE','employee'),(138,'LabourHoliday','*','READ','ALLOW','ROLE','employee'),(139,'LabourHolidayLegend','*','READ','ALLOW','ROLE','employee'),(140,'LabourHolidayType','*','READ','ALLOW','ROLE','employee'),(141,'Zone','*','*','ALLOW','ROLE','deliveryBoss'),(142,'ZoneCalendar','*','WRITE','ALLOW','ROLE','deliveryBoss'),(143,'ZoneIncluded','*','*','ALLOW','ROLE','deliveryBoss'),(144,'Stowaway','*','*','ALLOW','ROLE','employee'),(145,'Ticket','getPossibleStowaways','READ','ALLOW','ROLE','employee'),(147,'UserConfigView','*','*','ALLOW','ROLE','employee'),(148,'UserConfigView','*','*','ALLOW','ROLE','employee'),(149,'Sip','*','READ','ALLOW','ROLE','employee'),(150,'Sip','*','WRITE','ALLOW','ROLE','hr'),(151,'Department','*','READ','ALLOW','ROLE','employee'),(152,'Department','*','WRITE','ALLOW','ROLE','hr'),(153,'Route','*','READ','ALLOW','ROLE','employee'),(154,'Route','*','WRITE','ALLOW','ROLE','delivery'),(155,'Calendar','*','READ','ALLOW','ROLE','hr'),(156,'WorkerLabour','*','READ','ALLOW','ROLE','hr'),(157,'Calendar','absences','READ','ALLOW','ROLE','employee'),(158,'ItemTag','*','WRITE','ALLOW','ROLE','accessory'),(160,'TicketServiceType','*','READ','ALLOW','ROLE','employee'),(161,'TicketConfig','*','READ','ALLOW','ROLE','employee'),(162,'InvoiceOut','delete','WRITE','ALLOW','ROLE','invoicing'),(163,'InvoiceOut','book','WRITE','ALLOW','ROLE','invoicing'),(165,'TicketDms','*','*','ALLOW','ROLE','employee'),(167,'Worker','isSubordinate','READ','ALLOW','ROLE','employee'),(168,'Worker','mySubordinates','READ','ALLOW','ROLE','employee'),(169,'WorkerTimeControl','filter','READ','ALLOW','ROLE','employee'),(170,'WorkerTimeControl','addTime','WRITE','ALLOW','ROLE','employee'),(171,'TicketServiceType','*','WRITE','ALLOW','ROLE','administrative'),(172,'Sms','*','READ','ALLOW','ROLE','employee'),(173,'Sms','send','WRITE','ALLOW','ROLE','employee'),(174,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(175,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(176,'Device','*','*','ALLOW','ROLE','employee'),(177,'Device','*','*','ALLOW','ROLE','employee'),(178,'WorkerTimeControl','*','*','ALLOW','ROLE','employee'),(179,'ItemLog','*','READ','ALLOW','ROLE','employee'),(180,'RouteLog','*','READ','ALLOW','ROLE','employee'),(181,'Dms','removeFile','WRITE','ALLOW','ROLE','employee'),(182,'Dms','uploadFile','WRITE','ALLOW','ROLE','employee'),(183,'Dms','downloadFile','READ','ALLOW','ROLE','employee'),(184,'Client','uploadFile','WRITE','ALLOW','ROLE','employee'),(185,'ClientDms','removeFile','WRITE','ALLOW','ROLE','employee'),(186,'ClientDms','*','READ','ALLOW','ROLE','trainee'),(187,'Ticket','uploadFile','WRITE','ALLOW','ROLE','employee'),(190,'Route','updateVolume','WRITE','ALLOW','ROLE','deliveryBoss'),(191,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(192,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(194,'Postcode','*','WRITE','ALLOW','ROLE','deliveryBoss'),(195,'Ticket','addSale','WRITE','ALLOW','ROLE','employee'),(196,'Dms','updateFile','WRITE','ALLOW','ROLE','employee'),(197,'Dms','*','READ','ALLOW','ROLE','trainee'),(198,'ClaimDms','removeFile','WRITE','ALLOW','ROLE','employee'),(199,'ClaimDms','*','READ','ALLOW','ROLE','employee'),(200,'Claim','uploadFile','WRITE','ALLOW','ROLE','employee'),(201,'Sale','updateConcept','WRITE','ALLOW','ROLE','employee'),(202,'Claim','updateClaimAction','WRITE','ALLOW','ROLE','claimManager'),(203,'UserPhone','*','*','ALLOW','ROLE','employee'),(204,'WorkerDms','removeFile','WRITE','ALLOW','ROLE','hr'),(205,'WorkerDms','*','READ','ALLOW','ROLE','hr'),(206,'Chat','*','*','ALLOW','ROLE','employee'),(207,'Chat','sendMessage','*','ALLOW','ROLE','employee'),(208,'Sale','recalculatePrice','WRITE','ALLOW','ROLE','employee'),(209,'Ticket','recalculateComponents','WRITE','ALLOW','ROLE','employee'),(211,'TravelLog','*','READ','ALLOW','ROLE','buyer'),(212,'Thermograph','*','*','ALLOW','ROLE','buyer'),(213,'TravelThermograph','*','WRITE','ALLOW','ROLE','buyer'),(214,'Entry','*','*','ALLOW','ROLE','buyer'),(215,'TicketWeekly','*','WRITE','ALLOW','ROLE','buyer'),(216,'TravelThermograph','*','READ','ALLOW','ROLE','employee'),(218,'Intrastat','*','*','ALLOW','ROLE','buyer'),(219,'Account','acl','READ','ALLOW','ROLE','account'),(220,'Account','getCurrentUserData','READ','ALLOW','ROLE','account'),(221,'UserConfig','getUserConfig','READ','ALLOW','ROLE','account'),(222,'Client','*','READ','ALLOW','ROLE','trainee'),(226,'ClientObservation','*','READ','ALLOW','ROLE','trainee'),(227,'Address','*','READ','ALLOW','ROLE','trainee'),(228,'AddressObservation','*','READ','ALLOW','ROLE','trainee'),(230,'ClientCredit','*','READ','ALLOW','ROLE','trainee'),(231,'ClientContact','*','READ','ALLOW','ROLE','trainee'),(232,'ClientSample','*','READ','ALLOW','ROLE','trainee'),(233,'EntryLog','*','READ','ALLOW','ROLE','buyer'),(234,'WorkerLog','*','READ','ALLOW','ROLE','salesAssistant'),(235,'CustomsAgent','*','*','ALLOW','ROLE','employee'),(236,'Buy','*','*','ALLOW','ROLE','buyer'),(237,'WorkerDms','filter','*','ALLOW','ROLE','employee'),(238,'Town','*','WRITE','ALLOW','ROLE','deliveryBoss'),(239,'Province','*','WRITE','ALLOW','ROLE','deliveryBoss'),(240,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(241,'SupplierContact','*','WRITE','ALLOW','ROLE','administrative'),(242,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(244,'supplier','*','WRITE','ALLOW','ROLE','administrative'),(246,'Account','changePassword','*','ALLOW','ROLE','account'),(247,'UserAccount','exists','*','ALLOW','ROLE','account'),(248,'RoleMapping','*','READ','ALLOW','ROLE','account'),(249,'UserPassword','*','READ','ALLOW','ROLE','account'),(250,'Town','*','WRITE','ALLOW','ROLE','deliveryBoss'),(251,'Province','*','WRITE','ALLOW','ROLE','deliveryBoss'),(252,'Supplier','*','READ','ALLOW','ROLE','employee'),(253,'Supplier','*','WRITE','ALLOW','ROLE','administrative'),(254,'SupplierLog','*','READ','ALLOW','ROLE','employee'),(256,'Image','*','WRITE','ALLOW','ROLE','employee'),(257,'FixedPrice','*','*','ALLOW','ROLE','buyer'),(258,'PayDem','*','READ','ALLOW','ROLE','employee'),(259,'Client','createReceipt','*','ALLOW','ROLE','salesAssistant'),(260,'PrintServerQueue','*','WRITE','ALLOW','ROLE','employee'),(261,'SupplierAccount','*','*','ALLOW','ROLE','administrative'),(262,'Entry','*','*','ALLOW','ROLE','administrative'),(263,'InvoiceIn','*','*','ALLOW','ROLE','administrative'),(264,'StarredModule','*','*','ALLOW','ROLE','employee'),(265,'ItemBotanical','*','WRITE','ALLOW','ROLE','logisticBoss'),(266,'ZoneLog','*','READ','ALLOW','ROLE','employee'),(267,'Genus','*','WRITE','ALLOW','ROLE','logisticBoss'),(268,'Specie','*','WRITE','ALLOW','ROLE','logisticBoss'),(269,'InvoiceOut','createPdf','WRITE','ALLOW','ROLE','employee'),(270,'SupplierAddress','*','*','ALLOW','ROLE','employee'),(271,'SalesMonitor','*','*','ALLOW','ROLE','employee'),(272,'InvoiceInLog','*','*','ALLOW','ROLE','employee'),(273,'InvoiceInTax','*','*','ALLOW','ROLE','administrative'),(274,'InvoiceInLog','*','READ','ALLOW','ROLE','administrative'),(275,'InvoiceOut','createManualInvoice','WRITE','ALLOW','ROLE','invoicing'),(276,'InvoiceOut','globalInvoicing','WRITE','ALLOW','ROLE','invoicing'),(277,'Role','*','*','ALLOW','ROLE','it'),(278,'RoleInherit','*','WRITE','ALLOW','ROLE','grant'),(279,'MailAlias','*','*','ALLOW','ROLE','marketing'),(282,'UserAccount','*','WRITE','ALLOW','ROLE','it'),(283,'EntryObservation','*','*','ALLOW','ROLE','buyer'),(284,'LdapConfig','*','*','ALLOW','ROLE','sysadmin'),(285,'SambaConfig','*','*','ALLOW','ROLE','sysadmin'),(286,'ACL','*','*','ALLOW','ROLE','developer'),(287,'AccessToken','*','*','ALLOW','ROLE','developer'),(288,'MailAliasAccount','*','*','ALLOW','ROLE','marketing'),(289,'MailAliasAccount','*','*','ALLOW','ROLE','hr'),(290,'MailAlias','*','*','ALLOW','ROLE','hr'),(291,'MailForward','*','*','ALLOW','ROLE','marketing'),(292,'MailForward','*','*','ALLOW','ROLE','hr'),(293,'RoleInherit','*','*','ALLOW','ROLE','it'),(294,'RoleRole','*','*','ALLOW','ROLE','it'),(295,'AccountConfig','*','*','ALLOW','ROLE','sysadmin'),(296,'Collection','*','READ','ALLOW','ROLE','employee'),(297,'Sale','payBack','WRITE','ALLOW','ROLE','employee'),(298,'InvoiceInDueDay','*','*','ALLOW','ROLE','administrative'),(299,'Collection','setSaleQuantity','*','ALLOW','ROLE','employee'),(300,'Docuware','*','*','ALLOW','ROLE','employee'),(301,'Agency','*','READ','ALLOW','ROLE','employee'),(302,'AgencyTerm','*','*','ALLOW','ROLE','administrative'),(303,'ClaimLog','*','READ','ALLOW','ROLE','claimManager'),(304,'Edi','updateData','WRITE','ALLOW','ROLE','employee'),(305,'EducationLevel','*','*','ALLOW','ROLE','employee'),(306,'InvoiceInIntrastat','*','*','ALLOW','ROLE','employee'),(307,'SupplierAgencyTerm','*','*','ALLOW','ROLE','administrative'),(308,'InvoiceInIntrastat','*','*','ALLOW','ROLE','employee'); /*!40000 ALTER TABLE `ACL` ENABLE KEYS */; UNLOCK TABLES; @@ -174,7 +194,7 @@ UNLOCK TABLES; LOCK TABLES `defaultViewConfig` WRITE; /*!40000 ALTER TABLE `defaultViewConfig` DISABLE KEYS */; -INSERT INTO `defaultViewConfig` VALUES ('itemsIndex','{\"intrastat\":false,\"stemMultiplier\":false,\"landed\":false}'),('latestBuys','{\"intrastat\":false,\"description\":false,\"density\":false,\"isActive\":false,\n \"freightValue\":false,\"packageValue\":false,\"isIgnored\":false,\"price2\":false,\"ektFk\":false,\"weight\":false,\n \"size\":false,\"comissionValue\":false,\"landing\":false}'),('ticketsMonitor','{\"id\":false}'); +INSERT INTO `defaultViewConfig` VALUES ('itemsIndex','{\"intrastat\":false,\"stemMultiplier\":false,\"landed\":false,\"producer\":false}'),('latestBuys','{\"intrastat\":false,\"description\":false,\"density\":false,\"isActive\":false,\n \"freightValue\":false,\"packageValue\":false,\"isIgnored\":false,\"price2\":false,\"ektFk\":false,\"weight\":false,\n \"size\":false,\"comissionValue\":false,\"landing\":false}'),('ticketsMonitor','{\"id\":false}'); /*!40000 ALTER TABLE `defaultViewConfig` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -186,7 +206,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2022-03-28 9:44:14 +-- Dump completed on 2022-05-02 10:56:20 USE `vn`; -- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64) -- @@ -340,7 +360,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',0),(14,'porte extra por dia semana',6,NULL,NULL,1,'extraCostPerWeekDay',0),(15,'reparto',6,NULL,NULL,1,'delivery',1),(17,'recobro',5,NULL,NULL,1,'debtCollection',0),(21,'ajuste',11,NULL,NULL,1,'adjustment',0),(22,'venta por paquete',9,1,NULL,0,'salePerPackage',0),(23,'venta por caja',9,2,NULL,0,'salePerBox',0),(28,'valor de compra',1,NULL,NULL,1,'purchaseValue',1),(29,'margen',4,NULL,NULL,1,'margin',1),(32,'descuento ultimas unidades',9,3,-0.05,0,'lastUnitsDiscount',0),(33,'venta por caja',9,1,NULL,0,'salePerBox',0),(34,'descuento comprador',4,NULL,NULL,1,'buyerDiscount',0),(35,'cartera comprador',10,NULL,NULL,1,NULL,0),(36,'descuadre',12,NULL,NULL,1,'imbalance',0),(37,'maná',7,4,NULL,0,'mana',0),(38,'embolsado',9,NULL,NULL,1,'bagged',0),(39,'maná auto',7,NULL,NULL,1,'autoMana',0),(40,'cambios Santos 2016',4,NULL,NULL,1,NULL,0),(41,'bonificacion porte',6,NULL,NULL,1,'freightCharge',0),(42,'promocion Francia',4,NULL,NULL,1,'frenchOffer',0),(43,'promocion Floramondo',4,NULL,NULL,1,'floramondoPromo',0),(44,'rappel cadena',2,NULL,NULL,1,'rappel',0); +INSERT INTO `component` VALUES (10,'Precios Especiales',4,NULL,NULL,1,'specialPrices',0),(14,'porte extra por dia semana',6,NULL,NULL,1,'extraCostPerWeekDay',0),(15,'reparto',6,NULL,NULL,1,'delivery',1),(17,'recobro',5,NULL,NULL,1,'debtCollection',0),(21,'ajuste',11,NULL,NULL,1,'adjustment',0),(22,'venta por paquete',9,1,NULL,0,'salePerPackage',0),(23,'venta por caja',9,2,NULL,0,'salePerBox',0),(28,'valor de compra',1,NULL,NULL,1,'purchaseValue',1),(29,'margen',4,NULL,NULL,1,'margin',1),(32,'descuento ultimas unidades',9,3,-0.05,0,'lastUnitsDiscount',0),(33,'venta por caja',9,1,NULL,0,'salePerBox',0),(34,'descuento comprador',4,NULL,NULL,1,'buyerDiscount',0),(35,'cartera comprador',10,NULL,NULL,1,NULL,0),(36,'descuadre',12,NULL,NULL,1,'imbalance',0),(37,'maná',7,4,NULL,0,'mana',0),(38,'embolsado',9,NULL,NULL,1,'bagged',0),(39,'maná auto',7,NULL,NULL,1,'autoMana',0),(40,'cambios Santos 2016',4,NULL,NULL,1,NULL,0),(41,'bonificacion porte',6,NULL,NULL,1,'freightCharge',0),(42,'promocion Francia',4,NULL,NULL,1,'frenchOffer',0),(43,'promocion Floramondo',4,NULL,NULL,1,'floramondoPromo',0),(44,'rappel cadena',2,NULL,NULL,1,'rappel',0),(45,'maná reclamacion',7,4,NULL,0,'manaClaim',0); /*!40000 ALTER TABLE `component` ENABLE KEYS */; UNLOCK TABLES; @@ -370,7 +390,7 @@ UNLOCK TABLES; LOCK TABLES `department` WRITE; /*!40000 ALTER TABLE `department` DISABLE KEYS */; -INSERT INTO `department` VALUES (1,NULL,'VERDNATURA',1,94,763,0,NULL,NULL,NULL,0,0,0,30,NULL,'/',NULL,0,NULL,0,0,0,0),(22,NULL,'COMPRAS',2,3,NULL,72,596,2,5,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0),(23,NULL,'CAMARA',13,14,NULL,72,3758,2,6,1,1,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,1),(31,'IT','INFORMATICA',4,5,NULL,72,127,3,9,0,0,1,0,1,'/1/','informatica-cau',1,NULL,1,0,0,0),(34,NULL,'CONTABILIDAD',6,7,NULL,0,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0),(35,NULL,'FINANZAS',8,9,NULL,0,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,1,'finanzas@verdnatura.es',1,0,0,0),(36,NULL,'LABORAL',10,11,NULL,0,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0),(37,NULL,'PRODUCCION',12,27,NULL,72,3758,3,11,1,1,1,7,1,'/1/',NULL,0,NULL,0,1,1,1),(38,NULL,'SACADO',15,16,NULL,72,230,4,14,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0),(39,NULL,'ENCAJADO',17,18,NULL,72,3758,4,12,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0),(41,NULL,'ADMINISTRACION',28,29,NULL,72,599,3,8,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0),(43,NULL,'VENTAS',30,49,NULL,0,NULL,NULL,NULL,0,0,1,9,1,'/1/',NULL,1,'',1,0,0,0),(44,NULL,'GERENCIA',50,51,NULL,72,300,2,7,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0),(45,NULL,'LOGISTICA',52,53,NULL,72,596,3,19,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0),(46,NULL,'REPARTO',54,55,NULL,72,659,3,10,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0),(48,NULL,'ALMACENAJE',56,57,NULL,0,3758,NULL,NULL,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0),(49,NULL,'PROPIEDAD',58,59,NULL,72,1008,1,1,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0),(52,NULL,'CARGA AEREA',60,61,NULL,72,163,4,28,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0),(53,NULL,'MARKETING Y COMUNICACIÓN',62,63,NULL,72,1238,0,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0),(54,NULL,'ORNAMENTALES',64,65,NULL,72,433,3,21,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0),(55,NULL,'TALLER NATURAL',66,67,NULL,72,3758,2,23,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,1,0),(56,NULL,'TALLER ARTIFICIAL',68,69,NULL,72,1780,2,24,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,1,0),(58,NULL,'CAMPOS',70,71,NULL,72,3758,2,2,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0),(59,NULL,'MANTENIMIENTO',72,73,NULL,72,1907,4,16,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0),(60,NULL,'RECLAMACIONES',74,75,NULL,72,563,3,20,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0),(61,NULL,'VNH',76,77,NULL,73,1297,3,17,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0),(63,NULL,'VENTAS FRANCIA',31,32,NULL,72,277,2,27,0,0,2,0,43,'/1/43/',NULL,0,NULL,0,0,0,0),(66,NULL,'VERDNAMADRID',78,79,NULL,72,163,3,18,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0),(68,NULL,'COMPLEMENTOS',19,20,NULL,72,617,3,26,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0),(69,NULL,'VERDNABARNA',80,81,NULL,74,432,3,22,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0),(80,NULL,'EQUIPO J VALLES',33,34,NULL,72,693,3,4,0,0,2,0,43,'/1/43/','jvp_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0),(86,NULL,'LIMPIEZA',82,83,NULL,72,599,0,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0),(89,NULL,'COORDINACION',84,85,NULL,0,3758,NULL,NULL,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0),(90,NULL,'TRAILER',86,87,NULL,0,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0),(91,NULL,'ARTIFICIAL',21,22,NULL,0,3758,NULL,NULL,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0),(92,NULL,'EQUIPO SILVERIO',35,36,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','sdc_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0),(93,NULL,'CONFECCION',88,89,NULL,0,3758,NULL,NULL,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,1,0),(94,NULL,'EQUIPO J BROCAL',37,38,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','jes_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0),(95,NULL,'EQUIPO C ZAMBRANO',39,40,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','czg_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0),(96,NULL,'EQUIPO C LOPEZ',41,42,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','cla_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0),(115,NULL,'EQUIPO CLAUDI',43,44,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','csr_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0),(123,NULL,'EQUIPO ELENA BASCUÑANA',45,46,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','ebt_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0),(124,NULL,'CONTROL INTERNO',90,91,NULL,72,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0),(125,NULL,'EQUIPO MIRIAM MAR',47,48,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','mir_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0),(126,NULL,'PRESERVADO',92,93,NULL,0,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,1,0),(128,NULL,'PALETIZADO',23,24,NULL,0,NULL,NULL,NULL,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0),(130,NULL,'REVISION',25,26,NULL,0,NULL,NULL,NULL,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0); +INSERT INTO `department` VALUES (1,NULL,'VERDNATURA',1,94,763,0,NULL,NULL,NULL,0,0,0,30,NULL,'/',NULL,0,NULL,0,0,0,0,NULL),(22,NULL,'COMPRAS',2,3,NULL,72,596,2,5,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(23,NULL,'CAMARA',13,14,NULL,72,3758,2,6,1,1,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,1,NULL),(31,'IT','INFORMATICA',4,5,NULL,72,127,3,9,0,0,1,0,1,'/1/','informatica-cau',1,NULL,1,0,0,0,NULL),(34,NULL,'CONTABILIDAD',6,7,NULL,0,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(35,NULL,'FINANZAS',8,9,NULL,0,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(36,NULL,'LABORAL',10,11,NULL,0,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(37,NULL,'PRODUCCION',12,27,NULL,72,3758,3,11,1,1,1,7,1,'/1/',NULL,0,NULL,0,1,1,1,NULL),(38,NULL,'SACADO',15,16,NULL,72,230,4,14,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL),(39,NULL,'ENCAJADO',17,18,NULL,72,3758,4,12,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL),(41,NULL,'ADMINISTRACION',28,29,NULL,72,599,3,8,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(43,NULL,'VENTAS',30,49,NULL,0,NULL,NULL,NULL,0,0,1,9,1,'/1/',NULL,1,'',1,0,0,0,NULL),(44,NULL,'GERENCIA',50,51,NULL,72,300,2,7,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(45,NULL,'LOGISTICA',52,53,NULL,72,596,3,19,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(46,NULL,'REPARTO',54,55,NULL,72,659,3,10,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL),(48,NULL,'ALMACENAJE',56,57,NULL,0,3758,NULL,NULL,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(49,NULL,'PROPIEDAD',58,59,NULL,72,1008,1,1,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(52,NULL,'CARGA AEREA',60,61,NULL,72,163,4,28,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(53,NULL,'MARKETING Y COMUNICACIÓN',62,63,NULL,72,1238,0,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(54,NULL,'ORNAMENTALES',64,65,NULL,72,433,3,21,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(55,NULL,'TALLER NATURAL',66,67,3366,72,3758,2,23,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,1,0,1118),(56,NULL,'TALLER ARTIFICIAL',68,69,8470,72,1780,2,24,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,1,0,1927),(58,NULL,'CAMPOS',70,71,NULL,72,3758,2,2,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(59,NULL,'MANTENIMIENTO',72,73,NULL,72,1907,4,16,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(60,NULL,'RECLAMACIONES',74,75,NULL,72,563,3,20,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(61,NULL,'VNH',76,77,NULL,73,1297,3,17,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(63,NULL,'VENTAS FRANCIA',31,32,NULL,72,277,2,27,0,0,2,0,43,'/1/43/',NULL,0,NULL,0,0,0,0,NULL),(66,NULL,'VERDNAMADRID',78,79,NULL,72,163,3,18,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(68,NULL,'COMPLEMENTOS',19,20,NULL,72,617,3,26,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL),(69,NULL,'VERDNABARNA',80,81,NULL,74,432,3,22,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(80,NULL,'EQUIPO J VALLES',33,34,NULL,72,693,3,4,0,0,2,0,43,'/1/43/','jvp_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0,NULL),(86,NULL,'LIMPIEZA',82,83,NULL,72,599,0,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(89,NULL,'COORDINACION',84,85,NULL,0,3758,NULL,NULL,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(90,NULL,'TRAILER',86,87,NULL,0,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL),(91,NULL,'ARTIFICIAL',21,22,NULL,0,3758,NULL,NULL,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL),(92,NULL,'EQUIPO SILVERIO',35,36,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','sdc_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0,NULL),(93,NULL,'CONFECCION',88,89,NULL,0,3758,NULL,NULL,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,1,0,NULL),(94,NULL,'EQUIPO J BROCAL',37,38,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','jes_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0,NULL),(95,NULL,'EQUIPO C ZAMBRANO',39,40,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','czg_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0,NULL),(96,NULL,'EQUIPO C LOPEZ',41,42,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','cla_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0,NULL),(115,NULL,'EQUIPO CLAUDI',43,44,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','csr_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0,NULL),(123,NULL,'EQUIPO ELENA BASCUÑANA',45,46,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','ebt_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0,NULL),(124,NULL,'CONTROL INTERNO',90,91,NULL,72,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL),(125,NULL,'EQUIPO MIRIAM MAR',47,48,NULL,0,NULL,NULL,NULL,0,0,2,0,43,'/1/43/','mir_equipo',1,'direccioncomercial@verdnatura.es',1,0,0,0,NULL),(126,NULL,'PRESERVADO',92,93,NULL,0,NULL,NULL,NULL,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,1,0,NULL),(128,NULL,'PALETIZADO',23,24,NULL,0,NULL,NULL,NULL,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL),(130,NULL,'REVISION',25,26,NULL,0,NULL,NULL,NULL,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL); /*!40000 ALTER TABLE `department` ENABLE KEYS */; UNLOCK TABLES; @@ -410,7 +430,7 @@ UNLOCK TABLES; LOCK TABLES `state` WRITE; /*!40000 ALTER TABLE `state` DISABLE KEYS */; -INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING',NULL,1,0,0,0,0,0,0,4,1),(2,'Libre',2,0,'FREE',NULL,2,1,0,0,0,1,0,4,1),(3,'OK',3,0,'OK',3,28,1,0,0,0,1,1,3,0),(4,'Impreso',4,0,'PRINTED',2,29,1,0,1,0,0,1,2,0),(5,'Preparación',6,1,'ON_PREPARATION',7,5,0,0,0,2,0,0,2,0),(6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0,1,0,3,0,0,1,0),(7,'Sin Acabar',1,0,'NOT_READY',NULL,7,0,0,0,0,0,0,4,1),(8,'Revisado',8,1,'CHECKED',NULL,8,0,1,0,3,0,0,1,0),(9,'Encajando',9,2,'PACKING',NULL,9,0,1,0,0,0,0,1,0),(10,'Encajado',10,2,'PACKED',NULL,10,0,1,0,0,0,0,0,0),(11,'Facturado',0,3,'INVOICED',NULL,11,0,1,0,0,0,0,0,0),(12,'Bloqueado',0,0,'BLOCKED',NULL,12,0,0,0,0,0,0,4,1),(13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0,1,0,0,0,0,0,0),(14,'Preparado',6,1,'PREPARED',NULL,14,0,1,0,2,0,0,1,0),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0,1,0,0,0,0,0,0),(16,'Entregado',13,3,'DELIVERED',NULL,16,0,1,0,0,0,0,0,0),(20,'Asignado',4,0,'PICKER_DESIGNED',NULL,20,1,0,0,0,0,0,2,0),(21,'Retornado',4,1,'PRINTED_BACK',6,21,0,0,0,0,0,0,2,0),(22,'Pte. Ampliar',2,0,'EXPANDABLE',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,28,0,0,0,1,0,0,2,0),(27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0,0,0,0,0,0,2,0),(28,'Previa OK',3,1,'OK PREVIOUS',3,28,0,0,0,1,1,1,3,0),(29,'Previa Impreso',4,1,'PRINTED PREVIOUS',2,29,0,0,1,1,0,1,3,0),(30,'Embarcado',4,1,'BOARD',5,30,0,0,0,2,0,0,3,0),(31,'Polizon Impreso',4,1,'PRINTED STOWAWAY',2,29,1,0,1,0,0,1,3,0),(32,'Polizon OK',3,1,'OK STOWAWAY',3,31,1,0,0,1,1,1,3,0),(33,'Auto_Impreso',4,0,'PRINTED_AUTO',2,29,1,0,1,0,0,1,2,0),(34,'Pte Pago',3,0,'WAITING_FOR_PAYMENT',NULL,34,0,0,0,0,0,0,4,1),(35,'Semi-Encajado',9,2,'HALF_PACKED',NULL,10,0,1,0,0,0,0,1,0),(36,'Control Previa',3,1,'PREVIOUS_CONTROL',1,36,0,1,0,4,0,1,3,0); +INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING',NULL,1,0,0,0,0,0,0,4,1,'alert'),(2,'Libre',2,0,'FREE',NULL,2,1,0,0,0,1,0,4,1,'notice'),(3,'OK',3,0,'OK',3,28,1,0,0,0,1,1,3,0,'success'),(4,'Impreso',4,0,'PRINTED',2,29,1,0,1,0,0,1,2,0,'success'),(5,'Preparación',6,1,'ON_PREPARATION',7,5,0,0,0,2,0,0,2,0,'warning'),(6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0,1,0,3,0,0,1,0,'warning'),(7,'Sin Acabar',1,0,'NOT_READY',NULL,7,0,0,0,0,0,0,4,1,'alert'),(8,'Revisado',8,1,'CHECKED',NULL,8,0,1,0,3,0,0,1,0,'warning'),(9,'Encajando',9,2,'PACKING',NULL,9,0,1,0,0,0,0,1,0,NULL),(10,'Encajado',10,2,'PACKED',NULL,10,0,1,0,0,0,0,0,0,NULL),(11,'Facturado',0,3,'INVOICED',NULL,11,0,1,0,0,0,0,0,0,NULL),(12,'Bloqueado',0,0,'BLOCKED',NULL,12,0,0,0,0,0,0,4,1,'alert'),(13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0,1,0,0,0,0,0,0,NULL),(14,'Preparado',6,1,'PREPARED',NULL,14,0,1,0,2,0,0,1,0,'warning'),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0,1,0,0,0,0,0,0,NULL),(16,'Entregado',13,3,'DELIVERED',NULL,16,0,1,0,0,0,0,0,0,NULL),(20,'Asignado',4,0,'PICKER_DESIGNED',NULL,20,1,0,0,0,0,0,2,0,'success'),(21,'Retornado',4,1,'PRINTED_BACK',6,21,0,0,0,0,0,0,2,0,'success'),(22,'Pte. Ampliar',2,0,'EXPANDABLE',NULL,22,0,0,0,0,0,0,4,1,'alert'),(23,'URGENTE',5,1,'LAST_CALL',NULL,23,1,0,1,0,0,0,4,1,'success'),(24,'Encadenado',4,0,'CHAINED',4,24,0,0,0,0,0,0,3,1,'success'),(25,'Embarcando',3,0,'BOARDING',5,25,1,0,0,0,0,0,3,0,'alert'),(26,'Prep Previa',5,1,'PREVIOUS_PREPARATION',1,28,0,0,0,1,0,0,2,0,'warning'),(27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0,0,0,0,0,0,2,0,'success'),(28,'Previa OK',3,1,'OK PREVIOUS',3,28,0,0,0,1,1,1,3,0,'warning'),(29,'Previa Impreso',4,1,'PRINTED PREVIOUS',2,29,0,0,1,1,0,1,3,0,'success'),(30,'Embarcado',4,1,'BOARD',5,30,0,0,0,2,0,0,3,0,'success'),(31,'Polizon Impreso',4,1,'PRINTED STOWAWAY',2,29,1,0,1,0,0,1,3,0,'success'),(32,'Polizon OK',3,1,'OK STOWAWAY',3,31,1,0,0,1,1,1,3,0,'warning'),(33,'Auto_Impreso',4,0,'PRINTED_AUTO',2,29,1,0,1,0,0,1,2,0,'success'),(34,'Pte Pago',3,0,'WAITING_FOR_PAYMENT',NULL,34,0,0,0,0,0,0,4,1,'alert'),(35,'Semi-Encajado',9,2,'HALF_PACKED',NULL,10,0,1,0,0,0,0,1,0,NULL),(36,'Control Previa',3,1,'PREVIOUS_CONTROL',1,36,0,1,0,4,0,1,3,0,'warning'); /*!40000 ALTER TABLE `state` ENABLE KEYS */; UNLOCK TABLES; @@ -452,7 +472,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2022-03-28 9:44:14 +-- Dump completed on 2022-05-02 10:56:21 USE `cache`; -- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64) -- @@ -488,7 +508,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2022-03-28 9:44:14 +-- Dump completed on 2022-05-02 10:56:21 USE `hedera`; -- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64) -- @@ -506,6 +526,16 @@ USE `hedera`; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +-- +-- Dumping data for table `browser` +-- + +LOCK TABLES `browser` WRITE; +/*!40000 ALTER TABLE `browser` DISABLE KEYS */; +INSERT INTO `browser` VALUES ('Chrome',29),('Firefox',20),('Iceweasel',20),('IE',12),('Opera',12),('Safari',9); +/*!40000 ALTER TABLE `browser` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Dumping data for table `imageCollection` -- @@ -516,6 +546,106 @@ INSERT INTO `imageCollection` VALUES (1,'catalog','Artículo',3840,2160,'Item',' /*!40000 ALTER TABLE `imageCollection` ENABLE KEYS */; UNLOCK TABLES; +-- +-- Dumping data for table `imageCollectionSize` +-- + +LOCK TABLES `imageCollectionSize` WRITE; +/*!40000 ALTER TABLE `imageCollectionSize` DISABLE KEYS */; +INSERT INTO `imageCollectionSize` VALUES (2,1,50,50,1),(3,1,200,200,1),(5,5,200,200,1),(6,1,70,70,1),(8,5,50,50,1),(9,1,1600,900,0),(13,6,160,160,1),(14,6,520,520,1),(15,6,1600,1600,1); +/*!40000 ALTER TABLE `imageCollectionSize` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `language` +-- + +LOCK TABLES `language` WRITE; +/*!40000 ALTER TABLE `language` DISABLE KEYS */; +INSERT INTO `language` VALUES ('ca','Català','Catalan',1),('en','English','English',1),('es','Español','Spanish',1),('fr','Français','French',1),('mn','Португалий','Mongolian',1),('pt','Português','Portuguese',1); +/*!40000 ALTER TABLE `language` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `link` +-- + +LOCK TABLES `link` WRITE; +/*!40000 ALTER TABLE `link` DISABLE KEYS */; +INSERT INTO `link` VALUES (16,'Printing server','Manage the CUPS printing server','http://server.verdnatura.es:631','printer'),(20,'Webmail','Verdnatura webmail','https://webmail.verdnatura.es/','mail'),(23,'Verdnatura Beta','Trial version of the web page','https://test.verdnatura.es/','vn'),(25,'Shared folder','Shared folder','/share','backup'),(29,'phpMyAdmin','Manage MySQL database','https://pma.verdnatura.es/','pma'),(30,'Nagios','Monitoring system','https://nagios.verdnatura.es/','nagios'),(33,'Gitea','Version control system','https://gitea.verdnatura.es/','git'),(34,'Wiknatura','Verdnatura wiki page','https://wiki.verdnatura.es/','wiki'),(35,'phpLDAPadmin','Manage the LDAP database','https://pla.verdnatura.es/','pla'),(36,'Applications','Access applications repository','/vn-access','backup'); +/*!40000 ALTER TABLE `link` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `location` +-- + +LOCK TABLES `location` WRITE; +/*!40000 ALTER TABLE `location` DISABLE KEYS */; +INSERT INTO `location` VALUES (2,'39.2095886','-0.4173501','Valencia','Calle Fenollar, 2','46680','Algemesi','Valencia','963 242 100','es'),(3,'40.4564969','-3.4875829','Madrid','Avenida de la Constitución, 3 - Nave E','28850','Torrejón de Ardoz','Madrid','916 774 777',NULL),(4,'41.4962045','2.3765504','Barcelona','Camí del crist, 33','08340','Vilassar de Mar','Barcelona','607 562 391','ca'),(5,'52.2612312','4.7818154','Holland','Aalsmeer Flower Auction','1430 BA','Legmeerdijk 313','Aalsmeer','Nederland','nl'),(6,'43.4375416','5.2261456','Marseille','ruben@verdnatura.es','13054','Marigname','Marseille','+33 781 533 900','fr'); +/*!40000 ALTER TABLE `location` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `menu` +-- + +LOCK TABLES `menu` WRITE; +/*!40000 ALTER TABLE `menu` DISABLE KEYS */; +INSERT INTO `menu` VALUES (1,'Home','cms/home',6,NULL,1),(2,'Orders',NULL,11,NULL,1),(3,'Catalog','ecomerce/catalog',6,NULL,2),(5,'About',NULL,6,NULL,2),(6,'Location','cms/location',6,5,2),(7,'Administration',NULL,1,NULL,2),(8,'Users','admin/users',1,7,2),(9,'Connections','admin/connections',1,7,2),(11,'Agencies','agencies/packages',3,NULL,2),(12,'News','news/news',1,7,3),(14,'Why','cms/why',6,5,2),(15,'Photos','admin/photos',1,7,3),(16,'Training','cms/training',6,NULL,2),(17,'Configuration',NULL,11,NULL,3),(19,'Control panel','admin/links',1,7,1),(20,'About us','cms/about',6,5,1),(21,'Basket','ecomerce/basket',11,NULL,1),(22,'Last orders','ecomerce/orders',11,2,2),(23,'Invoices','ecomerce/invoices',11,2,2),(24,'Account','account/conf',11,17,1),(25,'Addresses','account/address-list',11,17,2),(26,'Shelves','reports/shelves',1,29,1),(27,'Items list','reports/items-form',1,29,1),(28,'Visits','admin/visits',1,7,2),(29,'Reports',NULL,1,NULL,2),(30,'Items','admin/items',1,7,3); +/*!40000 ALTER TABLE `menu` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `message` +-- + +LOCK TABLES `message` WRITE; +/*!40000 ALTER TABLE `message` DISABLE KEYS */; +INSERT INTO `message` VALUES (1,'ORDER_DATE_HOLIDAY','No es posible realizar pedidos para días festivos'),(2,'ORDER_EMPTY','El pedido esta vacío'),(3,'ORDER_UNAVAILABLE','Algunos artículos ya no están disponibles, verifica las cantidades resaltadas en rojo'),(4,'SURVEY_MAX_ONE_VOTE','Solo es posible realizar un voto por encuesta'),(5,'ORDER_MAX_EXCEEDED','Has excedido el número máximo de pedidos por confirmar, por favor elimina o confirma los pedidos iniciados'),(6,'LOGIN_INCORRECT','Usuario o contraseña incorrectos. Recuerda que se hace distinción entre mayúsculas y minúsculas.'),(7,'ORDER_DATE_PAST','La fecha de su pedido debe ser mayor o igual al día de hoy'),(8,'ORDER_DATE_LAST','No es posible realizar más para hoy, por favor atrasa la fecha de tu pedido a mañana o días posteriores'),(9,'ORDER_DATE_SUNDAY','No es posible confirmar pedidos para Domingo'),(10,'ORDER_DATE_SATURATED','Estamos saturados de pedidos, por favor selecciona otra fecha de envío o recogida '),(11,'USER_DISCONNECTED','Has sido desconectado del servidor, por favor vuelve a iniciar sesión'),(12,'UNAUTH_ACTION','Acción no permitida'),(13,'ORDER_INVALID_AGENCY','La agencia de envío no es válida'),(14,'ORDER_EMPTY_ADDRESS','Selecciona una dirección de envío'),(15,'ORDER_AMOUNT_ROUNDED','Este artículo se vende agrupado y la cantidad ha sido redondeada'),(16,'ORDER_ALREADY_CONFIRMED','Este pedido ya estaba confirmado'); +/*!40000 ALTER TABLE `message` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `metatag` +-- + +LOCK TABLES `metatag` WRITE; +/*!40000 ALTER TABLE `metatag` DISABLE KEYS */; +INSERT INTO `metatag` VALUES (2,'title','Verdnatura Levante SL, mayorista de flores, plantas y complementos para floristería y decoración'),(3,'description','Verdnatura Levante SL, mayorista de flores, plantas y complementos para floristería y decoración. Envío a toda España, pedidos por internet o por teléfono.'),(4,'keywords','verdnatura, mayorista, floristería, flores, verdes, plantas, ramos, complementos, artificial, natural, decoración, rosas, helecho, fern, clavel, lilium, orquídea, tulipan, crisantemo, cala, gerbera, hiedra, eucaliptus, cinerea, aralia'),(6,'revisit-after','15 days'),(7,'rating','general'),(8,'author','Juan Ferrer Toribio'),(9,'owner','Verdnatura Levante S.L.'),(10,'robots','index, follow'); +/*!40000 ALTER TABLE `metatag` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `newsTag` +-- + +LOCK TABLES `newsTag` WRITE; +/*!40000 ALTER TABLE `newsTag` DISABLE KEYS */; +INSERT INTO `newsTag` VALUES ('course','Curso'),('new','Noticia'),('offer','Oferta'); +/*!40000 ALTER TABLE `newsTag` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `restPriv` +-- + +LOCK TABLES `restPriv` WRITE; +/*!40000 ALTER TABLE `restPriv` DISABLE KEYS */; +INSERT INTO `restPriv` VALUES (1,'tpv/transaction',2),(2,'dms/add',1),(3,'image/upload',1),(4,'misc/sms',1),(5,'core/supplant',1),(6,'core/sync-user',5),(7,'core/set-password',1),(8,'core/change-password',11),(9,'misc/access-version',9); +/*!40000 ALTER TABLE `restPriv` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `social` +-- + +LOCK TABLES `social` WRITE; +/*!40000 ALTER TABLE `social` DISABLE KEYS */; +INSERT INTO `social` VALUES (1,'Blog','https://blog.verdnatura.es/','blog.svg',0),(3,'Facebook','http://www.facebook.com/verdnatura','facebook.svg',2),(4,'YouTube','http://www.youtube.com/user/verdnatura','youtube.svg',2),(5,'Twitter','https://twitter.com/Verdnatura','twitter.svg',1),(6,'Instagram','https://www.instagram.com/verdnatura','instagram.svg',2),(7,'Linkedin','https://www.linkedin.com/company/verdnatura','linkedin.svg',1),(8,'Pinterest','https://es.pinterest.com/verdnatura/','pinterest.svg',1); +/*!40000 ALTER TABLE `social` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Dumping data for table `tpvError` -- @@ -535,16 +665,6 @@ LOCK TABLES `tpvResponse` WRITE; INSERT INTO `tpvResponse` VALUES (101,'Tarjeta Caducada'),(102,'Tarjeta en excepción transitoria o bajo sospecha de fraude'),(104,'Operación no permitida para esa tarjeta o terminal'),(106,'Intentos de PIN excedidos'),(116,'Disponible Insuficiente'),(118,'Tarjeta no Registrada'),(125,'Tarjeta no efectiva'),(129,'Código de seguridad (CVV2/CVC2) incorrecto'),(180,'Tarjeta ajena al servicio'),(184,'Error en la autenticación del titular'),(190,'Denegación sin especificar motivo'),(191,'Fecha de caducidad errónea'),(202,'Tarjeta en excepción transitoria o bajo sospecha de fraude con retirada de tarjeta'),(904,'Comercio no registrado en FUC'),(909,'Error de sistema'),(912,'Emisor no Disponible'),(913,'Pedido repetido'),(944,'Sesión Incorrecta'),(950,'Operación de devolución no permitida'),(9064,'Número de posiciones de la tarjeta incorrecto'),(9078,'No existe método de pago válido para esa tarjeta'),(9093,'Tarjeta no existente'),(9094,'Rechazo servidores internacionales'),(9104,'A petición del usuario se ha cancelado el pago'),(9218,'El comercio no permite op. seguras por entrada /operaciones'),(9253,'Tarjeta no cumple el check-digit'),(9256,'El comercio no puede realizar preautorizaciones'),(9257,'Esta tarjeta no permite operativa de preautorizaciones'),(9261,'Operación detenida por superar el control de restricciones en la entrada al SIS'),(9912,'Emisor no Disponible'),(9913,'Error en la confirmación que el comercio envía al TPV Virtual (solo aplicable en la opción de sincronización SOAP)'),(9914,'Confirmación “KO” del comercio (solo aplicable en la opción de sincronización SOAP)'),(9915,'A petición del usuario se ha cancelado el pago'),(9928,'Anulación de autorización en diferido realizada por el SIS (proceso batch)'),(9929,'Anulación de autorización en diferido realizada por el comercio'),(9998,'Operación en proceso de solicitud de datos de tarjeta'),(9999,'Operación que ha sido redirigida al emisora autenticar'); /*!40000 ALTER TABLE `tpvResponse` ENABLE KEYS */; UNLOCK TABLES; - --- --- Dumping data for table `imageCollectionSize` --- - -LOCK TABLES `imageCollectionSize` WRITE; -/*!40000 ALTER TABLE `imageCollectionSize` DISABLE KEYS */; -INSERT INTO `imageCollectionSize` VALUES (2,1,50,50,1),(3,1,200,200,1),(5,5,200,200,1),(6,1,70,70,1),(8,5,50,50,1),(9,1,1600,900,0),(13,6,160,160,1),(14,6,520,520,1),(15,6,1600,1600,1); -/*!40000 ALTER TABLE `imageCollectionSize` ENABLE KEYS */; -UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; @@ -554,7 +674,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2022-03-28 9:44:14 +-- Dump completed on 2022-05-02 10:56:21 USE `postgresql`; -- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64) -- @@ -640,7 +760,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2022-03-28 9:44:14 +-- Dump completed on 2022-05-02 10:56:21 USE `sage`; -- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64) -- @@ -696,4 +816,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2022-03-28 9:44:14 +-- Dump completed on 2022-05-02 10:56:21 diff --git a/db/dump/structure.sql b/db/dump/structure.sql index f317dd7f7..a9e21b377 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -2674,22 +2674,6 @@ CREATE TABLE `compradores_evolution` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `conveyorStats` --- - -DROP TABLE IF EXISTS `conveyorStats`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `conveyorStats` ( - `created` datetime NOT NULL, - `saturacion` int(11) DEFAULT NULL, - `velocidad` int(11) DEFAULT NULL, - `rutas` int(11) DEFAULT NULL, - PRIMARY KEY (`created`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `customerEvolution` -- @@ -3062,21 +3046,6 @@ CREATE TABLE `nightTaskConfig` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `novemberSales` --- - -DROP TABLE IF EXISTS `novemberSales`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `novemberSales` ( - `ticketFk` int(11) NOT NULL, - `saleFk` int(11) NOT NULL DEFAULT '0', - `año` int(4) DEFAULT NULL, - `importe` decimal(28,8) DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `packingSpeed` -- @@ -3190,32 +3159,6 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `salaries2018` --- - -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', - `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, - `Modalidad` varchar(22) CHARACTER SET utf8mb4 NOT NULL DEFAULT '', - `reason` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `worker` varchar(82) CHARACTER SET utf8 DEFAULT NULL, - `totalDays` decimal(32,0) DEFAULT NULL, - `totalAnual` decimal(16,0) DEFAULT NULL, - `virtualMonthlySalary` decimal(16,0) DEFAULT NULL, - `departamento` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `category_name` varchar(50) CHARACTER SET utf8 NOT NULL, - `level_name` varchar(5) CHARACTER SET utf8 DEFAULT NULL, - `thisYearDateStart` varchar(10) CHARACTER SET utf8mb4 DEFAULT NULL, - PRIMARY KEY (`person_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `sale` -- @@ -4148,44 +4091,12 @@ DELIMITER ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `carteras_add`() -BEGIN - -DELETE FROM bs.carteras -WHERE Año >= YEAR(CURDATE()) - 1; - -INSERT INTO bs.carteras(Año,Mes,CodigoTrabajador,Peso) -SELECT year as Año, month as Mes, CodigoTrabajador, sum(importe) as Peso -FROM vn2008.time t -JOIN bs.ventas v on t.date = v.fecha -JOIN vn2008.Clientes c on c.Id_Cliente = v.Id_Cliente -JOIN vn2008.Trabajadores tr on tr.Id_Trabajador = c.Id_Trabajador -WHERE t.year >= YEAR(CURDATE()) - 1 -GROUP BY CodigoTrabajador, Año, Mes; - - -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 `carteras_add2` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `carteras_add2`() BEGIN /** - * Inserta en "bs.carteras". + * Inserta en @bs.carteras. */ DELETE FROM bs.carteras - WHERE Año >= YEAR(CURDATE()) - 1; + WHERE Año >= YEAR(CURDATE()) - 1; INSERT INTO bs.carteras(Año,Mes,CodigoTrabajador,Peso) SELECT t.year AS Año, t.month AS Mes, w.code AS CodigoTrabajador, SUM(v.importe) AS Peso @@ -4215,9 +4126,11 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `clean`() BEGIN DECLARE vFourYearsAgo DATETIME; DECLARE vOneYearAgo DATETIME; + DECLARE vTwoYearAgo DATETIME; - SET vFourYearsAgo = TIMESTAMPADD(YEAR, -4,CURDATE()); SET vOneYearAgo = TIMESTAMPADD(YEAR, -1,CURDATE()); + SET vTwoYearAgo = TIMESTAMPADD(YEAR, -2,CURDATE()); + SET vFourYearsAgo = TIMESTAMPADD(YEAR, -4,CURDATE()); DELETE FROM bs.clientNewBorn WHERE lastShipped < vOneYearAgo; @@ -4230,6 +4143,12 @@ BEGIN DELETE FROM payMethodClientEvolution WHERE dated < vFourYearsAgo; + + DELETE FROM bs.salesByclientSalesPerson + WHERE dated < vFourYearsAgo; + + DELETE FROM bs.m3 + WHERE fecha < vTwoYearAgo; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -4642,51 +4561,14 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `compradores_add`(IN intYEAR INT, IN intWEEK_START INT, IN intWEEK_END INT) -BEGIN - -REPLACE bs.compradores - -SELECT tp.Id_Trabajador - , intYEAR as año - , tm.week as semana - , sum(importe) as importe - , 0 as comision - -FROM bs.ventas v -JOIN vn2008.time tm on tm.date = v.fecha -JOIN vn2008.Tipos tp using(tipo_id) -WHERE tm.year = intYEAR and tm.week between intWEEK_START and intWEEK_END -AND reino_id != 6 -GROUP BY tp.Id_Trabajador, tm.week; - - - - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `compradores_add2` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `compradores_add2`(IN vYear INT, IN vWeekFrom INT, IN vWeekTo INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `compradores_add`(IN vYear INT, IN vWeekFrom INT, IN vWeekTo INT) BEGIN /** * Sustituye los registros de "bs.compradores". * * @param vYear: año ventas * @param vWeekFrom: semana desde - * @param vWeekTo: semana hastas + * @param vWeekTo: semana hasta */ REPLACE bs.compradores SELECT it.workerFk AS Id_Trabajador, vYear AS año, tm.week AS semana, SUM(importe) AS importe, 0 AS comision @@ -4858,91 +4740,6 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `fondo_evolution_add`() BEGIN -/* - -Inserta en la tabla fondo_maniobra los saldos acumulados en los ultimos 365 dias - -*/ - -DECLARE datFEC DATE DEFAULT '2015-01-01'; - - -SELECT TIMESTAMPADD(DAY,1,MAX(fecha)) INTO datFEC FROM bs.fondo_maniobra; - - WHILE datFEC < CURDATE() DO - - -- esto solo sirve para no aburrirse mientras esperamos... - - IF day(datFEC) mod 28 = 0 then - SELECT datFEC; - end if; - - - REPLACE bs.fondo_maniobra(Fecha, clientes_facturas, clientes_cobros,proveedores_facturas,proveedores_pagos, fondo) - SELECT datFEC as Fecha, Facturas, Cobros,Recibidas,Pagos, Facturas + Cobros + Recibidas + Pagos - FROM - ( - SELECT Sum(Facturas.Importe) AS Facturas - FROM vn2008.Facturas - INNER JOIN vn2008.Clientes ON Facturas.Id_Cliente = Clientes.Id_cliente - WHERE Clientes.`real` - AND empresa_id <>1381 - AND Fecha between '2011-01-01' and datFEC) fac - JOIN - ( - SELECT - Sum(Entregado) AS Cobros - FROM vn2008.Recibos - INNER JOIN vn2008.Clientes ON Recibos.Id_Cliente = Clientes.Id_cliente - WHERE Clientes.`real` - AND empresa_id <> 1381 - AND Fechacobro Between '2011-01-01' and datFEC) cob - JOIN - ( - SELECT - Sum(cantidad) AS Recibidas - FROM vn2008.recibida - INNER JOIN vn2008.recibida_vencimiento ON recibida.id = recibida_vencimiento.recibida_id - WHERE empresa_id <> 1381 - AND recibida.fecha Between '2015-01-01' and datFEC) rec - JOIN - ( - SELECT Sum(importe) AS Pagos - FROM vn2008.pago - WHERE empresa_id <>1381 AND pago.fecha Between '2015-01-01' and datFEC) pag; - - - - UPDATE bs.fondo_maniobra - JOIN - (SELECT avg(fondo) as media - FROM bs.fondo_maniobra - WHERE fecha <= datFEC) sub - SET fondo_medio = media - WHERE fecha = datFEC; - - - SET datFEC = TIMESTAMPADD(DAY,1,datFEC); - - END WHILE; - - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `fondo_evolution_add2` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `fondo_evolution_add2`() -BEGIN /** * Inserta en la tabla fondo_maniobra los saldos acumulados en los ultimos 365 dias */ @@ -16363,9 +16160,9 @@ DELIMITER ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8mb4 */ ; /*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `order_confirmWithUser`(IN `vOrder` INT, IN `vUserId` INT) BEGIN @@ -16490,7 +16287,7 @@ BEGIN SET vShipment = IFNULL(vShipment, CURDATE()); - CALL vn.ticketCreateWithUser( + CALL vn.ticket_add( vClientId, vShipment, vWarehouse, @@ -16500,6 +16297,7 @@ BEGIN NULL, vDelivery, vUserId, + TRUE, vTicket ); ELSE @@ -26668,6 +26466,8 @@ CREATE TABLE `addressFilter` ( `isVNHSupplier` tinyint(1) DEFAULT '0' COMMENT 'corresponde al campo edi.VMPSettings.isVNHSupplier', `isEarlyBird` tinyint(1) DEFAULT '0' COMMENT 'corresponde al campo edi.marketPlace.isEarlybird', `warehouseFk` smallint(5) unsigned DEFAULT NULL, + `beforeDated` date DEFAULT NULL, + `afterDated` date DEFAULT NULL, PRIMARY KEY (`id`), KEY `addressFilter_FK` (`provinceFk`), KEY `addressFilter_FK_1` (`countryFk`), @@ -26857,6 +26657,21 @@ CREATE TABLE `agencyTerm` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `agencyTermConfig` +-- + +DROP TABLE IF EXISTS `agencyTermConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `agencyTermConfig` ( + `expenceFk` varchar(10) DEFAULT NULL, + `vatAccountSupported` varchar(15) DEFAULT NULL, + `vatPercentage` decimal(28,10) DEFAULT NULL, + `transaction` varchar(50) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `alertLevel` -- @@ -27463,15 +27278,15 @@ CREATE TABLE `budgetNotes` ( /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`$manager`@`%`*/ /*!50003 TRIGGER budgetNotes_BeforeInsert -BEFORE INSERT -ON budgetNotes FOR EACH ROW +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`budgetNotes_BeforeInsert` + BEFORE INSERT ON `budgetNotes` + FOR EACH ROW BEGIN IF ISNULL(NEW.userFk) THEN @@ -27607,6 +27422,7 @@ trig: BEGIN DECLARE vGrouping INT; DECLARE vGroupingMode TINYINT; DECLARE vGenericFk INT; + DECLARE vGenericInDate BOOL; IF @isModeInventory THEN LEAVE trig; @@ -27645,9 +27461,20 @@ trig: BEGIN IF vGenericFk THEN - SET NEW.itemOriginalFk = NEW.itemFk; - - SET NEW.itemFk = vGenericFk; + SELECT COUNT(*) INTO vGenericInDate + FROM vn.genericAllocation ga + JOIN vn.entry e ON e.id = NEW.entryFk + JOIN vn.travel tr on tr.id = e.travelFk + WHERE ga.itemFk = vGenericFk + AND tr.landed BETWEEN ga.startDated AND ga.endDated; + + IF vGenericInDate THEN + + SET NEW.itemOriginalFk = NEW.itemFk; + + SET NEW.itemFk = vGenericFk; + + END IF; END IF; @@ -27696,8 +27523,8 @@ DELIMITER ;; BEFORE UPDATE ON `buy` FOR EACH ROW trig:BEGIN - DECLARE vGenericFk INT; + DECLARE vGenericInDate BOOL; IF @isTriggerDisabled THEN @@ -27717,12 +27544,22 @@ trig:BEGIN IF vGenericFk THEN - SET NEW.itemOriginalFk = NEW.itemFk; - - SET NEW.itemFk = vGenericFk; + SELECT COUNT(*) INTO vGenericInDate + FROM vn.genericAllocation ga + JOIN vn.entry e ON e.id = NEW.entryFk + JOIN vn.travel tr on tr.id = e.travelFk + WHERE ga.itemFk = vGenericFk + AND tr.landed BETWEEN ga.startDated AND ga.endDated; + + IF vGenericInDate THEN + + SET NEW.itemOriginalFk = NEW.itemFk; + + SET NEW.itemFk = vGenericFk; + + END IF; END IF; - END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -27746,6 +27583,8 @@ trig: BEGIN DECLARE vBuyerFk INT; DECLARE vIsBuyerToBeEmailed BOOL; DECLARE vItemName VARCHAR(50); + DECLARE vIsInventory BOOL; + DECLARE vEmail VARCHAR(255); IF !(NEW.id <=> OLD.id) OR !(NEW.entryFk <=> OLD.entryFk) @@ -27797,7 +27636,34 @@ trig: BEGIN 'Este email se ha generado automáticamente' ); END IF; + END IF; + + SELECT e.isInventory INTO vIsInventory + FROM entry e + WHERE e.id = NEW.entryFk; + + SELECT e.mailToNotify INTO vEmail + FROM entryConfig e + LIMIT 1; + + IF vIsInventory AND + (!(NEW.quantity <=> OLD.quantity) + OR !(NEW.price1<=>OLD.price1) + OR !(NEW.price2<=>OLD.price2) + OR !(NEW.price3<=>OLD.price3)) THEN + + CALL mail_insert( + vEmail, + NULL, + CONCAT('Se ha modificado la entrada ', NEW.entryFk ,' del Artículo ', NEW.itemFk, ' siendo inventario'), + CONCAT( + 'Antes: Cantidad: ', OLD.quantity, ' Precio1: ', OLD.price1, ' Precio2: ', OLD.price2, ' Precio3: ', OLD.price3, + '
', + 'Despues: Cantidad: ', NEW.quantity, ' Precio1: ', NEW.price1, ' Precio2: ', NEW.price2, ' Precio3: ', NEW.price3 + ) + ); END IF; + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -28736,6 +28602,46 @@ CREATE TABLE `clientDms` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `clientItemCategory` +-- + +DROP TABLE IF EXISTS `clientItemCategory`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `clientItemCategory` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `clientFk` int(11) NOT NULL, + `itemCategoryFk` int(10) unsigned NOT NULL, + PRIMARY KEY (`id`), + KEY `clientItemCategory_FK` (`clientFk`), + KEY `clientItemCategory_FK_1` (`itemCategoryFk`), + CONSTRAINT `clientItemCategory_FK` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `clientItemCategory_FK_1` FOREIGN KEY (`itemCategoryFk`) REFERENCES `itemCategory` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `clientItemType` +-- + +DROP TABLE IF EXISTS `clientItemType`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `clientItemType` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `clientFk` int(11) NOT NULL, + `itemTypeFk` varchar(3) COLLATE utf8_unicode_ci NOT NULL, + `isAllowed` tinyint(1) DEFAULT '0', + PRIMARY KEY (`id`), + KEY `clientItemType_FK` (`clientFk`), + KEY `clientItemType_FK_1` (`itemTypeFk`), + CONSTRAINT `clientItemType_FK` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `clientItemType_FK_1` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`code`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='son familias de productos que se quieren sustraer a la oferta del cliente'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `clientLog` -- @@ -29038,6 +28944,7 @@ CREATE TABLE `cmr` ( `merchandiseDetail` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `state` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `landed` datetime DEFAULT NULL COMMENT 'Hora de llegada a destino', + `ead` datetime DEFAULT NULL COMMENT 'Estimated Arriving Date', PRIMARY KEY (`id`), KEY `cmr_fk1_idx` (`ticketFk`), KEY `cmr_fk2_idx` (`companyFk`), @@ -29100,7 +29007,8 @@ DROP TABLE IF EXISTS `cmrConfig`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `cmrConfig` ( - `dayOfMonth` int(11) DEFAULT NULL + `dayOfMonth` int(11) DEFAULT NULL, + `landingDays` tinyint(4) NOT NULL DEFAULT '1' ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -30351,11 +30259,14 @@ CREATE TABLE `department` ( `hasToSendMail` tinyint(1) DEFAULT '0' COMMENT 'Para el envio de mail en el procedimiento workerTimeControl_sendMail()', `hasToCheckLogin` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Para comprobar en el login de la app', `hasToMistake` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Indica si al departamento pueden serles puestos errores', + `clientFk` int(11) DEFAULT NULL COMMENT 'Cuenta de cliente que se utiliza para los compras de consumo departamental', PRIMARY KEY (`id`), UNIQUE KEY `name_UNIQUE` (`name`), KEY `fk_department_Trabajadores1_idx` (`workerFk`), KEY `dep_org_ibfk_3_idx` (`companyFk`), KEY `lft_rgt_depth_idx` (`lft`,`rgt`,`depth`), + KEY `department_FK` (`clientFk`), + CONSTRAINT `department_FK` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_department_Trabajadores1` 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 */; @@ -30795,6 +30706,38 @@ CREATE TABLE `dock` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Se utiliza para el panel de grafana: https://grafana.verdnatura.es/d/w9w3Uo-7z/'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `docuware` +-- + +DROP TABLE IF EXISTS `docuware`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `docuware` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `code` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `fileCabinetName` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `dialogName` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `find` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `docuwareConfig` +-- + +DROP TABLE IF EXISTS `docuwareConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `docuwareConfig` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `url` varchar(75) COLLATE utf8_unicode_ci DEFAULT NULL, + `token` varchar(1000) COLLATE utf8_unicode_ci DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `dua` -- @@ -31322,6 +31265,7 @@ DROP TABLE IF EXISTS `entryConfig`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `entryConfig` ( `defaultEntry` int(11) NOT NULL, + `mailToNotify` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`defaultEntry`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -32490,6 +32434,10 @@ CREATE TABLE `genericAllocation` ( `numFlores` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, `category` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `productor` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `longName` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `size` int(11) DEFAULT NULL, + `startDated` date DEFAULT NULL, + `endDated` date DEFAULT NULL, PRIMARY KEY (`id`), KEY `genericAllocation_FK` (`itemFk`), KEY `genericAllocation_FK_1` (`typeFk`), @@ -32499,6 +32447,8 @@ CREATE TABLE `genericAllocation` ( KEY `genericAllocation_numFlores_IDX` (`numFlores`) USING BTREE, KEY `genericAllocation_category_IDX` (`category`) USING BTREE, KEY `genericAllocation_productor_IDX` (`productor`) USING BTREE, + KEY `genericAllocation_longName_IDX` (`longName`) USING BTREE, + KEY `genericAllocation_size_IDX` (`size`) USING BTREE, CONSTRAINT `genericAllocation_FK` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena los filtros para asignar códigos genéricos a los items'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -32702,33 +32652,35 @@ DROP TABLE IF EXISTS `host`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `host` ( + `id` int(11) NOT NULL AUTO_INCREMENT, `code` varchar(30) CHARACTER SET utf8 NOT NULL, `description` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `workerFk` int(10) unsigned DEFAULT NULL, `windowsSerial` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL, `printerFk` tinyint(3) unsigned DEFAULT NULL, - `itemPackingTypeFk` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, - `packingSite` tinyint(3) unsigned DEFAULT NULL, + `itemPackingTypeFk__` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, + `packingSite__` tinyint(3) unsigned DEFAULT NULL, `warehouseFk` smallint(5) unsigned DEFAULT '60', `companyFk` smallint(5) unsigned DEFAULT '442', `bankFk` int(11) DEFAULT '13', `routeDaysBefore` smallint(6) DEFAULT '2', `routeDaysAfter` smallint(6) DEFAULT '1', `updated` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`code`), + PRIMARY KEY (`id`), + UNIQUE KEY `host_UN` (`code`), KEY `configHost_FK_3` (`companyFk`), KEY `configHost_FK` (`printerFk`), - KEY `configHost_FK_1` (`itemPackingTypeFk`), + KEY `configHost_FK_1` (`itemPackingTypeFk__`), KEY `configHost_FK_2` (`warehouseFk`), KEY `configHost_FK_4` (`bankFk`), KEY `configHost_FK_5` (`workerFk`), CONSTRAINT `configHost_FK` FOREIGN KEY (`printerFk`) REFERENCES `printer` (`id`) ON UPDATE CASCADE, - CONSTRAINT `configHost_FK_1` FOREIGN KEY (`itemPackingTypeFk`) REFERENCES `itemPackingType` (`code`) ON UPDATE CASCADE, + CONSTRAINT `configHost_FK_1` FOREIGN KEY (`itemPackingTypeFk__`) REFERENCES `itemPackingType` (`code`) ON UPDATE CASCADE, CONSTRAINT `configHost_FK_2` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `configHost_FK_3` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE, CONSTRAINT `configHost_FK_4` FOREIGN KEY (`bankFk`) REFERENCES `accounting` (`id`) ON UPDATE CASCADE, CONSTRAINT `configHost_FK_5` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) -) 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 */ ; @@ -33303,7 +33255,7 @@ CREATE TABLE `invoiceInIntrastat` ( PRIMARY KEY (`id`), KEY `intrastat_id` (`intrastatFk`), KEY `invoiceInIntrastat_FK` (`invoiceInFk`), - CONSTRAINT `invoiceInIntrastat_FK` FOREIGN KEY (`invoiceInFk`) REFERENCES `invoiceIn` (`id`), + CONSTRAINT `invoiceInIntrastat_FK` FOREIGN KEY (`invoiceInFk`) REFERENCES `invoiceIn` (`id`) ON DELETE CASCADE, CONSTRAINT `invoiceInIntrastat_ibfk_1` FOREIGN KEY (`intrastatFk`) REFERENCES `intrastat` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -33838,7 +33790,7 @@ CREATE TABLE `item` ( `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', + `sectorFk` int(11) DEFAULT NULL, `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', @@ -33867,6 +33819,8 @@ CREATE TABLE `item` ( KEY `item_id12` (`quality`), KEY `item_family` (`family`), KEY `item_FK` (`genericFk`), + KEY `item_size_IDX` (`size`) USING BTREE, + KEY `item_size_IDX2` (`longName`) USING BTREE, CONSTRAINT `item_FK` FOREIGN KEY (`genericFk`) REFERENCES `item` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `item_expenceFk` FOREIGN KEY (`expenceFk`) REFERENCES `expence` (`id`) ON UPDATE CASCADE, CONSTRAINT `item_family` FOREIGN KEY (`family`) REFERENCES `itemFamily` (`code`) ON UPDATE CASCADE, @@ -34118,10 +34072,13 @@ CREATE TABLE `itemCategory` ( `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', + `departmentFk` int(11) DEFAULT NULL COMMENT 'Departamento responsable del manufacturado de esta categoria', PRIMARY KEY (`id`), UNIQUE KEY `reino_UNIQUE` (`name`), KEY `itemCategory_idx3` (`merchandise`), - KEY `itemCategoryDisplayIdx` (`display`) + KEY `itemCategoryDisplayIdx` (`display`), + KEY `itemCategory_FK` (`departmentFk`), + CONSTRAINT `itemCategory_FK` FOREIGN KEY (`departmentFk`) REFERENCES `department` (`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 */ ; @@ -34191,6 +34148,18 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `itemConfig` +-- + +DROP TABLE IF EXISTS `itemConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `itemConfig` ( + `isItemTagTriggerDisabled` tinyint(1) NOT NULL DEFAULT '1' +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `itemConversor__` -- @@ -34718,29 +34687,27 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving_AFTER_INSERT` AFTER INSERT ON `itemShelving` FOR EACH ROW -INSERT INTO vn.itemShelvingLog(itemShelvingFk, - workerFk, - accion, - itemFk, - shelvingFk, - quantity, - available, +INSERT INTO vn.itemShelvingLog(itemShelvingFk, + workerFk, + accion, + itemFk, + shelvingFk, + available, visible, - `grouping`, - packing, - stars) - VALUES( NEW.id, - NEW.userFk, - 'CREA REGISTRO', - NEW.itemFk, - NEW.shelvingFk, - NEW.quantity, - NEW.available, + `grouping`, + packing, + stars) + VALUES( NEW.id, + NEW.userFk, + 'CREA REGISTRO', + NEW.itemFk, + NEW.shelvingFk, + NEW.available, NEW.visible, - NEW.`grouping`, - NEW.packing, - NEW.stars - ) */;; + NEW.`grouping`, + NEW.packing, + NEW.stars + ) */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; @@ -34778,29 +34745,27 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving_AFTER_UPDATE` AFTER UPDATE ON `itemShelving` FOR EACH ROW -INSERT INTO vn.itemShelvingLog(itemShelvingFk, - workerFk, - accion, - itemFk, - shelvingFk, - quantity, - available, +INSERT INTO vn.itemShelvingLog(itemShelvingFk, + workerFk, + accion, + itemFk, + shelvingFk, + available, visible, - `grouping`, - packing, - stars) - VALUES( NEW.id, - account.userGetId(), - 'CAMBIO', - NEW.itemFk, - NEW.shelvingFk, - NEW.quantity, - NEW.available, + `grouping`, + packing, + stars) + VALUES( NEW.id, + account.userGetId(), + 'CAMBIO', + NEW.itemFk, + NEW.shelvingFk, + NEW.available, NEW.visible, - NEW.`grouping`, - NEW.packing, - NEW.stars - ) */;; + NEW.`grouping`, + NEW.packing, + NEW.stars + ) */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; @@ -34952,7 +34917,6 @@ SET character_set_client = utf8; /*!50001 CREATE TABLE `itemShelvingPlacementSupplyStock` ( `itemShelvingFk` tinyint NOT NULL, `itemFk` tinyint NOT NULL, - `quantity` tinyint NOT NULL, `packing` tinyint NOT NULL, `stock` tinyint NOT NULL, `longName` tinyint NOT NULL, @@ -35032,30 +34996,6 @@ BEGIN SET isPicked = TRUE WHERE id = NEW.saleFk; -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_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelvingSale_AFTER_DELETE` - AFTER DELETE ON `itemShelvingSale` - FOR EACH ROW -BEGIN - - UPDATE vn.itemShelving - SET visible = visible + OLD.quantity - WHERE itemShelving.id = OLD.itemShelvingFk; - END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -35221,7 +35161,12 @@ DELIMITER ;; FOR EACH ROW trig: BEGIN DECLARE vItemFk INT; - IF @isTriggerDisabled THEN + DECLARE visTriggerDisabled BOOL; + + SELECT isItemTagTriggerDisabled INTO visTriggerDisabled + FROM vn.itemConfig; + + IF @isTriggerDisabled OR visTriggerDisabled THEN LEAVE trig; END IF; @@ -35274,7 +35219,12 @@ DELIMITER ;; FOR EACH ROW trig: BEGIN DECLARE vItemFk INT; - IF @isTriggerDisabled THEN + DECLARE visTriggerDisabled BOOL; + + SELECT isItemTagTriggerDisabled INTO visTriggerDisabled + FROM vn.itemConfig; + + IF @isTriggerDisabled OR visTriggerDisabled THEN LEAVE trig; END IF; @@ -35305,7 +35255,12 @@ DELIMITER ;; FOR EACH ROW trig: BEGIN DECLARE vItemFk INT; - IF @isTriggerDisabled THEN + DECLARE visTriggerDisabled BOOL; + + SELECT isItemTagTriggerDisabled INTO visTriggerDisabled + FROM vn.itemConfig; + + IF @isTriggerDisabled OR visTriggerDisabled THEN LEAVE trig; END IF; @@ -36478,19 +36433,25 @@ CREATE TABLE `packagingGifts` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `packingSite` +-- Table structure for table `packingSite` -- DROP TABLE IF EXISTS `packingSite`; -/*!50001 DROP VIEW IF EXISTS `packingSite`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `packingSite` ( - `hostFk` tinyint NOT NULL, - `printerFk` tinyint NOT NULL, - `code` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `packingSite` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `code` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, + `hostFk` int(11) NOT NULL, + `printerFk` tinyint(3) unsigned DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `packingSite_UN` (`code`), + KEY `packingSite_FK_1` (`printerFk`), + KEY `packingSite_FK` (`hostFk`), + CONSTRAINT `packingSite_FK` FOREIGN KEY (`hostFk`) REFERENCES `host` (`id`), + CONSTRAINT `packingSite_FK_1` FOREIGN KEY (`printerFk`) REFERENCES `printer` (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `packingSiteLog` @@ -36501,8 +36462,7 @@ DROP TABLE IF EXISTS `packingSiteLog`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `packingSiteLog` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `itemPackingTypeFk` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, - `packingSite` tinyint(3) unsigned DEFAULT NULL, + `packingSiteFk` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, `hostFk` varchar(15) COLLATE utf8_unicode_ci NOT NULL, `workerFk` int(10) unsigned NOT NULL, `printerModelFk` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, @@ -36512,12 +36472,12 @@ CREATE TABLE `packingSiteLog` ( PRIMARY KEY (`id`), UNIQUE KEY `packingSiteLog_UN` (`id`), KEY `packingSiteLog_FK` (`workerFk`), - KEY `packingSiteLog_FK_3` (`itemPackingTypeFk`), KEY `packingSiteLog_FK_4` (`typeErrorFk`), KEY `packingSiteLog_FK_1` (`printerModelFk`), + KEY `packingSiteLog_FK_2` (`packingSiteFk`), CONSTRAINT `packingSiteLog_FK` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`), CONSTRAINT `packingSiteLog_FK_1` FOREIGN KEY (`printerModelFk`) REFERENCES `printerModel` (`code`) ON UPDATE CASCADE, - CONSTRAINT `packingSiteLog_FK_3` FOREIGN KEY (`itemPackingTypeFk`) REFERENCES `itemPackingType` (`code`) ON UPDATE CASCADE, + CONSTRAINT `packingSiteLog_FK_2` FOREIGN KEY (`packingSiteFk`) REFERENCES `packingSite` (`code`) ON UPDATE CASCADE, CONSTRAINT `packingSiteLog_FK_4` FOREIGN KEY (`typeErrorFk`) REFERENCES `packingSiteTypeError` (`code`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -36536,25 +36496,6 @@ CREATE TABLE `packingSiteTypeError` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `packingSite__` --- - -DROP TABLE IF EXISTS `packingSite__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `packingSite__` ( - `code` varchar(10) COLLATE utf8_unicode_ci NOT NULL, - `hostFk` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, - `printerFk` tinyint(3) unsigned DEFAULT NULL, - PRIMARY KEY (`code`), - KEY `packingSite_FK` (`hostFk`), - KEY `packingSite_FK_1` (`printerFk`), - CONSTRAINT `packingSite_FK` FOREIGN KEY (`hostFk`) REFERENCES `vn2008`.`config_host__` (`config_host_id`), - CONSTRAINT `packingSite_FK_1` FOREIGN KEY (`printerFk`) REFERENCES `printer` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `parking` -- @@ -37454,7 +37395,6 @@ CREATE TABLE `printServerQueue` ( `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `reportFk__` tinyint(3) unsigned DEFAULT NULL, PRIMARY KEY (`id`), - UNIQUE KEY `Id_Impresora_2` (`printerFk`,`priorityFk`,`labelReportFk`,`statusFk`,`param1`,`workerFk`,`param2`), KEY `Id_estado` (`statusFk`), KEY `Id_Impresora` (`printerFk`), KEY `Id_Prioridad` (`priorityFk`), @@ -37462,7 +37402,7 @@ CREATE TABLE `printServerQueue` ( KEY `printServerQueue_FK` (`labelReportFk`), CONSTRAINT `printServerQueue_FK` FOREIGN KEY (`labelReportFk`) REFERENCES `labelReport` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, 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 + CONSTRAINT `printServerQueue_printerFk` FOREIGN KEY (`printerFk`) REFERENCES `printer` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -37573,6 +37513,12 @@ CREATE TABLE `productionConfig` ( `rookieDays` int(11) NOT NULL DEFAULT '3' COMMENT 'dias en que se cuida con especial cuidado los pedidos de un cliente por ser nuevo o recuperado', `notBuyingMonths` int(11) NOT NULL DEFAULT '3' COMMENT 'numero de meses que han de pasar desde su ultima compra para considerar nueva la siguiente compra', `id` int(11) NOT NULL DEFAULT '1', + `isZoneClosedByExpeditionActivated` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'activa el procedimiento vn.zone_getClosed', + `maxNotReadyCollections` int(11) NOT NULL DEFAULT '5', + `minTicketsToCloseZone` int(11) DEFAULT '15' COMMENT 'mínimo numero de tickets que deben de tener expediciones para cerrar una zona', + `movingTicketDelRoute` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Si está activo, al cambiar la fecha de un ticket desde el F11, le quita la ruta', + `defaultZone` int(11) NOT NULL DEFAULT '697', + `defautlAgencyMode` int(11) NOT NULL DEFAULT '1328' COMMENT 'SENDING', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Recoge los parámetros que condicionan la producción'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -37815,14 +37761,14 @@ DROP TABLE IF EXISTS `propertyNotes`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `propertyNotes` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `propertyFk` int(10) unsigned NOT NULL, + `propertyFk` int(11) NOT NULL, `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `note` text COLLATE utf8_unicode_ci NOT NULL, `userFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `propertyNotes_FK_1` (`userFk`), KEY `propertyNotes_FK` (`propertyFk`), - CONSTRAINT `propertyNotes_FK` FOREIGN KEY (`propertyFk`) REFERENCES `account`.`user` (`id`), + CONSTRAINT `propertyNotes_FK` FOREIGN KEY (`propertyFk`) REFERENCES `property` (`id`), CONSTRAINT `propertyNotes_FK_1` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -38893,32 +38839,20 @@ BEGIN 'Este email se ha generado automáticamente' ) ); 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; - - IF !(NEW.quantity <=> OLD.quantity) THEN + IF (OLD.quantity > NEW.quantity) THEN + INSERT INTO saleComponent(saleFk, componentFk, value) + SELECT NEW.id, cm.id, sc.value + FROM saleComponent sc + JOIN component cd ON cd.id = sc.componentFk + JOIN component cm ON cm.code = 'mana' + WHERE saleFk = NEW.id AND cd.code = 'lastUnitsDiscount' + ON DUPLICATE KEY UPDATE value = sc.value + VALUES(value); + + DELETE sc.* + FROM vn.saleComponent sc + JOIN component c ON c.id = sc.componentFk + WHERE saleFk = NEW.id AND c.code = 'lastUnitsDiscount'; + END IF; INSERT IGNORE INTO `vn`.`routeRecalc` (`routeFk`) SELECT r.id FROM vn.sale s @@ -38929,6 +38863,22 @@ BEGIN AND r.created >= CURDATE() GROUP BY r.id; 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 + 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 + SET c.saleTotalCount = c.saleTotalCount + IF(OLD.quantity = 0, 1, -1); + + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -39174,8 +39124,8 @@ CREATE TABLE `saleGoal` ( `rank` smallint(6) NOT NULL, `walletWeightFrom` int(11) NOT NULL, `walletWeightTo` int(11) DEFAULT NULL, - `goal` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, - `goalType` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, + `goal` decimal(10,2) DEFAULT NULL, + `goalType` smallint(6) DEFAULT NULL COMMENT 'grado', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -40447,6 +40397,7 @@ CREATE TABLE `state` ( `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', + `classColor` varchar(12) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `code_UNIQUE` (`code`), KEY `state_id3` (`semaphore`), @@ -40470,8 +40421,8 @@ CREATE TABLE `stockBuyed` ( `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `reserved` decimal(10,2) DEFAULT NULL, `requested` decimal(10,2) DEFAULT NULL, + `description` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), - UNIQUE KEY `date_UNIQUE` (`date`,`user`), KEY `stockBuyed_user_idx` (`user`), CONSTRAINT `stockBuyedUserFk` FOREIGN KEY (`user`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -42981,11 +42932,18 @@ CREATE TABLE `vehicle` ( `deliveryPointFk` int(11) DEFAULT '6' COMMENT 'Direccion para Buscaman', `isKmTruckRate` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Computar km como camión en el cálculo de salario de reparto', `photo` blob, + `chassis` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'numero de bastidor', + `fuelTypeFk` int(11) DEFAULT NULL, + `ppeFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `empresa_id` (`companyFk`), KEY `provinceFk_idx` (`warehouseFk`), KEY `vehicle_deliveryPointFk_idx` (`deliveryPointFk`), + KEY `vehicle_FK` (`fuelTypeFk`), + KEY `vehicle_FK_1` (`ppeFk`), CONSTRAINT `provinceFk` FOREIGN KEY (`warehouseFk`) REFERENCES `province` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT `vehicle_FK` FOREIGN KEY (`fuelTypeFk`) REFERENCES `fuelType` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `vehicle_FK_1` FOREIGN KEY (`ppeFk`) REFERENCES `ppe` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `vehicle_deliveryPointFk` FOREIGN KEY (`deliveryPointFk`) REFERENCES `deliveryPoint` (`id`) ON UPDATE CASCADE, CONSTRAINT `vehicle_ibfk_1` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -43071,7 +43029,7 @@ CREATE TABLE `vehicleNotes` ( KEY `vehicleNotes_FK` (`vehicleFk`), CONSTRAINT `vehicleNotes_FK` FOREIGN KEY (`vehicleFk`) REFERENCES `vehicle` (`id`), CONSTRAINT `vehicleNotes_FK_1` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -43329,6 +43287,7 @@ CREATE TABLE `worker` ( `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', `sectorFk` int(11) DEFAULT NULL COMMENT 'Sector que tiene asociado el trabajador.', + `labelerFk` tinyint(3) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `CodigoTrabajador_UNIQUE` (`code`), UNIQUE KEY `user` (`user__`), @@ -43336,7 +43295,9 @@ CREATE TABLE `worker` ( UNIQUE KEY `Id_Cliente_Interno` (`clientFk__`), KEY `sub` (`sub`), KEY `boss_idx` (`bossFk`), + KEY `worker_FK` (`labelerFk`), CONSTRAINT `Clientes` FOREIGN KEY (`clientFk__`) REFERENCES `client` (`id`) ON UPDATE CASCADE, + CONSTRAINT `worker_FK` FOREIGN KEY (`labelerFk`) REFERENCES `printer` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `worker_ibfk_1` FOREIGN KEY (`id`) REFERENCES `account`.`user` (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -46737,6 +46698,42 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP FUNCTION IF EXISTS `firstDayOfWeek` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` FUNCTION `firstDayOfWeek`(vYear INT, vWeek INT) RETURNS date + DETERMINISTIC +BEGIN +/** + * Returns the date of the first day of the week + * + * @param vYear The year + * @param vWeek The week number + * @return Date of the first day of the week + */ + DECLARE vDate DATE; + + SELECT dated INTO vDate + FROM `time` + WHERE `year` = vYear + AND `week` = vWeek + ORDER BY dated + LIMIT 1; + + RETURN vDate; +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 `getAlert3State` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -48116,6 +48113,42 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP FUNCTION IF EXISTS `lastDayOfWeek` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` FUNCTION `lastDayOfWeek`(vYear INT, vWeek INT) RETURNS date + DETERMINISTIC +BEGIN +/** + * Returns the date of the last day of the week + * + * @param vYear The year + * @param vWeek The week number + * @return Date of the first day of the week + */ + DECLARE vDate DATE; + + SELECT dated INTO vDate + FROM `time` + WHERE `year` = vYear + AND `week` = vWeek + ORDER BY dated DESC + LIMIT 1; + + RETURN vDate; +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 `machineWorker_Worker` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -49357,7 +49390,7 @@ BEGIN LIMIT 1; IF vTicket IS NULL THEN - CALL vn.ticketCreateWithUser( + CALL vn.ticket_add( vClientFk, IFNULL(vShipped, CURDATE()), vWarehouseFk, @@ -49367,6 +49400,7 @@ BEGIN NULL, vShipped, `account`.`myUser_getId`(), + TRUE, vTicket ); END IF; @@ -50657,9 +50691,9 @@ DELIMITER ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8mb4 */ ; /*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `buyUltimate`(vWarehouseFk SMALLINT, vDated DATE) BEGIN @@ -50695,7 +50729,6 @@ BEGIN WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL) AND landed > vDated; - DROP TEMPORARY TABLE tmp.buyUltimateFromInterval; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -51604,31 +51637,30 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_calculate`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT) -BEGIN - - /** - * Calcula los articulos disponibles y sus precios - * - * @table tmp.item(itemFk) Listado de artículos a calcular - * @param vLanded Fecha de recepcion de mercancia - * @param vAddressFk Id del consignatario - * @param vAgencyModeFk Id de la agencia - * @return tmp.ticketCalculateItem(itemFk, available, producer, - * item, size, stems, category, inkFk, image, origin, price) - * @return tmp.ticketLot(warehouseFk, itemFk, available, buyFk) - * @return tmp.ticketComponent - * @return tmp.ticketComponentPrice - */ +BEGIN +/** + * Calcula los articulos disponibles y sus precios + * + * @table tmp.item(itemFk) Listado de artículos a calcular + * @param vLanded Fecha de recepcion de mercancia + * @param vAddressFk Id del consignatario + * @param vAgencyModeFk Id de la agencia + * @return tmp.ticketCalculateItem(itemFk, available, producer, + * item, size, stems, category, inkFk, image, origin, price) + * @return tmp.ticketLot(warehouseFk, itemFk, available, buyFk) + * @return tmp.ticketComponent + * @return tmp.ticketComponentPrice + */ DECLARE vAvailableCalc INT; - DECLARE vAvailableNoRaidsCalc INT; + -- DECLARE vAvailableNoRaidsCalc INT; DECLARE vShipped DATE; DECLARE vWarehouseFk SMALLINT; DECLARE vZoneFk INT; @@ -51668,6 +51700,7 @@ BEGIN origin VARCHAR(3), price DECIMAL(10,2), priceKg DECIMAL(10,2), + `grouping` INT(10) UNSIGNED, PRIMARY KEY `itemFk` (`itemFk`) ) ENGINE = MEMORY DEFAULT CHARSET=utf8; @@ -51682,7 +51715,7 @@ BEGIN END IF; CALL `cache`.available_refresh (vAvailableCalc, FALSE, vWarehouseFk, vShipped); - CALL `cache`.availableNoRaids_refresh (vAvailableNoRaidsCalc, FALSE, vWarehouseFk, vShipped); + -- CALL `cache`.availableNoRaids_refresh (vAvailableNoRaidsCalc, FALSE, vWarehouseFk, vShipped); CALL vn.buyUltimate(vWarehouseFk, vShipped); INSERT INTO tmp.ticketLot (warehouseFk, itemFk, available, buyFk, zoneFk) @@ -51692,12 +51725,15 @@ BEGIN bu.buyFk, vZoneFk FROM `cache`.available a - LEFT JOIN cache.availableNoRaids anr ON anr.item_id = a.item_id - AND anr.calc_id = vAvailableNoRaidsCalc + /*LEFT JOIN cache.availableNoRaids anr ON anr.item_id = a.item_id + AND anr.calc_id = vAvailableNoRaidsCalc*/ JOIN tmp.item i ON i.itemFk = a.item_id JOIN vn.item it ON it.id = i.itemFk + JOIN vn.`zone` z ON z.id = vZoneFk LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = a.item_id - LEFT JOIN edi.supplyOffer so ON so.srId = it.supplyResponseFk + LEFT JOIN edi.supplyResponse sr ON sr.ID = it.supplyResponseFk + LEFT JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID + LEFT JOIN edi.marketPlace mp ON mp.id = sr.MarketPlaceID LEFT JOIN (SELECT isVNHSupplier, isEarlyBird, TRUE AS itemAllowed FROM vn.addressFilter af JOIN (SELECT ad.provinceFk, p.countryFk, ad.isLogifloraAllowed @@ -51708,16 +51744,31 @@ BEGIN AND sub2.countryFk <=> IFNULL(af.countryFk, sub2.countryFk) AND sub2.isLogifloraAllowed <=> IFNULL(af.isLogifloraAllowed, sub2.isLogifloraAllowed) WHERE vWarehouseFk = af.warehouseFk - ) sub ON sub.isVNHSupplier = so.isVNHSupplier - AND IFNULL(sub.isEarlyBird, so.isEarlyBird) = so.isEarlyBird + AND (vShipped < af.beforeDated + OR ISNULL(af.beforeDated) + OR vShipped > af.afterDated + OR ISNULL(af.afterDated)) + ) sub ON sub.isVNHSupplier = v.isVNHSupplier + AND (sub.isEarlyBird = mp.isEarlyBird OR ISNULL(sub.isEarlyBird)) JOIN vn.agencyMode am ON am.id = vAgencyModeFk JOIN vn.agency ag ON ag.id = am.agencyFk JOIN vn.itemType itt ON itt.id = it.typeFk + JOIN vn.itemCategory itc on itc.id = itt.categoryFk + JOIN vn.address ad ON ad.id = vAddressFk + LEFT JOIN vn.clientItemType cit + ON cit.clientFk = ad.clientFk + AND cit.itemTypeFk = itt.id + LEFT JOIN vn.clientItemCategory cic + ON cic.clientFk = ad.clientFk + AND cic.itemCategoryFk = itc.id WHERE a.calc_id = vAvailableCalc AND a.available > 0 - AND (sub.itemAllowed OR NOT it.isFloramondo OR anr.available > 0) - AND (ag.isAnyVolumeAllowed OR NOT itt.isUnconventionalSize); - + AND (sub.itemAllowed OR NOT it.isFloramondo /*OR anr.available > 0*/) + AND (ag.isAnyVolumeAllowed OR NOT itt.isUnconventionalSize) + AND (itc.isReclining OR ISNULL(it.`size`) OR it.`size` < z.itemMaxSize OR ISNULL(z.itemMaxSize)) + AND NOT (cit.isAllowed <=> FALSE) + AND (ISNULL(cic.itemCategoryFk) OR cit.isAllowed); + DROP TEMPORARY TABLE tmp.buyUltimate; CALL vn.catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk); @@ -51734,7 +51785,8 @@ BEGIN image, origin, price, - priceKg) + priceKg, + `grouping`) SELECT tl.itemFk, SUM(tl.available) available, @@ -51747,17 +51799,20 @@ BEGIN i.image, o.code origin, bl.price, - bl.priceKg + bl.priceKg, + bl.`grouping` FROM tmp.ticketLot tl JOIN item i ON tl.itemFk = i.id LEFT JOIN producer p ON p.id = i.producerFk AND p.isVisible JOIN origin o ON o.id = i.originFk JOIN ( - SELECT * - FROM (SELECT price, itemFk, priceKg + SELECT price, itemFk, priceKg, MIN(`grouping`) `grouping` + FROM ( + SELECT price, itemFk, priceKg, `grouping` FROM tmp.ticketComponentPrice WHERE warehouseFk = vWarehouseFk - ORDER BY (rate = 2) DESC) sub + ORDER BY (rate = 2) DESC + ) sub GROUP BY itemFk ) bl ON bl.itemFk = tl.itemFk WHERE tl.zoneFk = vZoneFk AND tl.warehouseFk = vWarehouseFk @@ -51768,339 +51823,6 @@ BEGIN CLOSE cTravelTree; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `catalog_calculate_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`@`localhost` PROCEDURE `catalog_calculate_beta`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT) -BEGIN - - /** - * Calcula los articulos disponibles y sus precios - * - * @table tmp.item(itemFk) Listado de artículos a calcular - * @param vLanded Fecha de recepcion de mercancia - * @param vAddressFk Id del consignatario - * @param vAgencyModeFk Id de la agencia - * @return tmp.ticketCalculateItem(itemFk, available, producer, - * item, size, stems, category, inkFk, image, origin, price) - * @return tmp.ticketLot(warehouseFk, itemFk, available, buyFk) - * @return tmp.ticketComponent - * @return tmp.ticketComponentPrice - */ - - DECLARE vAvailableCalc INT; - DECLARE vAvailableNoRaidsCalc INT; - DECLARE vShipped DATE; - DECLARE vWarehouseFk SMALLINT; - DECLARE vZoneFk INT; - DECLARE vDone BOOL; - DECLARE cTravelTree CURSOR FOR - SELECT zoneFk, warehouseFk, shipped FROM tmp.zoneGetShipped; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - - CALL vn.zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, FALSE); - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; - CREATE TEMPORARY TABLE tmp.ticketLot( - `warehouseFk` smallint(5) unsigned NOT NULL, - `itemFk` int(11) NOT NULL, - `available` double DEFAULT NULL, - `buyFk` int(11) DEFAULT NULL, - `fix` tinyint(3) unsigned DEFAULT '0', -- este campo parece obsoleto - `zoneFk` int(11) NOT NULL, - KEY `itemFk` (`itemFk`), - KEY `item_warehouse` (`itemFk`,`warehouseFk`) USING HASH - ) ENGINE=MEMORY DEFAULT CHARSET=utf8; - - CALL catalog_componentPrepare(); - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketCalculateItem; - CREATE TEMPORARY TABLE tmp.ticketCalculateItem( - itemFk INT(11) NOT NULL, - available INT(11), - producer VARCHAR(50), - item VARCHAR(50), - size INT(10) UNSIGNED, - stems INT(11), - category VARCHAR(3), - inkFk VARCHAR(3), - image VARCHAR(50), - origin VARCHAR(3), - price DECIMAL(10,2), - priceKg DECIMAL(10,2), - PRIMARY KEY `itemFk` (`itemFk`) - ) ENGINE = MEMORY DEFAULT CHARSET=utf8; - - OPEN cTravelTree; - - l: LOOP - SET vDone = FALSE; - FETCH cTravelTree INTO vZoneFk, vWarehouseFk, vShipped; - - IF vDone THEN - LEAVE l; - END IF; - - CALL `cache`.available_refresh (vAvailableCalc, FALSE, vWarehouseFk, vShipped); - CALL `cache`.availableNoRaids_refresh (vAvailableNoRaidsCalc, FALSE, vWarehouseFk, vShipped); - CALL vn.buyUltimate(vWarehouseFk, vShipped); - - INSERT INTO tmp.ticketLot (warehouseFk, itemFk, available, buyFk, zoneFk) - SELECT vWarehouseFk, - a.item_id, - IFNULL(a.available, 0), - bu.buyFk, - vZoneFk - FROM `cache`.available a - LEFT JOIN cache.availableNoRaids anr ON anr.item_id = a.item_id - AND anr.calc_id = vAvailableNoRaidsCalc - JOIN tmp.item i ON i.itemFk = a.item_id - JOIN vn.item it ON it.id = i.itemFk - LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = a.item_id - LEFT JOIN edi.supplyOffer so ON so.srId = it.supplyResponseFk - LEFT JOIN (SELECT isVNHSupplier, isEarlyBird, TRUE AS itemAllowed - FROM vn.addressFilter af - JOIN (SELECT ad.provinceFk, p.countryFk, ad.isLogifloraAllowed - FROM vn.address ad - JOIN vn.province p ON p.id = ad.provinceFk - WHERE ad.id = vAddressFk - ) sub2 ON sub2.provinceFk <=> IFNULL(af.provinceFk, sub2.provinceFk) - AND sub2.countryFk <=> IFNULL(af.countryFk, sub2.countryFk) - AND sub2.isLogifloraAllowed <=> IFNULL(af.isLogifloraAllowed, sub2.isLogifloraAllowed) - WHERE vWarehouseFk = af.warehouseFk - ) sub ON sub.isVNHSupplier = so.isVNHSupplier - AND IFNULL(sub.isEarlyBird, so.isEarlyBird) = so.isEarlyBird - JOIN vn.agencyMode am ON am.id = vAgencyModeFk - JOIN vn.agency ag ON ag.id = am.agencyFk - JOIN vn.itemType itt ON itt.id = it.typeFk - WHERE a.calc_id = vAvailableCalc - AND a.available > 0 - AND (sub.itemAllowed OR NOT it.isFloramondo OR anr.available > 0) - AND (ag.isAnyVolumeAllowed OR NOT itt.isUnconventionalSize); - - DROP TEMPORARY TABLE tmp.buyUltimate; - - CALL vn.catalog_componentCalculate_beta(vZoneFk, vAddressFk, vShipped, vWarehouseFk); - - INSERT INTO tmp.ticketCalculateItem ( - itemFk, - available, - producer, - item, - size, - stems, - category, - inkFk, - image, - origin, - price, - priceKg) - SELECT - tl.itemFk, - SUM(tl.available) available, - p.name producer, - i.name item, - i.size size, - i.stems, - i.category, - i.inkFk, - i.image, - o.code origin, - bl.price, - bl.priceKg - FROM tmp.ticketLot tl - JOIN item i ON tl.itemFk = i.id - LEFT JOIN producer p ON p.id = i.producerFk AND p.isVisible - JOIN origin o ON o.id = i.originFk - JOIN ( - SELECT * - FROM (SELECT price, itemFk, priceKg - FROM tmp.ticketComponentPrice - WHERE warehouseFk = vWarehouseFk - ORDER BY (rate = 2) DESC) sub - GROUP BY itemFk - ) bl ON bl.itemFk = tl.itemFk - WHERE tl.zoneFk = vZoneFk AND tl.warehouseFk = vWarehouseFk - GROUP BY tl.itemFk - ON DUPLICATE KEY UPDATE available = available + VALUES(available); - - END LOOP; - - CLOSE cTravelTree; - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `catalog_calculate__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_calculate__`( - vLanded DATE, - vAddressFk INT, - vAgencyModeFk INT) -proc: BEGIN -/** - * Calcula los articulos disponibles y sus precios - * - * @table tmp.item(itemFk) Listado de artículos a calcular - * @param vLanded Fecha de recepcion de mercancia - * @param vAddressFk Id del consignatario - * @param vAgencyModeFk Id de la agencia - * @return tmp.ticketCalculateItem(itemFk, available, producer, - * item, size, stems, category, inkFk, image, origin, price) - * @return tmp.ticketLot(warehouseFk, itemFk, available, buyFk) - * @return tmp.ticketComponent - * @return tmp.ticketComponentPrice - * @return tmp.zoneGetShipped - */ - - DECLARE vAvailableCalc INT; - DECLARE vShipped DATE; - DECLARE vWarehouseFk SMALLINT; - DECLARE vZoneFk INT; - DECLARE vDone BOOL; - DECLARE cTravelTree CURSOR FOR - SELECT zoneFk, warehouseFk, shipped FROM tmp.zoneGetShipped; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - - -- Establece los almacenes y las fechas que van a entrar al disponible - - CALL vn.zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, FALSE); - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; - CREATE TEMPORARY TABLE tmp.ticketLot( - `warehouseFk` smallint(5) unsigned NOT NULL, - `itemFk` int(11) NOT NULL, - `available` double DEFAULT NULL, - `buyFk` int(11) DEFAULT NULL, - `fix` tinyint(3) unsigned DEFAULT '0', - `zoneFk` int(11) NOT NULL, - KEY `itemFk` (`itemFk`), - KEY `item_warehouse` (`itemFk`,`warehouseFk`) USING HASH - ) ENGINE=MEMORY DEFAULT CHARSET=utf8; - - CALL catalog_componentPrepare(); - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketCalculateItem; - CREATE TEMPORARY TABLE tmp.ticketCalculateItem( - itemFk INT(11) NOT NULL, - available INT(11), - producer VARCHAR(50), - item VARCHAR(50), - size INT(10) UNSIGNED, - stems INT(11), - category VARCHAR(3), - inkFk VARCHAR(3), - image VARCHAR(50), - origin VARCHAR(3), - price DECIMAL(10,2), - priceKg DECIMAL(10,2), - PRIMARY KEY `itemFk` (`itemFk`) - ) ENGINE = MEMORY DEFAULT CHARSET=utf8; - - OPEN cTravelTree; - - l: LOOP - SET vDone = FALSE; - FETCH cTravelTree INTO vZoneFk, vWarehouseFk, vShipped; - - IF vDone THEN - LEAVE l; - END IF; - - CALL `cache`.available_refresh (vAvailableCalc, FALSE, vWarehouseFk, vShipped); - CALL buyUltimate (vWarehouseFk, vShipped); - - INSERT INTO tmp.ticketLot (warehouseFk, itemFk, available, buyFk, zoneFk) - SELECT vWarehouseFk, - i.item_id, - IFNULL(i.available, 0), - bu.buyFk, - vZoneFk - FROM `cache`.available i - JOIN tmp.item br ON br.itemFk = i.item_id - LEFT JOIN item it ON it.id = i.item_id -- esta linea sobra ? - LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = i.item_id - WHERE i.calc_id = vAvailableCalc - AND i.available > 0; - - CALL util.debugAdd('ticketLot: ', (SELECT COUNT(*) FROM tmp.ticketLot)); - - DROP TEMPORARY TABLE tmp.buyUltimate; - - CALL vn.catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk); - - INSERT INTO tmp.ticketCalculateItem ( - itemFk, - available, - producer, - item, - size, - stems, - category, - inkFk, - image, - origin, - price, - priceKg) - SELECT - tl.itemFk, - SUM(tl.available) available, - p.name producer, - i.name item, - i.size size, - i.stems, - i.category, - i.inkFk, - i.image, - o.code origin, - bl.price, - bl.priceKg - FROM tmp.ticketLot tl - JOIN item i ON tl.itemFk = i.id - LEFT JOIN producer p ON p.id = i.producerFk AND p.isVisible - JOIN origin o ON o.id = i.originFk - JOIN ( - SELECT * - FROM (SELECT price, itemFk, priceKg - FROM tmp.ticketComponentPrice - WHERE warehouseFk = vWarehouseFk - ORDER BY (rate = 2) DESC) sub - GROUP BY itemFk - ) bl ON bl.itemFk = tl.itemFk - WHERE tl.zoneFk = vZoneFk AND tl.warehouseFk = vWarehouseFk - GROUP BY tl.itemFk - ON DUPLICATE KEY UPDATE available = available + VALUES(available); - - END LOOP; - - CLOSE cTravelTree; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -52111,11 +51833,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_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_componentCalculate`( vZoneFk INT, vAddressFk INT, @@ -52135,341 +51857,6 @@ BEGIN * @return tmp.ticketComponentPrice (warehouseFk, itemFk, rate, `grouping`, price, priceKg) */ - DECLARE vClientFk INT; - DECLARE vIsFrenchVNHBuyer BOOLEAN DEFAULT FALSE; - DECLARE vVNHWarehouseFk INT DEFAULT 7; - DECLARE vFrenchDiscount DECIMAL(3,2) DEFAULT 0.12; - - SELECT clientFk INTO vClientFK - FROM address - WHERE id = vAddressFk; - - SELECT (c.country = 'FRANCIA' AND vWarehouseFk = vVNHWarehouseFk) - INTO vIsFrenchVNHBuyer - FROM vn.country c - JOIN vn.province p ON p.countryFk = c.id - JOIN vn.address a ON a.provinceFk = p.id - WHERE a.id = vAddressFk; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentCalculate; - - CREATE TEMPORARY TABLE tmp.ticketComponentCalculate - (PRIMARY KEY (itemFk, warehouseFk)) - ENGINE = MEMORY - SELECT - tl.itemFk, - tl.warehouseFk, - tl.available, - -- IF((@rate2 := IFNULL(pf.rate2, b.price2)) < i.minPrice AND i.hasMinPrice, i.minPrice, @rate2) rate2, - IF(i.hasMinPrice, GREATEST(i.minPrice,IFNULL(pf.rate2, b.price2)),IFNULL(pf.rate2, b.price2)) rate2, - IF(i.hasMinPrice, GREATEST(i.minPrice,IFNULL(pf.rate3, b.price3)),IFNULL(pf.rate3, b.price3)) rate3, - -- @minPrice := IF((@rate3 := IFNULL(pf.rate3, b.price3)) < i.minPrice AND i.hasMinPrice, i.minPrice, @rate3) rate3, - -- TRUE AS minPrice, - IFNULL(pf.packing, GREATEST(b.grouping, b.packing)) packing, - IFNULL(pf.`grouping`, b.`grouping`) `grouping`, - ABS(IFNULL(pf.box, b.groupingMode)) groupingMode, - tl.buyFk, - i.typeFk, - IF(i.hasKgPrice, b.weight / b.packing, NULL) weightGrouping - FROM tmp.ticketLot tl - JOIN buy b ON b.id = tl.buyFk - JOIN item i ON i.id = tl.itemFk - JOIN itemType it ON it.id = i.typeFk - JOIN itemCategory ic ON ic.id = it.categoryFk - LEFT JOIN specialPrice sp ON sp.itemFk = i.id - AND sp.clientFk = vClientFk - LEFT JOIN ( - SELECT * FROM ( - SELECT pf.itemFk, - pf.`grouping`, - pf.packing, - pf.box, - pf.rate2, - pf.rate3, - zw.warehouseFk - FROM priceFixed pf - JOIN zoneWarehouse zw ON zw.zoneFk = vZoneFk - AND zw.warehouseFk IN (pf.warehouseFk,0) - WHERE vShipped BETWEEN pf.started AND pf.ended - ORDER BY pf.itemFk, pf.warehouseFk DESC - ) tpf - GROUP BY tpf.itemFk, tpf.warehouseFk - ) pf ON pf.itemFk = tl.itemFk - AND pf.warehouseFk = tl.warehouseFk - WHERE b.buyingValue + b.freightValue + b.packageValue + b.comissionValue > 0.01 - AND ic.merchandise - AND tl.zoneFk = vZoneFk - AND tl.warehouseFk = vWarehouseFk; - - -- Coste - INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) - SELECT - tcc.warehouseFk, - tcc.itemFk, - c2.id, - b.buyingValue + b.freightValue + b.packageValue + b.comissionValue - FROM tmp.ticketComponentCalculate tcc - JOIN vn.component c2 ON c2.code = 'purchaseValue' - JOIN buy b ON b.id = tcc.buyFk; - - -- Margen - INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) - SELECT - tcc.warehouseFk, - tcc.itemFk, - c2.id, - tcc.rate3 - b.buyingValue - b.freightValue - b.packageValue - b.comissionValue - FROM tmp.ticketComponentCalculate tcc - JOIN vn.component c2 ON c2.code = 'margin' - JOIN buy b ON b.id = tcc.buyFk; - - -- Promo Francia - IF vIsFrenchVNHBuyer THEN - - INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) - SELECT - tcc.warehouseFk, - tcc.itemFk, - c2.id, - - vFrenchDiscount * (b.buyingValue + b.freightValue + b.packageValue + b.comissionValue) / ( 1 - vFrenchDiscount) - FROM tmp.ticketComponentCalculate tcc - JOIN vn.component c2 ON c2.code = 'frenchOffer' - JOIN buy b ON b.id = tcc.buyFk; - - END IF; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentBase; - CREATE TEMPORARY TABLE tmp.ticketComponentBase ENGINE = MEMORY - SELECT tc.itemFk, ROUND(SUM(tc.cost), 4) AS base, tc.warehouseFk - FROM tmp.ticketComponent tc - JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tc.itemFk AND tcc.warehouseFk = tc.warehouseFk - GROUP BY tc.itemFk, warehouseFk; - - -- RECOBRO - INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost) - SELECT tcb.warehouseFk, tcb.itemFk, c2.id, - ROUND(tcb.base * - LEAST( - MAX(GREATEST(IFNULL(cr.priceIncreasing,0), - IFNULL(cr1.priceIncreasing,0), - IFNULL(cr2.priceIncreasing,0)) - ), - 0.25), - 3) - FROM tmp.ticketComponentBase tcb - JOIN vn.component c2 ON c2.code = 'debtCollection' - JOIN claimRatio cr ON cr.clientFk = vClientFk - LEFT JOIN clientYoke cy1 ON cy1.leftOx = cr.clientFk - LEFT JOIN claimRatio cr1 ON cr1.clientFk = cy1.rightOx - LEFT JOIN clientYoke cy2 ON cy2.rightOx = cr.clientFk - LEFT JOIN claimRatio cr2 ON cr2.clientFk = cy2.leftOx - WHERE GREATEST(IFNULL(cr.priceIncreasing,0), IFNULL(cr1.priceIncreasing,0), IFNULL(cr2.priceIncreasing,0)) > 0.009 - GROUP BY tcb.itemFk; - - -- Mana auto - INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost) - SELECT tcb.warehouseFk, tcb.itemFk, c2.id, ROUND(base * (0.01 + wm.pricesModifierRate), 3) as manaAuto - FROM tmp.ticketComponentBase tcb - JOIN `client` c on c.id = vClientFk - JOIN workerMana wm ON c.salesPersonFk = wm.workerFk - JOIN vn.component c2 ON c2.code = 'autoMana' - WHERE wm.isPricesModifierActivated - HAVING manaAuto <> 0; - - -- Precios especiales - INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost) - SELECT tcb.warehouseFk, - tcb.itemFk, - c2.id, - GREATEST( - IFNULL(ROUND(tcb.base * c2.tax, 4), 0), - IF(i.hasMinPrice, i.minPrice,0) - tcc.rate3 - ) cost - FROM tmp.ticketComponentBase tcb - JOIN vn.component c2 ON c2.code = 'lastUnitsDiscount' - JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tcb.itemFk AND tcc.warehouseFk = tcb.warehouseFk - LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk - JOIN vn.item i ON i.id = tcb.itemFk - WHERE sp.value IS NULL - AND i.supplyResponseFk IS NULL; - - -- Venta por paquetes - INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost) - SELECT tcc.warehouseFk, tcc.itemFk, c2.id, tcc.rate2 - tcc.rate3 - FROM tmp.ticketComponentCalculate tcc - JOIN vn.component c2 ON c2.code = 'salePerPackage' - JOIN buy b ON b.id = tcc.buyFk - LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk - WHERE sp.value IS NULL; - - DROP TEMPORARY TABLE IF EXISTS tmp.zone; - CREATE TEMPORARY TABLE IF NOT EXISTS tmp.zone (INDEX (id)) - ENGINE = MEMORY - SELECT vZoneFk id; - - CALL zone_getOptionsForShipment(vShipped, TRUE); - - -- Reparto - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFK, - tcc.itemFk, - c2.id, - z.inflation * ROUND(ic.cm3delivery * (IFNULL(zo.price,5000) - IFNULL(zo.bonus,0)) / (1000 * vc.standardFlowerBox) , 4) cost - FROM tmp.ticketComponentCalculate tcc - JOIN item i ON i.id = tcc.itemFk - JOIN tmp.zoneOption zo ON zo.zoneFk = vZoneFk - JOIN zone z ON z.id = vZoneFk - JOIN agencyMode am ON am.id = z.agencyModeFk - JOIN vn.volumeConfig vc - JOIN vn.component c2 ON c2.code = 'delivery' - LEFT JOIN itemCost ic ON ic.warehouseFk = tcc.warehouseFk - AND ic.itemFk = tcc.itemFk - HAVING cost <> 0; - - DROP TEMPORARY TABLE tmp.zoneOption; - /* - -- Extra reparto - INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost) - SELECT tcc.warehouseFk, tcc.itemFk, c2.id, ap.packagingValue cost - FROM tmp.ticketComponentCalculate tcc - JOIN vn.addressForPackaging ap - JOIN vn.component c2 ON c2.code = 'bagged' - WHERE ap.addressFk = vAddressFk; - */ - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentCopy; - CREATE TEMPORARY TABLE tmp.ticketComponentCopy ENGINE = MEMORY - SELECT * FROM tmp.ticketComponent; - - -- Precio especial - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFk, - tcc.itemFk, - c2.id, - sp.value - SUM(tcc.cost) sumCost - FROM tmp.ticketComponentCopy tcc - JOIN component c ON c.id = tcc.componentFk - JOIN specialPrice sp ON sp.clientFk = vClientFK AND sp.itemFk = tcc.itemFk - JOIN vn.component c2 ON c2.code = 'specialPrices' - WHERE c.classRate IS NULL - AND tcc.warehouseFk = vWarehouseFk - GROUP BY tcc.itemFk, tcc.warehouseFk - HAVING ABS(sumCost) > 0.001; - - -- Rappel - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFk, - tcc.itemFk, - IFNULL(c.componentFk ,c2.id), - SUM(tcc.cost) * ((1/(1-c.rappel/100)) -1) sumCost - FROM tmp.ticketComponentCopy tcc - JOIN vn.clientChain cc ON cc.clientFk = vClientFk - JOIN vn.`chain` c ON c.id = cc.chainFk - JOIN vn.component c2 ON c2.code = 'rappel' - WHERE tcc.warehouseFk = vWarehouseFk - GROUP BY tcc.itemFk, tcc.warehouseFk; - - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentSum; - CREATE TEMPORARY TABLE tmp.ticketComponentSum - (INDEX (itemFk, warehouseFk)) - ENGINE = MEMORY - SELECT SUM(cost) sumCost, tc.itemFk, tc.warehouseFk, c.classRate - FROM tmp.ticketComponent tc - JOIN component c ON c.id = tc.componentFk - GROUP BY tc.itemFk, tc.warehouseFk, c.classRate; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentRate; - CREATE TEMPORARY TABLE tmp.ticketComponentRate ENGINE = MEMORY - SELECT tcc.warehouseFk, - tcc.itemFk, - 1 rate, - IF(tcc.groupingMode = 1, tcc.`grouping`, 1) `grouping`, - CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) price, - CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) / weightGrouping priceKg - FROM tmp.ticketComponentCalculate tcc - JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk - AND tcs.warehouseFk = tcc.warehouseFk - WHERE IFNULL(tcs.classRate, 1) = 1 - AND tcc.groupingMode < 2 AND (tcc.packing > tcc.`grouping` or tcc.groupingMode = 0) - GROUP BY tcs.warehouseFk, tcs.itemFk; - - INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg) - SELECT - tcc.warehouseFk, - tcc.itemFk, - 2 rate, - tcc.packing `grouping`, - SUM(tcs.sumCost) price, - SUM(tcs.sumCost) / weightGrouping priceKg - FROM tmp.ticketComponentCalculate tcc - JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk - AND tcs.warehouseFk = tcc.warehouseFk - WHERE tcc.available IS NULL OR (IFNULL(tcs.classRate, 2) = 2 - AND tcc.packing > 0 AND tcc.available >= tcc.packing) - GROUP BY tcs.warehouseFk, tcs.itemFk; - - INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg) - SELECT - tcc.warehouseFk, - tcc.itemFk, - 3 rate, - tcc.available `grouping`, - SUM(tcs.sumCost) price, - SUM(tcs.sumCost) / weightGrouping priceKg - FROM tmp.ticketComponentCalculate tcc - JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk - AND tcs.warehouseFk = tcc.warehouseFk - WHERE IFNULL(tcs.classRate, 3) = 3 - GROUP BY tcs.warehouseFk, tcs.itemFk; - - INSERT INTO tmp.ticketComponentPrice (warehouseFk, itemFk, rate, `grouping`, price, priceKg) - SELECT * FROM ( - SELECT * FROM tmp.ticketComponentRate ORDER BY price - ) t - GROUP BY itemFk, warehouseFk, `grouping`; - - DROP TEMPORARY TABLE - tmp.ticketComponentCalculate, - tmp.ticketComponentSum, - tmp.ticketComponentBase, - tmp.ticketComponentRate, - tmp.ticketComponentCopy; - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `catalog_componentCalculate_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`@`localhost` PROCEDURE `catalog_componentCalculate_beta`( vZoneFk INT, - vAddressFk INT, - vShipped DATE, - vWarehouseFk INT) -BEGIN - /** - * Calcula los componentes de los articulos de tmp.ticketLot - * - * @param vZoneFk para calcular el transporte - * @param vAddressFk Consignatario - * @param vShipped dia de salida del pedido - * @param vWarehouseFk warehouse de salida del pedido - * @table tmp.ticketLot (warehouseFk, available, itemFk, buyFk, zoneFk) - * @table tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost) - * - * @return tmp.ticketComponentPrice (warehouseFk, itemFk, rate, `grouping`, price, priceKg) - */ - DECLARE vClientFk INT; DECLARE vIsFrenchVNHBuyer BOOLEAN DEFAULT FALSE; DECLARE vVNHWarehouseFk INT DEFAULT 7; @@ -52797,456 +52184,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `catalog_componentCalculate__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_componentCalculate__`( - vZoneFk INT, - vAddressFk INT, - vShipped DATE, - vWarehouseFk INT) -proc: BEGIN -/** - * Calcula los componentes de los articulos de tmp.ticketLot - * - * @param vZoneFk para calcular el transporte - * @param vAddressFk Consignatario - * @param vShipped dia de salida del pedido - * @param vWarehouseFk warehouse de salida del pedido - * @param tmp.ticketLot (warehouseFk, available, itemFk, buyFk, zoneFk) - * @table tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost) - * - * @return tmp.ticketComponentPrice (warehouseFk, itemFk, rate, `grouping`, price, priceKg) - */ - DECLARE vClientFk INT; - DECLARE vMinimumDensityWeight INT DEFAULT 167; - DECLARE vBoxVolume BIGINT; - DECLARE vSpecialPriceComponent INT DEFAULT 10; - DECLARE vDeliveryComponent INT DEFAULT 15; - DECLARE vRecoveryComponent INT DEFAULT 17; - DECLARE vSellByPacketComponent INT DEFAULT 22; - DECLARE vBuyValueComponent INT DEFAULT 28; - DECLARE vMarginComponent INT DEFAULT 29; - DECLARE vDiscountLastItemComponent INT DEFAULT 32; - DECLARE vExtraBaggedComponent INT DEFAULT 38; - DECLARE vManaAutoComponent INT DEFAULT 39; - DECLARE vFrenchOffer INT DEFAULT 42; - DECLARE vIsFrenchVNHBuyer BOOLEAN DEFAULT FALSE; - DECLARE vVNHWarehouseFk INT DEFAULT 7; - DECLARE vFloramondoWarehouseFk INT DEFAULT 40; - DECLARE vIsLogifloraAllowed BOOLEAN DEFAULT 0; - DECLARE vMaxLogifloraDays INT; - DECLARE vRangeLogifloraDays INT DEFAULT 3; - DECLARE vVisibleCache INT; - DECLARE vRappelComponent INT DEFAULT 44; - DECLARE vIsZonePremium BOOL; - DECLARE vFrenchDiscount DECIMAL(3,2) DEFAULT 0.12; - DECLARE vIsCatalonianBuyer BOOL; - DECLARE visAnyVolumeAllowed BOOL; - - SELECT (COUNT(*) > 0) INTO vIsZonePremium - FROM vn.zoneFilter zf - WHERE zf.zoneFk = vZoneFk; - - SELECT vc.standardFlowerBox * 1000 INTO vBoxVolume - FROM vn.volumeConfig vc; - - SELECT clientFk, isLogifloraAllowed INTO vClientFK, vIsLogifloraAllowed - FROM address - WHERE id = vAddressFk; - - SELECT (c.country IN ('Francia','Suiza') AND vWarehouseFk IN (vVNHWarehouseFk, vFloramondoWarehouseFk)) - INTO vIsFrenchVNHBuyer - FROM vn.country c - JOIN vn.province p ON p.countryFk = c.id - JOIN vn.address a ON a.provinceFk = p.id - WHERE a.id = vAddressFk; - - SELECT (p.name = 'Barcelona' AND vWarehouseFk = vVNHWarehouseFk) - INTO vIsCatalonianBuyer - FROM vn.province p - JOIN vn.address a ON a.provinceFk = p.id - WHERE a.id = vAddressFk; -- PAK 18/10/21 - - SELECT travellingDays INTO vMaxLogifloraDays - FROM edi.warehouseFloramondo - WHERE warehouseFk = vWarehouseFk; - - -- Se eliminan los productos de tamaños no convencionales, salvo agencias que lo permitan - SELECT a.isAnyVolumeAllowed INTO visAnyVolumeAllowed - FROM vn.agency a - JOIN vn.agencyMode am ON am.agencyFk = a.id - JOIN vn.`zone`z ON z.agencyModeFk = am.id - WHERE z.id = vZoneFk; - - IF NOT vIsAnyVolumeAllowed THEN - - DELETE tl.* - FROM tmp.ticketLot tl - JOIN vn.item i ON i.id = tl.itemFk - JOIN vn.itemType it ON it.id = i.typeFk - WHERE it.isUnconventionalSize; - - END IF; - - -- Esto sirve para que los franceses compren sólo por las cuentas de VNH - DELETE tl.* - FROM tmp.ticketLot tl - JOIN vn.item i ON i.id = tl.itemFk - JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk - JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID - WHERE v.isVNHSupplier != vIsFrenchVNHBuyer; - - IF (NOT vIsLogifloraAllowed AND vVNHWarehouseFk != vWarehouseFk) - OR NOT vn.isLogifloraDay(vShipped, vWarehouseFk) - -- OR NOT(vIsCatalonianBuyer OR vIsFrenchVNHBuyer) - THEN - - CALL cache.visible_refresh(vVisibleCache, FALSE, vWarehouseFk); - - DELETE tl FROM tmp.ticketLot tl - JOIN item i ON i.id = tl.itemFk - LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = vWarehouseFk - LEFT JOIN vn.buy b ON b.id = lb.buy_id - LEFT JOIN vn.entry e ON e.id = b.entryFk - LEFT JOIN vn.supplier s ON s.id = e.supplierFk -- PAK 13/10/21 - LEFT JOIN cache.visible v ON v.calc_id = vVisibleCache AND v.item_id = i.id - LEFT JOIN (SELECT DISTINCT s.itemFk - FROM vn.sale s - JOIN vn.ticket t ON t.id = s.ticketFk - WHERE t.warehouseFk = vWarehouseFk - AND t.addressFk = vAddressFk - AND t.shipped = vShipped - AND t.zoneFk = vZoneFk) sub ON sub.itemFk = i.id - WHERE (i.supplyResponseFk - AND (IFNULL(e.isRaid,TRUE) - OR s.nickname = 'INVENTARIO') -- PAK 13/10/21 - AND ISNULL(sub.itemFk) - AND IFNULL(v.visible,0) = 0 - AND vWarehouseFk = tl.warehouseFk); - - END IF; - - -- Eliminem productes de la oferta que no deuen vore els francesos - IF vIsFrenchVNHBuyer THEN - - CALL cache.visible_refresh(vVisibleCache, FALSE, vWarehouseFk); - - DELETE tl FROM tmp.ticketLot tl - JOIN item i ON i.id = tl.itemFk - JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk - JOIN edi.marketPlace mp ON mp.id = sr.MarketPlaceID - LEFT JOIN cache.visible v ON v.calc_id = vVisibleCache AND v.item_id = i.id - LEFT JOIN (SELECT DISTINCT s.itemFk - FROM vn.sale s - JOIN vn.ticket t ON t.id = s.ticketFk - WHERE t.warehouseFk = vWarehouseFk - AND t.addressFk = vAddressFk - AND t.shipped = vShipped - AND t.zoneFk = vZoneFk) sub ON sub.itemFk = i.id - WHERE (mp.isEarlyBird = FALSE - AND IFNULL(sub.itemFk,0) = 0 - AND IFNULL(v.visible ,0) = 0); - - END IF; - - -- Eliminem productes de la oferta que no deuen vore les zones PREMIUM - IF vIsZonePremium THEN - - DELETE tl.* - FROM tmp.ticketLot tl - JOIN item i ON i.id = tl.itemFk - LEFT JOIN vn.zoneFilter zf ON zf.itemTypeFk = i.typeFk - AND zf.zoneFk = vZoneFk - AND i.`size` <= zf.sizeMax - WHERE zf.id IS NULL ; - - END IF; - - -- Eliminem productes de la oferta que la zona no pot transportar - DELETE tl.* - FROM tmp.ticketLot tl - JOIN item i ON i.id = tl.itemFk - JOIN vn.zone z ON z.id = vZoneFk - WHERE i.size > z.itemMaxSize; - - SET @rate2 := 0; - SET @rate3 := 0; - SET @minPrice := 0; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentCalculate; - CREATE TEMPORARY TABLE tmp.ticketComponentCalculate - (PRIMARY KEY (itemFk, warehouseFk)) - ENGINE = MEMORY - SELECT - tl.itemFk, - tl.warehouseFk, - tl.available, - IF((@rate2 := IFNULL(pf.rate2, b.price2)) < i.minPrice AND i.hasMinPrice, i.minPrice, @rate2) * 1.0 rate2, - @minPrice := IF((@rate3 := IFNULL(pf.rate3, b.price3)) < i.minPrice AND i.hasMinPrice, i.minPrice, @rate3) * 1.0 rate3, - IFNULL(@minPrice, 0) AS minPrice, - IFNULL(pf.packing, GREATEST(b.grouping, b.packing)) packing, - IFNULL(pf.`grouping`, b.`grouping`) `grouping`, - ABS(IFNULL(pf.box, b.groupingMode)) groupingMode, - tl.buyFk, - i.typeFk, - IF(i.hasKgPrice, b.weight / b.packing, NULL) weightGrouping - FROM tmp.ticketLot tl - JOIN buy b ON b.id = tl.buyFk - JOIN item i ON i.id = tl.itemFk - JOIN itemType it ON it.id = i.typeFk - LEFT JOIN itemCategory ic ON ic.id = it.categoryFk - LEFT JOIN specialPrice sp ON sp.itemFk = i.id AND sp.clientFk = vClientFk - LEFT JOIN ( - SELECT * FROM ( - SELECT pf.itemFk, pf.`grouping`, pf.packing, pf.box, pf.rate2, pf.rate3, zw.warehouseFk - FROM priceFixed pf - JOIN zoneWarehouse zw ON zw.zoneFk = vZoneFk AND (zw.warehouseFk = pf.warehouseFk OR pf.warehouseFk = 0) - WHERE vShipped BETWEEN pf.started AND pf.ended ORDER BY pf.itemFk, pf.warehouseFk DESC - ) tpf - GROUP BY tpf.itemFk, tpf.warehouseFk - ) pf ON pf.itemFk = tl.itemFk AND pf.warehouseFk = tl.warehouseFk - WHERE b.buyingValue + b.freightValue + b.packageValue + b.comissionValue > 0.01 AND ic.merchandise <> 0 - AND tl.zoneFk = vZoneFk AND tl.warehouseFk = vWarehouseFk; - - -- Coste - INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) - SELECT - tcc.warehouseFk, - tcc.itemFk, - vBuyValueComponent, - b.buyingValue + b.freightValue + b.packageValue + b.comissionValue - FROM tmp.ticketComponentCalculate tcc - JOIN buy b ON b.id = tcc.buyFk; - - -- Margen - INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) - SELECT - tcc.warehouseFk, - tcc.itemFk, - vMarginComponent, - tcc.rate3 - b.buyingValue - b.freightValue - b.packageValue - b.comissionValue - FROM tmp.ticketComponentCalculate tcc - JOIN buy b ON b.id = tcc.buyFk; - - -- Promo Francia - IF vIsFrenchVNHBuyer THEN - - INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) - SELECT - tcc.warehouseFk, - tcc.itemFk, - vFrenchOffer, - - vFrenchDiscount * (b.buyingValue + b.freightValue + b.packageValue + b.comissionValue) / ( 1 - vFrenchDiscount) - FROM tmp.ticketComponentCalculate tcc - JOIN buy b ON b.id = tcc.buyFk; - - END IF; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentBase; - CREATE TEMPORARY TABLE tmp.ticketComponentBase ENGINE = MEMORY - SELECT tc.itemFk, ROUND(SUM(tc.cost), 4) AS base, tc.warehouseFk - FROM tmp.ticketComponent tc - JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tc.itemFk AND tcc.warehouseFk = tc.warehouseFk - GROUP BY tc.itemFk, warehouseFk; - - -- RECOBRO - INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost) - SELECT tcb.warehouseFk, tcb.itemFk, vRecoveryComponent, - ROUND(tcb.base * LEAST(MAX(GREATEST(IFNULL(cr.priceIncreasing,0), IFNULL(cr1.priceIncreasing,0), IFNULL(cr2.priceIncreasing,0))), 0.25), 3) - FROM tmp.ticketComponentBase tcb - JOIN claimRatio cr ON cr.clientFk = vClientFk - LEFT JOIN clientYoke cy1 ON cy1.leftOx = cr.clientFk - LEFT JOIN claimRatio cr1 ON cr1.clientFk = cy1.rightOx - LEFT JOIN clientYoke cy2 ON cy2.rightOx = cr.clientFk - LEFT JOIN claimRatio cr2 ON cr2.clientFk = cy2.leftOx - WHERE GREATEST(IFNULL(cr.priceIncreasing,0), IFNULL(cr1.priceIncreasing,0), IFNULL(cr2.priceIncreasing,0)) > 0.009 - GROUP BY tcb.itemFk; - - -- Mana auto - INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost) - SELECT tcb.warehouseFk, tcb.itemFk, vManaAutoComponent, ROUND(base * (0.01 + wm.pricesModifierRate), 3) as manaAuto - FROM tmp.ticketComponentBase tcb - JOIN `client` c on c.id = vClientFk - JOIN workerMana wm ON c.salesPersonFk = wm.workerFk - WHERE wm.isPricesModifierActivated - HAVING manaAuto <> 0; - - -- Precios especiales - INSERT INTO tmp.ticketComponent - SELECT tcb.warehouseFk, - tcb.itemFk, - c.id, - GREATEST(IFNULL(ROUND(tcb.base * c.tax, 4), 0), tcc.minPrice - tcc.rate3) - FROM tmp.ticketComponentBase tcb - JOIN component c - JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tcb.itemFk AND tcc.warehouseFk = tcb.warehouseFk - LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk - JOIN vn.item i ON i.id = tcb.itemFk - WHERE c.id = vDiscountLastItemComponent - AND c.tax <> 0 - AND tcc.minPrice < tcc.rate3 - AND sp.value IS NULL - AND i.supplyResponseFk IS NULL; -- FLORAMONDO - - -- Venta por paquetes - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFk, tcc.itemFk, vSellByPacketComponent, tcc.rate2 - tcc.rate3 - FROM tmp.ticketComponentCalculate tcc - JOIN buy b ON b.id = tcc.buyFk - LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk - WHERE sp.value IS NULL; - - DROP TEMPORARY TABLE IF EXISTS tmp.zone; - CREATE TEMPORARY TABLE IF NOT EXISTS tmp.zone (INDEX (id)) - ENGINE = MEMORY - SELECT vZoneFk id; - - CALL zone_getOptionsForShipment(vShipped, TRUE); - - -- Reparto - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFK, - tcc.itemFk, - vDeliveryComponent, - z.inflation * ROUND(ic.cm3delivery * (IFNULL(zo.price,5000) - IFNULL(zo.bonus,0)) / vBoxVolume, 4) cost - FROM tmp.ticketComponentCalculate tcc - JOIN item i ON i.id = tcc.itemFk - JOIN tmp.zoneOption zo ON zo.zoneFk = vZoneFk - JOIN zone z ON z.id = vZoneFk - JOIN agencyMode am ON am.id = z.agencyModeFk - LEFT JOIN itemCost ic ON ic.warehouseFk = tcc.warehouseFk - AND ic.itemFk = tcc.itemFk - HAVING cost <> 0; - - DROP TEMPORARY TABLE tmp.zoneOption; - - -- Extra reparto - IF (SELECT COUNT(*) FROM vn.addressForPackaging WHERE addressFk = vAddressFk) THEN - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFk, b.itemFk, vExtraBaggedComponent, ap.packagingValue cost - FROM tmp.ticketComponentCalculate tcc - JOIN vn.addressForPackaging ap - WHERE ap.addressFk = vAddressFk; - END IF; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentCopy; - CREATE TEMPORARY TABLE tmp.ticketComponentCopy ENGINE = MEMORY - SELECT * FROM tmp.ticketComponent; - - -- Precio especial - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFk, - tcc.itemFk, - vSpecialPriceComponent, - sp.value - SUM(tcc.cost) sumCost - FROM tmp.ticketComponentCopy tcc - JOIN component c ON c.id = tcc.componentFk - JOIN specialPrice sp ON sp.clientFk = vClientFK AND sp.itemFk = tcc.itemFk - WHERE c.classRate IS NULL - AND tcc.warehouseFk = vWarehouseFk - GROUP BY tcc.itemFk, tcc.warehouseFk - HAVING ABS(sumCost) > 0.001; - - -- Rappel - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFk, - tcc.itemFk, - IFNULL(c.componentFk ,vRappelComponent), - SUM(tcc.cost) * ((1/(1-c.rappel/100)) -1) sumCost - FROM tmp.ticketComponentCopy tcc - JOIN vn.clientChain cc ON cc.clientFk = vClientFk - JOIN vn.`chain` c ON c.id = cc.chainFk - WHERE tcc.warehouseFk = vWarehouseFk - GROUP BY tcc.itemFk, tcc.warehouseFk; - - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentSum; - CREATE TEMPORARY TABLE tmp.ticketComponentSum - (INDEX (itemFk, warehouseFk)) - ENGINE = MEMORY - SELECT SUM(cost) sumCost, tc.itemFk, tc.warehouseFk, c.classRate - FROM tmp.ticketComponent tc - JOIN component c ON c.id = tc.componentFk - GROUP BY tc.itemFk, tc.warehouseFk, c.classRate; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentRate; - CREATE TEMPORARY TABLE tmp.ticketComponentRate ENGINE = MEMORY - SELECT tcc.warehouseFk, - tcc.itemFk, - 1 rate, - IF(tcc.groupingMode = 1, tcc.`grouping`, 1) `grouping`, - CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) price, - CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) / weightGrouping priceKg - FROM tmp.ticketComponentCalculate tcc - JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk - AND tcs.warehouseFk = tcc.warehouseFk - WHERE IFNULL(tcs.classRate, 1) = 1 - AND tcc.groupingMode < 2 AND (tcc.packing > tcc.`grouping` or tcc.groupingMode = 0) - GROUP BY tcs.warehouseFk, tcs.itemFk; - - INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg) - SELECT - tcc.warehouseFk, - tcc.itemFk, - 2 rate, - tcc.packing `grouping`, - SUM(tcs.sumCost) price, - SUM(tcs.sumCost) / weightGrouping priceKg - FROM tmp.ticketComponentCalculate tcc - JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk - AND tcs.warehouseFk = tcc.warehouseFk - WHERE tcc.available IS NULL OR (IFNULL(tcs.classRate, 2) = 2 - AND tcc.packing > 0 AND tcc.available >= tcc.packing) - GROUP BY tcs.warehouseFk, tcs.itemFk; - - IF vIsZonePremium THEN - - DELETE - FROM tmp.ticketComponentRate - WHERE rate = 1; - - END IF; - - INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg) - SELECT - tcc.warehouseFk, - tcc.itemFk, - 3 rate, - tcc.available `grouping`, - SUM(tcs.sumCost) price, - SUM(tcs.sumCost) / weightGrouping priceKg - FROM tmp.ticketComponentCalculate tcc - JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk - AND tcs.warehouseFk = tcc.warehouseFk - WHERE IFNULL(tcs.classRate, 3) = 3 - GROUP BY tcs.warehouseFk, tcs.itemFk; - - INSERT INTO tmp.ticketComponentPrice (warehouseFk, itemFk, rate, `grouping`, price, priceKg) - SELECT * FROM ( - SELECT * FROM tmp.ticketComponentRate ORDER BY price - ) t - GROUP BY itemFk, warehouseFk, `grouping`; - - DROP TEMPORARY TABLE - tmp.ticketComponentCalculate, - tmp.ticketComponentSum, - tmp.ticketComponentBase, - tmp.ticketComponentRate, - tmp.ticketComponentCopy; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `catalog_componentPrepare` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -54375,7 +53312,7 @@ BEGIN FROM vn.warehouse WHERE hasConfectionTeam; - CALL vn.ticketCreateWithUser( + CALL vn.ticket_add( vClientFk ,CURDATE() ,vWarehouseFk -- Algemesi @@ -54385,6 +53322,7 @@ BEGIN ,NULL -- route ,CURDATE() ,account.myUser_getId() + ,TRUE ,vNewTicket); INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price) @@ -54825,7 +53763,12 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `cmr_getByTicket`(vTicketFk INT) BEGIN + + DECLARE vLandingDays INT; + SELECT landingDays INTO vLandingDays + FROM vn.cmrConfig; + IF vTicketFk THEN IF (SELECT count(ticketFk) FROM vn.cmr WHERE ticketFk = vTicketFk) THEN @@ -54834,8 +53777,8 @@ BEGIN ELSE - INSERT INTO vn.cmr(ticketFk, companyFk, addressFromFk, addressToFk, supplierFk) - SELECT vTicketFk, t.companyFk, a.id, t.addressFk, ag.supplierFk + INSERT INTO vn.cmr(ticketFk, companyFk, addressFromFk, addressToFk, supplierFk, ead) + SELECT vTicketFk, t.companyFk, a.id, t.addressFk, ag.supplierFk, vLandingDays FROM vn.ticket t JOIN vn.agencyMode am ON am.id = t.agencyModeFk JOIN vn.agency ag ON ag.id = am.agencyFk @@ -54849,7 +53792,7 @@ BEGIN ELSE - INSERT INTO vn.cmr(created) VALUES(NOW()); + INSERT INTO vn.cmr(created, ead) VALUES(NOW(), NOW() + INTERVAL vLandingDays DAY); SELECT LAST_INSERT_ID(); @@ -55284,54 +54227,6 @@ BEGIN CALL vn.sale_calculateComponent(vSaleFk, null); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `collection_faults` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_faults`( - vShelvingFk VARCHAR(10), - vQuantity INT, - vItemFk INT) -BEGIN - DECLARE vQuantityTotal INT DEFAULT 0; - DECLARE vshelve VARCHAR(2); - DECLARE vdeep INT(11); - DECLARE vpriority INT(11); - DECLARE vgrouping SMALLINT(5); - DECLARE vpacking INT(11); - DECLARE vpackagingFk VARCHAR(10); - DECLARE vlevel VARCHAR(45); - DECLARE vuserFk INT(10); - - - SELECT SUM(quantity),shelve,deep,priority,`grouping`,packing,packagingFk,`level`,userFk - INTO vQuantityTotal,vshelve,vdeep,vpriority,vgrouping,vpacking,vpackagingFk,vlevel,vuserFk - FROM vn.itemShelving - WHERE shelvingFk = vShelvingFk COLLATE utf8_unicode_ci AND itemFk = vItemFk - GROUP BY itemFk; - - SELECT vQuantityTotal - vQuantity INTO vQuantityTotal; - - DELETE FROM vn.itemShelving WHERE shelvingFk = vShelvingFk COLLATE utf8_unicode_ci AND itemFk = vItemFk; - - INSERT INTO vn.itemShelving (itemFk, shelvingFk,shelve,deep,quantity,visible,available,priority,`grouping`,packing,packagingFk,`level`,userFk ) - VALUES (vItemFk,vShelvingFk,vshelve,vdeep,vQuantityTotal,vQuantityTotal,vQuantityTotal,vpriority,vgrouping,vpacking,vpackagingFk,vlevel,vuserFk ); - - SELECT * FROM vn.itemShelving - WHERE shelvingFk = vShelvingFk COLLATE utf8_unicode_ci AND itemFk = vItemFk; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -55551,7 +54446,16 @@ BEGIN WHERE c.id = vClientFk LIMIT 1; - CALL ticketCreateWithUser(vClientFk, NOW(), vWarehouseFk, 442, vConsignatario, NULL, NULL, NULL, account.userGetId(), vTicketFk); + CALL ticket_add(vClientFk, + NOW(), vWarehouseFk, + 442, + vConsignatario, + NULL, + NULL, + NULL, + account.userGetId(), + TRUE, + vTicketFk); SELECT t.id INTO vTicketFk FROM vn.ticket t WHERE t.created > DATE_SUB(NOW(), INTERVAL 1 DAY) AND t.clientFk = vClientFk AND t.warehouseFk = vWarehouseFk LIMIT 1; @@ -56125,19 +55029,24 @@ proc:BEGIN DECLARE vMaxTicketPrinted INT; DECLARE vItemPackingTypeFk VARCHAR(1); DECLARE hasAssignedTickets BOOLEAN; - DECLARE vMaxNotReadyCollections INT DEFAULT 0; + DECLARE vMaxNotReadyCollections INT; DECLARE vNotReadyCollections INT; DECLARE vTrainFk INT DEFAULT 1; - - /*IF NOT vn.deviceProductionUser_Exists(vn.getUser()) THEN + DECLARE vUserFk INT; + DECLARE vHourMatters BOOL DEFAULT TRUE; + + SELECT pc.ticketPrintedMax * vWagons, pc.ticketTrolleyMax * vWagons, pc.maxNotReadyCollections + INTO vMaxTicketPrinted, vMaxTickets, vMaxNotReadyCollections + FROM vn.productionConfig pc; + /*IF NOT vn.deviceProductionUser_Exists(vUserFk) THEN LEAVE proc; END IF;*/ - SELECT w.code INTO vWorkerCode + SELECT w.code, w.id INTO vWorkerCode, vUserFk FROM vn.worker w - WHERE w.id = vn.getUser(); + WHERE w.id =account.userGetId(); -- Establecemos el almacén y si es un sector de preparación previa, así como el estado para los tickets que se vayan preparando SELECT isPreviousPrepared, warehouseFk, itemPackingTypeFk @@ -56148,8 +55057,8 @@ proc:BEGIN -- Si está habilitado el modo cazador para las motos, y el usuario no esta registrado, se sale. IF (SELECT isTractorHuntingMode FROM vn.deviceProductionConfig dpc) AND vItemPackingTypeFk = 'H' THEN - IF (SELECT COUNT(*) FROM vn.workerWithoutTractor wwt WHERE wwt.workerFk = account.userGetId()) THEN - INSERT INTO tmp.kk(userFk) VALUES(vn.getUser()); + IF (SELECT COUNT(*) FROM vn.workerWithoutTractor wwt WHERE wwt.workerFk = vUserFk) THEN + CALL util.throw('Usuario no registrado con moto'); LEAVE proc; END IF; END IF; @@ -56157,23 +55066,29 @@ proc:BEGIN -- Si hay colecciones sin terminar, sale del proceso SELECT count(*) INTO vNotReadyCollections - FROM vn.collection c - WHERE c.workerFk = vn.getUser() - AND c.saleTotalCount > c.salePickedCount + 1 - AND c.created > TIMESTAMPADD(HOUR , -5,NOW()); + FROM ( + SELECT count(DISTINCT s.id) totalRow, count(DISTINCT st.id) pickedRow + FROM vn.collection c + JOIN vn.ticketCollection tc ON tc.collectionFk = c.id + JOIN vn.sale s ON s.ticketFk = tc.ticketFk + JOIN vn.state ss ON ss.code = 'PREPARED' + LEFT JOIN vn.saleTracking st ON st.saleFk = s.id AND st.stateFk = ss.id + WHERE c.workerFk = vUserFk + AND c.created >= TIMESTAMPADD(HOUR , -6,NOW()) + AND s.quantity != 0 + GROUP BY c.id + HAVING totalRow > pickedRow) sub; IF vMaxNotReadyCollections < vNotReadyCollections THEN - + + CALL util.throw('Hay colecciones pendientes'); LEAVE proc; END IF; - SELECT ticketPrintedMax * vWagons, ticketTrolleyMax * vWagons - INTO vMaxTicketPrinted, vMaxTickets - FROM vn.productionConfig pc; - IF vIsPreviousPrepared THEN + CALL util.throw('Es de preparación previa'); LEAVE proc; -- Hasta que tengamos el altillo, vamos a cancelar esta opcion SELECT id INTO vStateFk @@ -56194,6 +55109,8 @@ proc:BEGIN SET vTrainFk = 2; + SET vHourMatters = FALSE; + DELETE pb.* FROM tmp.productionBuffer pb JOIN vn.volumeConfig vc @@ -56203,7 +55120,7 @@ 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 = vUserFk, itemPackingTypeFk = vItemPackingTypeFk, trainFk = vTrainFk; @@ -56283,7 +55200,7 @@ proc:BEGIN AND ( (pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH)) OR (pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV)) - OR (pb.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV)) + OR (pb.H = 0 AND pb.V = 0 AND pb.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV)) ) AND (pc.isPreviousPreparationRequired = FALSE OR pb.previousWithoutParking = FALSE); @@ -56293,7 +55210,7 @@ proc:BEGIN -- AutoPRINT INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) - SELECT s2.id, pb.ticketFk, vn.getUser() + SELECT s2.id, pb.ticketFk, vUserFk FROM tmp.productionBuffer pb JOIN vn.agencyMode am ON am.id = pb.agencyModeFk JOIN vn.agency a ON a.id = am.agencyFk @@ -56312,7 +55229,7 @@ proc:BEGIN AND ( (pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH)) OR (pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV)) - OR (pb.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV)) + OR (pb.H = 0 AND pb.V = 0 AND pb.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV)) ) AND t.created < TIMESTAMPADD(MINUTE, - tc.pickingDelay , NOW()) AND (pc.isPreviousPreparationRequired = FALSE @@ -56338,7 +55255,7 @@ proc:BEGIN WHERE ( (pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH)) OR (pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV)) - OR (pb.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV)) + OR (pb.H = 0 AND pb.V = 0 AND pb.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV)) ) AND (pb.ubicacion IS NOT NULL OR a.isOwn = FALSE ) @@ -56426,11 +55343,15 @@ proc:BEGIN LIMIT 1; -- Hay que excluir aquellos que no tengan la misma hora de preparación - DELETE - FROM tmp.ticket - WHERE HH != vHour - OR mm != vMinute; + IF vHourMatters THEN + DELETE + FROM tmp.ticket + WHERE HH != vHour + OR mm != vMinute; + + END IF; + -- En el caso de pedidos de más volumen de un carro, la colección será monoticket. Pero si el primer pedido -- no es monoticket, excluimos a los de más de un carro IF (SELECT (t.shelveLiters > vc.trolleyM3 * 1000) @@ -56632,7 +55553,7 @@ proc:BEGIN -- Actualiza el estado de los tickets INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) - SELECT vStateFk, ticketFk, account.myUser_getId() + SELECT vStateFk, ticketFk, vUserFk FROM vn.ticketCollection tc WHERE tc.collectionFk = vCollectionFk; @@ -56662,6 +55583,7 @@ proc:BEGIN ELSE + CALL util.throw('No ha sido posible obtener colección'); DELETE FROM vn.collection WHERE id = vCollectionFk; END IF; @@ -56671,7 +55593,8 @@ proc:BEGIN tmp.ticketShelveLiters, tmp.ticket, tmp.wagonsVolumetry, - tmp.ticketShelve; + tmp.ticketShelve, + tmp.productionBuffer; END ;; DELIMITER ; @@ -56679,7 +55602,7 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `collection_reject` */; +/*!50003 DROP PROCEDURE IF EXISTS `collection_newWithWagon_beta` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -56689,25 +55612,671 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_reject`(vSale INT, vQuantity INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_newWithWagon_beta`(vUserFk INT, vSectorFk INT, vWagons INT) +proc:BEGIN + + DECLARE vIsPreviousPrepared BOOLEAN; + DECLARE vCollectionFk INT; + DECLARE vWarehouseFk INT; + DECLARE vMaxTickets INT; + DECLARE vStateFk INT; + DECLARE vFirstTicketFk INT; + DECLARE vHour INT; + DECLARE vMinute INT; + DECLARE vWorkerCode VARCHAR(3); + DECLARE vWagon INT; + DECLARE vWagonCounter INT; + DECLARE vShelve INT; + DECLARE vTicket INT; + DECLARE vTicketToSplit INT; + DECLARE vPrintedTickets INT; + DECLARE vMaxTicketPrinted INT; + DECLARE vItemPackingTypeFk VARCHAR(1); + DECLARE hasAssignedTickets BOOLEAN; + DECLARE vMaxNotReadyCollections INT DEFAULT 0; + DECLARE vNotReadyCollections INT; + DECLARE vTrainFk INT DEFAULT 1; + DECLARE vNow DATETIME; + + SELECT ticketPrintedMax * vWagons, ticketTrolleyMax * vWagons, pc.maxNotReadyCollections , NOW() + INTO vMaxTicketPrinted, vMaxTickets, vMaxNotReadyCollections, vNow + FROM vn.productionConfig pc; + + SELECT w.code INTO vWorkerCode + FROM vn.worker w + WHERE w.id = vUserFk; + + -- Establecemos el almacén y si es un sector de preparación previa, así como el estado para los tickets que se vayan preparando + SELECT isPreviousPrepared, warehouseFk, itemPackingTypeFk + INTO vIsPreviousPrepared, vWarehouseFk, vItemPackingTypeFk + FROM vn.sector + WHERE id = vSectorFk; -- Hola + +-- Si está habilitado el modo cazador para las motos, y el usuario no esta registrado, se sale. + + IF (SELECT isTractorHuntingMode FROM vn.deviceProductionConfig dpc) AND vItemPackingTypeFk = 'H' THEN + IF (SELECT COUNT(*) FROM vn.workerWithoutTractor wwt WHERE wwt.workerFk = vUserFk) THEN + CALL util.throw('Usuario no registrado con moto'); + LEAVE proc; + END IF; + END IF; + +-- Si hay colecciones sin terminar, sale del proceso + SELECT count(*) INTO vNotReadyCollections + FROM ( + SELECT count(DISTINCT s.id) totalRow, count(DISTINCT st.id) pickedRow + FROM vn.collection c + JOIN vn.ticketCollection tc ON tc.collectionFk = c.id + JOIN vn.sale s ON s.ticketFk = tc.ticketFk + JOIN vn.state ss ON ss.code = 'PREPARED' + LEFT JOIN vn.saleTracking st ON st.saleFk = s.id AND st.stateFk = ss.id + WHERE c.workerFk = vUserFk + AND c.created >= TIMESTAMPADD(HOUR , -6,NOW()) + AND s.quantity != 0 + GROUP BY c.id + HAVING totalRow > pickedRow) sub; + +call util.debugAdd('wargo',CONCAT('vMaxNotReadyCollections ', vMaxNotReadyCollections)); +call util.debugAdd('wargo',CONCAT('vNotReadyCollections ',vNotReadyCollections)); + + IF vMaxNotReadyCollections < vNotReadyCollections THEN + + CALL util.throw('Hay colecciones pendientes'); + LEAVE proc; + + END IF; + + IF vIsPreviousPrepared THEN + + CALL util.throw('Es de preparación previa'); + LEAVE proc; -- Hasta que tengamos el altillo, vamos a cancelar esta opcion + + 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; + + CALL vn.productionControl(vWarehouseFk, 0); + + -- Esto hay que corregirlo añadiendo un nuevo parámetro al proc. PAK 23/12/21 + IF vSectorFk = 65 THEN -- Pedidos pequeños + + SET vTrainFk = 2; + + DELETE pb.* + FROM tmp.productionBuffer pb + JOIN vn.volumeConfig vc + WHERE pb.m3 * 1000 > vc.minTicketVolume; + + END IF; + + -- Se obtiene nº de colección y el buffer con los pedidos preparables + INSERT INTO vn.collection + SET workerFk = vUserFk, + itemPackingTypeFk = vItemPackingTypeFk, + trainFk = vTrainFk; + + SELECT LAST_INSERT_ID() INTO vCollectionFk; + + -- 05/08/2021 PAK Jose Frau pide que los tickets de recogida en Algemesí sólo se saquen si están asignados. + DELETE pb.* + FROM tmp.productionBuffer pb + JOIN vn.state s ON s.id = pb.state + WHERE pb.agency = 'REC_ALGEMESI' + AND s.code != 'PICKER_DESIGNED'; + + -- 2/3/2022 PAK Se acuerda con Pepe que los pedidos con riesgo no se sacan aunque se asignen. + DELETE pb.* + FROM tmp.productionBuffer pb + WHERE pb.problem LIKE '%RIESGO%'; + + -- 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 + WHERE (itemPackingTypeFk = vItemPackingTypeFk) ; + + DELETE FROM tmp.ticketToSplit + WHERE ticketFk = vTicketToSplit; + + DROP TEMPORARY TABLE tmp.ticketIPT; + + END WHILE; + + CALL vn.productionControl(vWarehouseFk, 0); + + 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 + JOIN vn.productionConfig pc + 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.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV)) + ) + AND (pc.isPreviousPreparationRequired = FALSE + OR pb.previousWithoutParking = FALSE); + +call util.debugAdd('wargo',CONCAT('vMaxTicketPrinted ', vMaxTicketPrinted)); +call util.debugAdd('wargo',CONCAT('vPrintedTickets ',vPrintedTickets)); + + SET vMaxTicketPrinted = vMaxTicketPrinted - vPrintedTickets; + + -- AutoPRINT + + INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) + SELECT s2.id, pb.ticketFk, vUserFk + 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' + JOIN vn.ticket t ON t.id = pb.ticketFk + JOIN vn.ticketConfig tc + JOIN vn.productionConfig pc + WHERE pb.shipped = CURDATE() + AND (LENGTH(pb.problem) = 0 + OR (pb.problem = 'PEQUEÑO' AND vTrainFk = 2)) + AND (pb.ubicacion IS NOT NULL + OR a.isOwn = FALSE ) + AND s.isPrintable + AND 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.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV)) + ) + AND t.created < TIMESTAMPADD(MINUTE, - tc.pickingDelay , NOW()) + AND (pc.isPreviousPreparationRequired = FALSE + OR pb.previousWithoutParking = FALSE) + ORDER BY HH, + mm, + s.`order` DESC, + pb.m3 DESC + LIMIT vMaxTicketPrinted; + + -- 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, IFNULL((pb.H + pb.V = 0),TRUE) isNeutral + 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 + JOIN vn.productionConfig pc + WHERE ( + (pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH)) + OR (pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV)) + OR (pb.H = 0 AND pb.V = 0 AND pb.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV)) + ) + AND (pb.ubicacion IS NOT NULL + OR a.isOwn = FALSE ) + AND LENGTH(pb.problem) = 0 + AND s.isPreparable + AND (pc.isPreviousPreparationRequired = FALSE + OR pb.previousWithoutParking = FALSE) + ORDER BY pb.HH, pb.mm, s.`order` DESC + LIMIT vMaxTickets; + +call util.debugAdd('wargo',CONCAT('tmp.ticketToSplit ', (SELECT COUNT(*) FROM tmp.ticketToSplit))); + + WHILE (SELECT COUNT(*) FROM tmp.ticketToSplit) DO + + SELECT MIN(ticketFk) INTO vTicketToSplit + FROM tmp.ticketToSplit; + + + IF (SELECT isNeutral + FROM tmp.ticketToSplit + WHERE ticketFk = vTicketToSplit) THEN + + INSERT INTO vn.ticketCollection(ticketFk, collectionFk) + VALUES(vTicketToSplit, vCollectionFk); + +call util.debugAdd('wargo',CONCAT('neutral ', vTicketToSplit)); + + ELSE + + CALL vn.ticket_splitItemPackingType(vTicketToSplit); + + INSERT INTO vn.ticketCollection(ticketFk, collectionFk) + SELECT ticketFk, vCollectionFk + FROM tmp.ticketIPT + WHERE itemPackingTypeFk = vItemPackingTypeFk; + +call util.debugAdd('wargo',CONCAT('NO neutral ', + (SELECT ticketFk FROM tmp.ticketIPT WHERE itemPackingTypeFk = vItemPackingTypeFk))); + + DROP TEMPORARY TABLE tmp.ticketIPT; + + END IF; + + DELETE FROM tmp.ticketToSplit + WHERE ticketFk = vTicketToSplit; + + END WHILE; + + END IF; + +call util.debugAdd('wargo',CONCAT('vn.ticketCollection ', + (SELECT COUNT(*) FROM vn.ticketCollection WHERE collectionFk = vCollectionFk))); + + -- Creamos una tabla temporal con los datos que necesitamos para depurar la colección + DROP TEMPORARY TABLE IF EXISTS tmp.ticket; + CREATE TEMPORARY TABLE tmp.ticket + SELECT pb.ticketFk, + pb.`lines`, + pb.m3 * 1000 liters, + 0 as height, + 0 as shelve, + 0 as wagon, + 0 AS shelveLiters, + pb.productionOrder, + pb.HH, + pb.mm + FROM tmp.productionBuffer pb + JOIN vn.ticketCollection tc ON tc.ticketFk = pb.ticketFk + WHERE tc.collectionFk = vCollectionFk + LIMIT vMaxTickets; + + -- Voumen de las lineas de los pedidos, de acuerdo con el packingShelve establecido por los controladores + DROP TEMPORARY TABLE IF EXISTS tmp.ticketShelveLiters; + CREATE TEMPORARY TABLE tmp.ticketShelveLiters + SELECT t.ticketFk, SUM(s.quantity * vc.shelveVolume / i.packingShelve) shelveLiters + FROM tmp.ticket t + JOIN vn.sale s ON s.ticketFk = t.ticketFk + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.volumeConfig vc + WHERE i.packingShelve + GROUP BY t.ticketFk; + + UPDATE tmp.ticket t + JOIN tmp.ticketShelveLiters tsl ON tsl.ticketFk = t.ticketFk + SET t.shelveLiters = tsl.shelveLiters; + + -- Es importante que el primer ticket se coja en todos los casos + + SET vFirstTicketFk = 0; + + SELECT ticketFk, HH, mm + INTO vFirstTicketFk, vHour, vMinute + FROM tmp.ticket + ORDER BY productionOrder DESC, HH, mm + LIMIT 1; + +call util.debugAdd('wargo',CONCAT('vFirstTicketFk ', vFirstTicketFk)); +call util.debugAdd('wargo',CONCAT('vHour ', vHour)); +call util.debugAdd('wargo',CONCAT('vMinute ', vMinute)); + +call util.debugAdd('wargo',CONCAT('tmp.ticket ', (SELECT COUNT(*) FROM tmp.ticket))); + + -- Hay que excluir aquellos que no tengan la misma hora de preparación + DELETE + FROM tmp.ticket + WHERE HH != vHour + OR mm != vMinute; + +call util.debugAdd('wargo',CONCAT('tmp.ticket misma hora ', (SELECT COUNT(*) FROM tmp.ticket))); + + -- En el caso de pedidos de más volumen de un carro, la colección será monoticket. Pero si el primer pedido + -- no es monoticket, excluimos a los de más de un carro + IF (SELECT (t.shelveLiters > vc.trolleyM3 * 1000) + FROM tmp.ticket t + JOIN vn.volumeConfig vc + WHERE t.ticketFk = vFirstTicketFk) THEN + + DELETE + FROM tmp.ticket + WHERE ticketFk != vFirstTicketFk; + + ELSE + + DELETE t.* + FROM tmp.ticket t + JOIN vn.volumeConfig vc + WHERE t.shelveLiters > vc.trolleyM3 * 1000; + + END IF; + +call util.debugAdd('wargo',CONCAT('tmp.ticket volumen ', (SELECT COUNT(*) FROM tmp.ticket))); + + -- 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; + +call util.debugAdd('wargo',CONCAT('vn.ticketCollection ', + (SELECT COUNT(*) FROM vn.ticketCollection WHERE collectionFk = vCollectionFk))); + + -- Construccion del tren + + -- 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 + WHERE cv.itemPackingTypeFk = IFNULL(vItemPackingTypeFk, 'H') + AND cv.trainFk = vTrainFk; + + 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 + WHERE cv.itemPackingTypeFk = IFNULL(vItemPackingTypeFk, 'H') + AND cv.trainFk = vTrainFk; + + 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.shelveLiters 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; + +call util.debugAdd('wargo',CONCAT('vn.ticketCollection bloqueados ', + (SELECT COUNT(*) FROM vn.ticketCollection WHERE collectionFk = vCollectionFk))); + + -- Elimina los tickets que ya estan en otra coleccion + DELETE tc.* + FROM vn.ticketCollection tc + JOIN vn.ticketCollection tc2 ON tc2.ticketFk = tc.ticketFk + WHERE tc.collectionFk = vCollectionFk + AND tc2.collectionFk != vCollectionFk; + +call util.debugAdd('wargo',CONCAT('vn.ticketCollection otra coleccion ', + (SELECT COUNT(*) FROM vn.ticketCollection WHERE collectionFk = vCollectionFk))); + + -- 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, + tc.itemCount = t.`lines`, + tc.liters = t.shelveLiters; + + -- Actualiza el estado de los tickets + INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) + SELECT vStateFk, ticketFk, vUserFk + 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; + + SELECT * FROM util.debug + where variable = 'wargo' + and created >= vNow + order by created; + + 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; + + CALL util.throw('No se ha obtenido colección'); + + END IF; + + DROP TEMPORARY TABLE + tmp.ticketToSplit, + tmp.ticketShelveLiters, + tmp.ticket, + tmp.wagonsVolumetry, + tmp.ticketShelve, + tmp.productionBuffer; + +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_printSticker` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_printSticker`(vCollection INT) BEGIN - - DECLARE vDescription VARCHAR(100); - DECLARE vOriginalQuantity INT; - DECLARE vConcept VARCHAR(100); - DECLARE vOrigin INT; - SELECT concept INTO vConcept FROM sale WHERE id = vSale; - SELECT ticketFk INTO vOrigin FROM sale WHERE id = vSale; - SELECT quantity INTO vOriginalQuantity FROM sale WHERE id = vSale; - SELECT CONCAT("Cambio cantidad ",vConcept," de ", vOriginalQuantity," a ", vQuantity) INTO vDescription; + /*Imprime una etiqueta amarilla a partir de una colección + * + * @param vCollection colección + * @param vPrinterFk id de la impresora + */ - INSERT INTO ticketLog (originFk, userFk, action , description) - VALUES(vOrigin, getUser(), 'update', vDescription); + DECLARE vLabelReportFk INT; + DECLARE vLabelerFk INT; - UPDATE sale SET originalQuantity = vOriginalQuantity, quantity = vQuantity WHERE id = vSale; + SELECT s.labelReportFk, w.labelerFk INTO vLabelReportFk, vLabelerFk + FROM worker w + LEFT JOIN sector s ON s.id= w.sectorFk + WHERE w.id=account.myUser_getId() ; + + IF vLabelReportFk AND vLabelerFk THEN + + INSERT INTO ticketTrolley(ticket, labelCount) + SELECT ticketFk, 1 + FROM ticketCollection + WHERE collectionFk = vCollection + ON DUPLICATE KEY UPDATE labelCount = labelCount + 1; + + INSERT INTO printServerQueue(labelReportFk, param1, workerFk,printerFk) + SELECT vLabelReportFk, vCollection, getUser(),vLabelerFk; + + END IF; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -59743,48 +59312,68 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_splitByShelving`(vShelvingFk VARCHAR(3), vFromEntryFk INT, vToEntryFk INT) BEGIN - /** - * Divide las compras entre dos entradas de acuerdo con lo ubicado en una matr�cula - * - * @param vShelvingFk Identificador de vn.shelving - * @param vFromEntryFk Entrada origen - * @param vToEntryFk Entrada destino - */ - - DECLARE vItemFk INT; - DECLARE vStickers INT; +/** + * Divide las compras entre dos entradas de acuerdo con lo ubicado en una matr�cula + * + * @param vShelvingFk Identificador de vn.shelving + * @param vFromEntryFk Entrada origen + * @param vToEntryFk Entrada destino + */ DECLARE vBuyFk INT; - DECLARE vHasSameStickers BOOL; + DECLARE ishStickers INT; + DECLARE buyStickers INT; DECLARE vDone BOOLEAN DEFAULT FALSE; + DECLARE cur CURSOR FOR - SELECT itemFk, FLOOR(quantity / packing) AS stickers - FROM vn.itemShelving WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci ; + SELECT bb.id buyFk, + FLOOR(ish.visible / ish.packing) AS ishStickers, + bb.stickers buyStickers + FROM vn.itemShelving ish + JOIN (SELECT b.id, b.itemFk, b.stickers + FROM vn.buy b + WHERE b.entryFk = vFromEntryFk + ORDER BY b.stickers DESC) bb ON bb.itemFk = ish.itemFk + AND bb.stickers >= FLOOR(ish.visible / ish.packing) + WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci + GROUP BY ish.id; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + -- Cantidades de la matrícula que exceden la de las entradas + SELECT ish.itemFk, + i.longName, + FLOOR(ish.visible / ish.packing) AS etiEnMatricula, + bb.stickers etiEnEntrada + FROM vn.itemShelving ish + JOIN vn.item i ON i.id = ish.itemFk + LEFT JOIN (SELECT b.id, b.itemFk, b.stickers + FROM vn.buy b + WHERE b.entryFk = vFromEntryFk + ORDER BY b.stickers DESC) bb ON bb.itemFk = ish.itemFk + WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci + AND IFNULL(bb.stickers,0) < FLOOR(ish.visible / ish.packing) + GROUP BY ish.id; + OPEN cur; read_loop: LOOP - - FETCH cur INTO vItemFk, vStickers; - - IF vDone THEN - LEAVE read_loop; - END IF; + SET vDone = FALSE; - SELECT b.id, (stickers = vStickers) INTO vBuyFk, vHasSameStickers - FROM vn.buy - WHERE entryFk = vFromEntryFk - AND itemFk = vItemFk - AND stickers >= vStickers - LIMIT 1; - - IF vHasSameStickers THEN - - UPDATE vn.buy SET entryFk = vToEntryFk WHERE id = vBuyFk; + FETCH cur INTO vBuyFk, ishStickers, buyStickers; + + IF vDone THEN + LEAVE read_loop; + END IF; + IF ishStickers = buyStickers THEN + UPDATE vn.buy + SET entryFk = vToEntryFk + WHERE id = vBuyFk; ELSE - - UPDATE vn.buy SET stickers = stickers - vStickers WHERE id = vBuyFk; + UPDATE vn.buy + SET stickers = stickers - ishStickers, + quantity = stickers * packing + WHERE id = vBuyFk; INSERT INTO vn.buy(entryFk, itemFk, @@ -59817,11 +59406,11 @@ BEGIN SELECT vToEntryFk, itemFk, - vStickers * packing, + ishStickers * packing, buyingValue, freightValue, isIgnored, - vStickers, + ishStickers, packing, `grouping`, groupingMode, @@ -59835,7 +59424,7 @@ BEGIN price3, minPrice, producer, - vStickers, + ishStickers, workerFk, isChecked, isPickedOff, @@ -59847,11 +59436,9 @@ BEGIN WHERE id = vBuyFk; END IF; - END LOOP; CLOSE cur; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -60298,6 +59885,39 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `expeditionPallet_printLabel` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionPallet_printLabel`(vPalletFk INT) +BEGIN + + DECLARE vLabel INT; + DECLARE vPrinterFk INT; + + UPDATE vn.expeditionPallet + SET isPrint = FALSE + WHERE id = vPalletFk; + + SELECT s.labelReportFk, w.labelerFk INTO vLabel, vPrinterFK + FROM worker w + LEFT JOIN sector s ON s.id= w.sectorFk + WHERE w.id=account.myUser_getId() ; + + INSERT INTO printServerQueue (printerFk, labelReportFk, statusFk, param1, workerFk) + VALUES(vPrinterFK, vLabel, 1, vPalletFk, account.myUser_getId()); +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 `expeditionPallet_PrintSet` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -60594,6 +60214,42 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `expeditionState_addByPallet` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionState_addByPallet`(vPalletFk INT, vStateCode VARCHAR(100)) +BEGIN +/** + * Inserta nuevos registros en la tabla vn.expeditionState + * + * @param vPalletFk Identificador de vn.expedition + * @param vStateCode Corresponde a vn.expeditionStateType.code + */ + DROP TEMPORARY TABLE IF EXISTS tmp.expeditionScan; + CREATE TEMPORARY TABLE tmp.expeditionScan + SELECT expeditionFk, est.id typeFk + FROM vn.expeditionScan e + JOIN vn.expeditionStateType est ON est.code = vStateCode + WHERE e.palletFk = vPalletFk; + + INSERT INTO vn.expeditionState(expeditionFk, typeFk) + SELECT expeditionFk, typeFk + FROM tmp.expeditionScan; + + DROP TEMPORARY TABLE IF EXISTS tmp.expeditionScan; +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 `expeditionState_addByRoute` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -60707,9 +60363,9 @@ DELIMITER ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8mb4 */ ; /*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `expedition_getFromRoute`(vRouteFk INT) BEGIN @@ -60718,7 +60374,6 @@ BEGIN * @param vRouteFk Id de la ruta */ - SELECT e.id, e.ticketFk, e.checked, @@ -60729,7 +60384,8 @@ BEGIN a.postalCode, t.addressFk, a.nickname, - sub2.itemPackingTypeConcat + sub2.itemPackingTypeConcat, + est.code FROM expedition e JOIN ticket t ON t.id = e.ticketFk JOIN ticketState ts ON ts.ticketFk = e.ticketFk @@ -60745,9 +60401,9 @@ BEGIN GROUP BY t.id,i.itemPackingTypeFk)sub GROUP BY sub.ticketFk ) sub2 ON sub2.ticketFk = t.id + LEFT JOIN expeditionStateType est ON est.id = e.stateTypeFk WHERE t.routeFk = vRouteFk AND e.isBox <> FALSE; - - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -66481,73 +66137,62 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingMakeFromDate`(IN `vShelvingFk` VARCHAR(8), IN `vBarcode` VARCHAR(22), IN `vShelve` VARCHAR(2), IN `vDeep` INT, IN `vQuantity` INT, IN `vPackagingFk` VARCHAR(10), IN `vGrouping` INT, IN `vPacking` INT, IN `vWarehouseFk` INT, IN `vLevel` INT,`vCreated` VARCHAR(22)) +CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingMakeFromDate`(IN `vShelvingFk` VARCHAR(8), IN `vBarcode` VARCHAR(22), IN `vShelve` VARCHAR(2), IN `vQuantity` INT, IN `vPackagingFk` VARCHAR(10), IN `vGrouping` INT, IN `vPacking` INT, IN `vWarehouseFk` INT, `vCreated` VARCHAR(22)) BEGIN - - DECLARE vItemFk INT; - - - + SELECT vn.barcodeToItem(vBarcode) INTO vItemFk; - - SELECT itemFk INTO vItemFk - FROM vn.buy b + SELECT itemFk INTO vItemFk + FROM vn.buy b WHERE b.id = vItemFk; - - - IF (SELECT COUNT(*) FROM vn.shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN - - INSERT IGNORE INTO vn.parking(`code`) VALUES(vShelvingFk); - INSERT INTO vn.shelving(`code`, parkingFk) - SELECT vShelvingFk, id - FROM vn.parking - WHERE `code` = vShelvingFk COLLATE utf8_unicode_ci; - - END IF; - - IF (SELECT COUNT(*) FROM vn.itemShelving - WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk - AND itemFk = vItemFk - AND packing = vPacking) = 1 THEN - UPDATE vn.itemShelving SET quantity = quantity+vQuantity,visible = visible+vQuantity,available = available+vQuantity, created = vCreated - WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking; - + IF (SELECT COUNT(*) FROM vn.shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN + + INSERT IGNORE INTO vn.parking(`code`) VALUES(vShelvingFk); + INSERT INTO vn.shelving(`code`, parkingFk) + SELECT vShelvingFk, id + FROM vn.parking + WHERE `code` = vShelvingFk COLLATE utf8_unicode_ci; + + END IF; + + IF (SELECT COUNT(*) FROM vn.itemShelving + WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk + AND itemFk = vItemFk + AND packing = vPacking) = 1 THEN + + UPDATE vn.itemShelving + SET visible = visible+vQuantity, + created = vCreated + WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk + AND itemFk = vItemFk + AND packing = vPacking; + ELSE - CALL cache.last_buy_refresh(FALSE); - INSERT INTO itemShelving( itemFk, - shelvingFk, - shelve, - deep, - quantity, - visible, - available, - created, - `grouping`, - packing, - packagingFk, - level) - SELECT - vItemFk, - vShelvingFk, - vShelve, - vDeep, - vQuantity, - vQuantity, - vQuantity, - vCreated, - IF(vGrouping = 0, IFNULL(b.packing, vPacking), vGrouping) as `grouping`, - IF(vPacking = 0, b.packing, vPacking) as packing, - IF(vPackagingFk = '', b.packageFk, vPackagingFk) as packaging, - vLevel - FROM vn.item i - LEFT JOIN cache.last_buy lb ON i.id = lb.item_id AND lb.warehouse_id = vWarehouseFk - LEFT JOIN vn.buy b ON b.id = lb.buy_id - WHERE i.id = vItemFk; - END IF; + CALL cache.last_buy_refresh(FALSE); + INSERT INTO itemShelving( itemFk, + shelvingFk, + shelve, + visible, + created, + `grouping`, + packing, + packagingFk) + SELECT vItemFk, + vShelvingFk, + vShelve, + vQuantity, + vCreated, + IF(vGrouping = 0, IFNULL(b.packing, vPacking), vGrouping) `grouping`, + IF(vPacking = 0, b.packing, vPacking) packing, + IF(vPackagingFk = '', b.packageFk, vPackagingFk) packaging + FROM vn.item i + LEFT JOIN cache.last_buy lb ON i.id = lb.item_id AND lb.warehouse_id = vWarehouseFk + LEFT JOIN vn.buy b ON b.id = lb.buy_id + WHERE i.id = vItemFk; + END IF; END ;; DELIMITER ; @@ -66693,20 +66338,18 @@ DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingPlacementSupplyAdd`(vItemShelvingFk INT, vItemPlacementSupplyFk INT, vQuantity INT) BEGIN - INSERT INTO vn.itemShelvingPlacementSupply( itemShelvingFk, - itemPlacementSupplyFk, - quantity, + INSERT INTO vn.itemShelvingPlacementSupply( itemShelvingFk, + itemPlacementSupplyFk, + quantity, userFk) - VALUES ( vItemShelvingFk, - vItemPlacementSupplyFk, - vQuantity, - getUser()); - - UPDATE vn.itemShelving - SET quantity = quantity - vQuantity, - visible = visible - vQuantity, - available = available - vQuantity - WHERE id = vItemShelvingFk; + VALUES (vItemShelvingFk, + vItemPlacementSupplyFk, + vQuantity, + getUser()); + + UPDATE vn.itemShelving + SET visible = visible - vQuantity + WHERE id = vItemShelvingFk; END ;; @@ -67124,25 +66767,27 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingRadar_Urgent`(vWorkerFk INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingRadar_Urgent`() BEGIN +/** + * Devuelve lo mismo que itemShelving_filterBuyer per sin filtrar + */ DECLARE vCalcVisibleFk INT; DECLARE vWarehouseFk INT DEFAULT 60; - -- Eliminar cuando tengamos programador de Android - 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(DATE_FORMAT(sub2.etd,'%H:%i'), ' salen ', 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)) nicho + CAST(visible - upstairs - downstairs AS DECIMAL(10,0)) nicho, + sub2.etd FROM (SELECT iss.itemFk, CONCAT(i.longName,' ',i.size,' ',IFNULL(i.subName,'') ) longName, '' size, @@ -67150,19 +66795,19 @@ BEGIN 0 upstairs, SUM(IFNULL(iss.visible,0)) downstairs, IF(it.isPackaging, null, IFNULL(v.visible,0)) visible, - 0 sectorFk + IFNULL(iss.sectorFk,0) sectorFk FROM itemShelvingStock iss JOIN sector s ON s.id = iss.sectorFk JOIN item i on i.id = iss.itemFk JOIN itemType it ON it.id = i.typeFk - LEFT JOIN cache.visible v ON v.item_id = iss.itemFk AND v.calc_id = vCalcVisibleFk + LEFT JOIN cache.visible v ON v.item_id = iss.itemFk AND v.calc_id = @vCalcVisibleFk WHERE s.warehouseFk = vWarehouseFk - AND it.workerFk = vWorkerFk GROUP BY itemFk - ) sub LEFT JOIN (SELECT s.itemFk, SUM(s.quantity) pendiente + ) sub LEFT JOIN (SELECT s.itemFk, SUM(s.quantity) pendiente, MIN(zc.`hour`) etd FROM sale s LEFT JOIN saleTracking st ON st.saleFk = s.id - JOIN ticket t ON t.id = s.ticketFk + JOIN ticket t ON t.id = s.ticketFk + LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk JOIN client c on c.id = t.clientFk JOIN clientType ct ON ct.id = c.clientTypeFk WHERE t.shipped BETWEEN CURDATE() AND util.dayend(CURDATE()) @@ -67173,21 +66818,23 @@ BEGIN UNION ALL SELECT v.item_id , i.longName, - CONCAT('Hoy saldrán ', CAST(sub5.pendiente AS DECIMAL(10,0)), ' unidades.') `size`, + CONCAT(DATE_FORMAT(sub5.etd,'%H:%i'), ' salen ', CAST(sub5.pendiente AS DECIMAL(10,0)), ' unidades.') `size`, CONCAT(IF(sub5.pendiente,'(0) ','(3) ')) producer, 0, 0, v.visible, - 0, - v.visible nicho + IFNULL(iss.sectorFk,0), + v.visible nicho, + sub5.etd FROM cache.visible v JOIN item i ON i.id = v.item_id JOIN itemType it ON it.id = i.typeFk LEFT JOIN itemShelvingStock iss ON iss.itemFk = v.item_id - LEFT JOIN (SELECT s.itemFk , SUM(s.quantity) pendiente + LEFT JOIN (SELECT s.itemFk , SUM(s.quantity) pendiente, MIN(zc.`hour`) etd FROM sale s LEFT JOIN saleTracking st ON st.saleFk = s.id - JOIN ticket t ON t.id = s.ticketFk + JOIN ticket t ON t.id = s.ticketFk + LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk JOIN client c on c.id = t.clientFk JOIN clientType ct ON ct.id = c.clientTypeFk WHERE t.shipped BETWEEN CURDATE() AND util.dayend(CURDATE()) @@ -67195,13 +66842,11 @@ BEGIN AND ct.code IN ('normal', 'trust') GROUP BY s.itemFk ) sub5 ON sub5.itemFk = v.item_id - WHERE v.calc_id = vCalcVisibleFk + WHERE v.calc_id = @vCalcVisibleFk AND ISNULL(iss.itemFk) - AND it.workerFk = vWorkerFk ) sub3 WHERE nicho - ORDER BY producer; - + ORDER BY LEFT(producer,3), etd, producer; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -67315,20 +66960,21 @@ DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingSaleAdd`(vItemShelvingFk INT, saleFk INT, vQuantity INT) BEGIN -IF saleFk <> 0 THEN - INSERT INTO vn.itemShelvingSale( itemShelvingFk, - saleFk, - quantity, - userFk) - VALUES ( vItemShelvingFk, - saleFk, + IF saleFk <> 0 THEN + INSERT INTO vn.itemShelvingSale(itemShelvingFk, + saleFk, + quantity, + userFk) + VALUES (vItemShelvingFk, + saleFk, vQuantity, getUser()); - -END IF; - UPDATE vn.itemShelving SET quantity = (quantity - vQuantity), available = (available - vQuantity), visible = (visible - vQuantity) - WHERE id = vItemShelvingFk; + END IF; + + UPDATE vn.itemShelving + SET visible = (visible - vQuantity) + WHERE id = vItemShelvingFk; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -67392,38 +67038,34 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingSaleSupplyAddVoz`(vItemShelvingFk VARCHAR(50), saleFk INT, vQuantity INT,idMovimiento INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingSaleSupplyAddVoz`(vItemShelvingFk VARCHAR(50), saleFk INT, vQuantity INT, idMovimiento INT) BEGIN + DECLARE vItemShelvingFkAux INT; + DECLARE vItemFk INT; + SELECT itemFk INTO vItemFk FROM vn.sale WHERE id = saleFk; -/*INSERT INTO `vn`.`errorLogApp` (`error`, `workerFk`) VALUES (CONCAT(vItemShelvingFk," ",saleFk), '14255');*/ + SELECT id INTO vItemShelvingFkAux FROM vn.itemShelving WHERE shelvingFk = vItemShelvingFk COLLATE utf8_general_ci AND itemFk = vItemFk; -DECLARE vItemShelvingFkAux INT; -DECLARE vItemFk INT; + INSERT INTO vn.itemShelvingSale( + itemShelvingFk, + saleFk, + quantity, + userFk + ) VALUES ( + vItemShelvingFkAux, + saleFk, + vQuantity, + getUser() + ); -SELECT itemFk INTO vItemFk FROM vn.sale WHERE id = saleFk; - -SELECT id INTO vItemShelvingFkAux FROM vn.itemShelving WHERE shelvingFk = vItemShelvingFk COLLATE utf8_general_ci AND itemFk = vItemFk; - -INSERT INTO vn.itemShelvingSale( itemShelvingFk, - saleFk, - quantity, - userFk) - VALUES ( vItemShelvingFkAux, - saleFk, - vQuantity, - getUser()); - - UPDATE vn.itemShelving - SET quantity = quantity - vQuantity, - visible = visible - vQuantity, - available = available - vQuantity - WHERE id = vItemShelvingFkAux; - - UPDATE vn2008.Movimientos_mark - SET valor = 1 - WHERE Id_Movimiento = idMovimiento; + UPDATE vn.itemShelving + SET visible = visible - vQuantity + WHERE id = vItemShelvingFkAux; + UPDATE vn2008.Movimientos_mark + SET valor = 1 + WHERE Id_Movimiento = idMovimiento; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -67542,84 +67184,118 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_add`(IN vShelvingFk VARCHAR(8), IN vBarcode VARCHAR(22), IN vShelve VARCHAR(2), IN vDeep INT, IN vQuantity INT, IN vPackagingFk VARCHAR(10), IN vGrouping INT, IN vPacking INT, IN vWarehouseFk INT, IN vLevel INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_add`(IN vShelvingFk VARCHAR(8), IN vBarcode VARCHAR(22), IN vShelve VARCHAR(2), IN vQuantity INT, IN vPackagingFk VARCHAR(10), IN vGrouping INT, IN vPacking INT, IN vWarehouseFk INT) BEGIN + /** * Añade registro o lo actualiza si ya existe. * * @param vShelvingFk matrícula del carro * @param vBarcode el id del registro * @param vShelve de itemshleving - * @param vDeep indica profundidad * @param vQuantity indica la cantidad del producto * @param vPackagingFk el packaging del producto en itemShelving, NULL para coger el de la ultima compra * @param vGrouping el grouping del producto en itemShelving, NULL para coger el de la ultima compra * @param vPacking el packing del producto, NULL para coger el de la ultima compra * @param vWarehouseFk indica el sector - * @param vLevel indica el level * **/ - - DECLARE vItemFk INT; - SELECT barcodeToItem(vBarcode) INTO vItemFk; - + DECLARE vItemFk INT; + + SELECT barcodeToItem(vBarcode) INTO vItemFk; + IF (SELECT COUNT(*) FROM shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN - + INSERT IGNORE INTO parking(code) VALUES(vShelvingFk); - INSERT INTO shelving(code, parkingFk) + INSERT INTO shelving(code, parkingFk) SELECT vShelvingFk, id FROM parking - WHERE `code` = vShelvingFk COLLATE utf8_unicode_ci; - - END IF; - - IF (SELECT COUNT(*) FROM itemShelving + WHERE `code` = vShelvingFk COLLATE utf8_unicode_ci; + + END IF; + + IF (SELECT COUNT(*) FROM itemShelving WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking) = 1 THEN - UPDATE itemShelving SET quantity = quantity+vQuantity,visible = visible+vQuantity,available = available+vQuantity - WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking; - - ELSE + UPDATE itemShelving + SET visible = visible+vQuantity + WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking; + + ELSE CALL cache.last_buy_refresh(FALSE); - INSERT INTO itemShelving( itemFk, - shelvingFk, - shelve, - deep, - quantity, - visible, - available, - grouping, - packing, - packagingFk, - level) - - SELECT - vItemFk, - vShelvingFk, - vShelve, - vDeep, - vQuantity, - vQuantity, - vQuantity, - IFNULL(vGrouping, b.grouping), - IFNULL(vPacking, b.packing), - IFNULL(vPackagingFk, b.packageFk), - vLevel - FROM item i + INSERT INTO itemShelving( itemFk, + shelvingFk, + shelve, + visible, + grouping, + packing, + packagingFk) + + SELECT vItemFk, + vShelvingFk, + vShelve, + vQuantity, + IFNULL(vGrouping, b.grouping), + IFNULL(vPacking, b.packing), + IFNULL(vPackagingFk, b.packageFk) + FROM item i LEFT JOIN cache.last_buy lb ON i.id = lb.item_id AND lb.warehouse_id = vWarehouseFk LEFT JOIN buy b ON b.id = lb.buy_id WHERE i.id = vItemFk; - END IF; + END IF; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `itemShelving_addByClaim` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_addByClaim`(vClaimFk INT, vShelvingFk VARCHAR(3)) +BEGIN +/** + * Insert items of claim into itemShelving. + * + * @param vClaimFk The claim + * @param vShelvingFk The shelving + * @table tmp.buyUltimate + */ + DECLARE vWarehouseFk INT; + + SELECT t.warehouseFk INTO vWarehouseFk + FROM claim c + JOIN ticket t ON t.id = c.ticketFk + WHERE c.id = vClaimFk; + + CALL buyUltimate (vWarehouseFk, CURDATE()); + + INSERT INTO itemShelving (itemFk, shelvingFk, quantity, packing, `grouping`, visible) + SELECT s.itemFk, vShelvingFk, cb.quantity, b.packing, b.`grouping`, cb.quantity AS visible + FROM claim c + JOIN claimBeginning cb ON c.id = cb.claimFk + JOIN sale s ON s.id = cb.saleFk + JOIN ticket t ON t.id = s.ticketFk + JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk AND bu.warehouseFk = t.warehouseFk + JOIN buy b ON b.id = bu.buyFk + WHERE c.id = vClaimFk; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -67707,6 +67383,11 @@ proc:BEGIN */ DECLARE vCalcVisibleFk INT; + IF vBuyerFk = 103 THEN -- hay que arreglarlo despues de la campaña PAK 23/04/2022 + CALL vn.itemShelvingRadar_Urgent(); + LEAVE proc; + END IF; + CALL cache.visible_refresh(vCalcVisibleFk, TRUE, vWarehouseFk); SELECT * FROM @@ -67777,7 +67458,6 @@ proc:BEGIN ) sub3 WHERE nicho ORDER BY producer; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -68071,12 +67751,11 @@ BEGIN * @param vPacking el packing del del producto en itemShelving * @param vGrouping el grouping del producto en itemShelving */ - UPDATE itemShelving SET - available = vVisible, - visible = vVisible, - packing = vPacking, - grouping = vGrouping - WHERE id = vShelf; + UPDATE itemShelving + SET visible = vVisible, + packing = vPacking, + grouping = vGrouping + WHERE id = vShelf; END ;; DELIMITER ; @@ -68231,38 +67910,6 @@ BEGIN WHERE calc_id = vCalc AND item_id = vItemFk; -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 `itemStockVisible_verify` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemStockVisible_verify`(vItemFk INT, vQuantity INT) -BEGIN - - INSERT INTO vn.itemShelving(itemFk, - shelvingFk, - quantity, - visible, - available, - packing) - VALUES( vItemFk, - 'FAL', - -vQuantity, - -vQuantity, - -vQuantity, - -vQuantity); - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -69117,8 +68764,8 @@ BEGIN JOIN supplier s ON s.id = e.supplierFk JOIN alertLevel al ON al.id = CASE - WHEN tr.shipped < CURDATE() THEN 3 - WHEN tr.shipped = CURDATE() AND tr.isReceived = TRUE THEN 3 + WHEN tr.landed < CURDATE() THEN 3 + WHEN tr.landed = CURDATE() AND tr.isReceived = TRUE THEN 3 ELSE 0 END JOIN state st ON st.code = al.code @@ -70244,32 +69891,46 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `item_setGeneric`(vSelf INT) BEGIN - - /* Asigna el código genérico a un item - * - * @param vSelf identificador de vn.item - */ - +/** + * Asigna el código genérico a un item, salvo que sea un código de item genérico. + * + * @param vSelf identificador de vn.item + */ DECLARE vGenericFk INT; - - SELECT ga.itemFk INTO vGenericFk - FROM vn.genericAllocation ga - JOIN vn.item i ON (i.typeFk = ga.typeFk OR ISNULL(ga.typeFk)) - JOIN vn.itemTag it1 ON it1.itemFk = i.id AND (it1.value = ga.origin OR ISNULL(ga.origin)) - JOIN vn.itemTag it2 ON it2.itemFk = i.id AND (it2.value = ga.color OR ISNULL(ga.color)) - JOIN vn.itemTag it3 ON it3.itemFk = i.id AND (it3.value = ga.quality OR ISNULL(ga.quality)) - JOIN vn.itemTag it4 ON it4.itemFk = i.id AND (it4.value = ga.numFlores OR ISNULL(ga.numFlores)) - JOIN vn.itemTag it5 ON it5.itemFk = i.id AND (it5.value = ga.category OR ISNULL(ga.category)) - JOIN vn.itemTag it6 ON it6.itemFk = i.id AND (it6.value = ga.productor OR ISNULL(ga.productor)) - WHERE i.id = vSelf - AND ga.itemFk != vSelf - AND NOT i.isFloramondo - LIMIT 1; + SELECT itemFk INTO vGenericFk + FROM ( + SELECT itemFk, (sum(matches) = maxMatches) `match` + FROM ( + SELECT ga.id gaid, + ga.itemFk, + (it.value <=> ga.origin) + + (it.value <=> ga.color) + + (it.value <=> ga.quality) + + (it.value <=> ga.numFlores) + + (it.value <=> ga.category) + + (it.value <=> ga.productor) matches, + !ISNULL(ga.origin) + +!ISNULL(ga.color) + +!ISNULL(ga.quality) + +!ISNULL(ga.numFlores) + +!ISNULL(ga.category) + +!ISNULL(ga.productor) maxMatches + FROM vn.item i + JOIN vn.itemTag it ON it.itemFk = i.id + JOIN vn.genericAllocation ga + ON (i.typeFk = ga.typeFk OR ga.typeFk IS NULL) + AND (i.longName = ga.longName OR ga.longName IS NULL) + AND (i.`size` = ga.`size` OR ga.`size` IS NULL) + AND i.id != ga.itemFk + WHERE i.id = vSelf + AND NOT i.isFloramondo) sub + GROUP BY gaid + HAVING `match`) sub2; + UPDATE vn.item SET genericFk = vGenericFk WHERE id = vSelf; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -72075,7 +71736,7 @@ BEGIN IF vIsInvoiceable THEN - CALL ticketCreateWithUser(vClient, + CALL ticket_add(vClient, vDateEnd, vWarehouse, vCompany, @@ -72084,6 +71745,7 @@ BEGIN NULL, vDateEnd, account.userGetId(), + TRUE, vNewTicket); INSERT INTO ticketPackaging( @@ -72890,21 +72552,48 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `previousSticker_get`(vSaleGroupFk INT) BEGIN - - /* - * Devuelve los campos a imprimir en una etiqueta de preparación previa - * - * @param vSaleGroupFk Identificador de vn.saleGroup - */ +/** + * Devuelve los campos a imprimir en una etiqueta de preparación previa. + * Actualiza el valor de vn.saleGroup.parkingFk en el caso de que exista un saleGroup del mismo ticket + * con parking, del mismo sector, para que todos se pongan juntos + * + * @param vSaleGroupFk Identificador de vn.saleGroup + */ + DECLARE vTicketFk INT; + DECLARE vParkingFk INT; + DECLARE vSectorFk INT; - SELECT sgd.saleGroupFk, + SELECT s.ticketFk + INTO vTicketFk + FROM vn.saleGroupDetail sgd + JOIN vn.sale s ON s.id = sgd.saleFk + WHERE sgd.saleGroupFk = vSaleGroupFk + LIMIT 1; + + SELECT sg.parkingFk, sc.sectorFk + INTO vParkingFk, vSectorFk + FROM vn.saleGroup sg + JOIN vn.sectorCollectionSaleGroup scsg ON scsg.saleGroupFk = sg.id + JOIN vn.sectorCollection sc ON sc.id = scsg.sectorCollectionFk + JOIN vn.saleGroupDetail sgd ON sgd.saleGroupFk = sg.id + JOIN vn.sale s ON s.id = sgd.saleFk + WHERE s.ticketFk = vTicketFk + AND sg.parkingFk IS NOT NULL + LIMIT 1; + + UPDATE vn.saleGroup sg + SET sg.parkingFk = vParkingFk + WHERE sg.id = vSaleGroupFk + AND sg.sectorFk = vSectorFk; + + SELECT sgd.saleGroupFk, 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 , - IFNULL(MAX(i.itemPackingTypeFk),'H') itemPackingTypeFk , - count(*) items + IF(HOUR(t.shipped), HOUR(t.shipped), HOUR(z.`hour`)) shippingHour, + IF(MINUTE(t.shipped), MINUTE(t.shipped), MINUTE(z.`hour`)) shippingMinute , + IFNULL(MAX(i.itemPackingTypeFk),'H') itemPackingTypeFk , + count(*) items FROM vn.sale s JOIN vn.item i ON i.id = s.itemFk JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id @@ -72913,7 +72602,6 @@ BEGIN LEFT JOIN vn.parking p ON p.id = sg.parkingFk LEFT JOIN vn.`zone` z ON z.id = t.zoneFk WHERE sgd.saleGroupFk = vSaleGroupFk; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -73337,8 +73025,10 @@ proc: BEGIN -- Clientes Nuevos o Recuperados UPDATE tmp.productionBuffer pb LEFT JOIN bs.clientNewBorn cnb ON cnb.clientFk = pb.clientFk + JOIN vn.productionConfig pc SET pb.problem = TRIM(CAST(CONCAT('NUEVO ', pb.problem) AS CHAR(255))) - WHERE ISNULL(cnb.clientFk) OR cnb.isRookie ; + WHERE (ISNULL(cnb.clientFk) OR cnb.isRookie) + AND pc.rookieDays; -- Líneas y volumen por ticket UPDATE tmp.productionBuffer pb @@ -74463,104 +74153,57 @@ DELIMITER ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8mb4 */ ; /*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `reportLabelCollection_get`(vSelf INT) -BEGIN - +CREATE DEFINER=`root`@`localhost` PROCEDURE `reportLabelCollection_get`(vParam INT) +BEGIN /** - * Obtiene los datos necesarios de un ticket o colección + * Obtiene los datos de etiquetas a partir de de un ticket o colección. * - * @param vSelf Ticket/Colección del que sacar los datos - **/ - - DECLARE vItemPackingTypeFk VARCHAR(1); + * @param vParam Ticket/Colección del que sacar los datos + */ DECLARE vIsTicket BOOL; - -- Averiguamos si es un ticket o una colección SELECT IF(id, TRUE, FALSE) INTO vIsTicket - FROM vn.ticket + FROM ticket WHERE created > (CURRENT_DATE() - INTERVAL 1 MONTH) - AND id = vSelf; - - -- Si los sacadores NO son de V, pinta los colores - SELECT itemPackingTypeFk INTO vItemPackingTypeFk - FROM vn.collection - WHERE id = vSelf; - - 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, - COUNT(*) notes, - w.code workerCode, - tt.labelCount, - IF(HOUR(t.shipped), TIME(t.shipped), TIME(zo.`hour`)) horaagencia, - t.shipped, - COUNT(*) lineas, - t.nickName, - CONCAT(CAST(SUM(sv.volume) AS DECIMAL(5,2)) , "m³") m3 - FROM vn.ticket t - JOIN vn.ticketCollection tc ON tc.ticketFk = t.id - JOIN vn.collection c ON c.id = tc.collectionFk - JOIN vn.collectionColors cc ON cc.shelve = tc.`level` - AND cc.wagon = tc.wagon - AND cc.trainFk = c.trainFk - JOIN vn.sale s ON s.ticketFk = t.id - LEFT JOIN vn.saleVolume sv ON sv.saleFk = s.id - 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.zoneEstimatedDelivery ze ON ze.zoneFk = t.zoneFk - LEFT JOIN vn.agencyMode agm ON r.agencyModeFk =agm.id - LEFT JOIN vn.zone zo ON t.zoneFk = zo.id - WHERE IF(vIsTicket, tc.ticketFk = vSelf, tc.collectionFk = vSelf) - GROUP BY t.id - ORDER BY cc.code; - - 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, - CAST(IF(ic.code = 'plant', CONCAT(MAX(i.`size`),' cm'), COUNT(*)) AS CHAR) notes, - w.code workerCode, - tt.labelCount, - IF(HOUR(t.shipped), TIME(t.shipped), TIME(zo.`hour`)) horaagencia, - t.shipped, - COUNT(*) lineas, - t.nickName, - CONCAT(CAST(SUM(sv.volume) AS DECIMAL(5,2)), "m³") m3 - FROM vn.ticket t - JOIN vn.ticketCollection tc ON tc.ticketFk = t.id - JOIN vn.collection c ON c.id = tc.collectionFk - JOIN vn.sale s ON s.ticketFk = t.id - LEFT JOIN vn.saleVolume sv ON sv.saleFk = s.id - 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 - 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.zoneEstimatedDelivery ze ON ze.zoneFk = t.zoneFk - LEFT JOIN vn.agencyMode agm ON r.agencyModeFk =agm.id - LEFT JOIN vn.`zone` zo ON t.zoneFk = zo.id - WHERE IF(vIsTicket, tc.ticketFk = vSelf, tc.collectionFk = vSelf) - GROUP BY t.id; - - END IF; + AND id = vParam; + SELECT c.itemPackingTypeFk, + CONCAT(tc.collectionFk, ' ', LEFT(cc.code, 4)) color, + CONCAT(tc.collectionFk, ' ', SUBSTRING('ABCDEFGH',tc.wagon, 1), '-', tc.`level`) levelV, + tc.ticketFk, + LEFT(IF(t.routeFk IS NULL, am.name, zo.name ), 12) agencyDescription, + am.name, + t.clientFk, + CONCAT(CAST(SUM(sv.volume) AS DECIMAL(5, 2)), 'm³') m3 , + CAST(IF(ic.code = 'plant', CONCAT(MAX(i.`size`),' cm'), COUNT(*)) AS CHAR) size, + w.code workerCode, + tt.labelCount, + IF(HOUR(t.shipped), TIME(t.shipped), TIME(zo.`hour`)) agencyHour, + t.shipped, + COUNT(*) lineCount, + t.nickName + FROM ticket t + JOIN ticketCollection tc ON tc.ticketFk = t.id + JOIN collection c ON c.id = tc.collectionFk + JOIN collectionColors cc ON cc.shelve = tc.`level` + AND cc.wagon = tc.wagon + AND cc.trainFk = c.trainFk + JOIN sale s ON s.ticketFk = t.id + LEFT JOIN saleVolume sv ON sv.saleFk = s.id + JOIN item i ON i.id = s.itemFk + JOIN itemType it ON it.id = i.typeFk + JOIN itemCategory ic ON ic.id = it.categoryFk + JOIN worker w ON w.id = c.workerFk + JOIN agencyMode am ON am.id = t.agencyModeFk + LEFT JOIN ticketTrolley tt ON tt.ticket = t.id + LEFT JOIN `zone` zo ON t.zoneFk = zo.id + WHERE IF(vIsTicket, tc.ticketFk = vParam, tc.collectionFk = vParam) + GROUP BY t.id + ORDER BY cc.`code`; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -75365,18 +75008,17 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `saleGroup_add`() +CREATE DEFINER=`root`@`localhost` PROCEDURE `saleGroup_add`(vSectorFk INT) BEGIN - - /* - * Añade un nuevo registro a la tabla y devuelve su id - */ - - INSERT INTO vn.saleGroup(userFk) - VALUES (account.myUser_getId()); +/** + * Añade un nuevo registro a la tabla y devuelve su id. + * + * @param vSectorFk Identificador de vn.sector + */ + INSERT INTO vn.saleGroup(userFk, sectorFk) + VALUES (account.myUser_getId(), vSectorFk); SELECT LAST_INSERT_ID(); - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -76571,12 +76213,12 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_getFromTicketOrCollection`(vParam INT) BEGIN -/* - * Visualizar lineas de la tabla sale a través del parámetro vParam que puede ser ticket o collection +/** + * Visualizar lineas de la tabla sale a través del parámetro vParam que puede + * ser ticket o collection. * * @param vParam Identificador de ticket o collection */ - DECLARE vItemPackingTypeFk VARCHAR(1); DECLARE vIsCollection BOOL; @@ -76588,7 +76230,6 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticket2; IF vIsCollection THEN - CREATE TEMPORARY TABLE tmp.ticket (INDEX (id)) ENGINE = MEMORY @@ -76616,8 +76257,6 @@ BEGIN SELECT vParam id; END IF; - - SELECT s.ticketFk, sgd.saleGroupFk, s.id as saleFk, @@ -76652,7 +76291,8 @@ BEGIN sub2.originalQuantity as startQuantity, -- eliminar cuando tengamos la nueva apk IFNULL(c.workerFk,getUser()) as workerFk, IFNULL(SUM(iss.quantity),0) as pickedQuantity, - i.packingShelve + i.packingShelve, + MIN(iss.created) picked FROM tmp.ticket t JOIN sale s ON s.ticketFk = t.id JOIN ticket tt ON tt.id = t.id @@ -76678,10 +76318,9 @@ BEGIN LEFT JOIN parking p ON p.id = sg.parkingFk GROUP BY s.id; - - DROP TEMPORARY TABLE tmp.ticket; - DROP TEMPORARY TABLE tmp.ticket2; - + DROP TEMPORARY TABLE + tmp.ticket, + tmp.ticket2; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -76700,15 +76339,13 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_getProblems`(IN vIsTodayRelative tinyint(1)) BEGIN - /** - * Calcula los problemas de cada venta - * para un conjunto de tickets. - * - * @param vIsTodayRelative Indica si se calcula el disponible como si todo saliera hoy - * @table tmp.sale_getProblems(ticketFk, clientFk, warehouseFk, shipped) Identificadores de los tickets a calcular - * @return tmp.sale_problems - */ - +/** + * Calcula los problemas de cada venta para un conjunto de tickets. + * + * @param vIsTodayRelative Indica si se calcula el disponible como si todo saliera hoy + * @table tmp.sale_getProblems(ticketFk, clientFk, warehouseFk, shipped) Identificadores de los tickets a calcular + * @return tmp.sale_problems + */ DECLARE vWarehouseFk INT; DECLARE vDate DATE; DECLARE vAvailableCache INT; @@ -76724,6 +76361,13 @@ BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = 1; + DELETE tt.* + FROM tmp.sale_getProblems tt + JOIN vn.ticketObservation tto ON tto.ticketFk = tt.ticketFk + JOIN vn.observationType ot ON ot.id = tto.observationTypeFk + WHERE ot.code = 'administrative' + AND tto.description = 'Miriam'; + DROP TEMPORARY TABLE IF EXISTS tmp.sale_problems; CREATE TEMPORARY TABLE tmp.sale_problems ( ticketFk INT(11), @@ -76733,10 +76377,10 @@ BEGIN hasHighRisk TINYINT(1) DEFAULT 0, hasTicketRequest INTEGER(1) DEFAULT 0, isAvailable INTEGER(1) DEFAULT 1, - itemShortage VARCHAR(250), + itemShortage VARCHAR(255), isTaxDataChecked INTEGER(1) DEFAULT 1, - itemDelay VARCHAR(250), - itemLost VARCHAR(250), + itemDelay VARCHAR(255), + itemLost VARCHAR(255), hasComponentLack INTEGER(1), isTooLittle BOOL DEFAULT FALSE, PRIMARY KEY (ticketFk, saleFk) @@ -76755,20 +76399,23 @@ BEGIN -- Too Little INSERT INTO tmp.sale_problems(ticketFk, isTooLittle) - SELECT sub.ticketFk, TRUE - FROM (SELECT tl.ticketFk, SUM(sv.litros) litros, t.totalWithoutVat - FROM tmp.ticket_list tl - JOIN vn.saleVolume sv ON sv.ticketFk = tl.ticketFk - JOIN vn.ticket t ON t.id = tl.ticketFk - JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk AND zc.dated = CURDATE() - JOIN vn.agencyMode am ON am.id = t.agencyModeFk - JOIN vn.deliveryMethod dm ON dm.id = am.deliveryMethodFk - WHERE NOW() < TIMESTAMPADD(MINUTE,MINUTE(zc.`hour`) ,TIMESTAMPADD(HOUR,HOUR(zc.`hour`),CURDATE())) - AND dm.code IN('AGENCY','DELIVERY','PICKUP') - GROUP BY tl.ticketFk) sub + SELECT tp.ticketFk, TRUE + FROM tmp.sale_getProblems tp + JOIN vn.ticket t ON t.id = tp.ticketFk + JOIN (SELECT t.addressFk, SUM(sv.litros) litros, t.totalWithoutVat + FROM tmp.ticket_list tl + JOIN vn.saleVolume sv ON sv.ticketFk = tl.ticketFk + JOIN vn.ticket t ON t.id = tl.ticketFk + JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk AND zc.dated = CURDATE() + JOIN vn.agencyMode am ON am.id = t.agencyModeFk + JOIN vn.deliveryMethod dm ON dm.id = am.deliveryMethodFk + WHERE NOW() < TIMESTAMPADD(MINUTE,MINUTE(zc.`hour`) ,TIMESTAMPADD(HOUR,HOUR(zc.`hour`),CURDATE())) + AND dm.code IN('AGENCY','DELIVERY','PICKUP') + AND t.shipped BETWEEN CURDATE() AND util.midnight() + GROUP BY t.addressFk) sub ON sub.addressFk = t.addressFk JOIN vn.volumeConfig vc WHERE sub.litros < vc.minTicketVolume - AND sub.totalWithoutVat < vc.minTicketValue; + AND sub.totalWithoutVat < vc.minTicketValue; -- Faltan componentes INSERT INTO tmp.sale_problems(ticketFk, hasComponentLack, saleFk) @@ -76857,7 +76504,7 @@ BEGIN SELECT ticketFk, problem, saleFk FROM ( SELECT tl.ticketFk, - CONCAT('F: ',GROUP_CONCAT(i.id, ' ', i.longName, ' ')) problem, + LEFT(CONCAT('F: ',GROUP_CONCAT(i.id, ' ', i.longName, ' ')),250) problem, s.id AS saleFk FROM tmp.ticket_list tl JOIN vn.ticket t ON t.id = tl.ticketFk @@ -76885,7 +76532,7 @@ BEGIN INSERT INTO tmp.sale_problems(ticketFk, itemLost, saleFk) SELECT ticketFk, problem, saleFk FROM ( - SELECT tl.ticketFk, GROUP_CONCAT('I: ',i.id, ' ', i.longName, ' ') problem, s.id AS saleFk + SELECT tl.ticketFk, LEFT(GROUP_CONCAT('I: ',i.id, ' ', i.longName, ' '),250) problem, s.id AS saleFk FROM tmp.ticket_list tl JOIN vn.ticket t ON t.id = tl.ticketFk JOIN vn.sale s ON s.ticketFk = t.id @@ -76911,7 +76558,7 @@ BEGIN INSERT INTO tmp.sale_problems(ticketFk, itemDelay, saleFk) SELECT ticketFk, problem, saleFk FROM ( - SELECT tl.ticketFk, GROUP_CONCAT('R: ',i.id, ' ', i.longName, ' ') problem, s.id AS saleFk + SELECT tl.ticketFk, LEFT(GROUP_CONCAT('R: ',i.id, ' ', i.longName, ' '),250) problem, s.id AS saleFk FROM tmp.ticket_list tl JOIN vn.ticket t ON t.id = tl.ticketFk JOIN vn.sale s ON s.ticketFk = t.id @@ -76948,7 +76595,6 @@ BEGIN DROP TEMPORARY TABLE tmp.clientGetDebt, tmp.ticket_list; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -77658,23 +77304,22 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `sectorCollection_new`(vSectorFk INT) BEGIN - /** - * Inserta una nueva colección, si el usuario no tiene ninguna vacia. - * Esto se hace para evitar que por error se generen colecciones sin sentido. - * - * @param vSectorFk Identificador de vn.sector - */ - - DECLARE hasEmptyCollections BOOLEAN; +/** + * Inserta una nueva colección, si el usuario no tiene ninguna vacia. + * Esto se hace para evitar que por error se generen colecciones sin sentido. + * + * @param vSectorFk Identificador de vn.sector + */ + DECLARE hasEmptyCollections BOOL; DECLARE vUserFk INT; SET vUserFk = account.myUser_getId(); @@ -77684,14 +77329,13 @@ BEGIN LEFT JOIN vn.sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id WHERE ISNULL(scsg.id) AND sc.userFk = vUserFk - AND sc.sectorFk = vSectorFk; + AND sc.sectorFk = vSectorFk + AND sc.created >= CURDATE(); IF NOT hasEmptyCollections THEN - INSERT INTO vn.sectorCollection(userFk, sectorFk) VALUES(vUserFk, vSectorFk); END IF; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -78764,105 +78408,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `stockBuyed` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `stockBuyed`(vDate DATE) -BEGIN - DECLARE vVolume DECIMAL(10,2); - DECLARE vWarehouse INT DEFAULT 7; - DECLARE vRuben INT; - DECLARE vClaudi INT; - DECLARE vJose INT; - - SELECT w.id INTO vRuben - FROM vn.worker w - WHERE w.code = 'RET'; - - SELECT w.id INTO vClaudi - FROM vn.worker w - WHERE w.code = 'CSR'; - - SELECT w.id INTO vJose - FROM vn.worker w - WHERE w.code = 'ATJ'; - - CALL stockTraslation(vDate); - - -- SELECT Volumen INTO vVolume FROM vn2008.Cubos WHERE Id_Cubo = 'cc' LIMIT 1; - - INSERT INTO stockBuyed(user, buyed, `date`) - SELECT tr.user_id, SUM(( amount / c.packing ) * vn.buy_getVolume(Id_Compra)) / vc.palletM3 / 1000000 buyed, vDate - FROM tmp_item i - JOIN vn2008.Articles a ON a.Id_Article = i.item_id - JOIN vn2008.Tipos t ON a.tipo_id = t.tipo_id - JOIN vn2008.reinos r ON r.id = t.reino_id - JOIN vn2008.Trabajadores tr ON tr.Id_Trabajador = t.Id_Trabajador - JOIN tmp.buyUltimate bu ON bu.itemFk = Id_Article AND bu.warehouseFk = vWarehouse - JOIN vn2008.Compres c ON c.Id_compra = bu.buyFk - JOIN vn.volumeConfig vc - WHERE r.display <> 0 - GROUP BY tr.Id_Trabajador - ON DUPLICATE KEY UPDATE buyed = VALUES(buyed); - - INSERT INTO stockBuyed(USER, buyed, `date`) - SELECT vRuben, @amount := SUM(ic.cm3 * io.amount / vc.palletM3 / 1000000), vDate - FROM vn2008.item_out io - JOIN vn.itemCost ic ON ic.itemFk = io.item_id AND ic.warehouseFk = vWarehouse - JOIN vn.ticket t ON t.id = io.ticketFk - JOIN vn.address a ON a.id = t.addressFk - JOIN vn.province p ON p.id = a.provinceFk - JOIN vn.country c ON c.id = p.countryFk - JOIN vn.volumeConfig vc - WHERE dat = vDate - AND warehouse_id = vWarehouse - AND c.country = 'Francia' - ON DUPLICATE KEY UPDATE buyed = buyed + @amount; - - INSERT INTO stockBuyed(USER, buyed, `date`) - SELECT vJose, @amount := SUM(ic.cm3 * io.amount / vc.palletM3 / 1000000), vDate - FROM vn2008.item_out io - JOIN vn.itemCost ic ON ic.itemFk = io.item_id AND ic.warehouseFk = vWarehouse - JOIN vn.ticket t ON t.id = io.ticketFk - JOIN vn.address a ON a.id = t.addressFk - JOIN vn.province p ON p.id = a.provinceFk - JOIN vn.country c ON c.id = p.countryFk - JOIN vn.volumeConfig vc - WHERE dat = vDate - AND warehouse_id = vWarehouse - AND c.country = 'Holanda' - ON DUPLICATE KEY UPDATE buyed = buyed + @amount; - - INSERT INTO stockBuyed(USER, buyed, `date`) - SELECT vClaudi, @amount := SUM(ic.cm3 * io.amount / vc.palletM3 / 1000000), vDate - FROM vn2008.item_out io - JOIN vn.itemCost ic ON ic.itemFk = io.item_id AND ic.warehouseFk = vWarehouse - JOIN vn.ticket t ON t.id = io.ticketFk - JOIN vn.address a ON a.id = t.addressFk - JOIN vn.province p ON p.id = a.provinceFk - JOIN vn.country c ON c.id = p.countryFk - JOIN vn.volumeConfig vc - WHERE dat BETWEEN vDate AND util.dayend(vDate) - AND warehouse_id = vWarehouse - AND c.country NOT IN ('Francia','Holanda') - ON DUPLICATE KEY UPDATE buyed = buyed + @amount; - - DROP TEMPORARY TABLE - tmp.buyUltimate, - tmp_item; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `stockBuyedByWorker` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -78936,6 +78481,69 @@ 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 `stockBuyed_add` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `stockBuyed_add`(vDated DATE) +BEGIN +/** + * Inserta el volumen de compra por comprador en vn.stockBuyed de acuerdo con la fecha + * + * @param vDated Fecha de compra + */ + CALL vn.stockTraslation(vDated); + + DELETE + FROM vn.stockBuyed + WHERE `date` = vDated; + + INSERT INTO vn.stockBuyed(`user`, buyed, `date`, description) + SELECT it.workerFk, + SUM(( ti.amount / b.packing ) * vn.buy_getVolume(b.id)) / vc.palletM3 / 1000000 buyed, + vDated, + u.name + FROM tmp_item ti + JOIN vn.item i ON i.id = ti.item_id + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk + JOIN vn.warehouse wh ON wh.code = 'VNH' + JOIN tmp.buyUltimate bu ON bu.itemFk = i.id AND bu.warehouseFk = wh.id + JOIN vn.buy b ON b.id = bu.buyFk + JOIN vn.volumeConfig vc + JOIN account.`user` u ON u.id = it.workerFk + WHERE ic.display != 0 + GROUP BY it.workerFk; + + INSERT INTO stockBuyed(buyed, `date`, description) + SELECT SUM(ic.cm3 * ito.quantity / vc.palletM3 / 1000000), vDated, IF(c.country = 'España',p.name,c.country) destiny + FROM vn.itemTicketOut ito + JOIN vn.ticket t ON t.id = ito.ticketFk + JOIN vn.address a ON a.id = t.addressFk + JOIN vn.province p ON p.id = a.provinceFk + JOIN vn.country c ON c.id = p.countryFk + JOIN vn.warehouse wh ON wh.id = t.warehouseFk + JOIN vn.itemCost ic ON ic.itemFk = ito.itemFk AND ic.warehouseFk = t.warehouseFk + JOIN vn.volumeConfig vc + WHERE ito.shipped BETWEEN vDated AND util.dayend(vDated) + AND wh.code = 'VNH' + GROUP BY destiny; + + DROP TEMPORARY TABLE + tmp.buyUltimate, + tmp_item; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `stockTraslation` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -80801,11 +80409,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_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCreateWithUser`( vClientId INT @@ -80819,191 +80427,19 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCreateWithUser`( ,vUserId INT ,OUT vNewTicket INT) BEGIN --- si se modifica algo avisad a jgallego - DECLARE vZoneFk INT; - DECLARE vPrice DECIMAL(10,2); - DECLARE vBonus DECIMAL(10,2); - - IF vClientId IS NULL THEN - CALL util.throw ('CLIENT_NOT_ESPECIFIED'); - END IF; - - IF NOT vAddressFk OR vAddressFk IS NULL THEN - SELECT id INTO vAddressFk - FROM address - WHERE clientFk = vClientId AND isDefaultAddress; - END IF; - - IF vAgencyModeFk IS NOT NULL THEN - - CALL vn.zone_getShipped (vlanded, vAddressFk, vAgencyModeFk, TRUE); - - SELECT zoneFk, price, bonus INTO vZoneFk, vPrice, vBonus - FROM tmp.zoneGetShipped - WHERE shipped = vShipped AND warehouseFk = vWarehouseFk LIMIT 1; - - IF vZoneFk IS NULL OR vZoneFk = 0 THEN - CALL util.throw ('NOT_ZONE_WITH_THIS_PARAMETERS'); - END IF; - END IF; - INSERT INTO ticket ( - clientFk, - shipped, - addressFk, - agencyModeFk, - nickname, - warehouseFk, - routeFk, - companyFk, - landed, - zoneFk, - zonePrice, - zoneBonus - ) - SELECT - vClientId, - vShipped, - a.id, - vAgencyModeFk, - a.nickname, - vWarehouseFk, - IF(vRouteFk,vRouteFk,NULL), - vCompanyFk, - vlanded, - vZoneFk, - vPrice, - vBonus - FROM address a - JOIN agencyMode am ON am.id = a.agencyModeFk - WHERE a.id = vAddressFk; - - SET vNewTicket = LAST_INSERT_ID(); - - INSERT INTO ticketObservation(ticketFk, observationTypeFk, description) - SELECT vNewTicket, ao.observationTypeFk, ao.description - FROM addressObservation ao - JOIN address a ON a.id = ao.addressFk - WHERE a.id = vAddressFk; - - IF (SELECT COUNT(*) FROM bs.clientNewBorn cnb - WHERE cnb.clientFk = vClientId - AND NOT cnb.isRookie) = 0 THEN - - CALL vn.ticketObservation_addNewBorn(vNewTicket); - END IF; - - INSERT INTO vn.ticketLog - SET originFk = vNewTicket, userFk = vUserId, `action` = 'insert', description = CONCAT('Ha creado el ticket:', ' ', vNewTicket); - - IF (SELECT ct.isCreatedAsServed FROM vn.clientType ct JOIN vn.client c ON c.typeFk = ct.code WHERE c.id = vClientId ) <> FALSE THEN - INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) - SELECT id, vNewTicket, account.myUser_getId() - FROM state - WHERE `code` = 'DELIVERED'; - END IF; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `ticketCreateWithUser__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCreateWithUser__`( - vClientId INT - ,vShipped DATE - ,vWarehouseFk INT - ,vCompanyFk INT - ,vAddressFk INT - ,vAgencyModeFk INT - ,vRouteFk INT - ,vlanded DATE - ,vUserId INT - ,OUT vNewTicket INT) -BEGIN - - DECLARE vZoneFk INT; - DECLARE vPrice DECIMAL(10,2); - DECLARE vBonus DECIMAL(10,2); - - IF vClientId IS NULL THEN - CALL util.throw ('CLIENT_NOT_ESPECIFIED'); - END IF; - - IF NOT vAddressFk OR vAddressFk IS NULL THEN - SELECT id INTO vAddressFk - FROM address - WHERE clientFk = vClientId AND isDefaultAddress; - END IF; - - IF vAgencyModeFk IS NOT NULL THEN - - CALL vn.zone_getShippedWarehouse(vlanded, vAddressFk, vAgencyModeFk); - - SELECT zoneFk, price, bonus INTO vZoneFk, vPrice, vBonus - FROM tmp.zoneGetShipped - WHERE shipped = vShipped AND warehouseFk = vWarehouseFk LIMIT 1; - - IF vZoneFk IS NULL OR vZoneFk = 0 THEN - CALL util.throw ('NOT_ZONE_WITH_THIS_PARAMETERS'); - END IF; - END IF; - INSERT INTO ticket ( - clientFk, - shipped, - addressFk, - agencyModeFk, - nickname, - warehouseFk, - routeFk, - companyFk, - landed, - zoneFk, - zonePrice, - zoneBonus - ) - SELECT - vClientId, - vShipped, - a.id, - vAgencyModeFk, - a.nickname, - vWarehouseFk, - IF(vRouteFk,vRouteFk,NULL), - vCompanyFk, - vlanded, - vZoneFk, - vPrice, - vBonus - FROM address a - JOIN agencyMode am ON am.id = a.agencyModeFk - WHERE a.id = vAddressFk; - - SET vNewTicket = LAST_INSERT_ID(); - - INSERT INTO ticketObservation(ticketFk, observationTypeFk, description) - SELECT vNewTicket, ao.observationTypeFk, ao.description - FROM addressObservation ao - JOIN address a ON a.id = ao.addressFk - WHERE a.id = vAddressFk; - - INSERT INTO vn.ticketLog - SET originFk = vNewTicket, userFk = vUserId, `action` = 'insert', description = CONCAT('Ha creado el ticket:', ' ', vNewTicket); - - IF (SELECT ct.isCreatedAsServed FROM vn.clientType ct JOIN vn.client c ON c.typeFk = ct.code WHERE c.id = vClientId ) <> FALSE THEN - INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) - SELECT id, vNewTicket, getWorker() - FROM state - WHERE `code` = 'DELIVERED'; - END IF; + CALL ticket_add( + vClientId, + vShipped, + vWarehouseFk, + vCompanyFk, + vAddressFk, + vAgencyModeFk, + vRouteFk, + vlanded, + vUserId, + TRUE, + vNewTicket + ); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -81806,11 +81242,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_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketPackagingRecovery__`() BEGIN @@ -81841,8 +81277,17 @@ BEGIN WHILE NOT done DO - CALL vn.ticketCreate(vClientFk,vShipped,vWarehouseFk,vCompanyFk, NULL, NULL, NULL, - vShipped,vTicketNewFk); + CALL vn.ticket_add(vClientFk, + vShipped, + vWarehouseFk, + vCompanyFk, + NULL, + NULL, + NULL, + vShipped, + account.userGetId(), + TRUE, + vTicketNewFk); UPDATE vn.ticketPackaging set ticketFk = vTicketNewFk WHERE ticketFk = vTicketFk; @@ -82805,6 +82250,99 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_canAdvance` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_canAdvance`(vDated DATE, vWarehouseFk INT) +BEGIN +/** + * Devuelve los tickets y la cantidad de lineas de venta que se pueden adelantar. + * + * @param vDated Fecha de los tickets que se quieren adelantar. + * @param vWarehouseFk Almacén + */ + DECLARE vDateInventory DATE; + DECLARE vDateToAdvance DATE; + + SELECT inventoried INTO vDateInventory FROM vn.config; + + SET vDateToAdvance = TIMESTAMPADD(DAY,-1,vDated); + + DROP TEMPORARY TABLE IF EXISTS tmp.stock; + CREATE TEMPORARY TABLE tmp.stock + (itemFk INT PRIMARY KEY, + amount INT) + ENGINE = MEMORY; + + INSERT INTO tmp.stock(itemFk, amount) + SELECT itemFk, SUM(quantity) amount FROM + ( + SELECT itemFk, quantity + FROM vn.itemTicketOut + WHERE shipped >= vDateInventory + AND shipped < vDated + AND warehouseFk = vWarehouseFk + UNION ALL + SELECT itemFk, quantity + FROM vn.itemEntryIn + WHERE landed >= vDateInventory + AND landed < vDated + AND isVirtualStock = FALSE + AND warehouseInFk = vWarehouseFk + UNION ALL + SELECT itemFk, quantity + FROM vn.itemEntryOut + WHERE shipped >= vDateInventory + AND shipped < vDated + AND warehouseOutFk = vWarehouseFk + ) t + GROUP BY itemFk HAVING amount != 0; + + SELECT s.ticketFk ticketFuture, + sum((s.quantity <= IFNULL(st.amount,0))) hasStock, + count(DISTINCT s.id) saleCount, + st.name tfState, + GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) tfIpt, + t2.ticketFk, + t2.state, + t2.ipt + FROM vn.ticket t + JOIN vn.ticketState ts ON ts.ticketFk = t.id + JOIN vn.state st ON st.id = ts.stateFk + LEFT JOIN (SELECT + t2.id ticketFk, + t2.addressFk, + st.name state, + GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt + FROM vn.ticket t2 + JOIN vn.sale s ON s.ticketFk = t2.id + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.ticketState ts ON ts.ticketFk = t2.id + JOIN vn.state st ON st.id = ts.stateFk + WHERE t2.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance) + AND t2.warehouseFk = vWarehouseFk + GROUP BY t2.id) t2 ON t2.addressFk = t.addressFk + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk + LEFT JOIN tmp.stock st ON st.itemFk = s.itemFk + WHERE t.shipped BETWEEN vDated AND util.dayend(vDated) + AND t.warehouseFk = vWarehouseFk + GROUP BY t.id; + + DROP TEMPORARY TABLE tmp.stock; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_canMerge` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -82817,36 +82355,52 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_canMerge`(vDated DATE, vScopeDays INT, vLitersMax INT, vLinesMax INT, vWarehouseFk INT) BEGIN - - /* Devuelve un listado de tickets susceptibles de fusionarse con otros tickets en el futuro - * - * @param vDated Fecha en cuestión - * @param vScopeDays Dias en el futuro a sondear - * @param vLitersMax Volumen máximo de los tickets a catapultar - * @param vLinesMax Número máximo de lineas de los tickets a catapultar - * @param vWarehouseFk Identificador de vn.warehouse - */ - +/** + * Devuelve un listado de tickets susceptibles de fusionarse con otros tickets en el futuro + * + * @param vDated Fecha en cuestión + * @param vScopeDays Dias en el futuro a sondear + * @param vLitersMax Volumen máximo de los tickets a catapultar + * @param vLinesMax Número máximo de lineas de los tickets a catapultar + * @param vWarehouseFk Identificador de vn.warehouse + */ SELECT sv.ticketFk , + GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt, CAST(sum(litros) AS DECIMAL(10,0)) liters, CAST(count(*) AS DECIMAL(10,0)) `lines`, + st.name state, sub2.id ticketFuture, - sub2.shipped + sub2.shipped, + sub2.iptd tfIpt, + sub2.state tfState FROM vn.saleVolume sv + JOIN vn.sale s ON s.id = sv.saleFk + JOIN vn.item i ON i.id = s.itemFk JOIN vn.ticket t ON t.id = sv.ticketFk JOIN vn.address a ON a.id = t.addressFk JOIN vn.province p ON p.id = a.provinceFk JOIN vn.country c ON c.id = p.countryFk JOIN vn.ticketState ts ON ts.ticketFk = t.id + JOIN vn.state st ON st.id = ts.stateFk JOIN vn.alertLevel al ON al.id = ts.alertLevel LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id LEFT JOIN ( SELECT * FROM ( - SELECT t.addressFk , t.id, t.shipped + SELECT + t.addressFk , + t.id, + t.shipped, + st.name state, + GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) iptd FROM vn.ticket t + JOIN vn.ticketState ts ON ts.ticketFk = t.id + JOIN vn.state st ON st.id = ts.stateFk + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk WHERE t.shipped BETWEEN TIMESTAMPADD(DAY, vScopeDays,vDated) AND util.dayend(TIMESTAMPADD(DAY, vScopeDays,vDated)) AND t.warehouseFk = vWarehouseFk + GROUP BY t.id ) sub GROUP BY sub.addressFk ) sub2 ON sub2.addressFk = t.addressFk AND t.id != sub2.id @@ -83301,13 +82855,12 @@ BEGIN JOIN vn.sale saleClon ON saleOriginal.itemFk = saleClon.itemFk AND saleOriginal.quantity = saleClon.quantity WHERE saleOriginal.ticketFk = vTicketFk AND saleClon.ticketFk = vNewTicket; - INSERT INTO ticketRequest (description,ordered,shipped,salesPersonCode,buyerCode,quantity,price,itemFk,clientFk,response, - total,buyed,saleFk) - SELECT o.description,o.ordered,vShipment,o.salesPersonCode,o.buyerCode,o.quantity,o.price,o.itemFk,o.clientFk,o.response, - o.total,o.buyed,s2.id - FROM sale s JOIN ticketRequest o ON o.saleFk = s.id - JOIN sale s2 ON s.concept = s2.concept AND s.quantity = s2.quantity AND s.itemFk = s2.itemFk - WHERE s.ticketFk = vTicketFk AND s2.ticketFk = vNewTicket; + INSERT INTO ticketRequest (description,ordered,shipped,quantity,price,itemFk,clientFk,response, + total,buyed,requesterFk,attenderFk,ticketFk) + SELECT description,ordered,shipped,quantity,price,itemFk,clientFk,response, + total,buyed,requesterFk,attenderFk,vNewTicket + FROM ticketRequest + WHERE ticketFk =vTicketFk; INSERT INTO ticketObservation(ticketFk,observationTypeFk,description) VALUES(vNewTicket,4,CONCAT('turno desde ticket: ',vTicketFk)) ON DUPLICATE KEY UPDATE description = CONCAT(ticketObservation.description,VALUES(description),' '); @@ -84174,6 +83727,7 @@ proc: BEGIN DECLARE vDone BOOL; DECLARE vTicketFk INT; + DECLARE vError INT; DECLARE cCur CURSOR FOR SELECT ticketFk FROM ticketRecalc; @@ -84185,6 +83739,17 @@ proc: BEGIN BEGIN DO RELEASE_LOCK('vn.ticket_doRecalc'); ROLLBACK; + GET DIAGNOSTICS CONDITION 2 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT; + SET vError = IFNULL(@errno, 0) ; + IF NOT(vError = 1105 OR vError = 1751) THEN + CALL `vn`.`mail_insert`('cau@verdnatura.es', + NULL, + 'Problema al recalcular el total de ticket', + CONCAT('Se ha detectado un problema en ticket_doRecalc al calcular el total del ticket : ', + vTicketFk,' el error es el: ', + CONCAT('ERROR ', IFNULL(@errno, 0), ': ', ifnull(@text, ''))) + ); + END IF; RESIGNAL; END; @@ -84452,9 +84017,9 @@ DELIMITER ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8mb4 */ ; /*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getMovable`(vTicketFk INT, vDatedNew DATETIME, vWarehouseFk INT) BEGIN @@ -84495,7 +84060,8 @@ BEGIN WHERE t.id = vTicketFk; DROP TEMPORARY TABLE IF EXISTS tmp.itemList; - DROP TEMPORARY TABLE IF EXISTS tmp.itemMinacum; + DROP TEMPORARY TABLE IF EXISTS tmp.itemMinacum; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -84646,6 +84212,156 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_getSplitList` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getSplitList`(vDated DATE, vHour TIME, vWarehouseFk INT) +BEGIN +/** + * Devuelve un listado con los tickets posibles para splitar HOY. + * + * @param vDated Fecha a estudiar + * @param vHour Hora a partir de la cual todavía se puede enviar, si la fecha es la de hoy + * @param vWarehouseFk Almacén + */ + DECLARE vAvailableCache INT; + DECLARE vVisibleCache INT; + + CALL cache.available_refresh(vAvailableCache, FALSE, vWarehouseFk, CURDATE()); + CALL cache.visible_refresh(vVisibleCache, FALSE, vWarehouseFk); + CALL `vn`.`zoneClosure_recalc`(); + + DROP TEMPORARY TABLE IF EXISTS tmp.salesToSplit; + + CREATE TEMPORARY TABLE tmp.salesToSplit + (saleFk INT PRIMARY KEY, + ticketFk INT, + problem VARCHAR(1)) ENGINE = MEMORY; + + INSERT INTO tmp.salesToSplit(saleFk, ticketFk, problem) + SELECT s.id, s.ticketFk, 'F' + FROM vn.ticket t + 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 + JOIN vn.itemCategory ic ON ic.id = it.categoryFk + LEFT JOIN cache.visible v ON v.item_id = i.id AND v.calc_id = vVisibleCache + LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache + LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk + WHERE IFNULL(v.visible,0) < s.quantity + AND IFNULL(av.available ,0) < s.quantity + AND IFNULL(issw.visible, 0) < s.quantity + AND s.isPicked = FALSE + AND s.reserved = FALSE + AND ic.merchandise = TRUE + AND t.shipped BETWEEN CURDATE() AND util.dayend(CURDATE()) + AND NOT i.generic + AND t.warehouseFk = vWarehouseFk; + + INSERT IGNORE INTO tmp.salesToSplit(saleFk, ticketFk, problem) + SELECT s.id, s.ticketFk, 'I' + FROM vn.ticket t + 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 + JOIN vn.itemCategory ic ON ic.id = it.categoryFk + LEFT JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vVisibleCache + LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk + WHERE IFNULL(v.visible,0) >= s.quantity + AND IFNULL(issw.visible, 0) < s.quantity + AND s.quantity > 0 + AND s.isPicked = FALSE + AND s.reserved = FALSE + AND ic.merchandise = TRUE + AND t.shipped BETWEEN CURDATE() AND util.dayend(CURDATE()) + AND NOT i.generic + AND t.warehouseFk = vWarehouseFk; + + INSERT IGNORE INTO tmp.salesToSplit(saleFk, ticketFk, problem) + SELECT s.id, s.ticketFk, 'R' + FROM vn.ticket t + 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 + JOIN vn.itemCategory ic ON ic.id = it.categoryFk + LEFT JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vVisibleCache + LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache + LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk + WHERE IFNULL(v.visible,0) < s.quantity + AND IFNULL(av.available ,0) >= s.quantity + AND IFNULL(issw.visible, 0) < s.quantity + AND s.quantity > 0 + AND s.isPicked = FALSE + AND s.reserved = FALSE + AND ic.merchandise = TRUE + AND t.shipped BETWEEN CURDATE() AND util.dayend(CURDATE()) + AND NOT i.generic + AND t.warehouseFk = vWarehouseFk; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketsToSplit; + + CREATE TEMPORARY TABLE tmp.ticketsToSplit + (ticketFk INT PRIMARY KEY, + problems VARCHAR(100), + addressFk INT, + ipt VARCHAR(10), + etd TIME) ENGINE = MEMORY; + + INSERT INTO tmp.ticketsToSplit + SELECT + ss.ticketFk, + GROUP_CONCAT(DISTINCT ss.problem ORDER BY ss.problem) problems, + t.addressFk, + GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt, + zc.`hour` etd + FROM tmp.salesToSplit ss + JOIN vn.ticket t ON t.id = ss.ticketFk + JOIN vn.sale s ON s.id = ss.saleFk + JOIN vn.item i ON i.id = s.itemFk + LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk + GROUP BY ss.ticketFk; + + SELECT + ts.*, + t.id ticketFuture, + st.name state, + zc.`hour` tfEtd, + GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) tfIpt, + st2.name tfState + FROM tmp.ticketsToSplit ts + LEFT JOIN vn.ticketState ts2 ON ts2.ticketFk = ts.ticketFk + LEFT JOIN vn.state st ON st.id = ts2.stateFk + LEFT JOIN vn.ticket t + ON t.id != ts.ticketFk + AND t.addressFk = ts.addressFk + AND t.shipped BETWEEN vDated AND util.dayend(vDated) + LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk AND zc.dated = vDated + LEFT JOIN vn.sale s ON s.ticketFk = t.id + LEFT JOIN vn.item i ON i.id = s.itemFk + LEFT JOIN vn.ticketState tst ON tst.ticketFk = t.id + LEFT JOIN vn.state st2 ON st2.id = tst.stateFk + WHERE (t.id IS NULL + OR (vDated > CURDATE()) + OR (vDated = CURDATE() AND vHour >= zc.`hour`)) + AND ts.etd <= vHour + GROUP BY ts.ticketFk, t.id + ORDER BY ts.etd, ts.ticketFk; + + DROP TEMPORARY TABLE + tmp.ticketsToSplit; +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_getTax` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -85503,6 +85219,96 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_split` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_split`(vTicketFk INT, vTicketFutureFk INT, vDated DATE) +proc:BEGIN +/** + * Mueve las lineas con problemas a otro ticket existente o a uno nuevo. + * + * @param vTicketFk Identificador del ticket a splittar + * @param vTicketFutureFk Identificador del ticket al que se quieren mover las lineas + * @param vDate Fecha a la que se va a mover + * @table tmp.salesToSplit(saleFk, ticketFk, problem) + */ + DECLARE vHasFullProblem BOOL; + DECLARE vProblemLines INT; + DECLARE vTotalLines INT; + + SELECT COUNT(*) INTO vProblemLines + FROM tmp.salesToSplit + WHERE ticketFk = vTicketFk; + + SELECT count(*) INTO vTotalLines + FROM vn.sale s + WHERE s.ticketFk = vTicketFk; + + SET vHasFullProblem = (vTotalLines = vProblemLines); + + -- Ticket completo + IF vHasFullProblem THEN + + UPDATE vn.ticket + SET landed = vDated + 1, + shipped = vDated, + nickname = CONCAT('(',DAY(curdate()),') ', nickname ) + WHERE id = vTicketFk; + + SELECT CONCAT("Se ha cambiado el ticket ", vTicketFk, " al dia ", vDated); + LEAVE proc; + + END IF; + + -- Ticket a futuro existe + IF vTicketFutureFk THEN + + UPDATE vn.sale s + JOIN tmp.salesToSplit ss ON s.id = ss.saleFk + SET s.ticketFk = vTicketFutureFk, + s.concept = CONCAT('(s) ', s.concept) + WHERE ss.ticketFk = vTicketFk; + + SELECT CONCAT("Se han movido lineas del ticket ", vTicketFk, + " al ticket existente ", vTicketFutureFk,"(", vDated,")"); + LEAVE proc; + + END IF; + + -- Ticket nuevo + CALL vn.ticket_Clone(vTicketFk, vTicketFutureFk); + + UPDATE vn.ticket t + JOIN vn.productionConfig pc + SET t.landed = vDated + 1, + t.shipped = vDated, + t.agencyModeFk = pc.defautlAgencyMode, + t.zoneFk = pc.defaultZone + WHERE t.id = vTicketFutureFk; + + UPDATE vn.sale s + JOIN tmp.salesToSplit sts ON sts.saleFk = s.id + SET s.ticketFk = vTicketFutureFk, + s.concept = CONCAT('(s) ', s.concept) + WHERE sts.ticketFk = vTicketFk; + + CALL vn.ticketStateUpdate(vTicketFutureFk, 'FIXING'); + + SELECT CONCAT("Se han movido lineas del ticket ", vTicketFk, + " al nuevo ticket ", vTicketFutureFk,"(", vDated,")"); +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 */ ; @@ -90992,29 +90798,19 @@ DELIMITER ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8mb4 */ ; /*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_sendMailByDepartment`(IN vWeek int, IN vYear int, IN vWorkerFk int) +CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_sendMailByDepartment`(IN vDatedFrom DATETIME, IN vDatedTo DATETIME, IN vWorkerFk INT) BEGIN - - /** - * Inserta el registro de horario semanalmente de PRODUCCION, CAMARA, REPARTO, TALLER NATURAL y TALLER ARTIFICIAL en vn.mail. - * - * @param vWeek - * @param vYear - * @param vWorkerFk -> En el caso de querer generarlo para todos los empleados deberá de informarse como NULL - */ - - DECLARE vDateStart DATETIME; - DECLARE vDateEnd DATETIME; - - SELECT CONCAT (MIN(dated), ' 00:00:00'), CONCAT (MAX(dated), ' 23:59:59') INTO vDateStart, vDateEnd - FROM time - WHERE year = vYear AND - week = vWeek; - +/** + * Inserta el registro de horario semanalmente de PRODUCCION, CAMARA, REPARTO, TALLER NATURAL y TALLER ARTIFICIAL en vn.mail. + * + * @param vDatedFrom + * @param vDatedTo + * @param vWorkerFk -> En el caso de querer generarlo para todos los empleados deberá de pasarse = NULL + */ SET session group_concat_max_len = 15000; DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate; @@ -91022,15 +90818,15 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.reportHours; IF vWorkerFk IS NULL THEN - CALL timeControl_calculateAll(vDateStart,vDateEnd); - CALL timeBusiness_calculateAll(vDateStart,vDateEnd); + CALL timeControl_calculateAll(vDatedFrom,vDatedTo); + CALL timeBusiness_calculateAll(vDatedFrom,vDatedTo); ELSE - CALL timeControl_calculateByUser(vWorkerFk,vDateStart,vDateEnd); - CALL timeBusiness_calculateByUser(vWorkerFk,vDateStart,vDateEnd); + CALL timeControl_calculateByUser(vWorkerFk,vDatedFrom,vDatedTo); + CALL timeBusiness_calculateByUser(vWorkerFk,vDatedFrom,vDatedTo); END IF; CREATE TEMPORARY TABLE tmp.reportHours - SELECT t.dated, + SELECT t.dated, IF (tm.hoursWeek IS NULL,'', GROUP_CONCAT(DATE_FORMAT(wtc.timed,'%H:%i') ORDER BY wtc.timed ASC SEPARATOR ' ') ) timeWorkDay, SEC_TO_TIME(IFNULL(tm.timeWorkSeconds, 0)) tm, SEC_TO_TIME(IFNULL(tc.timeWorkSeconds, 0)) tc, @@ -91059,12 +90855,11 @@ BEGIN LEFT JOIN client c ON c.id = w.id WHERE wc.name NOT IN ('VNH') AND d.hasToSendMail - AND (wl.ended >= CURDATE() OR wl.ended IS NULL) GROUP BY tm.userFk,t.dated ORDER BY tm.userFk,t.dated; INSERT INTO vn.mail (receiver, replyTo, subject, body) - SELECT eu.email, 'laboral@verdnatura.es', CONCAT('Registro de horas semana ', vWeek, ' año ', vYear) , + SELECT eu.email, 'laboral@verdnatura.es', CONCAT('Registro de horas semana ', WEEK(vDatedFrom), ' año ', YEAR(vDatedFrom)) , CONCAT(' @@ -91150,16 +90945,12 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_sendMailByDepartmentLauncher`() BEGIN - DECLARE vWeek,vYear INT; + DECLARE vDatedFrom, vDatedTo DATETIME; IF (DAYNAME(CURDATE()) = 'miércoles') THEN - SELECT week,year INTO vWeek,vYear - FROM vn.time - WHERE dated IN (DATE_ADD(CURDATE(), INTERVAL -10 DAY), DATE_ADD(CURDATE(), INTERVAL -4 DAY)) - GROUP BY year,week - LIMIT 1; - - CALL vn.workerTimeControl_sendMailByDepartment(vWeek, vYear, NULL); + SELECT DATE_SUB(CURDATE(), INTERVAL 9 DAY), CONCAT(DATE_SUB(CURDATE(), INTERVAL 3 DAY), ' 23:59:59') INTO vDatedFrom, vDatedTo; + + CALL vn.workerTimeControl_sendMailByDepartment(vDatedFrom, vDatedTo, NULL); END IF; END ;; DELIMITER ; @@ -93088,37 +92879,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `zonePromo_Make__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `zonePromo_Make__`() -BEGIN - - INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price) - SELECT t.id , 98, - packages, '-- DIA DE COMPRA BONIFICADO --', zp.amount - FROM vn.ticket t - JOIN vn.zonePromo zp ON zp.zoneFk = t.zoneFk AND zp.dated = DATE(t.shipped) - WHERE zp.isDone = FALSE - AND zp.dated < CURDATE() - AND t.refFk IS NULL; - - UPDATE vn.zonePromo - SET isDone = TRUE - WHERE dated < 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 `zone_doCalcInitialize` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -93290,6 +93050,53 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `zone_getClosed` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getClosed`() +proc:BEGIN +/** + * Devuelve una tabla con las zonas cerradas para hoy + * + * @table tmp.closedZones(zoneFk, warehouseFk); + */ + DROP TEMPORARY TABLE IF EXISTS tmp.closedZones; + + CREATE TEMPORARY TABLE tmp.closedZones ( + `zoneFk` int(11) NOT NULL, + `warehouseFk` smallint(6) unsigned NOT NULL, + PRIMARY KEY `zoneFk` (`zoneFk`,`warehouseFk`), + KEY `warehouseFk` (`warehouseFk`)) + ENGINE=MEMORY DEFAULT CHARSET=utf8; + + INSERT INTO tmp.closedZones(zoneFk, warehouseFk) + SELECT zoneFk, warehouseFk + FROM ( + SELECT t.zoneFk, t.warehouseFk, count(DISTINCT t.id) numTickets, pc.minTicketsToCloseZone + FROM vn.ticket t + JOIN vn.expedition e ON e.ticketFk = t.id + JOIN vn.`zone`z on z.id = t.zoneFk + JOIN vn.agencyMode am ON am.id = z.agencyModeFk + JOIN vn.agency a ON a.id = am.agencyFk + JOIN vn.productionConfig pc + WHERE a.isOwn + AND pc.isZoneClosedByExpeditionActivated + AND e.created >= CURDATE() + GROUP BY t.zoneFk, t.warehouseFk + HAVING numTickets >= minTicketsToCloseZone) sub; + END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `zone_getCollisions` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -93582,34 +93389,42 @@ DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getLanded`(vShipped DATE, vAddressFk INT, vAgencyModeFk INT, vWarehouseFk INT, vShowExpiredZones BOOLEAN) BEGIN /** -* Devuelve una tabla temporal con el dia de recepcion para vShipped. -* -* @param vShipped Fecha de preparacion de mercancia -* @param vAddressFk Id de consignatario, %NULL para recogida -* @param vAgencyModeFk Id agencia -* @param vWarehouseFk vWarehouseFk -* @table tmp.zoneGetLanded Datos de recepción -*/ + * Devuelve una tabla temporal con el dia de recepcion para vShipped. + * Excluye las que tengan cajas preparadas + * + * @param vShipped Fecha de preparacion de mercancia + * @param vAddressFk Id de consignatario, %NULL para recogida + * @param vAgencyModeFk Id agencia + * @param vWarehouseFk vWarehouseFk + * @table tmp.zoneGetLanded Datos de recepción + */ + CALL vn.zone_getFromGeo(address_getGeo(vAddressFk)); - CALL zone_getFromGeo(address_getGeo(vAddressFk)); - CALL zone_getOptionsForShipment(vShipped, vShowExpiredZones); + CALL vn.zone_getOptionsForShipment(vShipped, vShowExpiredZones); + + CALL vn.zone_getClosed(); DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetLanded; CREATE TEMPORARY TABLE tmp.zoneGetLanded ENGINE = MEMORY SELECT vWarehouseFk warehouseFk, - TIMESTAMPADD(DAY,zo.travelingDays, vShipped) landed, + TIMESTAMPADD(DAY,zo.travelingDays, vShipped) landed, zo.zoneFk FROM tmp.zoneOption zo - JOIN zone z ON z.id = zo.zoneFk - JOIN zoneWarehouse zw ON zw.zoneFk = z.id - WHERE agencyModeFk = vAgencyModeFk - AND zw.warehouseFk = vWarehouseFk; - + JOIN vn.`zone` z ON z.id = zo.zoneFk + JOIN vn.zoneWarehouse zw ON zw.zoneFk = z.id + LEFT JOIN tmp.closedZones cz + ON cz.warehouseFk = zw.warehouseFk + AND cz.zoneFk = zw.zoneFk + AND zo.shipped = CURDATE() + WHERE z.agencyModeFk = vAgencyModeFk + AND zw.warehouseFk = vWarehouseFk + AND (ISNULL(cz.zoneFk) OR vShowExpiredZones); + DROP TEMPORARY TABLE - tmp.zone, - tmp.zoneOption; - + tmp.`zone`, + tmp.zoneOption, + tmp.closedZones; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -94062,7 +93877,8 @@ BEGIN l.travelingDays, IFNULL(e.price, z.price) price, IFNULL(e.bonus, z.bonus) bonus, - l.landed + l.landed, + vShipped shipped FROM tmp.zone t JOIN zone z ON z.id = t.id JOIN zoneEvent e ON e.zoneFk = t.id @@ -94099,123 +93915,6 @@ BEGIN WHERE vShipped < CURDATE() OR (vShipped = CURDATE() AND CURTIME() > `hour`); 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 `zone_getOptionsForShipment_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_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getOptionsForShipment_beta`(vShipped DATE, vShowExpiredZones BOOLEAN) -BEGIN -/** - * Gets computed options for the passed zones and shipping date. - * - * @table tmp.zones(id) The zones ids - * @param vShipped The shipping date - * @return tmp.zoneOption(zoneFk, hour, travelingDays, price, bonus, specificity) The computed options - */ - DECLARE vHour TIME DEFAULT TIME(NOW()); - - DROP TEMPORARY TABLE IF EXISTS tLandings; - CREATE TEMPORARY TABLE tLandings - (INDEX (eventFk)) - ENGINE = MEMORY - SELECT e.id eventFk, - @travelingDays := IFNULL(e.travelingDays, z.travelingDays) travelingDays, - TIMESTAMPADD(DAY, @travelingDays, vShipped) landed - FROM tmp.zone t - JOIN zone z ON z.id = t.id - JOIN zoneEvent e ON e.zoneFk = t.id; - - SELECT * FROM tLandings - JOIN vn.zoneEvent ze ON ze.id = eventFk - WHERE ze.zoneFk = 25; - - DROP TEMPORARY TABLE IF EXISTS tmp.zoneOption; - CREATE TEMPORARY TABLE tmp.zoneOption - ENGINE = MEMORY - SELECT * - FROM ( - SELECT t.id zoneFk, - TIME(IFNULL(e.`hour`, z.`hour`)) `hour`, - l.travelingDays, - IFNULL(e.price, z.price) price, - IFNULL(e.bonus, z.bonus) bonus, - l.landed - FROM tmp.zone t - JOIN zone z ON z.id = t.id - JOIN zoneEvent e ON e.zoneFk = t.id - JOIN tLandings l ON l.eventFk = e.id - WHERE ( - e.`type` = 'day' - AND e.`dated` = l.landed - ) OR ( - e.`type` != 'day' - AND e.weekDays & (1 << WEEKDAY(l.landed)) - AND (e.`started` IS NULL OR l.landed >= e.`started`) - AND (e.`ended` IS NULL OR l.landed <= e.`ended`) - ) - ORDER BY - zoneFk, - CASE - WHEN e.`type` = 'day' - THEN -1 - WHEN e.`type` = 'range' - THEN 2 - ELSE 3 - END - ) t - GROUP BY zoneFk; - - SELECT e.id, e.type, (e.`dated` = l.landed), e.`dated` , l.landed, t.id zoneFk, - TIME(IFNULL(e.`hour`, z.`hour`)) `hour`, - l.travelingDays, - IFNULL(e.price, z.price) price, - IFNULL(e.bonus, z.bonus) bonus, - l.landed - FROM tmp.zone t - JOIN zone z ON z.id = t.id - JOIN zoneEvent e ON e.zoneFk = t.id - JOIN tLandings l ON l.eventFk = e.id - WHERE zoneFk = 25 - ORDER BY - zoneFk, - CASE - WHEN e.`type` = 'day' - THEN 1 - WHEN e.`type` = 'range' - THEN 2 - ELSE 3 - END; - - SELECT * FROm tmp.zoneOption WHERE zoneFk = 25; - - DROP TEMPORARY TABLE tLandings; - - DELETE t FROM tmp.zoneOption t - JOIN zoneExclusion e - ON e.zoneFk = t.zoneFk AND e.`dated` = t.landed; - - SELECT * FROm tmp.zoneOption WHERE zoneFk = 25; - - IF NOT vShowExpiredZones THEN - DELETE FROM tmp.zoneOption - WHERE vShipped < CURDATE() - OR (vShipped = CURDATE() AND CURTIME() > `hour`); - END IF; - - - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -94236,36 +93935,99 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getShipped`(vLanded DATE, vAdd BEGIN /** * Devuelve la mínima fecha de envío para cada warehouse - * + * Excluye aquellas zonas que ya tienen cajas preparadas en ese almacén + * * @param vLanded La fecha de recepcion * @param vAddressFk Id del consignatario * @param vAgencyModeFk Id de la agencia * @return tmp.zoneGetShipped - */ - CALL zone_getFromGeo(address_getGeo(vAddressFk)); - CALL zone_getOptionsForLanding(vLanded, vShowExpiredZones); - + */ + CALL vn.zone_getFromGeo(address_getGeo(vAddressFk)); + CALL vn.zone_getOptionsForLanding(vLanded, vShowExpiredZones); + CALL vn.zone_getClosed(); + DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetShipped; CREATE TEMPORARY TABLE tmp.zoneGetShipped ENGINE = MEMORY SELECT * FROM ( - SELECT zo.zoneFk, - TIMESTAMPADD(DAY,-zo.travelingDays, vLanded) shipped, - zo.`hour`, + SELECT zo.zoneFk, + zo.shipped, + zo.`hour`, zw.warehouseFk, - z.agencyModeFk, - zo.price, - zo.bonus + z.agencyModeFk, + zo.price, + zo.bonus FROM tmp.zoneOption zo - JOIN zoneWarehouse zw ON zw.zoneFk = zo.zoneFk - JOIN zone z ON z.id = zo.zoneFk + JOIN vn.zoneWarehouse zw ON zw.zoneFk = zo.zoneFk + JOIN vn.`zone` z ON z.id = zo.zoneFk + LEFT JOIN tmp.closedZones cz + ON cz.warehouseFk = zw.warehouseFk + AND cz.zoneFk = zw.zoneFk + AND zo.shipped = CURDATE() WHERE z.agencyModeFk = vAgencyModeFk - ORDER BY shipped) t + AND (ISNULL(cz.zoneFk) OR vShowExpiredZones) + ORDER BY shipped) t GROUP BY warehouseFk; - + DROP TEMPORARY TABLE - tmp.zone, - tmp.zoneOption; + tmp.`zone`, + tmp.zoneOption, + tmp.closedZones; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `zone_getState` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getState`(vDated DATE) +BEGIN +/** + * Devuelve las zonas y el estado para la fecha solicitada + * + * @param vDated Fecha en cuestión + */ + DROP TEMPORARY TABLE IF EXISTS tmp.zone; + + CREATE TEMPORARY TABLE tmp.zone ( + id INT PRIMARY KEY) + ENGINE=MEMORY; + + INSERT INTO tmp.zone(id) + SELECT id + FROM vn.zone; + + CALL vn.zone_getOptionsForShipment(vDated, TRUE); + + CALL vn.zone_getClosed(); + + SELECT zo.zoneFk, + zo.`hour`etd, + (zo.`hour` <= TIME(now())) isLate, + !ISNULL(cz.zoneFk) isFull, + zw.warehouseFk, + zo.landed + FROM tmp.zoneOption zo + JOIN vn.zone z ON z.id = zo.zoneFk + JOIN vn.zoneWarehouse zw ON zw.zoneFk = z.id + LEFT JOIN tmp.closedZones cz + ON cz.warehouseFk = zw.warehouseFk + AND cz.zoneFk = zo.zoneFk; + + DROP TEMPORARY TABLE + tmp.closedZones, + tmp.zoneOption, + tmp.zone; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -97150,7 +96912,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` 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`.`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 */; @@ -97535,25 +97297,6 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `packingSite` --- - -/*!50001 DROP TABLE IF EXISTS `packingSite`*/; -/*!50001 DROP VIEW IF EXISTS `packingSite`*/; -/*!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_unicode_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `packingSite` AS select `h`.`code` AS `hostFk`,`h`.`printerFk` AS `printerFk`,concat(`h`.`itemPackingTypeFk`,`h`.`packingSite`) AS `code` from `host` `h` where (`h`.`itemPackingTypeFk` is not null) order by `h`.`itemPackingTypeFk`,`h`.`packingSite` */; -/*!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 `payDemDetail__` -- @@ -98095,11 +97838,11 @@ USE `vn`; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8 */; -/*!50001 SET character_set_results = utf8 */; -/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`$itBoss`@`%` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `ticketLocation` AS select `tl`.`Id_Ticket` AS `ticketFk`,`tl`.`longitude` AS `longitude`,`tl`.`latitude` AS `latitude` from `vn2008`.`ticket_location` `tl` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -98690,4 +98433,4 @@ USE `vncontrol`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2022-03-28 9:44:10 +-- Dump completed on 2022-05-02 9:27:49 diff --git a/db/export-data.sh b/db/export-data.sh index 135047f04..900e630f7 100755 --- a/db/export-data.sh +++ b/db/export-data.sh @@ -14,6 +14,8 @@ echo "" > "$DUMPED_FILE" TABLES=( util config + version + versionLog ) dump_tables ${TABLES[@]} @@ -74,10 +76,20 @@ dump_tables ${TABLES[@]} TABLES=( hedera + browser imageCollection + imageCollectionSize + language + link + location + menu + message + metatag + newsTag + restPriv + social tpvError tpvResponse - imageCollectionSize ) dump_tables ${TABLES[@]}