diff --git a/db/dump/dumpedFixtures.sql b/db/dump/dumpedFixtures.sql index 309aea6df..94c62e984 100644 --- a/db/dump/dumpedFixtures.sql +++ b/db/dump/dumpedFixtures.sql @@ -23,7 +23,7 @@ USE `util`; LOCK TABLES `config` WRITE; /*!40000 ALTER TABLE `config` DISABLE KEYS */; -INSERT INTO `config` VALUES (1,'10170',0,'production',NULL); +INSERT INTO `config` VALUES (1,'10190',0,'production',NULL); /*!40000 ALTER TABLE `config` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -36,7 +36,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-06-02 12:15:09 +-- Dump completed on 2020-06-23 8:07:57 USE `account`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -94,7 +94,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-06-02 12:15:10 +-- Dump completed on 2020-06-23 8:07:57 USE `salix`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -119,7 +119,7 @@ USE `salix`; LOCK TABLES `ACL` WRITE; /*!40000 ALTER TABLE `ACL` DISABLE KEYS */; -INSERT INTO `ACL` VALUES (1,'Account','*','*','ALLOW','ROLE','employee'),(3,'Address','*','*','ALLOW','ROLE','employee'),(5,'AgencyService','*','READ','ALLOW','ROLE','employee'),(7,'Client','*','*','ALLOW','ROLE','employee'),(9,'ClientObservation','*','*','ALLOW','ROLE','employee'),(11,'ContactChannel','*','READ','ALLOW','ROLE','trainee'),(13,'Employee','*','READ','ALLOW','ROLE','employee'),(14,'PayMethod','*','READ','ALLOW','ROLE','trainee'),(16,'FakeProduction','*','READ','ALLOW','ROLE','employee'),(17,'Warehouse','* ','READ','ALLOW','ROLE','trainee'),(18,'State','*','READ','ALLOW','ROLE','employee'),(20,'TicketState','*','*','ALLOW','ROLE','employee'),(24,'Delivery','*','READ','ALLOW','ROLE','employee'),(25,'Zone','*','READ','ALLOW','ROLE','employee'),(26,'ClientCredit','*','*','ALLOW','ROLE','employee'),(27,'ClientCreditLimit','*','READ','ALLOW','ROLE','trainee'),(30,'GreugeType','*','READ','ALLOW','ROLE','trainee'),(31,'Mandate','*','READ','ALLOW','ROLE','trainee'),(32,'MandateType','*','READ','ALLOW','ROLE','trainee'),(33,'Company','*','READ','ALLOW','ROLE','trainee'),(34,'Greuge','*','READ','ALLOW','ROLE','trainee'),(35,'AddressObservation','*','*','ALLOW','ROLE','employee'),(36,'ObservationType','*','*','ALLOW','ROLE','employee'),(37,'Greuge','*','WRITE','ALLOW','ROLE','employee'),(38,'AgencyMode','*','READ','ALLOW','ROLE','employee'),(39,'ItemTag','*','WRITE','ALLOW','ROLE','buyer'),(40,'ItemBotanical','*','WRITE','ALLOW','ROLE','buyer'),(41,'ItemBotanical','*','READ','ALLOW','ROLE','employee'),(42,'ItemPlacement','*','WRITE','ALLOW','ROLE','buyer'),(43,'ItemPlacement','*','WRITE','ALLOW','ROLE','replenisher'),(44,'ItemPlacement','*','READ','ALLOW','ROLE','employee'),(45,'ItemBarcode','*','READ','ALLOW','ROLE','employee'),(46,'ItemBarcode','*','WRITE','ALLOW','ROLE','buyer'),(47,'ItemBarcode','*','WRITE','ALLOW','ROLE','replenisher'),(48,'ItemNiche','*','READ','ALLOW','ROLE','employee'),(49,'ItemNiche','*','WRITE','ALLOW','ROLE','buyer'),(50,'ItemNiche','*','WRITE','ALLOW','ROLE','replenisher'),(51,'ItemTag','*','READ','ALLOW','ROLE','employee'),(53,'Item','*','READ','ALLOW','ROLE','employee'),(54,'Item','*','WRITE','ALLOW','ROLE','buyer'),(55,'Recovery','*','READ','ALLOW','ROLE','trainee'),(56,'Recovery','*','WRITE','ALLOW','ROLE','administrative'),(58,'CreditClassification','*','*','ALLOW','ROLE','insurance'),(60,'CreditInsurance','*','*','ALLOW','ROLE','insurance'),(61,'InvoiceOut','*','READ','ALLOW','ROLE','employee'),(62,'Ticket','*','*','ALLOW','ROLE','employee'),(63,'TicketObservation','*','*','ALLOW','ROLE','employee'),(64,'Route','*','READ','ALLOW','ROLE','employee'),(65,'Sale','*','READ','ALLOW','ROLE','employee'),(66,'TicketTracking','*','READ','ALLOW','ROLE','employee'),(68,'TicketPackaging','*','*','ALLOW','ROLE','employee'),(69,'Packaging','*','READ','ALLOW','ROLE','employee'),(70,'Packaging','*','WRITE','ALLOW','ROLE','logistic'),(71,'SaleChecked','*','READ','ALLOW','ROLE','employee'),(72,'SaleComponent','*','READ','ALLOW','ROLE','employee'),(73,'Expedition','*','READ','ALLOW','ROLE','employee'),(74,'Expedition','*','WRITE','ALLOW','ROLE','deliveryBoss'),(75,'Expedition','*','WRITE','ALLOW','ROLE','production'),(76,'AnnualAverageInvoiced','*','READ','ALLOW','ROLE','employee'),(77,'WorkerMana','*','READ','ALLOW','ROLE','employee'),(78,'TicketTracking','*','WRITE','ALLOW','ROLE','production'),(79,'TicketTracking','changeState','*','ALLOW','ROLE','employee'),(80,'Sale','removes','*','ALLOW','ROLE','employee'),(81,'Sale','moveToTicket','*','ALLOW','ROLE','employee'),(82,'Sale','updateQuantity','*','ALLOW','ROLE','employee'),(83,'Sale','updatePrice','*','ALLOW','ROLE','employee'),(84,'Sale','updateDiscount','*','ALLOW','ROLE','employee'),(85,'SaleTracking','*','READ','ALLOW','ROLE','employee'),(86,'Order','*','*','ALLOW','ROLE','employee'),(87,'OrderRow','*','*','ALLOW','ROLE','employee'),(88,'ClientContact','*','*','ALLOW','ROLE','employee'),(89,'Sale','moveToNewTicket','*','ALLOW','ROLE','employee'),(90,'Sale','reserve','*','ALLOW','ROLE','employee'),(91,'TicketWeekly','*','READ','ALLOW','ROLE','employee'),(94,'Agency','landsThatDay','*','ALLOW','ROLE','employee'),(96,'ClaimEnd','*','READ','ALLOW','ROLE','employee'),(97,'ClaimEnd','*','WRITE','ALLOW','ROLE','salesAssistant'),(98,'ClaimBeginning','*','*','ALLOW','ROLE','employee'),(99,'ClaimDevelopment','*','READ','ALLOW','ROLE','employee'),(100,'ClaimDevelopment','*','WRITE','ALLOW','ROLE','salesAssistant'),(101,'Claim','*','*','ALLOW','ROLE','employee'),(102,'Claim','createFromSales','*','ALLOW','ROLE','employee'),(103,'ClaimEnd','importTicketSales','WRITE','ALLOW','ROLE','salesAssistant'),(104,'Item','*','WRITE','ALLOW','ROLE','marketingBoss'),(105,'ItemBarcode','*','WRITE','ALLOW','ROLE','marketingBoss'),(106,'ItemBotanical','*','WRITE','ALLOW','ROLE','marketingBoss'),(107,'ItemNiche','*','WRITE','ALLOW','ROLE','marketingBoss'),(108,'ItemPlacement','*','WRITE','ALLOW','ROLE','marketingBoss'),(109,'UserConfig','*','*','ALLOW','ROLE','employee'),(110,'Bank','*','READ','ALLOW','ROLE','trainee'),(111,'ClientLog','*','READ','ALLOW','ROLE','trainee'),(112,'Defaulter','*','READ','ALLOW','ROLE','employee'),(113,'ClientRisk','*','READ','ALLOW','ROLE','trainee'),(114,'Receipt','*','READ','ALLOW','ROLE','trainee'),(115,'Receipt','*','WRITE','ALLOW','ROLE','administrative'),(116,'BankEntity','*','*','ALLOW','ROLE','employee'),(117,'ClientSample','*','*','ALLOW','ROLE','employee'),(118,'WorkerTeam','*','*','ALLOW','ROLE','salesPerson'),(119,'Travel','*','READ','ALLOW','ROLE','employee'),(120,'Travel','*','WRITE','ALLOW','ROLE','buyer'),(121,'Item','regularize','*','ALLOW','ROLE','employee'),(122,'TicketRequest','*','*','ALLOW','ROLE','employee'),(123,'Worker','*','*','ALLOW','ROLE','employee'),(124,'Client','confirmTransaction','WRITE','ALLOW','ROLE','administrative'),(125,'Agency','getAgenciesWithWarehouse','*','ALLOW','ROLE','employee'),(126,'Client','activeWorkersWithRole','*','ALLOW','ROLE','employee'),(127,'TicketLog','*','READ','ALLOW','ROLE','employee'),(129,'TicketService','*','*','ALLOW','ROLE','employee'),(130,'Expedition','*','WRITE','ALLOW','ROLE','packager'),(131,'CreditInsurance','*','READ','ALLOW','ROLE','trainee'),(132,'CreditClassification','*','READ','ALLOW','ROLE','trainee'),(133,'ItemTag','*','WRITE','ALLOW','ROLE','marketingBoss'),(135,'ZoneGeo','*','READ','ALLOW','ROLE','employee'),(136,'ZoneCalendar','*','READ','ALLOW','ROLE','employee'),(137,'ZoneIncluded','*','READ','ALLOW','ROLE','employee'),(138,'LabourHoliday','*','READ','ALLOW','ROLE','employee'),(139,'LabourHolidayLegend','*','READ','ALLOW','ROLE','employee'),(140,'LabourHolidayType','*','READ','ALLOW','ROLE','employee'),(141,'Zone','*','*','ALLOW','ROLE','deliveryBoss'),(142,'ZoneCalendar','*','WRITE','ALLOW','ROLE','deliveryBoss'),(143,'ZoneIncluded','*','*','ALLOW','ROLE','deliveryBoss'),(144,'Stowaway','*','*','ALLOW','ROLE','employee'),(145,'Ticket','getPossibleStowaways','READ','ALLOW','ROLE','employee'),(147,'UserConfigView','*','*','ALLOW','ROLE','employee'),(148,'UserConfigView','*','*','ALLOW','ROLE','employee'),(149,'Sip','*','READ','ALLOW','ROLE','employee'),(150,'Sip','*','WRITE','ALLOW','ROLE','hr'),(151,'Department','*','READ','ALLOW','ROLE','employee'),(152,'Department','*','WRITE','ALLOW','ROLE','hr'),(153,'Route','*','READ','ALLOW','ROLE','employee'),(154,'Route','*','WRITE','ALLOW','ROLE','delivery'),(155,'WorkerCalendar','*','READ','ALLOW','ROLE','hr'),(156,'WorkerLabour','*','READ','ALLOW','ROLE','hr'),(157,'WorkerCalendar','absences','READ','ALLOW','ROLE','employee'),(158,'ItemTag','*','WRITE','ALLOW','ROLE','accessory'),(160,'TicketServiceType','*','READ','ALLOW','ROLE','employee'),(161,'TicketConfig','*','READ','ALLOW','ROLE','employee'),(162,'InvoiceOut','delete','WRITE','ALLOW','ROLE','invoicing'),(163,'InvoiceOut','book','WRITE','ALLOW','ROLE','invoicing'),(164,'InvoiceOut','regenerate','WRITE','ALLOW','ROLE','invoicing'),(165,'TicketDms','*','READ','ALLOW','ROLE','employee'),(167,'Worker','isSubordinate','READ','ALLOW','ROLE','employee'),(168,'Worker','mySubordinates','READ','ALLOW','ROLE','employee'),(169,'WorkerTimeControl','filter','READ','ALLOW','ROLE','employee'),(170,'WorkerTimeControl','addTime','WRITE','ALLOW','ROLE','employee'),(171,'TicketServiceType','*','WRITE','ALLOW','ROLE','administrative'),(172,'Sms','*','READ','ALLOW','ROLE','employee'),(173,'Sms','send','WRITE','ALLOW','ROLE','employee'),(174,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(175,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(176,'Device','*','*','ALLOW','ROLE','employee'),(177,'Device','*','*','ALLOW','ROLE','employee'),(178,'WorkerTimeControl','*','*','ALLOW','ROLE','employee'),(179,'ItemLog','*','READ','ALLOW','ROLE','employee'),(180,'RouteLog','*','READ','ALLOW','ROLE','employee'),(181,'Dms','removeFile','WRITE','ALLOW','ROLE','employee'),(182,'Dms','uploadFile','WRITE','ALLOW','ROLE','employee'),(183,'Dms','downloadFile','READ','ALLOW','ROLE','employee'),(184,'Client','uploadFile','WRITE','ALLOW','ROLE','employee'),(185,'ClientDms','removeFile','WRITE','ALLOW','ROLE','employee'),(186,'ClientDms','*','READ','ALLOW','ROLE','trainee'),(187,'Ticket','uploadFile','WRITE','ALLOW','ROLE','employee'),(188,'TicketDms','removeFile','WRITE','ALLOW','ROLE','employee'),(189,'TicketDms','*','READ','ALLOW','ROLE','employee'),(190,'Route','updateVolume','WRITE','ALLOW','ROLE','deliveryBoss'),(191,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(192,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(194,'Postcode','*','WRITE','ALLOW','ROLE','employee'),(195,'Ticket','addSale','WRITE','ALLOW','ROLE','employee'),(196,'Dms','updateFile','WRITE','ALLOW','ROLE','employee'),(197,'Dms','*','READ','ALLOW','ROLE','trainee'),(198,'ClaimDms','removeFile','WRITE','ALLOW','ROLE','employee'),(199,'ClaimDms','*','READ','ALLOW','ROLE','employee'),(200,'Claim','uploadFile','WRITE','ALLOW','ROLE','employee'),(201,'Sale','updateConcept','WRITE','ALLOW','ROLE','employee'),(202,'Claim','updateClaimAction','WRITE','ALLOW','ROLE','salesAssistant'),(203,'UserPhone','*','*','ALLOW','ROLE','employee'),(204,'WorkerDms','removeFile','WRITE','ALLOW','ROLE','hr'),(205,'WorkerDms','*','READ','ALLOW','ROLE','hr'),(206,'Chat','*','*','ALLOW','ROLE','employee'),(207,'Chat','sendMessage','*','ALLOW','ROLE','employee'),(208,'Sale','recalculatePrice','WRITE','ALLOW','ROLE','employee'),(209,'Ticket','recalculateComponents','WRITE','ALLOW','ROLE','employee'),(211,'TravelLog','*','READ','ALLOW','ROLE','buyer'),(212,'Thermograph','*','*','ALLOW','ROLE','buyer'),(213,'TravelThermograph','*','*','ALLOW','ROLE','buyer'),(214,'Entry','*','*','ALLOW','ROLE','buyer'),(215,'TicketWeekly','*','WRITE','ALLOW','ROLE','buyer'),(216,'TravelThermograph','*','READ','ALLOW','ROLE','employee'),(218,'Intrastat','*','*','ALLOW','ROLE','buyer'),(219,'Account','acl','READ','ALLOW','ROLE','account'),(220,'Account','getCurrentUserData','READ','ALLOW','ROLE','account'),(221,'UserConfig','getUserConfig','READ','ALLOW','ROLE','account'),(222,'Client','*','READ','ALLOW','ROLE','trainee'),(226,'ClientObservation','*','READ','ALLOW','ROLE','trainee'),(227,'Address','*','READ','ALLOW','ROLE','trainee'),(228,'AddressObservation','*','READ','ALLOW','ROLE','trainee'),(229,'CustomsAgent','*','*','ALLOW','ROLE','employee'),(230,'ClientCredit','*','READ','ALLOW','ROLE','trainee'),(231,'ClientContact','*','READ','ALLOW','ROLE','trainee'),(232,'ClientSample','*','READ','ALLOW','ROLE','trainee'),(233,'EntryLog','*','READ','ALLOW','ROLE','buyer'); +INSERT INTO `ACL` VALUES (1,'Account','*','*','ALLOW','ROLE','employee'),(3,'Address','*','*','ALLOW','ROLE','employee'),(5,'AgencyService','*','READ','ALLOW','ROLE','employee'),(7,'Client','*','*','ALLOW','ROLE','employee'),(9,'ClientObservation','*','*','ALLOW','ROLE','employee'),(11,'ContactChannel','*','READ','ALLOW','ROLE','trainee'),(13,'Employee','*','READ','ALLOW','ROLE','employee'),(14,'PayMethod','*','READ','ALLOW','ROLE','trainee'),(16,'FakeProduction','*','READ','ALLOW','ROLE','employee'),(17,'Warehouse','* ','READ','ALLOW','ROLE','trainee'),(18,'State','*','READ','ALLOW','ROLE','employee'),(20,'TicketState','*','*','ALLOW','ROLE','employee'),(24,'Delivery','*','READ','ALLOW','ROLE','employee'),(25,'Zone','*','READ','ALLOW','ROLE','employee'),(26,'ClientCredit','*','*','ALLOW','ROLE','employee'),(27,'ClientCreditLimit','*','READ','ALLOW','ROLE','trainee'),(30,'GreugeType','*','READ','ALLOW','ROLE','trainee'),(31,'Mandate','*','READ','ALLOW','ROLE','trainee'),(32,'MandateType','*','READ','ALLOW','ROLE','trainee'),(33,'Company','*','READ','ALLOW','ROLE','trainee'),(34,'Greuge','*','READ','ALLOW','ROLE','trainee'),(35,'AddressObservation','*','*','ALLOW','ROLE','employee'),(36,'ObservationType','*','*','ALLOW','ROLE','employee'),(37,'Greuge','*','WRITE','ALLOW','ROLE','employee'),(38,'AgencyMode','*','READ','ALLOW','ROLE','employee'),(39,'ItemTag','*','WRITE','ALLOW','ROLE','buyer'),(40,'ItemBotanical','*','WRITE','ALLOW','ROLE','buyer'),(41,'ItemBotanical','*','READ','ALLOW','ROLE','employee'),(42,'ItemPlacement','*','WRITE','ALLOW','ROLE','buyer'),(43,'ItemPlacement','*','WRITE','ALLOW','ROLE','replenisher'),(44,'ItemPlacement','*','READ','ALLOW','ROLE','employee'),(45,'ItemBarcode','*','READ','ALLOW','ROLE','employee'),(46,'ItemBarcode','*','WRITE','ALLOW','ROLE','buyer'),(47,'ItemBarcode','*','WRITE','ALLOW','ROLE','replenisher'),(48,'ItemNiche','*','READ','ALLOW','ROLE','employee'),(49,'ItemNiche','*','WRITE','ALLOW','ROLE','buyer'),(50,'ItemNiche','*','WRITE','ALLOW','ROLE','replenisher'),(51,'ItemTag','*','READ','ALLOW','ROLE','employee'),(53,'Item','*','READ','ALLOW','ROLE','employee'),(54,'Item','*','WRITE','ALLOW','ROLE','buyer'),(55,'Recovery','*','READ','ALLOW','ROLE','trainee'),(56,'Recovery','*','WRITE','ALLOW','ROLE','administrative'),(58,'CreditClassification','*','*','ALLOW','ROLE','insurance'),(60,'CreditInsurance','*','*','ALLOW','ROLE','insurance'),(61,'InvoiceOut','*','READ','ALLOW','ROLE','employee'),(62,'Ticket','*','*','ALLOW','ROLE','employee'),(63,'TicketObservation','*','*','ALLOW','ROLE','employee'),(64,'Route','*','READ','ALLOW','ROLE','employee'),(65,'Sale','*','READ','ALLOW','ROLE','employee'),(66,'TicketTracking','*','READ','ALLOW','ROLE','employee'),(68,'TicketPackaging','*','*','ALLOW','ROLE','employee'),(69,'Packaging','*','READ','ALLOW','ROLE','employee'),(70,'Packaging','*','WRITE','ALLOW','ROLE','logistic'),(71,'SaleChecked','*','READ','ALLOW','ROLE','employee'),(72,'SaleComponent','*','READ','ALLOW','ROLE','employee'),(73,'Expedition','*','READ','ALLOW','ROLE','employee'),(74,'Expedition','*','WRITE','ALLOW','ROLE','deliveryBoss'),(75,'Expedition','*','WRITE','ALLOW','ROLE','production'),(76,'AnnualAverageInvoiced','*','READ','ALLOW','ROLE','employee'),(77,'WorkerMana','*','READ','ALLOW','ROLE','employee'),(78,'TicketTracking','*','WRITE','ALLOW','ROLE','production'),(79,'TicketTracking','changeState','*','ALLOW','ROLE','employee'),(80,'Sale','removes','*','ALLOW','ROLE','employee'),(81,'Sale','moveToTicket','*','ALLOW','ROLE','employee'),(82,'Sale','updateQuantity','*','ALLOW','ROLE','employee'),(83,'Sale','updatePrice','*','ALLOW','ROLE','employee'),(84,'Sale','updateDiscount','*','ALLOW','ROLE','employee'),(85,'SaleTracking','*','READ','ALLOW','ROLE','employee'),(86,'Order','*','*','ALLOW','ROLE','employee'),(87,'OrderRow','*','*','ALLOW','ROLE','employee'),(88,'ClientContact','*','*','ALLOW','ROLE','employee'),(89,'Sale','moveToNewTicket','*','ALLOW','ROLE','employee'),(90,'Sale','reserve','*','ALLOW','ROLE','employee'),(91,'TicketWeekly','*','READ','ALLOW','ROLE','employee'),(94,'Agency','landsThatDay','*','ALLOW','ROLE','employee'),(96,'ClaimEnd','*','READ','ALLOW','ROLE','employee'),(97,'ClaimEnd','*','WRITE','ALLOW','ROLE','salesAssistant'),(98,'ClaimBeginning','*','*','ALLOW','ROLE','employee'),(99,'ClaimDevelopment','*','READ','ALLOW','ROLE','employee'),(100,'ClaimDevelopment','*','WRITE','ALLOW','ROLE','salesAssistant'),(101,'Claim','*','*','ALLOW','ROLE','employee'),(102,'Claim','createFromSales','*','ALLOW','ROLE','employee'),(103,'ClaimEnd','importTicketSales','WRITE','ALLOW','ROLE','salesAssistant'),(104,'Item','*','WRITE','ALLOW','ROLE','marketingBoss'),(105,'ItemBarcode','*','WRITE','ALLOW','ROLE','marketingBoss'),(106,'ItemBotanical','*','WRITE','ALLOW','ROLE','marketingBoss'),(107,'ItemNiche','*','WRITE','ALLOW','ROLE','marketingBoss'),(108,'ItemPlacement','*','WRITE','ALLOW','ROLE','marketingBoss'),(109,'UserConfig','*','*','ALLOW','ROLE','employee'),(110,'Bank','*','READ','ALLOW','ROLE','trainee'),(111,'ClientLog','*','READ','ALLOW','ROLE','trainee'),(112,'Defaulter','*','READ','ALLOW','ROLE','employee'),(113,'ClientRisk','*','READ','ALLOW','ROLE','trainee'),(114,'Receipt','*','READ','ALLOW','ROLE','trainee'),(115,'Receipt','*','WRITE','ALLOW','ROLE','administrative'),(116,'BankEntity','*','*','ALLOW','ROLE','employee'),(117,'ClientSample','*','*','ALLOW','ROLE','employee'),(118,'WorkerTeam','*','*','ALLOW','ROLE','salesPerson'),(119,'Travel','*','READ','ALLOW','ROLE','employee'),(120,'Travel','*','WRITE','ALLOW','ROLE','buyer'),(121,'Item','regularize','*','ALLOW','ROLE','employee'),(122,'TicketRequest','*','*','ALLOW','ROLE','employee'),(123,'Worker','*','*','ALLOW','ROLE','employee'),(124,'Client','confirmTransaction','WRITE','ALLOW','ROLE','administrative'),(125,'Agency','getAgenciesWithWarehouse','*','ALLOW','ROLE','employee'),(126,'Client','activeWorkersWithRole','*','ALLOW','ROLE','employee'),(127,'TicketLog','*','READ','ALLOW','ROLE','employee'),(129,'TicketService','*','*','ALLOW','ROLE','employee'),(130,'Expedition','*','WRITE','ALLOW','ROLE','packager'),(131,'CreditInsurance','*','READ','ALLOW','ROLE','trainee'),(132,'CreditClassification','*','READ','ALLOW','ROLE','trainee'),(133,'ItemTag','*','WRITE','ALLOW','ROLE','marketingBoss'),(135,'ZoneGeo','*','READ','ALLOW','ROLE','employee'),(136,'ZoneCalendar','*','READ','ALLOW','ROLE','employee'),(137,'ZoneIncluded','*','READ','ALLOW','ROLE','employee'),(138,'LabourHoliday','*','READ','ALLOW','ROLE','employee'),(139,'LabourHolidayLegend','*','READ','ALLOW','ROLE','employee'),(140,'LabourHolidayType','*','READ','ALLOW','ROLE','employee'),(141,'Zone','*','*','ALLOW','ROLE','deliveryBoss'),(142,'ZoneCalendar','*','WRITE','ALLOW','ROLE','deliveryBoss'),(143,'ZoneIncluded','*','*','ALLOW','ROLE','deliveryBoss'),(144,'Stowaway','*','*','ALLOW','ROLE','employee'),(145,'Ticket','getPossibleStowaways','READ','ALLOW','ROLE','employee'),(147,'UserConfigView','*','*','ALLOW','ROLE','employee'),(148,'UserConfigView','*','*','ALLOW','ROLE','employee'),(149,'Sip','*','READ','ALLOW','ROLE','employee'),(150,'Sip','*','WRITE','ALLOW','ROLE','hr'),(151,'Department','*','READ','ALLOW','ROLE','employee'),(152,'Department','*','WRITE','ALLOW','ROLE','hr'),(153,'Route','*','READ','ALLOW','ROLE','employee'),(154,'Route','*','WRITE','ALLOW','ROLE','delivery'),(155,'WorkerCalendar','*','READ','ALLOW','ROLE','hr'),(156,'WorkerLabour','*','READ','ALLOW','ROLE','hr'),(157,'WorkerCalendar','absences','READ','ALLOW','ROLE','employee'),(158,'ItemTag','*','WRITE','ALLOW','ROLE','accessory'),(160,'TicketServiceType','*','READ','ALLOW','ROLE','employee'),(161,'TicketConfig','*','READ','ALLOW','ROLE','employee'),(162,'InvoiceOut','delete','WRITE','ALLOW','ROLE','invoicing'),(163,'InvoiceOut','book','WRITE','ALLOW','ROLE','invoicing'),(164,'InvoiceOut','regenerate','WRITE','ALLOW','ROLE','invoicing'),(165,'TicketDms','*','READ','ALLOW','ROLE','employee'),(167,'Worker','isSubordinate','READ','ALLOW','ROLE','employee'),(168,'Worker','mySubordinates','READ','ALLOW','ROLE','employee'),(169,'WorkerTimeControl','filter','READ','ALLOW','ROLE','employee'),(170,'WorkerTimeControl','addTime','WRITE','ALLOW','ROLE','employee'),(171,'TicketServiceType','*','WRITE','ALLOW','ROLE','administrative'),(172,'Sms','*','READ','ALLOW','ROLE','employee'),(173,'Sms','send','WRITE','ALLOW','ROLE','employee'),(174,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(175,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(176,'Device','*','*','ALLOW','ROLE','employee'),(177,'Device','*','*','ALLOW','ROLE','employee'),(178,'WorkerTimeControl','*','*','ALLOW','ROLE','employee'),(179,'ItemLog','*','READ','ALLOW','ROLE','employee'),(180,'RouteLog','*','READ','ALLOW','ROLE','employee'),(181,'Dms','removeFile','WRITE','ALLOW','ROLE','employee'),(182,'Dms','uploadFile','WRITE','ALLOW','ROLE','employee'),(183,'Dms','downloadFile','READ','ALLOW','ROLE','employee'),(184,'Client','uploadFile','WRITE','ALLOW','ROLE','employee'),(185,'ClientDms','removeFile','WRITE','ALLOW','ROLE','employee'),(186,'ClientDms','*','READ','ALLOW','ROLE','trainee'),(187,'Ticket','uploadFile','WRITE','ALLOW','ROLE','employee'),(188,'TicketDms','removeFile','WRITE','ALLOW','ROLE','employee'),(189,'TicketDms','*','READ','ALLOW','ROLE','employee'),(190,'Route','updateVolume','WRITE','ALLOW','ROLE','deliveryBoss'),(191,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(192,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(194,'Postcode','*','WRITE','ALLOW','ROLE','employee'),(195,'Ticket','addSale','WRITE','ALLOW','ROLE','employee'),(196,'Dms','updateFile','WRITE','ALLOW','ROLE','employee'),(197,'Dms','*','READ','ALLOW','ROLE','trainee'),(198,'ClaimDms','removeFile','WRITE','ALLOW','ROLE','employee'),(199,'ClaimDms','*','READ','ALLOW','ROLE','employee'),(200,'Claim','uploadFile','WRITE','ALLOW','ROLE','employee'),(201,'Sale','updateConcept','WRITE','ALLOW','ROLE','employee'),(202,'Claim','updateClaimAction','WRITE','ALLOW','ROLE','salesAssistant'),(203,'UserPhone','*','*','ALLOW','ROLE','employee'),(204,'WorkerDms','removeFile','WRITE','ALLOW','ROLE','hr'),(205,'WorkerDms','*','READ','ALLOW','ROLE','hr'),(206,'Chat','*','*','ALLOW','ROLE','employee'),(207,'Chat','sendMessage','*','ALLOW','ROLE','employee'),(208,'Sale','recalculatePrice','WRITE','ALLOW','ROLE','employee'),(209,'Ticket','recalculateComponents','WRITE','ALLOW','ROLE','employee'),(211,'TravelLog','*','READ','ALLOW','ROLE','buyer'),(212,'Thermograph','*','*','ALLOW','ROLE','buyer'),(213,'TravelThermograph','*','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'),(229,'CustomsAgent','*','*','ALLOW','ROLE','employee'),(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','hr'),(235,'CustomsAgent','*','*','ALLOW','ROLE','employee'); /*!40000 ALTER TABLE `ACL` ENABLE KEYS */; UNLOCK TABLES; @@ -142,7 +142,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-06-02 12:15:11 +-- Dump completed on 2020-06-23 8:07:58 USE `vn`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -227,7 +227,7 @@ UNLOCK TABLES; LOCK TABLES `tag` WRITE; /*!40000 ALTER TABLE `tag` DISABLE KEYS */; -INSERT INTO `tag` VALUES (1,'color','Color',0,0,'ink',NULL,NULL),(2,'','Forma',1,0,NULL,NULL,NULL),(3,'','Material',1,0,NULL,NULL,NULL),(4,'','Longitud',1,1,NULL,'mm',NULL),(5,'','Diámetro',1,1,NULL,'mm',NULL),(6,'','Perímetro',1,1,NULL,'mm',NULL),(7,'','Ancho de la base',1,1,NULL,'mm',NULL),(8,'','Altura',1,1,NULL,'mm',NULL),(9,'','Volumen',1,1,NULL,'ml',NULL),(10,'','Densidad',1,1,NULL,NULL,NULL),(11,'','Calidad',1,0,NULL,NULL,NULL),(12,'','Textura',1,0,NULL,NULL,NULL),(13,'','Material del mango',1,0,NULL,NULL,NULL),(14,'','Compra mínima',1,0,NULL,NULL,NULL),(15,'','Nº pétalos',1,1,NULL,NULL,NULL),(16,'','Ancho',1,1,NULL,'mm',NULL),(18,'','Profundidad',1,1,NULL,'mm',NULL),(19,'','Largo',1,1,NULL,'mm',NULL),(20,'','Ancho superior',1,1,NULL,'mm',NULL),(21,'','Ancho inferior',1,1,NULL,'mm',NULL),(22,'','Gramaje',1,1,NULL,'g',NULL),(23,'stems','Tallos',1,1,NULL,NULL,NULL),(24,'','Estado',1,0,NULL,NULL,NULL),(25,'','Color principal',0,0,'ink',NULL,NULL),(26,'','Color secundario',0,0,'ink',NULL,NULL),(27,'','Longitud(cm)',1,1,NULL,'cm',NULL),(28,'','Diámetro base',1,1,'','mm',NULL),(29,'','Colección',1,0,NULL,NULL,NULL),(30,'','Uds / caja',1,1,NULL,NULL,NULL),(31,'','Contenido',1,0,NULL,NULL,NULL),(32,'','Peso',1,1,NULL,'g',NULL),(33,'','Grosor',1,1,NULL,'mm',NULL),(34,'','Marca',1,0,NULL,NULL,NULL),(35,'origin','Origen',0,0,'origin',NULL,NULL),(36,'','Proveedor',1,0,NULL,NULL,NULL),(37,'producer','Productor',0,0,'producer',NULL,NULL),(38,'','Duración',1,1,NULL,'s',NULL),(39,'','Flor',1,0,NULL,NULL,NULL),(40,'','Soporte',1,0,NULL,NULL,NULL),(41,'','Tamaño flor',1,0,NULL,NULL,NULL),(42,'','Apertura',1,0,NULL,NULL,NULL),(43,'','Tallo',1,0,NULL,NULL,NULL),(44,'','Nº hojas',1,1,NULL,NULL,NULL),(45,'','Dimensiones',1,0,NULL,NULL,NULL),(46,'','Diámetro boca',1,1,NULL,'mm',NULL),(47,'','Nº flores',1,1,NULL,NULL,NULL),(48,'','Uds / paquete',1,1,NULL,NULL,NULL),(49,'','Maceta',1,1,NULL,'cm',NULL),(50,'','Textura flor',1,0,NULL,NULL,NULL),(51,'','Textura hoja',1,0,NULL,NULL,NULL),(52,'','Tipo de IVA',1,0,NULL,NULL,NULL),(53,'','Tronco',1,0,NULL,NULL,NULL),(54,'','Hoja',1,0,NULL,NULL,NULL),(55,'','Formato',1,0,NULL,NULL,NULL),(56,'','Genero',1,0,NULL,NULL,NULL),(57,'','Especie',1,0,NULL,NULL,NULL),(58,'','Variedad',1,0,NULL,NULL,NULL),(59,'','Medida grande',1,0,NULL,NULL,NULL),(60,'','Medida mediano',1,0,NULL,NULL,NULL),(61,'','Medida pequeño',1,0,NULL,NULL,NULL),(62,'','Medida pequeño',1,0,NULL,NULL,NULL),(63,'','Recipiente interior',1,0,NULL,NULL,NULL),(64,'','Material secundario',1,0,NULL,NULL,NULL),(65,'','Colores',1,0,NULL,NULL,NULL),(66,'','Referencia',1,0,NULL,NULL,NULL),(67,'','Categoria',1,0,NULL,NULL,NULL),(68,'','Amb',1,0,NULL,NULL,NULL),(69,'','Anchura',1,1,NULL,'cm',NULL),(70,'','Hueco interior',1,0,NULL,NULL,NULL),(71,'','Tamaño',1,0,NULL,NULL,NULL),(72,'','Color botón',1,0,NULL,NULL,NULL),(73,'','Tamaño minimo del botón',1,0,NULL,NULL,NULL),(74,'','Obtentor',1,0,NULL,NULL,NULL),(75,'','Longitud del brote',1,0,NULL,NULL,NULL),(76,'','Tallos / u.v.',1,0,NULL,NULL,NULL),(77,'','Madera de',1,0,NULL,NULL,NULL),(78,'','Unidad de venta',1,0,NULL,NULL,NULL),(79,'','Temporal',1,0,NULL,NULL,NULL),(80,'','Gramaje/tallo',1,1,NULL,'g',NULL),(81,'','Peso/paquete',1,1,NULL,'g',NULL),(82,'','Flexibilidad del tallo',1,0,NULL,NULL,NULL),(83,'','Nº planchas',1,1,NULL,NULL,NULL),(84,'','Nº páginas',1,1,NULL,NULL,NULL),(85,'','Editorial',1,0,NULL,NULL,NULL),(86,'','Idioma',1,0,NULL,NULL,NULL),(87,'','Fecha publicación',1,0,NULL,NULL,NULL),(88,'','Cubierta',1,0,NULL,NULL,NULL),(89,'','Encuadernación',1,0,NULL,NULL,NULL),(90,'','Autor',1,0,NULL,NULL,NULL),(91,'','Envoltorio',1,0,NULL,NULL,NULL),(92,'','Nombre temporal',1,0,NULL,NULL,NULL),(93,'','Modelo',1,0,NULL,NULL,NULL),(94,'','Producto',1,0,NULL,NULL,NULL),(95,'','Título',1,0,NULL,NULL,NULL),(96,'','Tomo',1,0,NULL,NULL,NULL),(97,'','Articulo',1,0,NULL,NULL,NULL),(98,'','Metodo de cultivo',1,0,NULL,NULL,NULL),(99,'','Edad',1,0,NULL,NULL,NULL),(100,'','Agotado',1,0,NULL,NULL,NULL),(101,'','Altura con asa',1,1,NULL,'cm',NULL),(102,'','Nº tallos',1,1,NULL,NULL,NULL),(103,'','Cultivo',1,0,NULL,NULL,NULL),(104,'','Sabor',1,0,NULL,NULL,NULL),(105,'','Talla',1,0,NULL,NULL,NULL),(106,'','Calibre',1,1,NULL,NULL,NULL),(107,'','Dulzura',1,1,NULL,'bx',NULL),(108,'','Piezas',1,0,NULL,NULL,NULL),(109,'','Altura con patas',1,0,NULL,NULL,NULL),(110,'','Envase',1,0,NULL,NULL,NULL),(111,'','Nº piezas',1,0,NULL,NULL,NULL),(112,'','Uso',1,0,NULL,'cm',NULL),(113,'','Color luz',1,0,NULL,NULL,NULL),(114,'','Capacidad',1,0,NULL,NULL,NULL); +INSERT INTO `tag` VALUES (1,'color','Color',0,0,'ink',NULL,NULL),(2,NULL,'Forma',1,0,NULL,NULL,NULL),(3,NULL,'Material',1,0,NULL,NULL,NULL),(4,NULL,'Longitud',1,1,NULL,'mm',NULL),(5,NULL,'Diámetro',1,1,NULL,'mm',NULL),(6,NULL,'Perímetro',1,1,NULL,'mm',NULL),(7,NULL,'Ancho de la base',1,1,NULL,'mm',NULL),(8,NULL,'Altura',1,1,NULL,'mm',NULL),(9,NULL,'Volumen',1,1,NULL,'ml',NULL),(10,NULL,'Densidad',1,1,NULL,NULL,NULL),(11,NULL,'Calidad',1,0,NULL,NULL,NULL),(12,NULL,'Textura',1,0,NULL,NULL,NULL),(13,NULL,'Material del mango',1,0,NULL,NULL,NULL),(14,NULL,'Compra mínima',1,0,NULL,NULL,NULL),(15,NULL,'Nº pétalos',1,1,NULL,NULL,NULL),(16,NULL,'Ancho',1,1,NULL,'mm',NULL),(18,NULL,'Profundidad',1,1,NULL,'mm',NULL),(19,NULL,'Largo',1,1,NULL,'mm',NULL),(20,NULL,'Ancho superior',1,1,NULL,'mm',NULL),(21,NULL,'Ancho inferior',1,1,NULL,'mm',NULL),(22,NULL,'Gramaje',1,1,NULL,'g',NULL),(23,'stems','Tallos',1,1,NULL,NULL,NULL),(24,NULL,'Estado',1,0,NULL,NULL,NULL),(25,NULL,'Color principal',0,0,'ink',NULL,NULL),(26,NULL,'Color secundario',0,0,'ink',NULL,NULL),(27,NULL,'Longitud(cm)',1,1,NULL,'cm',NULL),(28,NULL,'Diámetro base',1,1,'','mm',NULL),(29,NULL,'Colección',1,0,NULL,NULL,NULL),(30,NULL,'Uds / caja',1,1,NULL,NULL,NULL),(31,NULL,'Contenido',1,0,NULL,NULL,NULL),(32,NULL,'Peso',1,1,NULL,'g',NULL),(33,NULL,'Grosor',1,1,NULL,'mm',NULL),(34,NULL,'Marca',1,0,NULL,NULL,NULL),(35,'origin','Origen',0,0,'origin',NULL,NULL),(36,NULL,'Proveedor',1,0,NULL,NULL,NULL),(37,'producer','Productor',0,0,'producer',NULL,NULL),(38,NULL,'Duración',1,1,NULL,'s',NULL),(39,NULL,'Flor',1,0,NULL,NULL,NULL),(40,NULL,'Soporte',1,0,NULL,NULL,NULL),(41,NULL,'Tamaño flor',1,0,NULL,NULL,NULL),(42,NULL,'Apertura',1,0,NULL,NULL,NULL),(43,NULL,'Tallo',1,0,NULL,NULL,NULL),(44,NULL,'Nº hojas',1,1,NULL,NULL,NULL),(45,NULL,'Dimensiones',1,0,NULL,NULL,NULL),(46,NULL,'Diámetro boca',1,1,NULL,'mm',NULL),(47,NULL,'Nº flores',1,1,NULL,NULL,NULL),(48,NULL,'Uds / paquete',1,1,NULL,NULL,NULL),(49,NULL,'Maceta',1,1,NULL,'cm',NULL),(50,NULL,'Textura flor',1,0,NULL,NULL,NULL),(51,NULL,'Textura hoja',1,0,NULL,NULL,NULL),(52,NULL,'Tipo de IVA',1,0,NULL,NULL,NULL),(53,NULL,'Tronco',1,0,NULL,NULL,NULL),(54,NULL,'Hoja',1,0,NULL,NULL,NULL),(55,NULL,'Formato',1,0,NULL,NULL,NULL),(56,NULL,'Genero',1,0,NULL,NULL,NULL),(57,NULL,'Especie',1,0,NULL,NULL,NULL),(58,NULL,'Variedad',1,0,NULL,NULL,NULL),(59,NULL,'Medida grande',1,0,NULL,NULL,NULL),(60,NULL,'Medida mediano',1,0,NULL,NULL,NULL),(61,NULL,'Medida pequeño',1,0,NULL,NULL,NULL),(63,NULL,'Recipiente interior',1,0,NULL,NULL,NULL),(64,NULL,'Material secundario',1,0,NULL,NULL,NULL),(65,NULL,'Colores',1,0,NULL,NULL,NULL),(66,NULL,'Referencia',1,0,NULL,NULL,NULL),(67,NULL,'Categoria',1,0,NULL,NULL,NULL),(68,NULL,'Amb',1,0,NULL,NULL,NULL),(69,NULL,'Anchura',1,1,NULL,'cm',NULL),(70,NULL,'Hueco interior',1,0,NULL,NULL,NULL),(71,NULL,'Tamaño',1,0,NULL,NULL,NULL),(72,NULL,'Color botón',1,0,NULL,NULL,NULL),(73,NULL,'Tamaño minimo del botón',1,0,NULL,NULL,NULL),(74,NULL,'Obtentor',1,0,NULL,NULL,NULL),(75,NULL,'Longitud del brote',1,0,NULL,NULL,NULL),(76,NULL,'Tallos / u.v.',1,0,NULL,NULL,NULL),(77,NULL,'Madera de',1,0,NULL,NULL,NULL),(78,NULL,'Unidad de venta',1,0,NULL,NULL,NULL),(79,NULL,'Temporal',1,0,NULL,NULL,NULL),(80,NULL,'Gramaje/tallo',1,1,NULL,'g',NULL),(81,NULL,'Peso/paquete',1,1,NULL,'g',NULL),(82,NULL,'Flexibilidad del tallo',1,0,NULL,NULL,NULL),(83,NULL,'Nº planchas',1,1,NULL,NULL,NULL),(84,NULL,'Nº páginas',1,1,NULL,NULL,NULL),(85,NULL,'Editorial',1,0,NULL,NULL,NULL),(86,NULL,'Idioma',1,0,NULL,NULL,NULL),(87,NULL,'Fecha publicación',1,0,NULL,NULL,NULL),(88,NULL,'Cubierta',1,0,NULL,NULL,NULL),(89,NULL,'Encuadernación',1,0,NULL,NULL,NULL),(90,NULL,'Autor',1,0,NULL,NULL,NULL),(91,NULL,'Envoltorio',1,0,NULL,NULL,NULL),(92,NULL,'Nombre temporal',1,0,NULL,NULL,NULL),(93,NULL,'Modelo',1,0,NULL,NULL,NULL),(94,NULL,'Producto',1,0,NULL,NULL,NULL),(95,NULL,'Título',1,0,NULL,NULL,NULL),(96,NULL,'Tomo',1,0,NULL,NULL,NULL),(97,NULL,'Articulo',1,0,NULL,NULL,NULL),(98,NULL,'Metodo de cultivo',1,0,NULL,NULL,NULL),(99,NULL,'Edad',1,0,NULL,NULL,NULL),(100,NULL,'Agotado',1,0,NULL,NULL,NULL),(101,NULL,'Altura con asa',1,1,NULL,'cm',NULL),(102,NULL,'Nº tallos',1,1,NULL,NULL,NULL),(103,NULL,'Cultivo',1,0,NULL,NULL,NULL),(104,NULL,'Sabor',1,0,NULL,NULL,NULL),(105,NULL,'Talla',1,0,NULL,NULL,NULL),(106,NULL,'Calibre',1,1,NULL,NULL,NULL),(107,NULL,'Dulzura',1,1,NULL,'bx',NULL),(108,NULL,'Piezas',1,0,NULL,NULL,NULL),(109,NULL,'Altura con patas',1,0,NULL,NULL,NULL),(110,NULL,'Envase',1,0,NULL,NULL,NULL),(111,NULL,'Nº piezas',1,0,NULL,NULL,NULL),(112,NULL,'Uso',1,0,NULL,'cm',NULL),(113,NULL,'Color luz',1,0,NULL,NULL,NULL),(114,NULL,'Capacidad',1,0,NULL,NULL,NULL); /*!40000 ALTER TABLE `tag` ENABLE KEYS */; UNLOCK TABLES; @@ -307,7 +307,7 @@ UNLOCK TABLES; LOCK TABLES `department` WRITE; /*!40000 ALTER TABLE `department` DISABLE KEYS */; -INSERT INTO `department` VALUES (1,'VERDNATURA',1,2,763,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(22,'COMPRAS',3,4,NULL,72,596,2,5,0,0,0,0,NULL,'/',NULL),(23,'CAMARA',14,19,NULL,72,604,2,6,1,0,1,2,37,'/37/',NULL),(31,'INFORMATICA',5,6,NULL,72,127,3,9,0,0,0,0,NULL,'/','informatica'),(34,'CONTABILIDAD',7,8,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(35,'FINANZAS',9,10,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(36,'LABORAL',11,12,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(37,'PRODUCCION',13,46,NULL,72,230,3,11,1,0,0,14,NULL,'/',NULL),(38,'SACADO',20,21,NULL,72,230,4,14,1,0,1,0,37,'/37/',NULL),(39,'ENCAJADO',22,23,NULL,72,230,4,12,1,0,1,0,37,'/37/',NULL),(41,'ADMINISTRACION',47,48,NULL,72,599,3,8,0,0,0,0,NULL,'/',NULL),(43,'VENTAS',49,72,NULL,0,NULL,NULL,NULL,0,0,0,11,NULL,'/',NULL),(44,'GERENCIA',73,74,NULL,72,300,2,7,0,0,0,0,NULL,'/',NULL),(45,'LOGISTICA',75,76,NULL,72,596,3,19,0,0,0,0,NULL,'/',NULL),(46,'REPARTO',77,80,NULL,72,659,3,10,0,0,0,1,NULL,'/',NULL),(48,'ALMACENAJE',81,82,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(49,'PROPIEDAD',83,84,NULL,72,1008,1,1,0,0,0,0,NULL,'/',NULL),(52,'CARGA AEREA',85,86,NULL,72,163,4,28,0,0,0,0,NULL,'/',NULL),(53,'MARKETING Y COMUNICACIÓN',87,88,NULL,72,1238,0,0,0,0,0,0,NULL,'/',NULL),(54,'ORNAMENTALES',89,90,NULL,72,433,3,21,0,0,0,0,NULL,'/',NULL),(55,'TALLER NATURAL',91,92,NULL,72,695,2,23,0,0,0,0,NULL,'/',NULL),(56,'TALLER ARTIFICIAL',93,94,NULL,72,1780,2,24,0,0,0,0,NULL,'/',NULL),(58,'CAMPOS',95,96,NULL,72,225,2,2,0,0,0,0,NULL,'/',NULL),(59,'MANTENIMIENTO',97,98,NULL,72,1907,4,16,0,0,0,0,NULL,'/',NULL),(60,'RECLAMACIONES',99,100,NULL,72,563,3,20,0,0,0,0,NULL,'/',NULL),(61,'VNH',101,102,NULL,73,1297,3,17,0,0,0,0,NULL,'/',NULL),(63,'VENTAS FRANCIA',50,51,NULL,72,277,2,27,0,0,1,0,43,'/43/',NULL),(66,'VERDNAMADRID',103,104,NULL,72,163,3,18,0,0,0,0,NULL,'/',NULL),(68,'COMPLEMENTOS',24,25,NULL,72,617,3,26,1,0,1,0,37,'/37/',NULL),(69,'VERDNABARNA',105,106,NULL,74,432,3,22,0,0,0,0,NULL,'/',NULL),(77,'PALETIZADO',78,79,NULL,72,230,4,15,0,0,1,0,46,'/46/',NULL),(80,'EQUIPO J VALLES',52,53,NULL,72,693,3,4,0,0,1,0,43,'/43/','jvp_equipo'),(86,'LIMPIEZA',107,108,NULL,72,599,0,0,0,0,0,0,NULL,'/',NULL),(89,'COORDINACION',109,110,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(90,'TRAILER',111,112,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(91,'ARTIFICIAL',26,27,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(92,'EQUIPO SILVERIO',54,55,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','sdc_equipo'),(93,'CONFECCION',113,114,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(94,'EQUIPO J BROCAL',56,57,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jes_equipo'),(95,'EQUIPO C ZAMBRANO',58,59,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','czg_equipo'),(96,'EQUIPO C LOPEZ',60,61,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','cla_equipo'),(97,'EQUIPO D SARRION',62,63,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','dsr_equipo'),(98,'EQUIPO RODRIGO',64,65,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','rhr_equipo'),(99,'EQUIPO MANOLI',66,67,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','man_equipo'),(101,'EQUIPO J IBAÑEZ',68,69,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jmi_equipo'),(102,'EQ ROJO FV RUBEN C',28,29,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(103,'EQ AZUL FV A FOLQUES',30,31,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(104,'EQ AMARILLO FV NORMAN G',32,33,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(105,'EQ MORADO FV MATOU',34,35,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(106,'EQ VERDE PCA KEVIN GIMENEZ',36,37,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(107,'EQ NARANJA PCA RUBEN ZANON',38,39,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(110,'EQ ROSA PCA J BONDIA',40,41,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(111,'EQ REPONEDOR CAJAS',42,43,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(112,'CAMARA EQ EDGAR LLEO',15,16,NULL,0,NULL,NULL,NULL,0,0,2,0,23,'/37/23/',NULL),(113,'CAMARA EQ MARC ROCA',17,18,NULL,0,NULL,NULL,NULL,0,0,2,0,23,'/37/23/',NULL),(114,'EQ MARRON PCA JL NUEVO',44,45,NULL,0,NULL,NULL,NULL,0,0,1,0,37,'/37/',NULL),(115,'EQUIPO CLAUDI',70,71,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','csr_equipo'); +INSERT INTO `department` VALUES (1,'VERDNATURA',1,2,763,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(22,'COMPRAS',3,4,NULL,72,596,2,5,0,0,0,0,NULL,'/',NULL),(23,'CAMARA',14,19,NULL,72,604,2,6,1,0,1,2,37,'/37/',NULL),(31,'INFORMATICA',5,6,NULL,72,127,3,9,0,0,0,0,NULL,'/','informatica'),(34,'CONTABILIDAD',7,8,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(35,'FINANZAS',9,10,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(36,'LABORAL',11,12,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(37,'PRODUCCION',13,52,NULL,72,230,3,11,1,0,0,17,NULL,'/',NULL),(38,'SACADO',20,21,NULL,72,230,4,14,1,0,1,0,37,'/37/',NULL),(39,'ENCAJADO',22,23,NULL,72,230,4,12,1,0,1,0,37,'/37/',NULL),(41,'ADMINISTRACION',53,54,NULL,72,599,3,8,0,0,0,0,NULL,'/',NULL),(43,'VENTAS',55,78,NULL,0,NULL,NULL,NULL,0,0,0,11,NULL,'/',NULL),(44,'GERENCIA',79,80,NULL,72,300,2,7,0,0,0,0,NULL,'/',NULL),(45,'LOGISTICA',81,82,NULL,72,596,3,19,0,0,0,0,NULL,'/',NULL),(46,'REPARTO',83,86,NULL,72,659,3,10,0,0,0,1,NULL,'/',NULL),(48,'ALMACENAJE',87,88,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL),(49,'PROPIEDAD',89,90,NULL,72,1008,1,1,0,0,0,0,NULL,'/',NULL),(52,'CARGA AEREA',91,92,NULL,72,163,4,28,0,0,0,0,NULL,'/',NULL),(53,'MARKETING Y COMUNICACIÓN',93,94,NULL,72,1238,0,0,0,0,0,0,NULL,'/',NULL),(54,'ORNAMENTALES',95,96,NULL,72,433,3,21,0,0,0,0,NULL,'/',NULL),(55,'TALLER NATURAL',97,98,NULL,72,695,2,23,0,0,0,0,NULL,'/',NULL),(56,'TALLER ARTIFICIAL',99,100,NULL,72,1780,2,24,0,0,0,0,NULL,'/',NULL),(58,'CAMPOS',101,102,NULL,72,225,2,2,0,0,0,0,NULL,'/',NULL),(59,'MANTENIMIENTO',103,104,NULL,72,1907,4,16,0,0,0,0,NULL,'/',NULL),(60,'RECLAMACIONES',105,106,NULL,72,563,3,20,0,0,0,0,NULL,'/',NULL),(61,'VNH',107,108,NULL,73,1297,3,17,0,0,0,0,NULL,'/',NULL),(63,'VENTAS FRANCIA',56,57,NULL,72,277,2,27,0,0,1,0,43,'/43/',NULL),(66,'VERDNAMADRID',109,110,NULL,72,163,3,18,0,0,0,0,NULL,'/',NULL),(68,'COMPLEMENTOS',24,25,NULL,72,617,3,26,1,0,1,0,37,'/37/',NULL),(69,'VERDNABARNA',111,112,NULL,74,432,3,22,0,0,0,0,NULL,'/',NULL),(77,'PALETIZADO',84,85,NULL,72,230,4,15,1,0,1,0,46,'/46/',NULL),(80,'EQUIPO J VALLES',58,59,NULL,72,693,3,4,0,0,1,0,43,'/43/','jvp_equipo'),(86,'LIMPIEZA',113,114,NULL,72,599,0,0,0,0,0,0,NULL,'/',NULL),(89,'COORDINACION',115,116,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL),(90,'TRAILER',117,118,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(91,'ARTIFICIAL',26,27,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(92,'EQUIPO SILVERIO',60,61,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','sdc_equipo'),(93,'CONFECCION',119,120,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(94,'EQUIPO J BROCAL',62,63,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jes_equipo'),(95,'EQUIPO C ZAMBRANO',64,65,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','czg_equipo'),(96,'EQUIPO C LOPEZ',66,67,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','cla_equipo'),(97,'EQUIPO D SARRION',68,69,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','dsr_equipo'),(98,'EQUIPO RODRIGO',70,71,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','rhr_equipo'),(99,'EQUIPO MANOLI',72,73,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','man_equipo'),(101,'EQUIPO J IBAÑEZ',74,75,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jmi_equipo'),(102,'EQ ROJO FV RUBEN C',28,29,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(103,'EQ AZUL FV A FOLQUES',30,31,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(104,'EQ AMARILLO FV NORMAN G',32,33,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(105,'EQ MORADO FV MATOU',34,35,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(106,'EQ VERDE PCA KEVIN GIMENEZ',36,37,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(107,'EQ NARANJA PCA RUBEN ZANON',38,39,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(110,'EQ ROSA PCA J BONDIA',40,41,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(111,'EQ REPONEDOR CAJAS',42,43,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(112,'CAMARA EQ EDGAR LLEO',15,16,NULL,0,NULL,NULL,NULL,1,0,2,0,23,'/37/23/',NULL),(113,'CAMARA EQ MARC ROCA',17,18,NULL,0,NULL,NULL,NULL,1,0,2,0,23,'/37/23/',NULL),(114,'EQ MARRON PCA JL NUEVO',44,45,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(115,'EQUIPO CLAUDI',76,77,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','csr_equipo'),(120,'PCA PRODUCCION',46,47,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(121,'FV PRODUCCION',48,49,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL),(122,'PCA ALMACEN',50,51,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL); /*!40000 ALTER TABLE `department` ENABLE KEYS */; UNLOCK TABLES; @@ -317,7 +317,7 @@ UNLOCK TABLES; LOCK TABLES `component` WRITE; /*!40000 ALTER TABLE `component` DISABLE KEYS */; -INSERT INTO `component` VALUES (10,'Precios Especiales',4,NULL,NULL,1,'specialPrices'),(14,'porte extra por dia semana',6,NULL,NULL,1,'extraCostPerWeekDay'),(15,'reparto',6,NULL,NULL,1,'delivery'),(17,'recobro',5,NULL,NULL,1,'debtCollection'),(21,'ajuste',12,NULL,NULL,1,'adjustment'),(22,'venta por paquete',9,1,NULL,0,'salePerPackage'),(23,'venta por caja',9,2,NULL,0,'salePerBox'),(28,'valor de compra',1,NULL,NULL,1,'purchaseValue'),(29,'margen',4,NULL,NULL,1,'margin'),(32,'descuento ultimas unidades',9,3,-0.05,0,'lastUnitsDiscount'),(33,'venta por caja',9,1,NULL,0,'salePerBox'),(34,'descuento comprador',4,NULL,NULL,1,'buyerDiscount'),(35,'cartera comprador',10,NULL,NULL,1,NULL),(36,'descuadre',11,NULL,NULL,1,'imbalance'),(37,'maná',7,4,NULL,0,'mana'),(38,'embolsado',9,NULL,NULL,1,'bagged'),(39,'maná auto',7,NULL,NULL,1,'autoMana'),(40,'cambios Santos 2016',4,NULL,NULL,1,NULL),(41,'bonificacion porte',4,NULL,NULL,1,'freightCharge'); +INSERT INTO `component` VALUES (10,'Precios Especiales',4,NULL,NULL,1,'specialPrices'),(14,'porte extra por dia semana',6,NULL,NULL,1,'extraCostPerWeekDay'),(15,'reparto',6,NULL,NULL,1,'delivery'),(17,'recobro',5,NULL,NULL,1,'debtCollection'),(21,'ajuste',11,NULL,NULL,1,'adjustment'),(22,'venta por paquete',9,1,NULL,0,'salePerPackage'),(23,'venta por caja',9,2,NULL,0,'salePerBox'),(28,'valor de compra',1,NULL,NULL,1,'purchaseValue'),(29,'margen',4,NULL,NULL,1,'margin'),(32,'descuento ultimas unidades',9,3,-0.05,0,'lastUnitsDiscount'),(33,'venta por caja',9,1,NULL,0,'salePerBox'),(34,'descuento comprador',4,NULL,NULL,1,'buyerDiscount'),(35,'cartera comprador',10,NULL,NULL,1,NULL),(36,'descuadre',12,NULL,NULL,1,'imbalance'),(37,'maná',7,4,NULL,0,'mana'),(38,'embolsado',9,NULL,NULL,1,'bagged'),(39,'maná auto',7,NULL,NULL,1,'autoMana'),(40,'cambios Santos 2016',4,NULL,NULL,1,NULL),(41,'bonificacion porte',4,NULL,NULL,1,'freightCharge'); /*!40000 ALTER TABLE `component` ENABLE KEYS */; UNLOCK TABLES; @@ -327,7 +327,7 @@ UNLOCK TABLES; LOCK TABLES `componentType` WRITE; /*!40000 ALTER TABLE `componentType` DISABLE KEYS */; -INSERT INTO `componentType` VALUES (1,'coste',1,0),(2,'com ventas',1,1),(3,'com compras',1,1),(4,'empresa',1,1),(5,'cliente',0,0),(6,'agencia',0,0),(7,'cartera_comercial',0,1),(8,'cartera_producto',0,1),(9,'maniobra',1,1),(10,'cartera_comprador',0,1),(11,'errores',0,1),(12,'otros',0,1); +INSERT INTO `componentType` VALUES (1,'coste',1,0),(2,'com ventas',1,1),(3,'com compras',1,1),(4,'empresa',1,1),(5,'cliente',0,0),(6,'agencia',0,0),(7,'cartera_comercial',0,0),(8,'cartera_producto',0,1),(9,'maniobra',1,1),(10,'cartera_comprador',0,1),(11,'errores',0,1),(12,'otros',0,1); /*!40000 ALTER TABLE `componentType` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -340,7 +340,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-06-02 12:15:16 +-- Dump completed on 2020-06-23 8:08:02 USE `cache`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -378,7 +378,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-06-02 12:15:17 +-- Dump completed on 2020-06-23 8:08:02 USE `hedera`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -436,7 +436,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-06-02 12:15:18 +-- Dump completed on 2020-06-23 8:08:03 USE `postgresql`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -511,7 +511,7 @@ UNLOCK TABLES; LOCK TABLES `workcenter` WRITE; /*!40000 ALTER TABLE `workcenter` DISABLE KEYS */; -INSERT INTO `workcenter` VALUES (1,'Silla',20,1034,1,'Av espioca 100',552703),(2,'Mercaflor',19,NULL,NULL,NULL,NULL),(3,'Marjales',26,20008,NULL,NULL,NULL),(4,'VNH',NULL,NULL,3,NULL,NULL),(5,'Madrid',28,2852,5,'Av constitución 3',554145),(6,'Vilassar',88,88031,2,'Cami del Crist, 33',556412),(7,'Tenerife',NULL,NULL,10,NULL,NULL); +INSERT INTO `workcenter` VALUES (1,'Silla',20,1037,1,'Av espioca 100',552703),(2,'Mercaflor',19,NULL,NULL,NULL,NULL),(3,'Marjales',26,20008,NULL,NULL,NULL),(4,'VNH',NULL,NULL,3,NULL,NULL),(5,'Madrid',28,2852,5,'Av constitución 3',554145),(6,'Vilassar',88,88031,2,'Cami del Crist, 33',556412),(7,'Tenerife',NULL,NULL,10,NULL,NULL); /*!40000 ALTER TABLE `workcenter` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -524,4 +524,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-06-02 12:15:20 +-- Dump completed on 2020-06-23 8:08:05 diff --git a/db/dump/structure.sql b/db/dump/structure.sql index 69c9f85e4..95b056f3c 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -4396,6 +4396,41 @@ BEGIN END WHILE; +/* + +call bs.produccion_launcher('2018-01-01', '2018-02-01'); +call bs.produccion_launcher('2018-02-01', '2018-03-01'); +call bs.produccion_launcher('2018-03-01', '2018-04-01'); +call bs.produccion_launcher('2018-04-01', '2018-05-01'); +call bs.produccion_launcher('2018-05-01', '2018-06-01'); +call bs.produccion_launcher('2018-06-01', '2018-07-01'); +call bs.produccion_launcher('2018-07-01', '2018-08-01'); +call bs.produccion_launcher('2018-08-01', '2018-09-01'); +call bs.produccion_launcher('2018-09-01', '2018-10-01'); +call bs.produccion_launcher('2018-10-01', '2018-11-01'); +call bs.produccion_launcher('2018-11-01', '2018-12-01'); +call bs.produccion_launcher('2018-12-01', '2019-01-01'); + +call bs.produccion_launcher('2019-01-01', '2019-02-01'); +call bs.produccion_launcher('2019-02-01', '2019-03-01'); +call bs.produccion_launcher('2019-03-01', '2019-04-01'); +call bs.produccion_launcher('2019-04-01', '2019-05-01'); +call bs.produccion_launcher('2019-05-01', '2019-06-01'); +call bs.produccion_launcher('2019-06-01', '2019-07-01'); +call bs.produccion_launcher('2019-07-01', '2019-08-01'); +call bs.produccion_launcher('2019-08-01', '2019-09-01'); +call bs.produccion_launcher('2019-09-01', '2019-10-01'); +call bs.produccion_launcher('2019-10-01', '2019-11-01'); +call bs.produccion_launcher('2019-11-01', '2019-12-01'); +call bs.produccion_launcher('2019-12-01', '2020-01-01'); + +call bs.produccion_launcher('2020-01-01', '2020-02-01'); +call bs.produccion_launcher('2020-02-01', '2020-03-01'); +call bs.produccion_launcher('2020-03-01', '2020-04-01'); +call bs.produccion_launcher('2020-04-01', '2020-05-01'); +call bs.produccion_launcher('2020-05-01', '2020-06-01'); +call bs.produccion_launcher('2020-06-01', '2020-07-01'); +*/ END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -7667,6 +7702,23 @@ CREATE TABLE `item_group` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='/tmp/floricode/florecompc2/FO130916.txt'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `item_groupToOffer` +-- + +DROP TABLE IF EXISTS `item_groupToOffer`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `item_groupToOffer` ( + `group_code` int(11) unsigned NOT NULL, + `itemTypeFk` smallint(5) unsigned NOT NULL, + `intrastatFk` int(8) unsigned zerofill NOT NULL, + `originFk` tinyint(2) unsigned NOT NULL DEFAULT '17', + `expenseFk` varchar(10) COLLATE utf8_unicode_ci DEFAULT '6001000001', + PRIMARY KEY (`group_code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='se ofreceran para ser comprados'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `item_track` -- @@ -7742,6 +7794,7 @@ CREATE TABLE `marketPlace` ( `id` varchar(13) COLLATE utf8_unicode_ci NOT NULL, `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, `supplierFk` int(11) NOT NULL DEFAULT '1433', + `IsOffered` tinyint(2) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -7799,7 +7852,7 @@ CREATE TABLE `putOrder` ( `OrderTradeLineDateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'fecha de creacion en la tabla', `quantity` int(11) DEFAULT NULL, `EndUserPartyID` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `EndUserPartyGLN` varchar(13) COLLATE utf8_unicode_ci DEFAULT NULL, + `EndUserPartyGLN` varchar(13) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'The grower can use this reference in his EKT in the NAD (MA) segment.', `OrderStatus` int(11) DEFAULT '0' COMMENT '1 pending\n2 confirmed\n3 canceled', `isOrderProcessed` tinyint(4) DEFAULT NULL, PRIMARY KEY (`id`), @@ -8238,7 +8291,7 @@ BEGIN ,Productor ,Etiquetas ,Id_Cubo - ,weight + ,`weight` ) SELECT cfg.edi_entry @@ -8252,7 +8305,7 @@ BEGIN ,s.company_name ,e.qty ,IFNULL(c.Id_Cubo, e.package) - , a.density * (vn.item_getVolume(a.Id_Article, IFNULL(c.Id_Cubo, e.package))/ 1000000) + ,a.density * (vn.item_getVolume(a.Id_Article, IFNULL(c.Id_Cubo, e.package)) / 1000000) FROM vn2008.buy_edi e LEFT JOIN vn2008.Compres c ON c.Id_Compra = vBuy LEFT JOIN vn2008.Articles a ON a.Id_Article = c.Id_Article @@ -11351,7 +11404,7 @@ BEGIN SELECT id ticketFk FROM myTicket WHERE id = vSelf; - CALL vn.ticketGetTax; + CALL vn.ticket_getTax(NULL); SELECT IFNULL(SUM(taxableBase), 0.0), IFNULL(SUM(tax), 0.0) INTO vTaxBase, vTax @@ -11978,9 +12031,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -12091,11 +12144,8 @@ BEGIN LEAVE lDates; END IF; - IF vShipment IS NULL THEN - CALL util.throw ('ZONE_CLOSED'); - END IF; - -- Busca un ticket existente que coincida con los parametros + SELECT t.id INTO vTicket FROM vn.ticket t LEFT JOIN vn.ticketState tls on tls.ticket = t.id @@ -12162,18 +12212,18 @@ BEGIN IF vDone THEN LEAVE lRows; END IF; - SET vSale = NULL; - SELECT s.id INTO vSale + SET vSale = NULL; + SELECT s.id INTO vSale FROM vn.sale s - WHERE ticketFk = vTicket + WHERE ticketFk = vTicket AND price = vPrice - AND itemFk = vItem + AND itemFk = vItem LIMIT 1; IF vSale THEN UPDATE vn.sale SET quantity = quantity + vAmount WHERE id = vSale; - ELSE + ELSE INSERT INTO vn.sale SET itemFk = vItem, @@ -14924,6 +14974,7 @@ CREATE TABLE `calendar_state` ( `isAllowedToWork` tinyint(4) NOT NULL DEFAULT '0', `isPrintable` tinyint(1) NOT NULL DEFAULT '0', `discountRate` decimal(3,2) DEFAULT NULL, + `holidayEntitlementRate` decimal(3,2) DEFAULT '1.00', PRIMARY KEY (`calendar_state_id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -15673,7 +15724,7 @@ CREATE TABLE `log` ( `tableId` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `tableName` (`tableName`,`tableId`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17883,6 +17934,34 @@ 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 `time_createTable` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `time_createTable`(vStarted DATE, vEnded DATE) +BEGIN + DECLARE vCurrentDate DATE; + + DROP TEMPORARY TABLE IF EXISTS tmp.time; + CREATE TEMPORARY TABLE tmp.time (dated DATE PRIMARY KEY) ENGINE = MEMORY; + SET vCurrentDate = vStarted; + WHILE vCurrentDate <= vEnded DO + INSERT INTO tmp.time (dated) VALUES (vCurrentDate); + SET vCurrentDate = DATE_ADD(vCurrentDate, INTERVAL 1 DAY); + 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 `warn` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -18014,6 +18093,7 @@ CREATE TABLE `XDiario` ( `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `updated` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `FECREGCON` date DEFAULT NULL, + `enlazadoSage` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `empresa_id` (`empresa_id`), KEY `ASIENidx` (`id`,`ASIEN`), @@ -18093,7 +18173,8 @@ SET character_set_client = utf8; 1 AS `id`, 1 AS `name`, 1 AS `rgb`, - 1 AS `code`*/; + 1 AS `code`, + 1 AS `holidayEntitlementRate`*/; SET character_set_client = @saved_cs_client; -- @@ -18161,14 +18242,14 @@ CREATE TABLE `address` ( `nickname` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL, `isDefaultAddress` tinyint(1) NOT NULL DEFAULT '0', `agencyModeFk` int(11) NOT NULL DEFAULT '2', - `notes` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `hasInsurance` tinyint(1) NOT NULL DEFAULT '0', - `porte` double DEFAULT NULL, + `notes__` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `hasInsurance__` tinyint(1) NOT NULL DEFAULT '0', + `porte__` double DEFAULT NULL, `isActive` tinyint(4) NOT NULL DEFAULT '1', - `postcodeOLD` int(11) unsigned DEFAULT NULL, + `postcodeOLD__` int(11) unsigned DEFAULT NULL, `longitude` decimal(11,7) DEFAULT NULL, `latitude` decimal(11,7) DEFAULT NULL, - `codPosOld` char(5) COLLATE utf8_unicode_ci DEFAULT NULL, + `codPosOld__` char(5) COLLATE utf8_unicode_ci DEFAULT NULL, `isEqualizated` tinyint(1) DEFAULT NULL, `customsAgentFk` int(11) DEFAULT NULL, `incotermsFk` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, @@ -18429,6 +18510,24 @@ SET character_set_client = utf8; 1 AS `isVolumetric`*/; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `agencyTerm` +-- + +DROP TABLE IF EXISTS `agencyTerm`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `agencyTerm` ( + `agencyFk` smallint(5) unsigned NOT NULL, + `minimumPackages` int(11) DEFAULT NULL COMMENT 'numero minimo de bultos', + `kmPrice` decimal(10,2) DEFAULT NULL COMMENT 'precio extra por km', + `packagePrice` decimal(10,2) DEFAULT NULL COMMENT 'precio extra por bulto', + `routePrice` decimal(10,2) DEFAULT NULL COMMENT 'precio fijo por ruta', + `minimumKm` int(11) DEFAULT NULL, + PRIMARY KEY (`agencyFk`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `alertLevel` -- @@ -18554,7 +18653,7 @@ DROP TABLE IF EXISTS `bank`; CREATE TABLE `bank` ( `id` int(11) NOT NULL DEFAULT '0', `bank` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `account` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, + `account` varchar(10) CHARACTER SET utf8 DEFAULT NULL, `cash` smallint(6) NOT NULL DEFAULT '0', `entityFk` int(10) unsigned NOT NULL, `isActive` tinyint(4) NOT NULL DEFAULT '1', @@ -19088,6 +19187,7 @@ CREATE TABLE `claim` ( `isChargedToMana` tinyint(1) NOT NULL DEFAULT '0', `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `ticketFk` int(11) DEFAULT NULL, + `hasToPickUp` tinyint(1) NOT NULL, PRIMARY KEY (`id`), KEY `cl_dep_id` (`claimDepartmentFk`), KEY `cl_est_id` (`claimStateFk`), @@ -19373,8 +19473,10 @@ DROP TABLE IF EXISTS `claimState`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `claimState` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `code` varchar(45) CHARACTER SET utf8 DEFAULT NULL, `description` varchar(15) COLLATE utf8_unicode_ci NOT NULL, `roleFk` int(10) unsigned NOT NULL DEFAULT '1', + `priority` int(11) NOT NULL DEFAULT '1', PRIMARY KEY (`id`), KEY `roleFgn_idx` (`roleFk`), CONSTRAINT `roleFgn` FOREIGN KEY (`roleFk`) REFERENCES `account`.`role` (`id`) ON UPDATE CASCADE @@ -19404,7 +19506,7 @@ CREATE TABLE `client` ( `isOfficial` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'obsoleta (comprobar)', `isTaxDataChecked` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Deprecated', `mobile` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, - `accountingAccount` varchar(10) COLLATE utf8_unicode_ci NOT NULL, + `accountingAccount` varchar(10) CHARACTER SET utf8 NOT NULL, `isEqualizated` tinyint(1) NOT NULL DEFAULT '0', `city` varchar(25) COLLATE utf8_unicode_ci DEFAULT NULL, `provinceFk` smallint(5) unsigned DEFAULT NULL, @@ -20087,6 +20189,7 @@ CREATE TABLE `company` ( `isDefaulter` tinyint(4) NOT NULL DEFAULT '0', `companyGroupFk` int(11) NOT NULL DEFAULT '1' COMMENT 'usado para calcular los greuges ', `companyCode` int(2) DEFAULT NULL COMMENT 'Campo para movConta', + `companyCodeTest` int(2) DEFAULT NULL, `footnotes` longtext COLLATE utf8_unicode_ci COMMENT 'pie de paginas en las facturas', `phytosanitary` longtext COLLATE utf8_unicode_ci, PRIMARY KEY (`id`), @@ -21115,7 +21218,7 @@ CREATE TABLE `dms` ( `dmsTypeFk` int(11) NOT NULL DEFAULT '1', `reference` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, `description` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL, - `companyFk` smallint(5) unsigned NOT NULL DEFAULT '791', + `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', `hardCopyNumber` mediumint(8) unsigned DEFAULT NULL, `contentType` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, `file` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL, @@ -21522,9 +21625,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -21578,7 +21681,7 @@ BEGIN INSERT INTO entryLog SET action = 'update', description = 'Cambia a Contabilizada', - userFk = myWorker_getId(), + userFk = account.myUserGetId(), originFk = NEW.id; END IF; END */;; @@ -22271,7 +22374,8 @@ SET character_set_client = utf8; 1 AS `route`, 1 AS `scans`, 1 AS `destinos`, - 1 AS `fallos`*/; + 1 AS `fallos`, + 1 AS `expeditionTruckFk`*/; SET character_set_client = @saved_cs_client; -- @@ -22282,9 +22386,9 @@ DROP TABLE IF EXISTS `expence`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `expence` ( - `id` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, + `id` varchar(10) NOT NULL, `taxTypeFk` tinyint(4) NOT NULL, - `name` varchar(50) DEFAULT NULL, + `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, `isConbase` tinyint(4) NOT NULL DEFAULT '1', `isWithheld` tinyint(4) NOT NULL DEFAULT '0', `isForSale` tinyint(4) NOT NULL DEFAULT '0', @@ -22899,14 +23003,13 @@ CREATE TABLE `invoiceOutExpence` ( `id` int(11) NOT NULL AUTO_INCREMENT, `invoiceOutFk` int(10) unsigned NOT NULL, `amount` decimal(10,2) NOT NULL DEFAULT '0.00', - `expenceFk` varchar(10) COLLATE utf8_unicode_ci NOT NULL, + `expenceFk` varchar(10) CHARACTER SET utf8 NOT NULL, `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), - UNIQUE KEY `invoiceOutExpence_restriccion` (`expenceFk`,`invoiceOutFk`), KEY `invoiceOutExpence_FK_1_idx` (`invoiceOutFk`), KEY `invoiceOutExpence_FK_2_idx` (`expenceFk`), CONSTRAINT `invoiceOutExpence_FK_1` FOREIGN KEY (`invoiceOutFk`) REFERENCES `invoiceOut` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `invoiceOutExpence_FK_2` FOREIGN KEY (`expenceFk`) REFERENCES `expence` (`id`) ON UPDATE CASCADE + CONSTRAINT `invoiceOutExpence_expenceFk` FOREIGN KEY (`expenceFk`) REFERENCES `expence` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Desglosa la base imponible de una factura en funcion del tipo de gasto/venta'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -22976,7 +23079,7 @@ CREATE TABLE `item` ( `category` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, `originFk` tinyint(2) unsigned NOT NULL, `doPhoto` tinyint(4) NOT NULL DEFAULT '0', - `image` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `image` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `inkFk` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, `niche` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, `intrastatFk` int(8) unsigned zerofill NOT NULL DEFAULT '06039010', @@ -22991,7 +23094,7 @@ CREATE TABLE `item` ( `description` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `density` int(11) NOT NULL DEFAULT '167' COMMENT 'Almacena la densidad en kg/m3 para el calculo de los portes, si no se especifica se pone por defecto la del tipo en un trigger', `relevancy` tinyint(1) NOT NULL DEFAULT '0', - `expenceFk` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT '7001000000', + `expenceFk` varchar(10) CHARACTER SET utf8 NOT NULL DEFAULT '7001000000', `isActive` tinyint(1) NOT NULL DEFAULT '1', `longName` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `subName` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, @@ -23021,10 +23124,10 @@ CREATE TABLE `item` ( KEY `iva_group_id` (`taxClassFk`), KEY `tipo_id` (`typeFk`), KEY `producer_id` (`producerFk`), - KEY `expenceFk_idx` (`expenceFk`), KEY `ArticlesIsActive_idx` (`isActive`), KEY `item_ibfk_6_idx` (`sectorFk`), - CONSTRAINT `expenceFk` FOREIGN KEY (`expenceFk`) REFERENCES `expence` (`id`) ON UPDATE CASCADE, + KEY `item_expenceFk` (`expenceFk`), + CONSTRAINT `item_expenceFk` FOREIGN KEY (`expenceFk`) REFERENCES `expence` (`id`) ON UPDATE CASCADE, CONSTRAINT `item_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `origin` (`id`) ON UPDATE CASCADE, CONSTRAINT `item_ibfk_2` FOREIGN KEY (`intrastatFk`) REFERENCES `intrastat` (`id`) ON UPDATE CASCADE, CONSTRAINT `item_ibfk_4` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`id`) ON UPDATE CASCADE, @@ -24394,6 +24497,20 @@ CREATE TABLE `ledgerConfig` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `lungSize` +-- + +DROP TABLE IF EXISTS `lungSize`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `lungSize` ( + `hora` time DEFAULT NULL, + `size` decimal(5,0) DEFAULT NULL, + `dia` date NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `mail` -- @@ -24969,6 +25086,45 @@ CREATE TABLE `payMethod` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `pcs` +-- + +DROP TABLE IF EXISTS `pcs`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `pcs` ( + `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `routeFk` int(10) unsigned DEFAULT NULL, + `id` int(11) NOT NULL AUTO_INCREMENT, + `pallet` int(11) DEFAULT NULL, + `box` int(11) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `pcs_graf` +-- + +DROP TABLE IF EXISTS `pcs_graf`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `pcs_graf` ( + `id` int(11) NOT NULL DEFAULT '0', + `dia` date DEFAULT NULL, + `created` datetime DEFAULT NULL, + `box` decimal(4,0) DEFAULT NULL, + `pallet` decimal(2,0) DEFAULT NULL, + `routeFk` int(10) unsigned DEFAULT NULL, + `hh` int(11) DEFAULT NULL, + `mm` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `pcs_graf_index1` (`hh`), + KEY `pcs_graf_index2` (`mm`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `pedidosInternos` -- @@ -25078,6 +25234,20 @@ CREATE TABLE `pgcEqu` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Recoge las cuentas contables con recargo de equivalencia e identifica a la que corresponde al iva y la que corresponde al recargo'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `pgcMaster` +-- + +DROP TABLE IF EXISTS `pgcMaster`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `pgcMaster` ( + `code` varchar(10) COLLATE utf8_unicode_ci NOT NULL, + `description` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + PRIMARY KEY (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='tan solo tiene las cuentas de contaplus'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `plantpassport` -- @@ -25238,6 +25408,7 @@ CREATE TABLE `ppe` ( `groupFk` int(11) DEFAULT NULL, `account` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, `endowment` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, + `elementAccount` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, `nature` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL, `location` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL, `discharged` date DEFAULT NULL, @@ -25252,10 +25423,16 @@ CREATE TABLE `ppe` ( KEY `ppe_fk2_idx` (`planFk`), KEY `ppe_fk3_idx` (`groupFk`), KEY `ppe_fk4_idx` (`companyFk`), + KEY `ppe_fk5_idx` (`account`), + KEY `ppe_fk6` (`endowment`), + KEY `ppe_fk7` (`elementAccount`), CONSTRAINT `ppe_fk1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `ppe_fk2` FOREIGN KEY (`planFk`) REFERENCES `ppePlan` (`id`) ON UPDATE CASCADE, CONSTRAINT `ppe_fk3` FOREIGN KEY (`groupFk`) REFERENCES `ppeGroup` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `ppe_fk4` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE + CONSTRAINT `ppe_fk4` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE, + CONSTRAINT `ppe_fk5` FOREIGN KEY (`account`) REFERENCES `pgcMaster` (`code`) ON UPDATE CASCADE, + CONSTRAINT `ppe_fk6` FOREIGN KEY (`endowment`) REFERENCES `pgcMaster` (`code`) ON UPDATE CASCADE, + CONSTRAINT `ppe_fk7` FOREIGN KEY (`elementAccount`) REFERENCES `pgcMaster` (`code`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Property, plant & equipment\nInmvolizado, en español'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -25327,26 +25504,6 @@ CREATE TABLE `ppePlan` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Plan de amortizacion para la tabla ppe'; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `priceBuilderTag__` --- - -DROP TABLE IF EXISTS `priceBuilderTag__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `priceBuilderTag__` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `priceBuilderFk` int(11) NOT NULL, - `tagFk` int(11) NOT NULL, - `value` varchar(20) COLLATE utf8_unicode_ci NOT NULL, - PRIMARY KEY (`id`), - KEY `priceBuilderTag_fk1_idx` (`priceBuilderFk`), - KEY `priceBuilderTag_fk2_idx` (`tagFk`), - CONSTRAINT `priceBuilderTag_fk1` FOREIGN KEY (`priceBuilderFk`) REFERENCES `priceBuilder__` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `priceBuilderTag_fk2` FOREIGN KEY (`tagFk`) REFERENCES `tag` (`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 `priceBuilderWarehouse__` -- @@ -25850,6 +26007,49 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +-- +-- Table structure for table `recipe` +-- + +DROP TABLE IF EXISTS `recipe`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `recipe` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `itemFk` int(11) NOT NULL COMMENT 'bouquet al que hace referencia la receta', + `name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `size` int(10) unsigned DEFAULT NULL, + `originFk` tinyint(2) unsigned DEFAULT NULL, + `typeFk` smallint(5) unsigned DEFAULT NULL, + `longName` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `quantity` int(11) NOT NULL DEFAULT '1', + `element` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `inkFk` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `recipe_ix_1` (`element`), + KEY `recipe_ix_2` (`itemFk`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `recipe_log` +-- + +DROP TABLE IF EXISTS `recipe_log`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `recipe_log` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `recipe_ItemFk` int(11) NOT NULL, + `element` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `selected_ItemFk` int(11) NOT NULL, + PRIMARY KEY (`id`), + KEY `recipe_log_ix1` (`recipe_ItemFk`), + KEY `recipe_log_ix2` (`element`), + KEY `recipe_log_ix3` (`selected_ItemFk`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena las decisiones tomadas al generar recetas'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `recovery` -- @@ -25957,15 +26157,18 @@ CREATE TABLE `route` ( `description` text COLLATE utf8_unicode_ci, `zoneFk` int(11) DEFAULT NULL, `priority` int(11) NOT NULL DEFAULT '0', + `invoiceInFk` mediumint(8) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `Id_Agencia` (`agencyModeFk`), KEY `Fecha` (`created`), KEY `gestdoc_id` (`gestdocFk`), KEY `route_ibfk_2_idx` (`workerFk`), KEY `fk_route_1_idx` (`zoneFk`), - CONSTRAINT `fk_route_1` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON UPDATE CASCADE, + KEY `asdfasdf_idx` (`invoiceInFk`), + CONSTRAINT `fk_route_1` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `route_ibfk_1` FOREIGN KEY (`gestdocFk`) REFERENCES `dms` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `route_ibfk_2` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE + CONSTRAINT `route_ibfk_2` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, + CONSTRAINT `route_invoiceInFk` FOREIGN KEY (`invoiceInFk`) REFERENCES `vn2008`.`recibida` (`id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -26695,7 +26898,7 @@ CREATE TABLE `sharingCart` ( `workerSubstitute` int(11) NOT NULL, `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), - KEY `Worker` (`workerFk`), + UNIQUE KEY `workerFk_UNIQUE` (`workerFk`,`started`,`ended`,`workerSubstitute`), KEY `Suplent` (`workerSubstitute`), CONSTRAINT `Suplent_key` FOREIGN KEY (`workerSubstitute`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `Trabajador_key` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE @@ -26704,18 +26907,22 @@ CREATE TABLE `sharingCart` ( /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`sharingCart_beforeInsert` BEFORE INSERT ON `sharingCart` FOR EACH ROW - BEGIN IF NEW.workerFk = NEW.workerSubstitute THEN CALL util.throw ('worker and workerSubstitute must be different'); - END IF; + ELSE + INSERT IGNORE INTO sharingCartDaily (ownerFk, substituteFk, dated) + SELECT NEW.workerFk, NEW.workerSubstitute, dated + FROM time + WHERE dated BETWEEN NEW.started AND NEW.ended; + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -26725,9 +26932,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -26735,7 +26942,39 @@ DELIMITER ;; BEGIN IF NEW.workerFk = NEW.workerSubstitute THEN CALL util.throw ('worker and workerSubstitute must be different'); - END IF; + ELSE + DELETE sc FROM sharingCartDaily sc + WHERE sc.dated BETWEEN OLD.started AND OLD.ended AND + sc.ownerFk = OLD.workerFk AND + sc.substituteFk = OLD.workerSubstitute; + + INSERT IGNORE INTO sharingCartDaily (ownerFk, substituteFk, dated) + SELECT NEW.workerFk, NEW.workerSubstitute, dated + FROM time + WHERE dated BETWEEN NEW.started AND NEW.ended; + + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`sharingCart_beforeDelete` BEFORE DELETE ON `sharingCart` FOR EACH ROW +BEGIN + DELETE sc FROM sharingCartDaily sc + WHERE sc.dated BETWEEN OLD.started AND OLD.ended AND + sc.ownerFk = OLD.workerFk AND + sc.substituteFk = OLD.workerSubstitute; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -27006,6 +27245,33 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; ALTER DATABASE `vn` CHARACTER SET utf8 COLLATE utf8_unicode_ci ; +-- +-- Table structure for table `sorter` +-- + +DROP TABLE IF EXISTS `sorter`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `sorter` ( + `id` int(11) NOT NULL DEFAULT '0', + `created` datetime NOT NULL, + `routeFk` int(10) unsigned NOT NULL, + `ticketFk` int(10) NOT NULL, + `isBox` int(11) DEFAULT '1', + `itemFk` int(11) DEFAULT NULL, + `width` decimal(10,2) DEFAULT '0.00', + `depth` decimal(10,2) DEFAULT '0.00', + `height` decimal(10,2) DEFAULT '0.00', + `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT '1', + `weight` decimal(5,2) NOT NULL DEFAULT '0.00', + `buildingOrder` int(5) NOT NULL DEFAULT '0', + `ETD` time NOT NULL DEFAULT '23:59:00', + `palletOrder` int(5) DEFAULT NULL, + `lungGrow` int(11) DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `specialPrice` -- @@ -27103,7 +27369,7 @@ DROP TABLE IF EXISTS `supplier`; CREATE TABLE `supplier` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, - `account` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, + `account` varchar(10) DEFAULT NULL, `street` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, `city` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, `provinceFk` smallint(5) unsigned DEFAULT NULL, @@ -27260,15 +27526,16 @@ DROP TABLE IF EXISTS `tag`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `tag` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `code` varchar(45) CHARACTER SET utf8 NOT NULL, - `name` varchar(25) CHARACTER SET utf8 NOT NULL, + `code` varchar(45) CHARACTER SET utf8 DEFAULT NULL, + `name` varchar(35) COLLATE utf8_unicode_ci NOT NULL, `isFree` tinyint(1) NOT NULL DEFAULT '1', `isQuantitatif` tinyint(4) NOT NULL DEFAULT '0', `sourceTable` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `unit` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `ediTypeFk` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), - KEY `tagEdiTypeFkIdx` (`ediTypeFk`), + UNIQUE KEY `tagNameIdx` (`name`,`ediTypeFk`), + UNIQUE KEY `tagEdiTypeFkIdx` (`ediTypeFk`), CONSTRAINT `fgnTag` FOREIGN KEY (`ediTypeFk`) REFERENCES `edi`.`type` (`type_id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Categorias para etiquetar los productos'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -27355,7 +27622,7 @@ DROP TABLE IF EXISTS `taxClassCode`; CREATE TABLE `taxClassCode` ( `taxClassFk` tinyint(3) unsigned NOT NULL, `effectived` date NOT NULL, - `taxCodeFk` tinyint(3) unsigned NOT NULL, + `taxCodeFk` int(10) unsigned NOT NULL, PRIMARY KEY (`taxClassFk`,`effectived`,`taxCodeFk`), KEY `iva_codigo_id` (`taxCodeFk`), CONSTRAINT `taxClassCode_ibfk_1` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`id`) ON UPDATE CASCADE, @@ -27371,7 +27638,7 @@ DROP TABLE IF EXISTS `taxCode`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `taxCode` ( - `id` tinyint(2) unsigned NOT NULL AUTO_INCREMENT, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `dated` date NOT NULL, `code` varchar(10) COLLATE utf8_unicode_ci NOT NULL, `taxTypeFk` tinyint(2) NOT NULL, @@ -27522,7 +27789,7 @@ BEGIN END IF; INSERT INTO vncontrol.inter(Id_Ticket, state_id, Id_Trabajador) - SELECT NEW.id, id, vn.myWorker_getId() + SELECT NEW.id, id, account.myUserGetId() FROM state WHERE `code` = vStateCode COLLATE utf8_general_ci; @@ -27901,7 +28168,7 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`ticketPackaging_BEFORE_INSERT` BEFORE INSERT ON `ticketPackaging` FOR EACH ROW BEGIN - SET NEW.workerFk = vn.myWorker_getId(); + SET NEW.workerFk = account.myUserGetId(); END */;; DELIMITER ; @@ -28098,7 +28365,7 @@ CREATE TABLE `ticketService` ( CONSTRAINT `fgn_ticketFk` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketServiceIvaGroup` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`id`) ON UPDATE CASCADE, CONSTRAINT `ticketService_ticketServiceType` FOREIGN KEY (`ticketServiceTypeFk`) REFERENCES `ticketServiceType` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Servicios asociadas a un ticket'; +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Servicios asociadas a un ticket'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28111,10 +28378,10 @@ DROP TABLE IF EXISTS `ticketServiceType`; CREATE TABLE `ticketServiceType` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `expenceFk` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '7001000000', + `expenceFk` varchar(10) NOT NULL DEFAULT '7001000000', PRIMARY KEY (`id`), - KEY `ticketServiceType_expence_idx` (`expenceFk`), - CONSTRAINT `ticketServiceType_expence` FOREIGN KEY (`expenceFk`) REFERENCES `expence` (`id`) ON UPDATE CASCADE + KEY `ticketServiceType_expenceFk` (`expenceFk`), + CONSTRAINT `ticketServiceType_expenceFk` FOREIGN KEY (`expenceFk`) REFERENCES `expence` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COMMENT='Lista de los posibles servicios a elegir'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -28215,9 +28482,12 @@ DROP TABLE IF EXISTS `ticketWeekly`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ticketWeekly` ( `ticketFk` int(11) NOT NULL AUTO_INCREMENT, - `weekDay` tinyint(1) DEFAULT NULL COMMENT 'funcion de mysql Lunes = 0, Domingo = 6', + `weekDay` tinyint(1) NOT NULL COMMENT 'funcion de mysql Lunes = 0, Domingo = 6', + `agencyModeFk` int(11) DEFAULT NULL, PRIMARY KEY (`ticketFk`), - CONSTRAINT `Id_Ticket_fk` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + KEY `agencyModeFk_idx` (`agencyModeFk`), + CONSTRAINT `Id_Ticket_fk` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `agencyModeFk` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -28592,7 +28862,7 @@ BEGIN THEN INSERT INTO vn2008.travel_dits SET idaccion_dits = 89, - Id_Trabajador = myWorker_getId(), + Id_Trabajador = account.myUserGetId(), Id_Ticket = NEW.id, value_old = OLD.isDelivered, value_new = NEW.isDelivered; @@ -28977,7 +29247,7 @@ CREATE TABLE `worker` ( `phone` varchar(9) COLLATE utf8_unicode_ci NOT NULL, `clientFk__` int(11) DEFAULT NULL, `userFk` int(10) unsigned DEFAULT NULL, - `bossFk` int(11) NOT NULL DEFAULT '2', + `bossFk` int(11) NOT NULL DEFAULT '103', `fiDueDate` datetime DEFAULT NULL, `hasMachineryAutorized` tinyint(2) DEFAULT '0', PRIMARY KEY (`id`), @@ -29048,19 +29318,19 @@ CREATE TABLE `workerClockLog` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `workerConfig` +-- Table structure for table `workerConfig__` -- -DROP TABLE IF EXISTS `workerConfig`; +DROP TABLE IF EXISTS `workerConfig__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `workerConfig` ( +CREATE TABLE `workerConfig__` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `defaultWorkerFk` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `defaultWorkerFk` (`defaultWorkerFk`), - CONSTRAINT `workerConfig_ibfk_1` FOREIGN KEY (`defaultWorkerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + CONSTRAINT `workerConfig___ibfk_1` FOREIGN KEY (`defaultWorkerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29207,6 +29477,11 @@ CREATE TABLE `workerLog` ( `action` set('insert','update','delete') COLLATE utf8_unicode_ci NOT NULL, `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `description` text COLLATE utf8_unicode_ci NOT NULL, + `changedModel` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `oldInstance` text COLLATE utf8_unicode_ci, + `newInstance` text COLLATE utf8_unicode_ci, + `changedModelId` int(11) DEFAULT NULL, + `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `workerFk_idx` (`originFk`), KEY `userFk_idx` (`userFk`), @@ -29665,6 +29940,28 @@ CREATE TABLE `workers20190711_FichadasOctubre` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `workers20190711_Garrote` +-- + +DROP TABLE IF EXISTS `workers20190711_Garrote`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `workers20190711_Garrote` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `person_id` int(11) NOT NULL DEFAULT '0', + `nif` varchar(15) CHARACTER SET utf8 DEFAULT NULL, + `Apellidos` varchar(60) CHARACTER SET utf8 NOT NULL, + `Nombre` varchar(20) CHARACTER SET utf8 DEFAULT NULL, + `Fecha` date DEFAULT NULL, + `Hora` int(2) DEFAULT NULL, + `Minuto` int(2) DEFAULT NULL, + `sumable` double DEFAULT NULL, + `jornada` decimal(5,2) NOT NULL DEFAULT '8.00', + PRIMARY KEY (`id`) +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `workingHours` -- @@ -29733,23 +30030,6 @@ CREATE TABLE `zone` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `zoneCalendar__` --- - -DROP TABLE IF EXISTS `zoneCalendar__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `zoneCalendar__` ( - `zoneFk` int(11) NOT NULL, - `delivered` date NOT NULL, - `price` double NOT NULL, - `bonus` double NOT NULL, - PRIMARY KEY (`zoneFk`,`delivered`), - CONSTRAINT `zoneFk` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `zoneClosure` -- @@ -29775,6 +30055,7 @@ DROP TABLE IF EXISTS `zoneConfig`; CREATE TABLE `zoneConfig` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `scope` int(10) unsigned NOT NULL, + `forwardDays` int(10) NOT NULL DEFAULT '7' COMMENT 'days forward to show zone_upcomingDeliveries', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -29920,6 +30201,25 @@ CREATE TABLE `zoneIncluded` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `zonePromo` +-- + +DROP TABLE IF EXISTS `zonePromo`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `zonePromo` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `zoneFk` int(11) NOT NULL, + `dated` date NOT NULL, + `amount` decimal(10,2) NOT NULL, + `isDone` tinyint(4) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + KEY `zonePromo_fk1_idx` (`zoneFk`), + CONSTRAINT `zonePromo_fk1` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `zoneWarehouse` -- @@ -32753,7 +33053,7 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; ALTER DATABASE `vn` CHARACTER SET utf8 COLLATE utf8_unicode_ci ; -/*!50003 DROP FUNCTION IF EXISTS `myWorker_getId` */; +/*!50003 DROP FUNCTION IF EXISTS `myWorker_getId__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -32763,7 +33063,7 @@ ALTER DATABASE `vn` CHARACTER SET utf8 COLLATE utf8_unicode_ci ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` FUNCTION `myWorker_getId`() RETURNS int(11) +CREATE DEFINER=`root`@`%` FUNCTION `myWorker_getId__`() RETURNS int(11) DETERMINISTIC BEGIN /** @@ -32775,7 +33075,7 @@ BEGIN DECLARE vWorker INT; SELECT w.id INTO vWorker - FROM worker w, workerConfig c + FROM worker w, workerConfig__ c WHERE w.userFk = account.userGetId(); RETURN vWorker; @@ -33195,6 +33495,46 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP FUNCTION IF EXISTS `ticket_getFreightCost` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` FUNCTION `ticket_getFreightCost`(vTicketFk INT) RETURNS decimal(10,2) + DETERMINISTIC +BEGIN +/** + * Devuelve el coste de transportar un ticket. + * + * @vTicketFk Id del ticket a calcular + */ + DECLARE deliveryPrice DECIMAL (10,2); + + IF (SELECT isVolumetric FROM ticket t JOIN zone z ON t.zoneFk = z.id + WHERE t.id = vTicketFk) THEN + SELECT SUM(sv.freight) INTO deliveryPrice + FROM vn.saleVolume sv + WHERE sv.ticketFk = vTicketFk; + ELSE + SELECT SUM((t.zonePrice - t.zoneBonus) * ebv.ratio) INTO deliveryPrice + FROM vn.ticket t + LEFT JOIN expedition e ON e.ticketFk = t.id + JOIN expeditionBoxVol ebv ON ebv.boxFk = e.isBox + WHERE t.id = vTicketFk; + + END IF; + RETURN deliveryPrice; +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 `till_new` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -33489,7 +33829,7 @@ BEGIN END IF; IF vBossId = vWorkerId THEN RETURN FALSE; - ELSEIF vBossId = vn.myWorker_getId() THEN + ELSEIF vBossId = account.myUserGetId() THEN RETURN TRUE; ELSE INSERT INTO tCheckedWorker VALUES (vWorkerId); @@ -34912,9 +35252,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -35044,7 +35384,7 @@ proc: BEGIN LEFT JOIN producer p ON p.id = i.producerFk AND p.isVisible JOIN origin o ON o.id = i.originFk JOIN ( - SELECT MIN(price) price, itemFk, priceKg + SELECT MAX(price) price, itemFk, priceKg FROM tmp.ticketComponentPrice WHERE warehouseFk = vWarehouseFk GROUP BY itemFk @@ -35211,6 +35551,7 @@ proc: BEGIN * @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) * * @return tmp.ticketComponent(itemFk, warehouseFk, available, rate2, rate3, minPrice, @@ -35220,7 +35561,279 @@ proc: BEGIN DECLARE vClientFk INT; DECLARE vGeneralInflationCoefficient INT DEFAULT 1; DECLARE vMinimumDensityWeight INT DEFAULT 167; - DECLARE vBoxVolume BIGINT; + 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; + + SELECT volume INTO vBoxVolume + FROM vn.packaging + WHERE id = '94'; + + SELECT clientFk INTO vClientFK + FROM address + WHERE id = vAddressFk; + + SET @rate2 := 0; + SET @rate3 := 0; + 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, b.packing) packing, + IFNULL(pf.`grouping`, b.`grouping`) `grouping`, + ABS(IFNULL(pf.box, b.groupingMode)) groupingMode, + tl.buyFk, + i.typeFk, + IF(i.hasKgPrice, b.weight / b.packing, NULL) weightGrouping + FROM tmp.ticketLot tl + JOIN buy b ON b.id = tl.buyFk + JOIN item i ON i.id = tl.itemFk + JOIN itemType it ON it.id = i.typeFk + LEFT JOIN itemCategory ic ON ic.id = it.categoryFk + LEFT JOIN specialPrice sp ON sp.itemFk = i.id AND sp.clientFk = vClientFk + LEFT JOIN ( + SELECT * FROM ( + SELECT pf.itemFk, pf.`grouping`, pf.packing, pf.box, pf.rate2, pf.rate3, zw.warehouseFk + FROM priceFixed pf + JOIN zoneWarehouse zw ON zw.zoneFk = vZoneFk AND (zw.warehouseFk = pf.warehouseFk OR pf.warehouseFk = 0) + WHERE vShipped BETWEEN pf.started AND pf.ended ORDER BY pf.itemFk, pf.warehouseFk DESC + ) tpf + GROUP BY tpf.itemFk, tpf.warehouseFk + ) pf ON pf.itemFk = tl.itemFk AND pf.warehouseFk = tl.warehouseFk + WHERE b.buyingValue + b.freightValue + b.packageValue + b.comissionValue > 0.01 AND ic.display <> 0 + AND tl.zoneFk = vZoneFk AND tl.warehouseFk = vWarehouseFk; + + INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) + SELECT + tcc.warehouseFk, + tcc.itemFk, + vBuyValueComponent, + b.buyingValue + b.freightValue + b.packageValue + b.comissionValue + FROM tmp.ticketComponentCalculate tcc + JOIN buy b ON b.id = tcc.buyFk; + + INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) + SELECT + tcc.warehouseFk, + tcc.itemFk, + vMarginComponent, + tcc.rate3 - b.buyingValue - b.freightValue - b.packageValue - b.comissionValue + FROM tmp.ticketComponentCalculate tcc + JOIN buy b ON b.id = tcc.buyFk; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentBase; + CREATE TEMPORARY TABLE tmp.ticketComponentBase ENGINE = MEMORY + SELECT tc.itemFk, ROUND(SUM(tc.cost), 4) AS base, tc.warehouseFk + FROM tmp.ticketComponent tc + JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tc.itemFk AND tcc.warehouseFk = tc.warehouseFk + GROUP BY tc.itemFk, warehouseFk; + + INSERT INTO tmp.ticketComponent + SELECT tcb.warehouseFk, tcb.itemFk, vRecoveryComponent, ROUND(tcb.base * LEAST(cr.priceIncreasing, 0.25), 3) + FROM tmp.ticketComponentBase tcb + JOIN claimRatio cr ON cr.clientFk = vClientFk + WHERE cr.priceIncreasing > 0.009; + + INSERT INTO tmp.ticketComponent + SELECT tcb.warehouseFk, tcb.itemFk, vManaAutoComponent, ROUND(base * (0.01 + wm.pricesModifierRate), 3) as manaAuto + FROM tmp.ticketComponentBase tcb + JOIN `client` c on c.id = vClientFk + JOIN workerMana wm ON c.salesPersonFk = wm.workerFk + WHERE wm.isPricesModifierActivated + HAVING manaAuto <> 0; + + INSERT INTO tmp.ticketComponent + SELECT tcb.warehouseFk, + tcb.itemFk, + c.id, + GREATEST(IFNULL(ROUND(tcb.base * c.tax, 4), 0), tcc.minPrice - tcc.rate3) + FROM tmp.ticketComponentBase tcb + JOIN component c + JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tcb.itemFk AND tcc.warehouseFk = tcb.warehouseFk + LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk + WHERE c.id = vDiscountLastItemComponent AND c.tax <> 0 AND tcc.minPrice < tcc.rate3 AND sp.value IS NULL; + + INSERT INTO tmp.ticketComponent + SELECT tcc.warehouseFk, tcc.itemFk, vSellByPacketComponent, tcc.rate2 - tcc.rate3 + FROM tmp.ticketComponentCalculate tcc + JOIN buy b ON b.id = tcc.buyFk + LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk + WHERE sp.value IS NULL; + + DROP TEMPORARY TABLE IF EXISTS tmp.zone; + CREATE TEMPORARY TABLE IF NOT EXISTS tmp.zone (INDEX (id)) + ENGINE = MEMORY + SELECT vZoneFk id; + + CALL zone_getOptionsForShipment(vShipped, TRUE); + + INSERT INTO tmp.ticketComponent + SELECT tcc.warehouseFK, + tcc.itemFk, + vDeliveryComponent, + vGeneralInflationCoefficient + * ROUND(ic.cm3 * IFNULL((zo.price - zo.bonus),50) / vBoxVolume, 4) cost + /* + * ROUND(( + i.compression -- PAK 2020/06/19 ic.cm3 ya incorpora el volumen de entrada multiplicado por la compresion + * ic.cm3 + * IF(am.deliveryMethodFk = 1, (GREATEST(i.density, vMinimumDensityWeight) / vMinimumDensityWeight), 1) -- el packingOut soluciona este problema + * IFNULL((zo.price - zo.bonus) + * amz.inflation , 50)) / vBoxVolume, 4 + ) cost */ + FROM tmp.ticketComponentCalculate tcc + JOIN item i ON i.id = tcc.itemFk + JOIN tmp.zoneOption zo ON zo.zoneFk = vZoneFk + JOIN zone z ON z.id = vZoneFk + JOIN agencyMode am ON am.id = z.agencyModeFk + LEFT JOIN itemCost ic ON ic.warehouseFk = tcc.warehouseFk + AND ic.itemFk = tcc.itemFk + HAVING cost <> 0; + + DROP TEMPORARY TABLE tmp.zoneOption; + + IF (SELECT COUNT(*) FROM vn.addressForPackaging WHERE addressFk = vAddressFk) THEN + INSERT INTO tmp.ticketComponent + SELECT tcc.warehouseFk, b.itemFk, vExtraBaggedComponent, ap.packagingValue cost + FROM tmp.ticketComponentCalculate tcc + JOIN vn.addressForPackaging ap + WHERE ap.addressFk = vAddressFk; + END IF; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentCopy; + CREATE TEMPORARY TABLE tmp.ticketComponentCopy ENGINE = MEMORY + SELECT * FROM tmp.ticketComponent; + + INSERT INTO tmp.ticketComponent + SELECT tcc.warehouseFk, + tcc.itemFk, + vSpecialPriceComponent, + sp.value - SUM(tcc.cost) sumCost + FROM tmp.ticketComponentCopy tcc + JOIN component c ON c.id = tcc.componentFk + JOIN specialPrice sp ON sp.clientFk = vClientFK AND sp.itemFk = tcc.itemFk + WHERE c.classRate IS NULL + GROUP BY tcc.itemFk, tcc.warehouseFk + HAVING ABS(sumCost) > 0.001; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentSum; + CREATE TEMPORARY TABLE tmp.ticketComponentSum + (INDEX (itemFk, warehouseFk)) + ENGINE = MEMORY + SELECT SUM(cost) sumCost, tc.itemFk, tc.warehouseFk, c.classRate + FROM tmp.ticketComponent tc + JOIN component c ON c.id = tc.componentFk + GROUP BY tc.itemFk, tc.warehouseFk, c.classRate; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentRate; + CREATE TEMPORARY TABLE tmp.ticketComponentRate ENGINE = MEMORY + SELECT tcc.warehouseFk, + tcc.itemFk, + 1 rate, + IF(tcc.groupingMode = 1, tcc.`grouping`, 1) `grouping`, + CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) price, + CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) / weightGrouping priceKg + FROM tmp.ticketComponentCalculate tcc + JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk + AND tcs.warehouseFk = tcc.warehouseFk + WHERE IFNULL(tcs.classRate, 1) = 1 + AND tcc.groupingMode < 2 AND (tcc.packing > tcc.`grouping` or tcc.groupingMode = 0) + GROUP BY tcs.warehouseFk, tcs.itemFk; + + INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg) + SELECT + tcc.warehouseFk, + tcc.itemFk, + 2 rate, + tcc.packing `grouping`, + SUM(tcs.sumCost) price, + SUM(tcs.sumCost) / weightGrouping priceKg + FROM tmp.ticketComponentCalculate tcc + JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk + AND tcs.warehouseFk = tcc.warehouseFk + WHERE tcc.available IS NULL OR (IFNULL(tcs.classRate, 2) = 2 + AND tcc.packing > 0 AND tcc.available >= tcc.packing) + GROUP BY tcs.warehouseFk, tcs.itemFk; + + INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg) + SELECT + tcc.warehouseFk, + tcc.itemFk, + 3 rate, + tcc.available `grouping`, + SUM(tcs.sumCost) price, + SUM(tcs.sumCost) / weightGrouping priceKg + FROM tmp.ticketComponentCalculate tcc + JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk + AND tcs.warehouseFk = tcc.warehouseFk + WHERE IFNULL(tcs.classRate, 3) = 3 + GROUP BY tcs.warehouseFk, tcs.itemFk; + + 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__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `catalog_componentCalculate__`( + vZoneFk INT, + vAddressFk INT, + vShipped DATE, + 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 tmp.ticketLot (warehouseFk, available, itemFk, buyFk, zoneFk) + * + * @return tmp.ticketComponent(itemFk, warehouseFk, available, rate2, rate3, minPrice, + * packing, grouping, groupingMode, buyFk, typeFk) + * @return tmp.ticketComponentPrice (warehouseFk, itemFk, rate, grouping, price) + */ + DECLARE vClientFk INT; + DECLARE vGeneralInflationCoefficient INT DEFAULT 1; + DECLARE vMinimumDensityWeight INT DEFAULT 167; + DECLARE vBoxVolume BIGINT; -- DEFAULT 138000; DECLARE vSpecialPriceComponent INT DEFAULT 10; DECLARE vDeliveryComponent INT DEFAULT 15; DECLARE vRecoveryComponent INT DEFAULT 17; @@ -35458,282 +36071,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`@`%` PROCEDURE `catalog_componentCalculate__`( - vZoneFk INT, - vAddressFk INT, - vShipped DATE) -proc: BEGIN -/** - * Calcula los componentes de los articulos de tmp.ticketLot - * - * @param vZoneFk para calcular el transporte - * @param vAddressFk Consignatario - * @param vShipped dia de salida del pedido - * @param tmp.ticketLot (warehouseFk,available,itemFk,buyFk) - * - * @return tmp.ticketComponent(itemFk, warehouseFk, available, rate2, rate3, minPrice, - * packing, grouping, groupingMode, buyFk, typeFk) - * @return tmp.ticketComponentPrice (warehouseFk, itemFk, rate, grouping, price) - */ - DECLARE vClientFk INT; - DECLARE vGeneralInflationCoefficient INT DEFAULT 1; - DECLARE vMinimumDensityWeight INT DEFAULT 167; - DECLARE vBoxFreightItem INT DEFAULT 71; - DECLARE vBoxVolume BIGINT; -- DEFAULT 138000; - DECLARE vSpecialPriceComponent INT DEFAULT 10; - DECLARE vDeliveryComponent INT DEFAULT 15; - DECLARE vRecoveryComponent INT DEFAULT 17; - DECLARE vSellByPacketComponent INT DEFAULT 22; - DECLARE vBuyValueComponent INT DEFAULT 28; - DECLARE vMarginComponent INT DEFAULT 29; - DECLARE vDiscountLastItemComponent INT DEFAULT 32; - DECLARE vExtraBaggedComponent INT DEFAULT 38; - DECLARE vManaAutoComponent INT DEFAULT 39; - - SELECT volume INTO vBoxVolume - FROM vn.packaging - WHERE id = '94'; - - SELECT clientFk INTO vClientFK - FROM address - WHERE id = vAddressFk; - - SET @rate2 := 0; - SET @rate3 := 0; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentCalculate; - CREATE TEMPORARY TABLE tmp.ticketComponentCalculate - (PRIMARY KEY (itemFk, warehouseFk)) - ENGINE = MEMORY - SELECT - tl.itemFk, tl.warehouseFk, tl.available, - IF((@rate2 := IFNULL(pf.rate2, b.price2)) < i.minPrice AND i.hasMinPrice, i.minPrice, @rate2) * 1.0 rate2, - IF((@rate3 := IFNULL(pf.rate3, b.price3)) < i.minPrice AND i.hasMinPrice, i.minPrice, @rate3) * 1.0 rate3, - IFNULL(pf.rate3, 0) AS minPrice, - IFNULL(pf.packing, b.packing) packing, - IFNULL(pf.`grouping`, b.`grouping`) `grouping`, - ABS(IFNULL(pf.box, b.groupingMode)) groupingMode, - tl.buyFk, - i.typeFk, - IF(i.hasKgPrice, b.weight / b.packing, NULL) weightGrouping - FROM tmp.ticketLot tl - JOIN buy b ON b.id = tl.buyFk - JOIN item i ON i.id = tl.itemFk - JOIN itemType it ON it.id = i.typeFk - LEFT JOIN itemCategory ic ON ic.id = it.categoryFk - LEFT JOIN specialPrice sp ON sp.itemFk = i.id AND sp.clientFk = vClientFk - LEFT JOIN ( - SELECT * FROM ( - SELECT pf.itemFk, pf.`grouping`, pf.packing, pf.box, pf.rate2, pf.rate3, zw.warehouseFk - FROM priceFixed pf - JOIN zoneWarehouse zw ON zw.zoneFk = vZoneFk AND (zw.warehouseFk = pf.warehouseFk OR pf.warehouseFk = 0) - WHERE vShipped BETWEEN pf.started AND pf.ended ORDER BY pf.itemFk, pf.warehouseFk DESC - ) tpf - GROUP BY tpf.itemFk, tpf.warehouseFk - ) pf ON pf.itemFk = tl.itemFk AND pf.warehouseFk = tl.warehouseFk - WHERE b.buyingValue + b.freightValue + b.packageValue + b.comissionValue > 0.01 AND ic.display <> 0; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent; - CREATE TEMPORARY TABLE tmp.ticketComponent ( - `warehouseFk` INT UNSIGNED NOT NULL, - `itemFk` INT NOT NULL, - `componentFk` INT UNSIGNED NOT NULL, - `cost` DECIMAL(10,4) NOT NULL, - INDEX `itemWarehouse` USING BTREE (`itemFk` ASC, `warehouseFk` ASC), - UNIQUE INDEX `itemWarehouseComponent` (`itemFk` ASC, `warehouseFk` ASC, `componentFk` ASC)); - - INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) - SELECT - tcc.warehouseFk, - tcc.itemFk, - vBuyValueComponent, - b.buyingValue + b.freightValue + b.packageValue + b.comissionValue - FROM tmp.ticketComponentCalculate tcc - JOIN buy b ON b.id = tcc.buyFk; - - INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) - SELECT - tcc.warehouseFk, - tcc.itemFk, - vMarginComponent, - tcc.rate3 - b.buyingValue - b.freightValue - b.packageValue - b.comissionValue - FROM tmp.ticketComponentCalculate tcc - JOIN buy b ON b.id = tcc.buyFk; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentBase; - CREATE TEMPORARY TABLE tmp.ticketComponentBase ENGINE = MEMORY - SELECT tc.itemFk, ROUND(SUM(tc.cost), 4) AS base, tc.warehouseFk - FROM tmp.ticketComponent tc - GROUP BY tc.itemFk, warehouseFk; - - INSERT INTO tmp.ticketComponent - SELECT tcb.warehouseFk, tcb.itemFk, vRecoveryComponent, ROUND(tcb.base * LEAST(cr.priceIncreasing, 0.25), 3) - FROM tmp.ticketComponentBase tcb - JOIN claimRatio cr ON cr.clientFk = vClientFk - WHERE cr.priceIncreasing > 0.009; - - INSERT INTO tmp.ticketComponent - SELECT tcb.warehouseFk, tcb.itemFk, vManaAutoComponent, ROUND(base * (0.01 + wm.pricesModifierRate), 3) as manaAuto - FROM tmp.ticketComponentBase tcb - JOIN `client` c on c.id = vClientFk - JOIN workerMana wm ON c.salesPersonFk = wm.workerFk - WHERE wm.isPricesModifierActivated - HAVING manaAuto <> 0; - - INSERT INTO tmp.ticketComponent - SELECT tcb.warehouseFk, - tcb.itemFk, - c.id, - GREATEST(IFNULL(ROUND(tcb.base * c.tax, 4), 0), tcc.minPrice - tcc.rate3) - FROM tmp.ticketComponentBase tcb - JOIN component c - JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tcb.itemFk AND tcc.warehouseFk = tcb.warehouseFk - LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk - WHERE c.id = vDiscountLastItemComponent AND c.tax <> 0 AND tcc.minPrice < tcc.rate3 AND sp.value IS NULL; - - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFk, tcc.itemFk, vSellByPacketComponent, tcc.rate2 - tcc.rate3 - FROM tmp.ticketComponentCalculate tcc - JOIN buy b ON b.id = tcc.buyFk - LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk - WHERE sp.value IS NULL; - - DROP TEMPORARY TABLE IF EXISTS tmp.zone; - CREATE TEMPORARY TABLE IF NOT EXISTS tmp.zone (INDEX (id)) - ENGINE = MEMORY - SELECT vZoneFk id; - - CALL zone_getOptionsForShipment(vShipped, TRUE); - - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFK, - tcc.itemFk, - vDeliveryComponent, - vGeneralInflationCoefficient - * ROUND(( - i.compression - * ic.cm3 - * IF(am.deliveryMethodFk = 1, (GREATEST(i.density, vMinimumDensityWeight) / vMinimumDensityWeight), 1) - * IFNULL((zo.price - zo.bonus) - * 1/*amz.inflation*/ , 50)) / vBoxVolume, 4 - ) cost - FROM tmp.ticketComponentCalculate tcc - JOIN item i ON i.id = tcc.itemFk - JOIN tmp.zoneOption zo ON zo.zoneFk = vZoneFk - JOIN zone z ON z.id = vZoneFk - JOIN agencyMode am ON am.id = z.agencyModeFk - LEFT JOIN itemCost ic ON ic.warehouseFk = tcc.warehouseFk - AND ic.itemFk = tcc.itemFk - HAVING cost <> 0; - - DROP TEMPORARY TABLE tmp.zoneOption; - - IF (SELECT COUNT(*) FROM vn.addressForPackaging WHERE addressFk = vAddressFk) THEN - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFk, b.itemFk, vExtraBaggedComponent, ap.packagingValue cost - FROM tmp.ticketComponentCalculate tcc - JOIN vn.addressForPackaging ap - WHERE ap.addressFk = vAddressFk; - END IF; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentCopy; - CREATE TEMPORARY TABLE tmp.ticketComponentCopy ENGINE = MEMORY - SELECT * FROM tmp.ticketComponent; - - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFk, - tcc.itemFk, - vSpecialPriceComponent, - sp.value - SUM(tcc.cost) sumCost - FROM tmp.ticketComponentCopy tcc - JOIN component c ON c.id = tcc.componentFk - JOIN specialPrice sp ON sp.clientFk = vClientFK AND sp.itemFk = tcc.itemFk - WHERE c.classRate IS NULL - GROUP BY tcc.itemFk, tcc.warehouseFk - HAVING ABS(sumCost) > 0.001; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentSum; - CREATE TEMPORARY TABLE tmp.ticketComponentSum - (INDEX (itemFk, warehouseFk)) - ENGINE = MEMORY - SELECT SUM(cost) sumCost, tc.itemFk, tc.warehouseFk, c.classRate - FROM tmp.ticketComponent tc - JOIN component c ON c.id = tc.componentFk - GROUP BY tc.itemFk, tc.warehouseFk, c.classRate; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentRate; - CREATE TEMPORARY TABLE tmp.ticketComponentRate ENGINE = MEMORY - SELECT tcc.warehouseFk, - tcc.itemFk, - 1 rate, - IF(tcc.groupingMode = 1, tcc.`grouping`, 1) `grouping`, - CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) price, - CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) / weightGrouping priceKg - FROM tmp.ticketComponentCalculate tcc - JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk - AND tcs.warehouseFk = tcc.warehouseFk - WHERE IFNULL(tcs.classRate, 1) = 1 - AND tcc.groupingMode < 2 AND (tcc.packing > tcc.`grouping` or tcc.groupingMode = 0) - GROUP BY tcs.warehouseFk, tcs.itemFk; - - INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg) - SELECT - tcc.warehouseFk, - tcc.itemFk, - 2 rate, - tcc.packing `grouping`, - SUM(tcs.sumCost) price, - SUM(tcs.sumCost) / weightGrouping priceKg - FROM tmp.ticketComponentCalculate tcc - JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk - AND tcs.warehouseFk = tcc.warehouseFk - WHERE tcc.available IS NULL OR (IFNULL(tcs.classRate, 2) = 2 - AND tcc.packing > 0 AND tcc.available >= tcc.packing) - GROUP BY tcs.warehouseFk, tcs.itemFk; - - INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg) - SELECT - tcc.warehouseFk, - tcc.itemFk, - 3 rate, - tcc.available `grouping`, - SUM(tcs.sumCost) price, - SUM(tcs.sumCost) / weightGrouping priceKg - FROM tmp.ticketComponentCalculate tcc - JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk - AND tcs.warehouseFk = tcc.warehouseFk - WHERE IFNULL(tcs.classRate, 3) = 3 - GROUP BY tcs.warehouseFk, tcs.itemFk; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentPrice; - CREATE TEMPORARY TABLE tmp.ticketComponentPrice ENGINE = MEMORY - SELECT * FROM ( - SELECT * FROM tmp.ticketComponentRate ORDER BY price - ) t - GROUP BY itemFk, warehouseFk, `grouping`; - - DROP TEMPORARY TABLE - tmp.ticketComponentCalculate, - tmp.ticketComponentSum, - tmp.ticketComponentBase, - tmp.ticketComponentRate, - tmp.ticketComponentCopy; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `catalog_componentPrepare` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -35744,7 +36081,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`z-sysadmin`@`%` PROCEDURE `catalog_componentPrepare`() +CREATE DEFINER=`root`@`%` PROCEDURE `catalog_componentPrepare`() BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent; @@ -35800,9 +36137,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -35845,6 +36182,7 @@ BEGIN DELETE FROM travelLog WHERE creationDate < v3Month; DELETE sc FROM saleChecked sc JOIN sale s ON sc.saleFk = s.id WHERE s.created < vDateShort; + DELETE FROM zoneEvent WHERE `type` = 'day' AND dated < v3Month; DELETE bm FROM buyMark bm JOIN buy b ON b.id = bm.id @@ -37071,7 +37409,14 @@ BEGIN iss.id as itemShelvingSaleFk, ts.ticketFk ,iss.id + , st.saleFk as salePreviousPrepared + , iss.userFk FROM tmp.sale ts + LEFT JOIN (SELECT DISTINCT saleFk + FROM vn.saleTracking st + JOIN vn.state s ON s.id = st.stateFk + WHERE st.isChecked + AND s.semaphore = 1) st ON st.saleFk = ts.saleFk JOIN vn.itemShelving ish ON ish.itemFk = ts.itemFk JOIN vn.shelving sh ON sh.code = ish.shelvingFk JOIN vn.parking p ON p.id = sh.parkingFk @@ -37081,29 +37426,7 @@ BEGIN LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = ts.saleFk AND iss.itemShelvingFk = ish.id LEFT JOIN vn.worker wk ON wk.id = iss.userFk WHERE w.aliasFk = vWarehouseAliasFk - /* UNION ALL - SELECT ts.saleFk, - ts.itemFk, - ip.`code` COLLATE utf8_general_ci as placement, - '' COLLATE utf8_general_ci as shelving, - ip.modificationDate as created, - v.visible - SUM(IFNULL(iss.visible,0)) as visible, - IF(iss.visible <= 0, 1, 100000) * pk.pickingOrder as `order`, - g.`grouping`, - TO_SECONDS(NOW()) as priority, - 0 as saleOrder, - 0 as isPreviousPrepared, - 0, - ts.ticketFk - FROM tmp.sale2 ts - JOIN vn.itemPlacement ip ON ip.itemFk = ts.itemFk AND ip.warehouseFk = vWarehouseFk - LEFT JOIN vn.parking pk ON CAST(pk.column AS DECIMAL(3,0)) = CAST(LEFT(ip.`code`,3) AS DECIMAL(3,0)) - JOIN cache.visible v ON v.item_id = ts.itemFk AND v.calc_id = vCalcFk - LEFT JOIN tmp.grouping2 g ON g.itemFk = ts.itemFk - LEFT JOIN vn.itemShelvingStock iss ON iss.itemFk = ts.itemFk AND iss.warehouseFk = vWarehouseFk - GROUP BY ts.saleFk - HAVING length(placement) >= 3 AND `grouping` - AND visible > 0*/ + HAVING (iss.id AND st.saleFk) OR salePreviousPrepared IS NULL ; -- select * from tmp.salePlacementList; @@ -37201,7 +37524,7 @@ BEGIN s.originalQuantity, TRIM(CONCAT(LPAD(i.longName,30,' '), ' ',RPAD(IFNULL(i.size,''),5,' '))) as line1, TRIM(CONCAT(LPAD(IFNULL(ip.productor,''),30,' '), ' ',LPAD(IFNULL(o.code,''),4,' '))) as line2, - TRIM(CONCAT(ic.color, IF(MAX(IF(st.semaphore <=> 1, TRUE, FALSE)) AND t.id != t.showTicketFk, CONCAT(' [ TICKET ',t.id,' ] '),''))) as line3, + TRIM(CONCAT(ic.color, IF(MAX(IF(st.semaphore <=> 1, TRUE, FALSE)) AND t.id != t.showTicketFk, CONCAT(' [ TICKET ',t.id,' ] '),''), IFNULL(LPAD(st.parkingCode,40,' '),''))) as line3, s.isAdded, str.originalQuantity as startQuantity, c.workerFk @@ -37215,6 +37538,15 @@ BEGIN LEFT JOIN vn.origin o ON o.id = i.originFk LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = t.id LEFT JOIN vn.collection c ON c.id = tc.collectionFk + LEFT JOIN (SELECT st.saleFk, p.`code` as parkingCode + FROM vn.saleTracking st + JOIN vn.state s ON s.id = st.stateFk + JOIN vn.sale sa ON sa.id = st.saleFk + JOIN vn.ticketParking tp ON tp.ticketFk = sa.ticketFk + JOIN vn.parking p ON p.id = tp.parkingFk + WHERE st.isChecked + AND s.semaphore = 1 + GROUP BY st.saleFk) st ON st.saleFk = s.id GROUP BY s.id HAVING quantity > 0 OR workerFk != vn.getUser() ; @@ -37225,84 +37557,6 @@ BEGIN DROP TEMPORARY TABLE tmp.ticket2; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `collectionSale_get__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `collectionSale_get__`(vCollectionFk INT) -BEGIN - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket; - CREATE TEMPORARY TABLE tmp.ticket - SELECT t.id, clientFk, id as showTicketFk - FROM vn.ticket t - WHERE id = vCollectionFk - AND shipped > '2020-01-01' - UNION ALL - SELECT tc.ticketFk id, clientFk, tc.ticketFk as showTicketFk - FROM vn.ticketCollection tc - JOIN vn.ticket t ON t.id = tc.ticketFk - WHERE tc.collectionFk = vCollectionFk; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket2; - CREATE TEMPORARY TABLE tmp.ticket2 - SELECT sw.id, t.clientFk, sw.shipFk showTicketFk - FROM vn.stowaway sw - JOIN tmp.ticket t ON t.id = sw.shipFk; - - INSERT INTO tmp.ticket - SELECT * FROM tmp.ticket2; - - SELECT showTicketFk ticketFk, - s.id as saleFk, - s.itemFk, - s.quantity, - i.longName, - i.size, - s.reserved, - MAX(IF(st.semaphore <=> 1, TRUE, FALSE)) as isPreviousPrepared, - MAX(IF(st.semaphore <=> 2, TRUE, FALSE)) as isPrepared, - MAX(IF(st.semaphore <=> 3, TRUE, FALSE)) as isControlled, - ic.color, - ip.productor, - s.discount, - s.price, - i.stems, - i.category, - o.code AS origin, - t.clientFk, - s.originalQuantity, - TRIM(CONCAT(LPAD(i.longName,30,' '), ' ',RPAD(IFNULL(i.size,''),5,' '))) as line1, - TRIM(CONCAT(LPAD(IFNULL(ip.productor,''),30,' '), ' ',LPAD(IFNULL(o.code,''),4,' '))) as line2, - ic.color as line3 - FROM vn.sale s - JOIN tmp.ticket t ON t.id = s.ticketFk - JOIN vn.item i ON i.id = s.itemFk - LEFT JOIN vn.saleTracking str ON str.saleFk = s.id AND str.isChecked = 1 - LEFT JOIN vn.state st ON st.id = str.stateFk - LEFT JOIN vn.itemColor ic ON ic.itemFk = s.itemFk - LEFT JOIN vn.itemProductor ip ON ip.itemFk = s.itemFk - LEFT JOIN vn.origin o ON o.id = i.originFk - LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = t.id - GROUP BY s.id - HAVING quantity > 0; - - DROP TEMPORARY TABLE tmp.ticket; - DROP TEMPORARY TABLE tmp.ticket2; - - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -37744,6 +37998,39 @@ proc:BEGIN SELECT vCollectionFk; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `collection_addItem` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `collection_addItem`(vItemFk INT, vQuantity INT, vTicketFk INT) +BEGIN + DECLARE vConcept VARCHAR(50); + DECLARE vPrice DOUBLE default 0.0; + DECLARE itemFk INT; + + SELECT barcodeToItem(vItemFk) INTO itemFk; + + SELECT CONCAT(vn.getUser()," ",DATE_FORMAT(NOW( ), "%H:%i" )," ",i.name) INTO vConcept FROM vn.item i WHERE i.id = itemFk; + + SELECT i.minPrice INTO vPrice FROM vn.item i WHERE i.id = itemFk; + + INSERT INTO vn.sale (itemFk,ticketFk,concept,quantity,price) + VALUES (itemFk,vTicketFk,vConcept,vQuantity,vPrice); + + CALL vn.ticket_recalcComponents(vTicketFk,null); + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -41704,9 +41991,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -41795,6 +42082,264 @@ BEGIN GROUP BY iit.expenceFk; + -- -------------------------------------------------------------------- + -- ------- Lineas de IVA --------------- + -- -------------------------------------------------------------------- + + INSERT INTO vn2008.XDiario( ASIEN, + FECHA, + SUBCTA, + CONTRA, + EURODEBE, + BASEEURO, + CONCEPTO, + FACTURA, + IVA, + AUXILIAR, + SERIE, + TIPOOPE, + FECHA_EX, + FECHA_OP, + NFACTICK, + FACTURAEX, + L340, + LRECT349, + TIPOCLAVE, + TIPOEXENCI, + TIPONOSUJE, + TIPOFACT, + TIPORECTIF, + TERIDNIF, + TERNIF, + TERNOM, + FECREGCON, + empresa_id + ) + SELECT vBookNumber ASIEN, + n.bookEntried FECHA, + tc.code SUBCTA, + s.supplierAccount CONTRA, + ROUND(tc.rate/100 * SUM(it.taxableBase) + 0.0001, 2) EURODEBE, + SUM(it.taxableBase) BASEEURO, + GROUP_CONCAT(DISTINCT e.`name` SEPARATOR ', ') CONCEPTO, + vSerialNumber FACTURA, + tc.rate IVA, + IF(isUeeMember AND eWithheld.id IS NULL,'','*') AUXILIAR, + n.serial SERIE, + tt.TIPOOPE, + n.issued FECHA_EX, + n.operated FECHA_OP, + n.invoicesCount NFACTICK, + n.supplierRef FACTURAEX, + TRUE L340, + (isSameCountry OR NOT isUeeMember) LRECT349, + n.cplusTrascendency472Fk TIPOCLAVE, + n.cplusTaxBreakFk TIPOEXENCI, + n.cplusSubjectOpFk TIPONOSUJE, + n.cplusInvoiceType472Fk TIPOFACT, + n.cplusRectificationTypeFk TIPORECTIF, + iis.cplusTerIdNifFk TERIDNIF, + s.nif AS TERNIF, + s.name AS TERNOM, + n.booked FECREGCON, + n.companyFk + FROM newInvoiceIn n + JOIN newSupplier s + JOIN invoiceInTax it ON n.id = it.invoiceInFk + JOIN taxCode tc ON tc.id = it.taxCodeFk + JOIN taxType tt ON tt.id = tc.taxTypeFk + JOIN invoiceInSerial iis ON iis.code = tt.serial + JOIN expence e ON e.id = it.expenceFk + AND e.taxTypeFk = tc.taxTypeFk + LEFT JOIN (SELECT eWithheld.id + FROM invoiceInTax hold + JOIN expence eWithheld ON eWithheld.id = hold.expenceFk AND eWithheld.isWithheld + WHERE hold.invoiceInFk = vInvoiceInId LIMIT 1 + ) eWithheld ON TRUE + WHERE tc.type != '-' + AND tc.isActive + GROUP BY tc.rate; + + -- Linea iva inversor sujeto pasivo + + INSERT INTO vn2008.XDiario( ASIEN, + FECHA, + SUBCTA, + CONTRA, + EUROHABER, + BASEEURO, + CONCEPTO, + FACTURA, + IVA, + AUXILIAR, + SERIE, + TIPOOPE, + FECHA_EX, + FECHA_OP, + NFACTICK, + FACTURAEX, + L340, + LRECT349, + TIPOCLAVE, + TIPOEXENCI, + TIPONOSUJE, + TIPOFACT, + TIPORECTIF, + TERIDNIF, + TERNIF, + TERNOM, + empresa_id + ) + + SELECT vBookNumber ASIEN, + n.bookEntried FECHA, + tcLink.code SUBCTA, + s.supplierAccount CONTRA, + ROUND(tcLink.rate/100*SUM(it.taxableBase) + 0.0001,2) EUROHABER, + ROUND(SUM(it.taxableBase),2) BASEEURO, + GROUP_CONCAT(DISTINCT e.`name` SEPARATOR ', ') CONCEPTO, + vSerialNumber FACTURA, + tcLink.rate IVA, + '*' AUXILIAR, + n.serial SERIE, + tt.TIPOOPE, + n.issued FECHA_EX, + n.operated FECHA_OP, + n.invoicesCount NFACTICK, + n.supplierRef FACTURAEX, + FALSE L340, + (isSameCountry OR NOT isUeeMember) LRECT349, + 1 TIPOCLAVE, + n.cplusTaxBreakFk TIPOEXENCI, + n.cplusSubjectOpFk TIPONOSUJE, + n.cplusInvoiceType472Fk TIPOFACT, + n.cplusRectificationTypeFk TIPORECTIF, + iis.cplusTerIdNifFk TERIDNIF, + s.nif AS TERNIF, + s.name AS TERNOM, + n.companyFk + FROM newInvoiceIn n + JOIN newSupplier s + JOIN invoiceInTax it ON n.id = it.invoiceInFk + JOIN taxCode tc ON tc.id = it.taxCodeFk + JOIN taxType tt ON tt.id = tc.taxTypeFk + JOIN invoiceInSerial iis ON iis.code = tt.serial + JOIN taxCode tcLink ON tcLink.link = tc.link + AND tc.id != tcLink.id + AND tc.link + JOIN expence e ON e.id = it.expenceFk + AND e.taxTypeFk = tc.taxTypeFk + WHERE tc.isActive + AND (tc.type in('S','I') OR MID(s.supplierAccount,4,1) = '1') + GROUP BY tcLink.rate, e.id; + + -- Actualización del registro original + UPDATE invoiceIn ii + JOIN newInvoiceIn ni ON ii.id = ni.id + SET ii.serialNumber = vSerialNumber, + ii.isBooked = TRUE; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `invoiceInBookingMain__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `invoiceInBookingMain__`(vInvoiceInId INT) +BEGIN + DECLARE vTotalAmount,vTotalAmountDivisa DECIMAL(10,2); + DECLARE vBookNumber,vSerialNumber INT; + DECLARE vRate DECIMAL(10,4); + DECLARE vSerial VARCHAR(2); + + CALL invoiceInBookingCommon(vInvoiceInId,vSerialNumber); + + SELECT serial + INTO vSerial + FROM newInvoiceIn; + + SELECT SUM(iit.taxableBase * IF(vSerial = 'R', 1 +(tc.rate/100),1)), + SUM(iit.foreignValue * IF(vSerial = 'R', 1 +(tc.rate/100),1)), + iit.taxableBase/iit.foreignValue + INTO vTotalAmount, vTotalAmountDivisa, vRate + FROM newInvoiceIn i + JOIN invoiceInTax iit ON iit.invoiceInFk = i.id + JOIN taxCode tc ON iit.taxCodeFk = tc.id; + + CALL vn.ledger_next(vBookNumber); + + -- Apunte del proveedor + + INSERT INTO vn2008.XDiario( + ASIEN, + FECHA, + SUBCTA, + EUROHABER, + CONCEPTO, + CAMBIO, + HABERME, + NFACTICK, + CLAVE, + empresa_id) + SELECT + vBookNumber, + n.bookEntried, + s.supplierAccount, + vTotalAmount EUROHABER, + n.conceptWithSupplier, + vRate, + vTotalAmountDivisa, + n.invoicesCount, + vInvoiceInId, + n.companyFk + FROM newInvoiceIn n + JOIN newSupplier s; + + -- ----------------------------------------------------------- Linea de Gastos + INSERT INTO vn2008.XDiario (ASIEN, + FECHA, + SUBCTA, + CONTRA, + EURODEBE, + EUROHABER, + CONCEPTO, + CAMBIO, + DEBEME, + HABERME, + NFACTICK, + empresa_id + ) + SELECT vBookNumber ASIEN, + n.bookEntried FECHA, + IF(e.isWithheld,LPAD(RIGHT(s.supplierAccount,5),10,iit.expenceFk),iit.expenceFk) SUBCTA, + s.supplierAccount CONTRA, + IF(e.isWithheld,NULL,ABS(ROUND(SUM(iit.taxableBase),2))) EURODEBE, + IF(e.isWithheld,ABS(ROUND(SUM(iit.taxableBase),2)),NULL) EUROHABER, + n.conceptWithSupplier CONCEPTO, + vRate, + IF(e.isWithheld,NULL,ABS(ROUND(SUM(iit.foreignValue),2))) DEBEME, + IF(e.isWithheld,ABS(ROUND(SUM(iit.foreignValue),2)),NULL) HABERME, + n.invoicesCount NFACTICK, + n.companyFk empresa_id + FROM newInvoiceIn n + JOIN newSupplier s + JOIN invoiceInTax iit ON iit.invoiceInFk = n.id + JOIN taxCode tc ON tc.id = iit.taxCodeFk + JOIN expence e ON e.id = iit.expenceFk AND e.taxTypeFk = tc.taxTypeFk + WHERE iit.expenceFk != 5660000002 + GROUP BY iit.expenceFk; + + -- -------------------------------------------------------------------- -- ------- Lineas de IVA --------------- -- -------------------------------------------------------------------- @@ -41958,292 +42503,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 `invoiceInBookingMain__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `invoiceInBookingMain__`(vInvoiceInId INT) -BEGIN - DECLARE vTotalAmount,vTotalAmountDivisa DECIMAL(10,2); - DECLARE vBookNumber,vSerialNumber INT; - DECLARE vRate DECIMAL(10,4); - DECLARE vSerial VARCHAR(2); - - CALL invoiceInBookingCommon(vInvoiceInId,vSerialNumber); - - SELECT serial - INTO vSerial - FROM newInvoiceIn; - - SELECT SUM(iit.taxableBase * IF(vSerial = 'R', 1 +(tc.rate/100),1)), - SUM(iit.foreignValue * IF(vSerial = 'R', 1 +(tc.rate/100),1)), - iit.taxableBase/iit.foreignValue - INTO vTotalAmount, vTotalAmountDivisa, vRate - FROM newInvoiceIn i - JOIN invoiceInTax iit ON iit.invoiceInFk = i.id - JOIN taxCode tc ON iit.taxCodeFk = tc.id; - - SELECT MAX(ASIEN) + 1 - INTO vBookNumber - FROM vn2008.XDiario; - - -- Apunte del proveedor - - INSERT INTO vn2008.XDiario( - ASIEN, - FECHA, - SUBCTA, - EUROHABER, - CONCEPTO, - CAMBIO, - HABERME, - NFACTICK, - CLAVE, - empresa_id) - SELECT - vBookNumber, - n.bookEntried, - s.supplierAccount, - vTotalAmount EUROHABER, - n.conceptWithSupplier, - vRate, - vTotalAmountDivisa, - n.invoicesCount, - vInvoiceInId, - n.companyFk - FROM newInvoiceIn n - JOIN newSupplier s; - - -- ----------------------------------------------------------- Linea de Gastos - INSERT INTO vn2008.XDiario ( - ASIEN, - FECHA, - SUBCTA, - CONTRA, - EURODEBE, - EUROHABER, - CONCEPTO, - CAMBIO, - DEBEME, - HABERME, - NFACTICK, - empresa_id - ) - SELECT - vBookNumber ASIEN, - n.bookEntried FECHA, - if( - e.isWithheld, - LPAD(RIGHT(s.supplierAccount,5),10,iit.expenceFk), - iit.expenceFk - ) SUBCTA, - s.supplierAccount CONTRA, - if( - e.isWithheld, - NULL, - ABS(ROUND(SUM(iit.taxableBase),2)) - ) EURODEBE, - if( - e.isWithheld, - ABS(ROUND(SUM(iit.taxableBase),2)), - NULL - ) EUROHABER, - n.conceptWithSupplier CONCEPTO, - vRate, - if( - e.isWithheld, - NULL, - ABS(ROUND(SUM(iit.foreignValue),2)) - ) DEBEME, - if( - e.isWithheld, - ABS(ROUND(SUM(iit.foreignValue),2)), - NULL - ) HABERME, - n.invoicesCount NFACTICK, - n.companyFk empresa_id - FROM newInvoiceIn n - JOIN newSupplier s - JOIN invoiceInTax iit ON iit.invoiceInFk = n.id - JOIN taxCode tc ON tc.id = iit.taxCodeFk - JOIN expence e ON e.id = iit.expenceFk AND e.taxTypeFk = tc.taxTypeFk - WHERE iit.expenceFk != 5660000002 - GROUP BY iit.expenceFk; - - - -- -------------------------------------------------------------------- - -- ------- Lineas de IVA --------------- - -- -------------------------------------------------------------------- - - INSERT INTO vn2008.XDiario( - ASIEN, - FECHA, - SUBCTA, - CONTRA, - EURODEBE, - BASEEURO, - CONCEPTO, - FACTURA, - IVA, - AUXILIAR, - SERIE, - TIPOOPE, - FECHA_EX, - FECHA_OP, - NFACTICK, - FACTURAEX, - L340, - LRECT349, - TIPOCLAVE, - TIPOEXENCI, - TIPONOSUJE, - TIPOFACT, - TIPORECTIF, - TERIDNIF, - TERNIF, - TERNOM, - FECREGCON, - empresa_id - ) - SELECT vBookNumber ASIEN, - n.bookEntried FECHA, - tc.code SUBCTA, - s.supplierAccount CONTRA, - SUM(ROUND(tc.rate/100*it.taxableBase + 0.0001,2)) EURODEBE, - SUM(it.taxableBase) BASEEURO, - GROUP_CONCAT(DISTINCT e.`name` SEPARATOR ', ') CONCEPTO, - vSerialNumber FACTURA, - tc.rate IVA, - IF(isUeeMember AND eWithheld.id IS NULL,'','*') AUXILIAR, - n.serial SERIE, - tt.TIPOOPE, - n.issued FECHA_EX, - n.operated FECHA_OP, - n.invoicesCount NFACTICK, - n.supplierRef FACTURAEX, - TRUE L340, - (isSameCountry OR NOT isUeeMember) LRECT349, - n.cplusTrascendency472Fk TIPOCLAVE, - n.cplusTaxBreakFk TIPOEXENCI, - n.cplusSubjectOpFk TIPONOSUJE, - n.cplusInvoiceType472Fk TIPOFACT, - n.cplusRectificationTypeFk TIPORECTIF, - iis.cplusTerIdNifFk TERIDNIF, - s.nif AS TERNIF, - s.name AS TERNOM, - n.booked FECREGCON, - n.companyFk - - FROM newInvoiceIn n - JOIN newSupplier s - JOIN invoiceInTax it ON n.id = it.invoiceInFk - JOIN taxCode tc ON tc.id = it.taxCodeFk - JOIN taxType tt ON tt.id = tc.taxTypeFk - JOIN invoiceInSerial iis ON iis.code = tt.serial - JOIN expence e ON e.id = it.expenceFk AND e.taxTypeFk = tc.taxTypeFk - LEFT JOIN - (SELECT eWithheld.id - FROM invoiceInTax hold - JOIN expence eWithheld ON eWithheld.id = hold.expenceFk AND eWithheld.isWithheld - WHERE hold.invoiceInFk = 58262 LIMIT 1 - ) eWithheld ON TRUE - WHERE tc.type != '-' - AND tc.isActive - GROUP BY tc.rate; - - -- Linea iva inversor sujeto pasivo - - INSERT INTO vn2008.XDiario( - ASIEN, - FECHA, - SUBCTA, - CONTRA, - EUROHABER, - BASEEURO, - CONCEPTO, - FACTURA, - IVA, - AUXILIAR, - SERIE, - TIPOOPE, - FECHA_EX, - FECHA_OP, - NFACTICK, - FACTURAEX, - L340, - LRECT349, - TIPOCLAVE, - TIPOEXENCI, - TIPONOSUJE, - TIPOFACT, - TIPORECTIF, - TERIDNIF, - TERNIF, - TERNOM, - empresa_id - ) - - SELECT - vBookNumber ASIEN, - n.bookEntried FECHA, - tcLink.code SUBCTA, - s.supplierAccount CONTRA, - ROUND(tcLink.rate/100*SUM(it.taxableBase) + 0.0001,2) EUROHABER, - ROUND(SUM(it.taxableBase),2) BASEEURO, - GROUP_CONCAT(DISTINCT e.`name` SEPARATOR ', ') CONCEPTO, - vSerialNumber FACTURA, - tcLink.rate IVA, - '*' AUXILIAR, - n.serial SERIE, - tt.TIPOOPE, - n.issued FECHA_EX, - n.operated FECHA_OP, - n.invoicesCount NFACTICK, - n.supplierRef FACTURAEX, - FALSE L340, - (isSameCountry OR NOT isUeeMember) LRECT349, - 1 TIPOCLAVE, - n.cplusTaxBreakFk TIPOEXENCI, - n.cplusSubjectOpFk TIPONOSUJE, - n.cplusInvoiceType472Fk TIPOFACT, - n.cplusRectificationTypeFk TIPORECTIF, - iis.cplusTerIdNifFk TERIDNIF, - s.nif AS TERNIF, - s.name AS TERNOM, - n.companyFk - - FROM newInvoiceIn n - JOIN newSupplier s - JOIN invoiceInTax it ON n.id = it.invoiceInFk - JOIN taxCode tc ON tc.id = it.taxCodeFk - JOIN taxType tt ON tt.id = tc.taxTypeFk - JOIN invoiceInSerial iis ON iis.code = tt.serial - JOIN taxCode tcLink ON tcLink.link = tc.link AND tc.id != tcLink.id AND tc.link - JOIN expence e ON e.id = it.expenceFk AND e.taxTypeFk = tc.taxTypeFk - WHERE tc.isActive - AND (tc.type = 'S' OR MID(s.supplierAccount,4,1) = '1') - GROUP BY tcLink.rate, e.id; - - -- Actualización del registro original - UPDATE invoiceIn ii - JOIN newInvoiceIn ni ON ii.id = ni.id - SET ii.serialNumber = vSerialNumber, - ii.isBooked = TRUE; - - UPDATE vn.config - SET ASIEN = vBookNumber; -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 `invoiceInTaxMakeByDua` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -43336,7 +43595,7 @@ BEGIN DECLARE vSpainCountryCode INT DEFAULT 1; DECLARE vIsAnySaleToInvoice BOOL; DECLARE vNewRef VARCHAR(255); - DECLARE vWorker INT DEFAULT vn.myWorker_getId(); + DECLARE vWorker INT DEFAULT account.myUserGetId(); DECLARE vCompany INT; DECLARE vClient INT; DECLARE vCplusStandardInvoiceTypeFk INT DEFAULT 1; @@ -44138,38 +44397,39 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `itemLastEntries`(IN `vItem` INT, IN `vDays` DATE) -BEGIN - SELECT - w.id AS warehouseFk, - w.name AS warehouse, - tr.landed, - b.entryFk, - b.isIgnored, - b.price2, - b.price3, - b.stickers, - b.packing, - b.`grouping`, - b.groupingMode, - i.stems, - b.quantity, - b.buyingValue, - b.packageFk , - s.id AS supplierFk, - s.name AS supplier - FROM itemType it - RIGHT JOIN (entry e - LEFT JOIN supplier s ON s.id = e.supplierFk - RIGHT JOIN buy b ON b.entryFk = e.id - LEFT JOIN item i ON i.id = b.itemFk - LEFT JOIN ink ON ink.id = i.inkFk - LEFT JOIN travel tr ON tr.id = e.travelFk - LEFT JOIN warehouse w ON w.id = tr.warehouseInFk - LEFT JOIN origin o ON o.id = i.originFk - ) ON it.id = i.typeFk - LEFT JOIN edi.ekt ek ON b.ektFk = ek.id - WHERE b.itemFk = vItem And tr.shipped BETWEEN vDays AND DATE_ADD(CURDATE(), INTERVAl + 10 DAY) - ORDER BY tr.landed DESC , b.id DESC; +BEGIN + SELECT + w.id AS warehouseFk, + w.name AS warehouse, + tr.landed, + b.entryFk, + b.isIgnored, + b.price2, + b.price3, + b.stickers, + b.packing, + b.`grouping`, + b.groupingMode, + b.weight, + i.stems, + b.quantity, + b.buyingValue, + b.packageFk , + s.id AS supplierFk, + s.name AS supplier + FROM itemType it + RIGHT JOIN (entry e + LEFT JOIN supplier s ON s.id = e.supplierFk + RIGHT JOIN buy b ON b.entryFk = e.id + LEFT JOIN item i ON i.id = b.itemFk + LEFT JOIN ink ON ink.id = i.inkFk + LEFT JOIN travel tr ON tr.id = e.travelFk + LEFT JOIN warehouse w ON w.id = tr.warehouseInFk + LEFT JOIN origin o ON o.id = i.originFk + ) ON it.id = i.typeFk + LEFT JOIN edi.ekt ek ON b.ektFk = ek.id + WHERE b.itemFk = vItem And tr.shipped BETWEEN vDays AND DATE_ADD(CURDATE(), INTERVAl + 10 DAY) + ORDER BY tr.landed DESC , b.id DESC; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -46357,6 +46617,146 @@ SET tag8 = t.name, value8 = it.value WHERE it.priority = 4 AND (vItem IS NULL OR vItem = it.itemFk); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `item_getBalance` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `item_getBalance`(IN vItemId INT, IN vWarehouse INT) +BEGIN + DECLARE vDateInventory DATETIME; + DECLARE vCurdate DATE DEFAULT CURDATE(); + DECLARE vDayEnd DATETIME DEFAULT util.dayEnd(vCurdate); + + SELECT inventoried INTO vDateInventory FROM config; + SET @a = 0; + SET @currentLineFk = 0; + SET @shipped = ''; + + SELECT DATE(@shipped:= shipped) shipped, + alertLevel, + stateName, + origin, + reference, + clientFk, + name, + `in`, + `out`, + @a := @a + IFNULL(`in`,0) - IFNULL(`out`,0) as balance, + @currentLineFk := IF (@shipped < CURDATE() + OR (@shipped = CURDATE() AND (isPicked OR alertLevel >= 2)), + lineFk,@currentLineFk) lastPreparedLineFk, + isTicket, + lineFk,isPicked + FROM + ( SELECT tr.landed as shipped, + b.quantity as `in`, + NULL as `out`, + al.alertLevel as alertLevel, + st.name AS stateName, + s.name as name, + e.ref as reference, + e.id as origin, + s.id as clientFk, + IF(al.alertLevel = 3, TRUE, FALSE) isPicked, + FALSE AS isTicket, + b.id lineFk, + NULL `order` + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel tr ON tr.id = e.travelFk + JOIN supplier s ON s.id = e.supplierFk + JOIN alertLevel al ON al.alertLevel = + CASE + WHEN tr.shipped < CURDATE() THEN 3 + WHEN tr.shipped = CURDATE() AND tr.isReceived = TRUE THEN 3 + ELSE 0 + END + JOIN state st ON st.code = al.code + WHERE tr.landed >= vDateInventory + AND vWarehouse = tr.warehouseInFk + AND b.itemFk = vItemId + AND e.isInventory = FALSE + AND e.isRaid = FALSE + UNION ALL + + SELECT tr.shipped, + NULL as `in`, + b.quantity as `out`, + al.alertLevel as alertLevel, + st.name AS stateName, + s.name as name, + e.ref as reference, + e.id as origin, + s.id as clientFk, + IF(al.alertLevel = 3, TRUE, FALSE) isPicked, + FALSE AS isTicket, + b.id, + NULL `order` + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel tr ON tr.id = e.travelFk + JOIN warehouse w ON w.id = tr.warehouseOutFk + JOIN supplier s ON s.id = e.supplierFk + JOIN alertLevel al ON al.alertLevel = + CASE + WHEN tr.shipped < CURDATE() THEN 3 + WHEN tr.shipped = CURDATE() AND tr.isReceived = TRUE THEN 3 + ELSE 0 + END + JOIN state st ON st.code = al.code + WHERE tr.shipped >= vDateInventory + AND vWarehouse =tr.warehouseOutFk + AND s.id <> 4 + AND b.itemFk = vItemId + AND e.isInventory = FALSE + AND w.isFeedStock = FALSE + AND e.isRaid = FALSE + UNION ALL + + SELECT DATE(t.shipped), + NULL as `in`, + s.quantity as `out`, + al.alertLevel as alertLevel, + st.name AS stateName, + t.nickname as name, + t.refFk as reference, + t.id as origin, + t.clientFk, + stk.id as isPicked, + TRUE as isTicket, + s.id, + st.`order` + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + LEFT JOIN ticketState ts ON ts.ticket = t.id + LEFT JOIN state st ON st.code = ts.code + JOIN client c ON c.id = t.clientFk + JOIN alertLevel al ON al.alertLevel = + CASE + WHEN t.shipped < curdate() THEN 3 + WHEN t.shipped > util.dayEnd(curdate()) THEN 0 + ELSE IFNULL(ts.alertLevel, 0) + END + LEFT JOIN state stPrep ON stPrep.`code` = 'PREPARED' + LEFT JOIN saleTracking stk ON stk.saleFk = s.id AND stk.stateFk = stPrep.id + WHERE t.shipped >= vDateInventory + AND s.itemFk = vItemId + AND vWarehouse =t.warehouseFk + ORDER BY shipped, alertLevel DESC, isTicket, `order` DESC, isPicked DESC, `in` DESC, `out` DESC + ) AS itemDiary; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -46492,6 +46892,124 @@ BEGIN 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 `item_refreshTags` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `item_refreshTags`() +BEGIN +/** + * Actualiza la tabla item, los campos "cache" de tags + * + * @param temporary table vItem(id) del articulo + **/ + + UPDATE item i + JOIN tmp.item tmpI ON tmpI.id = i.id + LEFT JOIN itemTag it1 ON it1.priority = 1 AND it1.itemFk = i.id + LEFT JOIN itemTag it2 ON it2.priority = 2 AND it2.itemFk = i.id + LEFT JOIN itemTag it3 ON it3.priority = 3 AND it3.itemFk = i.id + SET i.longName = CONCAT_WS(' ', it1.`value`, it2.`value`, it3.`value`); + + UPDATE item i + JOIN tmp.item tmpI ON tmpI.id = i.id + LEFT JOIN itemTag it1 ON it1.priority = 1 AND it1.itemFk = i.id + LEFT JOIN tagAbbreviation ta1 ON ta1.`value` = it1.`value` + LEFT JOIN itemTag it2 ON it2.priority = 2 AND it2.itemFk = i.id + LEFT JOIN tagAbbreviation ta2 ON ta2.`value` = it2.`value` + LEFT JOIN itemTag it3 ON it3.priority = 3 AND it3.itemFk = i.id + LEFT JOIN tagAbbreviation ta3 ON ta3.`value` = it3.`value` + SET i.`name` = CONCAT_WS(' ', + IFNULL(ta1.abbreviation,it1.`value`), + IFNULL(ta2.abbreviation,it2.`value`), + IFNULL(ta3.abbreviation,it3.`value`)); + + UPDATE item i + JOIN tmp.item tmpI ON tmpI.id = i.id + LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 4 + SET i.subName = it.`value`; + + UPDATE item i + JOIN tmp.item tmpI ON tmpI.id = i.id + LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 5 + LEFT JOIN tag t ON t.id = it.tagFk + SET tag5 = t.name, value5 = it.`value`; + + UPDATE item i + JOIN tmp.item tmpI ON tmpI.id = i.id + LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 6 + LEFT JOIN tag t ON t.id = it.tagFk + SET tag6 = t.name, value6 = it.`value`; + + UPDATE item i + JOIN tmp.item tmpI ON tmpI.id = i.id + LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 7 + LEFT JOIN tag t ON t.id = it.tagFk + SET i.tag7 = t.name, i.value7 = it.`value`; + + UPDATE item i + JOIN tmp.item tmpI ON tmpI.id = i.id + LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 8 + LEFT JOIN tag t ON t.id = it.tagFk + SET tag8 = t.name, value8 = it.`value`; + + UPDATE item i + JOIN tmp.item tmpI ON tmpI.id = i.id + LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 9 + LEFT JOIN tag t ON t.id = it.tagFk + SET tag9 = t.name, value9 = it.`value`; + + UPDATE item i + JOIN tmp.item tmpI ON tmpI.id = i.id + LEFT JOIN itemTag it ON it.itemFk = i.id AND it.priority = 10 + LEFT JOIN tag t ON t.id = it.tagFk + SET tag10 = t.name, value10 = it.`value`; + + -- Al insertar el tag color se modifica también el antiguo campo color + UPDATE item i + JOIN tmp.item tmpI ON tmpI.id = i.id + JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = 1 + JOIN ink ON ink.`name` = it.`value` + SET i.inkFk = ink.id; + + -- Al insertar el tag origen se modifica también en la tabla item + UPDATE item i + JOIN tmp.item tmpI ON tmpI.id = i.id + JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = 35 + JOIN origin o ON o.`name` = it.`value` + SET i.originFk = o.id; + + -- Al insertar el tag medida se modifica también en la tabla item + UPDATE item i + JOIN tmp.item tmpI ON tmpI.id = i.id + JOIN itemTag it ON it.itemFk = i.id AND it.tagFk IN (4, 8) + SET i.size = it.`value`; + + -- Al insertar el tag productor se modifica también en la tabla item + UPDATE item i + JOIN tmp.item tmpI ON tmpI.id = i.id + JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = 37 + JOIN producer p ON p.`name` = it.`value` + SET i.producerFk = p.id; + + -- Al insertar el tag tallos se modifica también en la tabla item + UPDATE item i + JOIN tmp.item tmpI ON tmpI.id = i.id + JOIN itemTag it ON it.itemFk = i.id AND it.tagFk = 23 + SET i.stems = it.`value`; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -47148,6 +47666,67 @@ BEGIN PREPARE stmt FROM @qryLog; EXECUTE stmt; +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 `lungSize_generator` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`z-developer`@`%` PROCEDURE `lungSize_generator`(vDate DATE) +BEGIN + +SET @buildingOrder := 0; +SET @route := 0; +set @cajas := 0; + + UPDATE tmp.sorter + SET buildingOrder = @buildingOrder := IF(@route = @route := routeFk, @buildingOrder, 0) + 1 + where date(created) = vDate + order by routeFk, created, weight DESC; + + update tmp.sorter + SET palletOrder = buildingOrder mod 14, lungGrow = buildingOrder mod 14 + WHERE date(created) = vDate; + + UPDATE tmp.sorter + JOIN ( + SELECT routeFk, max(id) maxid + FROM tmp.sorter + where date(created) = vDate + GROUP BY routeFk) sub ON sub.maxid = id + SET lungGrow = 1 - palletOrder ; + + UPDATE tmp.sorter + SET lungGrow = IF(palletOrder = 0, -13, lungGrow); + + DELETE FROM tmp.lungSize WHERE dia = vDate; + + INSERT INTO tmp.lungSize(dia, hora,size) + select vDate,hora, @cajas := @cajas + cajas as size + from + ( + select IF(lungGrow BETWEEN -12 AND -1, ETD,time_format(created,"%H:%i")) as hora, sum(if(lungGrow <= 0, lungGrow, 1)) as cajas, @cajas := 0 + from tmp.sorter + where date(created) = vDate + group by hora + ) sub; + + SELECT * FROM tmp.lungSize + WHERE dia = vDate; + + + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -47225,7 +47804,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 `manaSpellersRequery` */; +/*!50003 DROP PROCEDURE IF EXISTS `makePCSGraf` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -47235,9 +47814,64 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `manaSpellersRequery`(vWorkerFk INTEGER) +CREATE DEFINER=`root`@`%` PROCEDURE `makePCSGraf`(vDated DATE) BEGIN + + DECLARE vHour INT DEFAULT 0; + DECLARE vMinute INT DEFAULT 0; + DECLARE vBoxes INT; + + + DROP TEMPORARY TABLE IF EXISTS vn.pcsDay; + CREATE TEMPORARY TABLE vn.pcsDay + SELECT 0 as hh, 0 as mm, 0 as boxes; + + -- Creamos una tabla soporte para acumular las cajas a lo largo del dia + WHILE vHour < 24 DO + + WHILE vMinute < 59 DO + + SET vMinute = vMinute + 1; + + INSERT INTO vn.pcsDay(hh,mm) VALUES(vHour, vMinute); + + END WHILE; + + SET vMinute = -1; + SET vHour = vHour + 1; + + END WHILE; + + -- Acumulamos + UPDATE vn.pcsDay pd + LEFT JOIN (SELECT * FROM vn.pcs_graf WHERE dia = vDated) pg USING(hh,mm) + SET pd.boxes = pd.boxes + pg.box; + + SELECT * FROM vn.pcsDay; + +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 `manaSpellersRequery` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `manaSpellersRequery`(vWorkerFk INTEGER) +BEGIN +/* +Hay una version en salix que machacará toda esta funcion/procedimiento +avisa a jgallego de los cambios que quieres hacer +*/ DECLARE vWorkerIsExcluded BOOLEAN; DECLARE vFromDated DATE; DECLARE vToDated DATE DEFAULT TIMESTAMPADD(DAY,1,CURDATE()); @@ -48144,7 +48778,7 @@ BEGIN SET valueFk = (IFNULL(valueFk,0) + 1) MOD 3; REPLACE vn2008.Movimientos_mark(Id_Movimiento, valor, Id_Trabajador, stateFk) - VALUES(saleFk,valueFk,myWorker_getId(),encajando); + VALUES(saleFk,valueFk,account.myUserGetId(),encajando); END ;; @@ -48201,6 +48835,51 @@ BEGIN SELECT * FROM vn.parking WHERE `column` BETWEEN vFromColumn AND vToColumn; +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 `parking_new` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `parking_new`(vStart INT, vEnd INT, vSectorFk INT) +BEGIN + + DECLARE vRow INT; + DECLARE vColumn INT; + DECLARE vLetters VARCHAR(200); + DECLARE vLettersLength INT; + + SET vColumn = vStart; + SET vRow = 1; + SET vLetters = 'ABCDEF'; + SET vLettersLength = LENGTH(vLetters); + + WHILE vColumn <= vEnd DO + + REPLACE vn.parking(`column`, `row`, `code`, sectorFk) + VALUES(vColumn, vRow, CONCAT(vColumn,MID(vLetters,vRow,1)), vSectorFk); + + SET vRow = vRow + 1; + + IF vRow > vLettersLength THEN + + SET vRow = 1; + SET vColumn = vColumn + 1; + + END IF; + + END WHILE; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -48307,7 +48986,7 @@ BEGIN DECLARE vShipmentHour VARCHAR(10); SELECT getTicketTrolleyLabelCount(vTicket) INTO vLabelCount; - SELECT myWorker_getId() INTO vWorker; + SELECT account.myUserGetId() INTO vWorker; SELECT CONCAT(getShipmentHour(vTicket),':00') INTO vShipmentHour; INSERT INTO printingQueue(printer @@ -48430,6 +49109,190 @@ 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 `recipe_Cook` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `recipe_Cook`(vItemFk INT, vBunchesQuantity INT, vDate DATE) +BEGIN + + DECLARE vCalc INT; + DECLARE vWarehouseFk INT DEFAULT 1; -- Silla FV + + SET @element := ''; + SET @counter := 0; + + CALL cache.available_refresh(vCalc, FALSE, vWarehouseFk, vDate); + + DROP TEMPORARY TABLE IF EXISTS tmp.recipeCook; + + CREATE TEMPORARY TABLE tmp.recipeCook + SELECT *, + @counter := IF(@element = element COLLATE utf8_general_ci , @counter + 1, 1) as counter, + @element := element COLLATE utf8_general_ci + FROM + ( + SELECT i.id itemFk, + CONCAT(i.longName, ' (ref: ',i.id,')') longName, + i.size, + i.inkFk, + a.available, + r.element, + vBunchesQuantity * r.quantity as quantity, + r.itemFk as bunchItemFk, + IFNULL((i.inkFk = r.inkFk ) ,0) + + IFNULL((i.size = r.size) ,0) + + IFNULL((i.name LIKE CONCAT('%',r.name,'%')) ,0) + + IFNULL((i.longName LIKE CONCAT('%',r.longName,'%')),0) + + IFNULL((i.typeFk = r.typeFk),0) as matches, + i.typeFk, + rl.previousSelected + FROM vn.recipe r + JOIN vn.item i ON (IFNULL(i.name LIKE CONCAT('%',r.name,'%'), 0) + OR IFNULL(i.longName LIKE CONCAT('%',r.longName,'%'),0)) + OR i.typeFk <=> r.typeFk + JOIN cache.available a ON a.item_id = i.id AND a.calc_id = vCalc + LEFT JOIN (SELECT recipe_ItemFk, element as log_element, selected_ItemFk, count(*) as previousSelected + FROM vn.recipe_log + GROUP BY recipe_ItemFk, element, selected_ItemFk) rl ON rl.recipe_ItemFk = r.itemFk + AND rl.log_element = r.element + AND rl.selected_ItemFk = i.id + WHERE r.itemFk = vItemFk + AND a.available > vBunchesQuantity * r.quantity + UNION ALL + SELECT 100 itemFk, + CONCAT('? ',r.element,' ',IFNULL(r.size,''),' ',IFNULL(r.inkFk,'')) as longName, + NULL, + NULL, + 0, + r.element, + vBunchesQuantity * r.quantity as quantity, + r.itemFk as bunchItemFk, + -1 as matches, + r.typeFk, + NULL + FROM vn.recipe r + WHERE r.itemFk = vItemFk + GROUP BY r.element + ) sub + + ORDER BY element, matches DESC, previousSelected DESC; + + SELECT * + FROM tmp.recipeCook + WHERE counter < 6 + OR itemFk = 100 + ; + +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 `recipe_Plaster` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `recipe_Plaster`(vItemFk INT, vTicketFk INT, vQuantity INT) +BEGIN + + DECLARE vLastCost DECIMAL(10,2); + DECLARE vWarehouseFk INT; + DECLARE vShipped DATE; + DECLARE vEntryFk INT; + DECLARE vTravelFk INT; + + CALL cache.last_buy_refresh(FALSE); + + SELECT warehouseFk, shipped + INTO vWarehouseFk, vShipped + FROM vn.ticket + WHERE id = vTicketFk; + + UPDATE vn.ticket t + JOIN vn.item i ON i.id = vItemFk + SET t.nickname = CONCAT(vQuantity,' ',i.longName) + WHERE t.id = vTicketFk; + + SELECT b.buyingValue INTO vLastCost + FROM vn.buy b + JOIN cache.last_buy lb ON lb.buy_id = b.id + WHERE lb.item_id = vItemFk + ORDER BY (lb.warehouse_id = vWarehouseFk) DESC + LIMIT 1; + + INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price) + SELECT vTicketFk, 98, - vQuantity, i.longName, vLastCost + FROM vn.item i + WHERE i.id = vItemFk; + /* + SELECT tr.id INTO vTravelFk + FROM vn.travel tr + JOIN vn.warehouse w ON w.id = tr.warehouseOutFk + WHERE tr.warehouseInFk = vWarehouseFk + AND tr.landed = vShipped + AND w.name = 'Confeccion'; + + IF IFNULL(vTravelFk,0) = 0 THEN + + INSERT INTO vn.travel(shipped, landed, warehouseInFk, warehouseOutFk, agencyFk) + SELECT vShipped, vShipped, vWarehouseFk, w.id, am.id + FROM vn.warehouse w + JOIN vn.agencyMode am + WHERE w.name = 'Confeccion' + AND am.name = 'DIRECTO PROVEEDOR'; + + SET vTravelFk = LAST_INSERT_ID(); + + END IF; + + SELECT e.id INTO vEntryFk + FROM vn.entry e + JOIN vn.supplier s ON s.id = supplierFk + WHERE e.travelFk = vTravelFk + AND s.name = 'Confeccion Natural' + AND e.isRaid = FALSE; + + IF IFNULL(vEntryFk,0) = 0 THEN + + INSERT INTO vn.entry(supplierFk, evaNotes, travelFk, companyFk) + SELECT s.id, t.nickname, vTravelFk, c.id + FROM vn.supplier s + JOIN vn.ticket t ON t.id = vTicketFk + JOIN vn.company c ON c.code = 'VNL' + WHERE s.name = 'Confeccion Natural'; + + SET vEntryFk = LAST_INSERT_ID(); + + END IF; + + INSERT INTO vn.buy(entryFk, itemFk, quantity, buyingValue, packageFk, packing, grouping) + SELECT vEntryFk, b.itemFk, vQuantity, b.buyingValue, b.packageFk, b.packing, b.grouping + FROM cache.last_buy lb + JOIN vn.buy b ON b.id = lb.buy_id + WHERE lb.item_id = vItemFk + ORDER BY (lb.warehouse_id = vWarehouseFk) DESC + LIMIT 1; +*/ +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `refund` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -48723,6 +49586,44 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `routeInfo` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`z-developer`@`%` PROCEDURE `routeInfo`(vRouteFk INT) +BEGIN + + DECLARE vPackages INT; + DECLARE vM3 INT; + DECLARE vKg INT; + + SELECT sum(packages) as bultos + INTO vPackages + FROM vn.ticket t + WHERE routeFk = vRouteFk; + + SELECT SUM(sv.physicalVolume), SUM(sv.physicalWeight) + INTO vM3, vKg + FROM vn.saleVolume sv + WHERE sv.routeFk = vRouteFk; + + SELECT vRouteFk as Ruta, + vPackages as Bultos, + vM3 as m3, + vKg as Kg; + +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 `routeSetOk` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -49003,7 +49904,7 @@ BEGIN WHERE s.ticketFk = vTicketFk; REPLACE vn2008.Movimientos_mark(Id_Movimiento, Valor, original_quantity, Id_Trabajador, stateFk) - SELECT s.id, s.isPicked, s.quantity, myWorker_getId(), vStateFk + SELECT s.id, s.isPicked, s.quantity, account.myUserGetId(), vStateFk FROM sale s JOIN vn.saleItemShelving sis ON sis.saleFk = s.id WHERE s.ticketFk = vTicketFk; @@ -49179,7 +50080,7 @@ BEGIN END IF; INSERT INTO ticketTracking(ticketFk, workerFk, stateFk) - SELECT vNewTicket, myWorker_getId(), s.id + SELECT vNewTicket, account.myUserGetId(), s.id FROM state s WHERE s.code = 'FIXING'; @@ -49535,7 +50436,7 @@ proc: BEGIN DECLARE vAgencyModeFk INT; DECLARE vAddressFk INT; DECLARE vTicketFk BIGINT; - DECLARE vItem BIGINT; + DECLARE vItemFk BIGINT; DECLARE vLanded DATE; DECLARE vIsEditable BOOLEAN; DECLARE vZoneFk INTEGER; @@ -49551,7 +50452,7 @@ proc: BEGIN t.landed INTO vIsEditable, vTicketFk, - vItem, + vItemFk, vZoneFk, vWarehouseFk, vShipped, @@ -49565,7 +50466,7 @@ proc: BEGIN IF vLanded IS NULL OR vZoneFk IS NULL THEN - CALL zone_getLanded(vShipped, vAddressFk, vAgencyModeFk, vWarehouseFk); + CALL zone_getLanded(vShipped, vAddressFk, vAgencyModeFk, vWarehouseFk, TRUE); IF (SELECT COUNT(*) FROM tmp.zoneGetLanded LIMIT 1) = 0 THEN CALL util.throw('There is no zone for these parameters'); @@ -49588,13 +50489,13 @@ proc: BEGIN -- rellena la tabla buyUltimate con la ultima compra CALL buyUltimate (vWarehouseFk, vShipped); - DELETE FROM tmp.buyUltimate WHERE itemFk != vItem; + DELETE FROM tmp.buyUltimate WHERE itemFk != vItemFk; DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; CREATE TEMPORARY TABLE tmp.ticketLot - SELECT vWarehouseFk warehouseFk, NULL available, vItem itemFk, buyFk, vZoneFk zoneFk + SELECT vWarehouseFk warehouseFk, NULL available, vItemFk itemFk, buyFk, vZoneFk zoneFk FROM tmp.buyUltimate - WHERE itemFk = vItem; + WHERE itemFk = vItemFk; CALL catalog_componentPrepare(); CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk); @@ -49609,11 +50510,8 @@ proc: BEGIN END IF; CALL ticketComponentUpdateSale(vOption); - - INSERT INTO ticketLog (originFk, userFk, `action`, description) - VALUES (vTicketFk, account.userGetId(), 'update', CONCAT('Bionizo linea id ', vSale)); - CALL catalog_componentPurge(); + DROP TEMPORARY TABLE tmp.buyUltimate; DROP TEMPORARY TABLE tmp.sale; END ;; @@ -50686,9 +51584,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -50704,7 +51602,7 @@ BEGIN IF myShipFk THEN INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) - SELECT id, myShipFk, myWorker_getId() + SELECT id, myShipFk, account.myUserGetId() FROM state WHERE code = 'OK STOWAWAY'; @@ -51074,7 +51972,7 @@ BEGIN WHERE t.id = vTicketNew; IF vLanded IS NULL THEN - CALL zone_getLanded(vShipped, vAddress, vAgency, vWarehouse); + CALL zone_getLanded(vShipped, vAddress, vAgency, vWarehouse, TRUE); UPDATE ticket t JOIN tmp.zoneGetLanded zgl ON t.warehouseFk = zgl.warehouseFk SET t.landed = zgl.landed, @@ -52540,7 +53438,7 @@ BEGIN IF (SELECT ct.isCreatedAsServed FROM vn.clientType ct JOIN vn.client c ON c.typeFk = ct.code WHERE c.id = vClientId ) <> FALSE THEN INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) - SELECT id, vNewTicket, myWorker_getId() + SELECT id, vNewTicket, account.myUserGetId() FROM state WHERE `code` = 'DELIVERED'; END IF; @@ -52879,11 +53777,11 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `ticketGetTax`() READS SQL DATA @@ -52986,11 +53884,11 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `ticketGetTaxAdd`(vTicketFk INT) BEGIN @@ -53003,7 +53901,7 @@ BEGIN ENGINE = MEMORY SELECT vTicketFk ticketFk; - CALL vn.ticketGetTax(); + CALL vn.ticket_getTax(NULL); SELECT tt.ticketFk, @@ -53109,9 +54007,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -53124,7 +54022,7 @@ BEGIN * @table tmp.ticket(ticketFk) Identificadores de los tickets a calcular * @return tmp.ticketTotal Total para cada ticket */ - CALL ticketGetTax; + CALL vn.ticketGetTax(); DROP TEMPORARY TABLE IF EXISTS tmp.ticketTotal; CREATE TEMPORARY TABLE tmp.ticketTotal @@ -53293,7 +54191,7 @@ BEGIN JOIN vn.zone z ON z.id = t.zoneFk JOIN vn.agencyMode am ON am.id = z.agencyModeFk JOIN vn.state s ON s.id = tst.state - WHERE s.alertLevel < 2 + WHERE (s.alertLevel < 2 AND tp.parkingFk = vParkingFk AND sc.isPackagingArea AND ( @@ -53302,7 +54200,13 @@ BEGIN OR ( tc.collectionFk = vCollectionFk AND LEFT(tc.level,1) < LEFT(vLevel,1) ) ) - ); + )) -- Etiquetas que no se han escaneado y ya estamos con una posterior + OR + (s.alertLevel > 1 + AND tp.parkingFk = vParkingFk + AND sc.isPackagingArea + AND tp.created < vParked + AND t.packages <=> 0); @@ -53410,6 +54314,38 @@ BEGIN CLOSE rs; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticketRequest_Add` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `ticketRequest_Add`(vDescription VARCHAR(255), vQuantity INT, vPrice DOUBLE, vTicketFk INT, vBuyerCode VARCHAR(3)) +BEGIN + + INSERT INTO vn.ticketRequest(description, + quantity, + price, + ticketFk, + buyerCode, + requesterFk) + VALUES(vDescription, + vQuantity, + vPrice, + vTicketFk, + vBuyerCode, + vn.getUser()); + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -53487,7 +54423,7 @@ BEGIN WHERE inter_id = vControlFk; */ INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador, Id_Supervisor) - SELECT s.nextStateFk, i.Id_Ticket, vLastWorkerFk, vn.myWorker_getId() + SELECT s.nextStateFk, i.Id_Ticket, vLastWorkerFk, account.myUserGetId() FROM vncontrol.inter i JOIN vn.state s ON i.state_id = s.id WHERE inter_id = vControlFk; @@ -53525,7 +54461,7 @@ CREATE DEFINER=`root`@`%` PROCEDURE `ticketStateUpdate`(vTicketFk INT, vStateCod BEGIN INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) - SELECT id, vTicketFk, myWorker_getId() + SELECT id, vTicketFk, account.myUserGetId() FROM vn.state WHERE `code` = vStateCode collate utf8_unicode_ci; @@ -53879,6 +54815,84 @@ 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_checkNoComponents` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `ticket_checkNoComponents`(vShippedFrom DATETIME, vShippedTo DATETIME) +BEGIN + +/** + * Comprueba que los tickets entre un rango de fechas tienen componentes + * + * @param vDatedFrom Id del ticket + * @param vIsTicketEditable si no se quiere forzar llamar con NULL + */ + DECLARE v_done BOOL DEFAULT FALSE; + DECLARE vSaleFk INTEGER; + DECLARE vCur CURSOR FOR + SELECT s.id + FROM ticket t + JOIN client clt ON clt.id = t.clientFk + JOIN sale s ON s.ticketFk = t.id + JOIN item i ON i.id = s.itemFk + JOIN itemType tp ON tp.id = i.typeFk + JOIN itemCategory ic ON ic.id = tp.categoryFk + LEFT JOIN tmp.coste c ON c.id = s.id + WHERE t.shipped >= vDatedFrom AND t.shipped <= vDatedTo + AND c.id IS NULL + AND clt.isActive != 0 + AND ic.merchandise != 0 + GROUP BY s.id; + + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET v_done = TRUE; + + DROP TEMPORARY TABLE IF EXISTS tmp.coste; + + DROP TEMPORARY TABLE IF EXISTS tmp.coste; + CREATE TEMPORARY TABLE tmp.coste + (primary key (id)) ENGINE = MEMORY + SELECT s.id + FROM ticket t + JOIN client clt ON clt.id = t.clientFk + JOIN sale s ON s.ticketFk = t.id + JOIN item i ON i.id = s.itemFk + JOIN itemType tp ON tp.id = i.typeFk + JOIN itemCategory ic ON ic.id = tp.categoryFk + JOIN saleComponent sc ON sc.saleFk = s.id + JOIN component c ON c.id = sc.componentFk + JOIN componentType ct ON ct.id = c.typeFk AND ct.id = 1 + WHERE t.shipped >= vDatedFrom + AND ic.merchandise != 0; + + OPEN vCur; + + l: LOOP + SET v_done = FALSE; + FETCH vCur INTO vSaleFk; + + IF v_done THEN + LEAVE l; + END IF; + + CALL sale_calculateComponent(vSaleFk, 1); + END LOOP; + + CLOSE vCur; + DROP TEMPORARY TABLE tmp.coste; + 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_checkNoComponents__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -54014,6 +55028,145 @@ BEGIN SET originFk = vNewTicket, userFk = account.myUserGetId(), `action` = 'insert', description = CONCAT('Ha creado el ticket:', ' ', vNewTicket, ' clonando el ', vOriginalTicket); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_cloneWeekly` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `ticket_cloneWeekly`(IN vWeek INT) +BEGIN + DECLARE vIsDone BOOL; + DECLARE vLanding DATE; + DECLARE vShipment DATE; + DECLARE vWarehouse INT; + DECLARE vTicket INT; + DECLARE vWeekDay INT; + DECLARE vClient INT; + DECLARE vEmpresa INT; + DECLARE vAddressFk INT; + DECLARE vAgencyModeFk INT; + DECLARE vNewTicket INT; + DECLARE vYear INT; + + DECLARE rsTicket CURSOR FOR + SELECT tw.ticketFk, weekDay, t.clientFk, t.warehouseFk, t.companyFk, t.addressFk, tw.agencyModeFk + FROM ticketWeekly tw + JOIN ticket t ON tt.ticketFk = t.id; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE; + + SET vYear = YEAR(CURDATE()) + IF(vWeek < WEEK(CURDATE()),1, 0); + + OPEN rsTicket; + + myLoop: LOOP + BEGIN + DECLARE vError TEXT; + DECLARE vSalesPersonEmail VARCHAR(150); + DECLARE vMailSent BOOL; + DECLARE vSubject VARCHAR(150); + DECLARE vMessage TEXT; + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION + BEGIN + GET DIAGNOSTICS CONDITION 1 + vError = MESSAGE_TEXT; + END; + + SET vIsDone = FALSE; + FETCH rsTicket INTO vTicket, vWeekDay, vClient, vWarehouse, vEmpresa, vAddressFk, vAgencyModeFk; + + IF vIsDone THEN + + LEAVE myLoop; + END IF; + SELECT date INTO vShipment + FROM `time` + WHERE `year` = vYear AND `week` = vWeek + AND WEEKDAY(date) = vWeekDay; + + -- busca si el ticket ya ha sido clonado + IF (SELECT COUNT(*) FROM vn.ticket tOrig + JOIN vn.sale saleOrig ON tOrig.id = saleOrig.ticketFk + JOIN vn.saleCloned sc ON sc.saleOriginalFk = saleOrig.id + JOIN vn.sale saleClon ON saleClon.id = sc.saleClonedFk + JOIN vn.ticket tClon ON tClon.id = saleClon.ticketFk + WHERE tOrig.id = vTicket AND DATE(tClon.shipped) = vShipment) > 0 + THEN + ITERATE myLoop; + END IF; + CALL vn.zone_getLanded(vShipment, vAddressFk, vAgencyModeFk, vWarehouse, TRUE); + + SELECT landed INTO vLanding from tmp.zoneGetLanded LIMIT 1; + + CALL vn.ticketCreateWithoutZone(vClient, vShipment, vWarehouse, vEmpresa, vAddressFk, vAgencyModeFk, NULL, vLanding, account.userGetId(), vNewTicket); + + IF (vLanding IS NULL) THEN + + SELECT e.email INTO vSalesPersonEmail + FROM vn.client c + JOIN vn.worker sp ON sp.id = c.salesPersonFk + JOIN account.emailUser e ON e.userFk = sp.userFk + WHERE c.id = vClient; + + SET vSubject = CONCAT('Turnos - No se ha podido clonar correctamente el ticket ', vTicket, + ' para el dia: ', vShipment); + SET vMessage = CONCAT('No se ha podido clonar el ticket ', vTicket, + ' para el dia: ', vShipment, + ' porque no hay una zona de envío disponible. Se ha creado el ticket: ', vNewTicket, + ' pero ha que revisar las fechas y la agencia'); + + SELECT COUNT(*) INTO vMailSent + FROM vn.mail + WHERE sender = vSalesPersonEmail + AND subject = vSubject; + + IF NOT vMailSent THEN + INSERT INTO vn.mail (sender,`subject`,body) + VALUES (vSalesPersonEmail, vSubject, vMessage); + END IF; + CALL vn.ticketStateUpdate (vNewTicket, 'FIXING'); + END IF; + + INSERT INTO vn.sale (ticketFk, itemFk, concept, quantity, price, discount, priceFixed, isPriceFixed) + SELECT vNewTicket, saleOrig.itemFk , saleOrig.concept , saleOrig.quantity, saleOrig.price , saleOrig.discount, saleOrig.priceFixed, saleOrig.isPriceFixed + FROM vn.ticket tOrig + JOIN vn.sale saleOrig ON tOrig.id = saleOrig.ticketFk + LEFT JOIN vn.saleCloned sc ON sc.saleOriginalFk = saleOrig.id + LEFT JOIN vn.sale saleClon ON saleClon.id = sc.saleClonedFk + LEFT JOIN vn.ticket tClon ON tClon.id = saleClon.ticketFk AND DATE(tClon.shipped) = vShipment + WHERE tOrig.id = vTicket AND saleClon.id IS NULL; + + INSERT IGNORE INTO vn.saleCloned(saleOriginalFk, saleClonedFk) + SELECT saleOriginal.id, saleClon.id + FROM vn.sale saleOriginal + JOIN vn.sale saleClon ON saleOriginal.itemFk = saleClon.itemFk AND saleOriginal.quantity = saleClon.quantity + WHERE saleOriginal.ticketFk = vTicket AND saleClon.ticketFk = vNewTicket; + + INSERT INTO ticketRequest (description, ordered, shipped, salesPersonCode, buyerCode, quantity, price, + itemFk ,clientFk, response, total, buyed, saleFk) + SELECT tr.description, tr.ordered, tr.shipped, tr.salesPersonCode, tr.buyerCode, tr.quantity, tr.price, + tr.itemFk, tr.clientFk, tr.response, tr.total, tr.buyed, tr.saleFk + FROM sale s JOIN ticketRequest tr ON tr.saleFk = s.id + JOIN sale s2 ON s.concept = s2.concept AND s.quantity = s2.quantity AND m.Id_Article = m2.Id_Article + WHERE s.ticketFk = vTicket AND s2.ticketFk = vNewTicket; + + CALL vn.ticketCalculateClon(vNewTicket, vTicket); + END; + END LOOP; + + CLOSE rsTicket; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -54024,9 +55177,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -54114,6 +55267,8 @@ BEGIN WHERE e.ticketFk = vTicketFk AND IFNULL(p.isPackageReturnable, 0) = 0 AND getSpecialPrice(e.itemFk, vClientFk) > 0 GROUP BY e.itemFk); + + CALL vn.zonePromo_Make(); IF(vHasDailyInvoice) AND vHasToInvoice THEN @@ -54332,55 +55487,55 @@ BEGIN * * @return tmp.ticketComponentPreview (warehouseFk, itemFk, componentFk, cost) */ - DECLARE vHasDataChanged BOOL DEFAULT FALSE; - DECLARE vHasAddressChanged BOOL; - DECLARE vHasZoneChanged BOOL DEFAULT FALSE; - DECLARE vHasWarehouseChanged BOOL DEFAULT FALSE; + DECLARE vHasDataChanged BOOL DEFAULT FALSE; + DECLARE vHasAddressChanged BOOL; + DECLARE vHasZoneChanged BOOL DEFAULT FALSE; + DECLARE vHasWarehouseChanged BOOL DEFAULT FALSE; DECLARE vShipped DATE; DECLARE vAddressTypeRateFk INT DEFAULT NULL; DECLARE vAgencyModeTypeRateFk INT DEFAULT NULL; - - DECLARE vHasChangeAll BOOL DEFAULT FALSE; - + + DECLARE vHasChangeAll BOOL DEFAULT FALSE; + SELECT DATE(landed) <> vLanded, addressFk <> vAddressFk, zoneFk <> vZoneFk, - warehouseFk <> vWarehouseFk + warehouseFk <> vWarehouseFk INTO vHasDataChanged, - vHasAddressChanged, - vHasZoneChanged, - vHasWarehouseChanged + vHasAddressChanged, + vHasZoneChanged, + vHasWarehouseChanged FROM vn.ticket t - WHERE t.id = vTicketFk; + WHERE t.id = vTicketFk; - IF vHasDataChanged OR vHasWarehouseChanged THEN + IF vHasDataChanged OR vHasWarehouseChanged THEN SET vHasChangeAll = TRUE; END IF; - + IF vHasAddressChanged THEN SET vAddressTypeRateFk = 5; - END IF; - + END IF; + IF vHasZoneChanged THEN SET vAgencyModeTypeRateFk = 6; - END IF; + END IF; SELECT TIMESTAMPADD(DAY, -travelingDays, vLanded) INTO vShipped FROM zone WHERE id = vZoneFk; - + CALL buyUltimate(vWarehouseFk, vShipped); - + DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; - CREATE TEMPORARY TABLE tmp.ticketLot ENGINE = MEMORY ( + CREATE TEMPORARY TABLE tmp.ticketLot ENGINE = MEMORY ( SELECT vWarehouseFk AS warehouseFk, NULL AS available, s.itemFk, bu.buyFk, - vZoneFk zoneFk + vZoneFk zoneFk FROM sale s LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk WHERE s.ticketFk = vTicketFk @@ -54400,10 +55555,8 @@ BEGIN OR (NOT vHasChangeAll AND (NOT (c.typeFk <=> vAddressTypeRateFk - OR c.typeFk <=> vAgencyModeTypeRateFk)))); + OR c.typeFk <=> vAgencyModeTypeRateFk)))); - SET @shipped = vShipped; - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentPreview; CREATE TEMPORARY TABLE tmp.ticketComponentPreview SELECT * FROM tmp.ticketComponent; @@ -54413,11 +55566,11 @@ BEGIN IF vShipped IS NULL THEN CALL util.throw('NO_ZONE_AVAILABLE'); - END IF; - + END IF; + IF vShipped < CURDATE() THEN CALL util.throw('ERROR_PAST_SHIPMENT'); - END IF; + END IF; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -54873,7 +56026,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ticket_recalcComponents`(IN vTicketFk BIGINT) +CREATE DEFINER=`root`@`%` PROCEDURE `ticket_recalcComponents`(IN vTicketFk BIGINT, vIsTicketEditable BOOLEAN) proc: BEGIN /** @@ -54888,23 +56041,28 @@ proc: BEGIN DECLARE vAgencyModeFk INT; DECLARE vAddressFk INT; DECLARE vLanded DATE; - DECLARE vIsTicketEditable BOOLEAN; DECLARE vZoneFk INTEGER; + IF vIsTicketEditable IS NULL THEN + SELECT IFNULL(ts.alertLevel,0) = 0 AND IFNULL(t.refFk,'') = '' + INTO vIsTicketEditable + FROM ticket t LEFT JOIN ticketState ts ON t.id = ts.ticket + WHERE id = vTicketFk; + END IF; + SELECT t.warehouseFk, t.shipped, t.addressFk, t.agencyModeFk, - t.landed, - IFNULL(ts.alertLevel,0) = 0 AND IFNULL(t.refFk,'') = '' , - t.zoneFk - INTO vWarehouseFk, vShipped, vAddressFk, vAgencyModeFk, vLanded, vIsTicketEditable, vZoneFk + t.landed, + t.zoneFk + INTO vWarehouseFk, vShipped, vAddressFk, vAgencyModeFk, vLanded, vZoneFk FROM ticket t LEFT JOIN ticketState ts ON t.id = ts.ticket WHERE t.id = vTicketFk; IF vLanded IS NULL OR vZoneFk IS NULL THEN - CALL zone_getLanded(vShipped, vAddressFk, vAgencyModeFk, vWarehouseFk); + CALL zone_getLanded(vShipped, vAddressFk, vAgencyModeFk, vWarehouseFk, TRUE); IF (SELECT COUNT(*) FROM tmp.zoneGetLanded LIMIT 1) = 0 THEN CALL util.throw('There is no zone for these parameters'); @@ -58762,6 +59920,37 @@ BEGIN HAVING isIncluded > 0) t GROUP BY agencyModeFk; +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 `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 = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `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 */ ; @@ -59116,7 +60305,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `zone_getLanded`(vShipped DATE, vAddressFk INT, vAgencyModeFk INT, vWarehouseFk INT) +CREATE DEFINER=`root`@`%` 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. @@ -59129,7 +60318,7 @@ BEGIN */ CALL zone_getFromGeo(address_getGeo(vAddressFk)); - CALL zone_getOptionsForShipment(vShipped, TRUE); + CALL zone_getOptionsForShipment(vShipped, vShowExpiredZones); DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetLanded; CREATE TEMPORARY TABLE tmp.zoneGetLanded @@ -59805,6 +60994,94 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `zone_upcomingDeliveries` */; +/*!50003 SET @saved_cs_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 `zone_upcomingDeliveries`() +BEGIN + + DECLARE vForwardDays INT; + + SELECT forwardDays INTO vForwardDays FROM zoneConfig; + CALL util.time_createTable(CURDATE(), DATE_ADD(CURDATE(), INTERVAL vForwardDays DAY)); + + 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, ti.dated) landed, + ti.dated shipped + FROM zone z + JOIN zoneEvent e ON e.zoneFk = z.id + JOIN tmp.time ti ON ti.dated BETWEEN curdate() AND TIMESTAMPADD(DAY, vForwardDays, curdate()); + + DROP TEMPORARY TABLE IF EXISTS tmp.zoneOption; + CREATE TEMPORARY TABLE tmp.zoneOption + ENGINE = MEMORY + SELECT * + FROM ( + SELECT z.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, + l.shipped + FROM zone z + JOIN zoneEvent e ON e.zoneFk = z.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, landed; + + DELETE t FROM tmp.zoneOption t + JOIN zoneExclusion e + ON e.zoneFk = t.zoneFk AND e.`dated` = t.landed; + + SELECT MAX(zo.`hour`) `hour`, zg.`name`, zo.shipped, zo.zoneFk + FROM tmp.zoneOption zo + JOIN `zone` z ON z.id = zo.zoneFk + JOIN agencyMode am ON am.id = z.agencyModeFk + JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk + JOIN zoneIncluded zi ON zi.zoneFk = z.id + JOIN zoneGeo zg ON zg.id = zi.geoFk AND zg.type = 'province' + WHERE dm.code = 'DELIVERY' + GROUP BY shipped, zg.`name` + ORDER BY shipped, zg.`name`; + + DROP TEMPORARY TABLE tmp.time, tLandings; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; -- -- Current Database: `vncontrol` @@ -60911,12 +62188,12 @@ USE `vn`; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8 */; -/*!50001 SET character_set_results = utf8 */; -/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `absenceType` AS select `cs`.`calendar_state_id` AS `id`,`cs`.`type` AS `name`,`cs`.`rgb` AS `rgb`,`cs`.`code` AS `code` from `postgresql`.`calendar_state` `cs` */; +/*!50001 VIEW `absenceType` AS select `cs`.`calendar_state_id` AS `id`,`cs`.`type` AS `name`,`cs`.`rgb` AS `rgb`,`cs`.`code` AS `code`,`cs`.`holidayEntitlementRate` AS `holidayEntitlementRate` from `postgresql`.`calendar_state` `cs` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -61384,7 +62661,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionTruck_Control_Detail_Pallet` AS select `et`.`id` AS `id`,`et`.`ETD` AS `ETD`,ifnull(ucase(`et`.`description`),'SIN ESCANEAR') AS `destino`,`ep`.`id` AS `pallet`,`t`.`routeFk` AS `route`,count(distinct `es`.`id`) AS `scans`,`et2`.`description` AS `destinos`,sum((`et`.`id` <> `rm`.`expeditionTruckFk`)) AS `fallos` from ((((((`vn`.`ticket` `t` left join `vn`.`expedition` `e` on((`t`.`id` = `e`.`ticketFk`))) left join `vn`.`expeditionScan` `es` on((`e`.`id` = `es`.`expeditionFk`))) left join `vn`.`expeditionPallet` `ep` on((`es`.`palletFk` = `ep`.`id`))) left join `vn`.`expeditionTruck` `et` on((`ep`.`truckFk` = `et`.`id`))) left join `vn2008`.`Rutas_monitor` `rm` on((`rm`.`Id_Ruta` = `t`.`routeFk`))) left join `vn`.`expeditionTruck` `et2` on((`et2`.`id` = `rm`.`expeditionTruckFk`))) where ((`t`.`shipped` >= curdate()) and `t`.`routeFk`) group by `et`.`id`,`ep`.`id`,`t`.`routeFk` order by `fallos` desc,`ep`.`id` */; +/*!50001 VIEW `expeditionTruck_Control_Detail_Pallet` AS select `et`.`id` AS `id`,`et`.`ETD` AS `ETD`,ifnull(ucase(`et`.`description`),'SIN ESCANEAR') AS `destino`,`ep`.`id` AS `pallet`,`t`.`routeFk` AS `route`,count(distinct `es`.`id`) AS `scans`,`et2`.`description` AS `destinos`,sum((`et`.`id` <> `rm`.`expeditionTruckFk`)) AS `fallos`,`rm`.`expeditionTruckFk` AS `expeditionTruckFk` from ((((((`vn`.`ticket` `t` left join `vn`.`expedition` `e` on((`t`.`id` = `e`.`ticketFk`))) left join `vn`.`expeditionScan` `es` on((`e`.`id` = `es`.`expeditionFk`))) left join `vn`.`expeditionPallet` `ep` on((`es`.`palletFk` = `ep`.`id`))) left join `vn`.`expeditionTruck` `et` on((`ep`.`truckFk` = `et`.`id`))) left join `vn2008`.`Rutas_monitor` `rm` on((`rm`.`Id_Ruta` = `t`.`routeFk`))) left join `vn`.`expeditionTruck` `et2` on((`et2`.`id` = `rm`.`expeditionTruckFk`))) where ((`t`.`shipped` >= curdate()) and `t`.`routeFk`) group by `et`.`id`,`ep`.`id`,`t`.`routeFk` order by `fallos` desc,`ep`.`id` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -62032,7 +63309,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleVolume` AS select `s`.`ticketFk` AS `ticketFk`,`s`.`id` AS `saleFk`,ifnull(round(((((`i`.`compression` * (greatest(`i`.`density`,167) / 167)) * `ic`.`cm3`) * `s`.`quantity`) / 1000),2),0) AS `litros`,`t`.`routeFk` AS `routeFk`,`t`.`shipped` AS `shipped`,(((`s`.`quantity` * `ic`.`cm3`) * `i`.`compression`) / 1000000) AS `volume`,((`s`.`quantity` * `ic`.`grams`) / 1000) AS `physicalWeight`,((((`s`.`quantity` * `ic`.`cm3`) * greatest(`i`.`density`,167)) / 167) / 1000000) AS `weight`,(((`s`.`quantity` * `ic`.`cm3`) * `i`.`compression`) / 1000000) AS `physicalVolume`,((((`s`.`quantity` * `ic`.`cm3`) * `t`.`zonePrice`) * `i`.`compression`) / `cb`.`volume`) AS `freight`,`t`.`zoneFk` AS `zoneFk`,`t`.`clientFk` AS `clientFk`,`s`.`isPicked` AS `isPicked` from ((((`sale` `s` join `item` `i` on((`i`.`id` = `s`.`itemFk`))) join `ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `packaging` `cb` on((`cb`.`id` = '94'))) join `itemCost` `ic` on(((`ic`.`itemFk` = `s`.`itemFk`) and (`ic`.`warehouseFk` = `t`.`warehouseFk`)))) */; +/*!50001 VIEW `saleVolume` AS select `s`.`ticketFk` AS `ticketFk`,`s`.`id` AS `saleFk`,ifnull(round(((((greatest(`i`.`density`,167) / 167) * `ic`.`cm3`) * `s`.`quantity`) / 1000),2),0) AS `litros`,`t`.`routeFk` AS `routeFk`,`t`.`shipped` AS `shipped`,((`s`.`quantity` * `ic`.`cm3`) / 1000000) AS `volume`,((`s`.`quantity` * `ic`.`grams`) / 1000) AS `physicalWeight`,((((`s`.`quantity` * `ic`.`cm3`) * greatest(`i`.`density`,167)) / 167) / 1000000) AS `weight`,((`s`.`quantity` * `ic`.`cm3`) / 1000000) AS `physicalVolume`,(((`s`.`quantity` * `ic`.`cm3`) * `t`.`zonePrice`) / `cb`.`volume`) AS `freight`,`t`.`zoneFk` AS `zoneFk`,`t`.`clientFk` AS `clientFk`,`s`.`isPicked` AS `isPicked` from ((((`sale` `s` join `item` `i` on((`i`.`id` = `s`.`itemFk`))) join `ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `packaging` `cb` on((`cb`.`id` = '94'))) join `itemCost` `ic` on(((`ic`.`itemFk` = `s`.`itemFk`) and (`ic`.`warehouseFk` = `t`.`warehouseFk`)))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -62520,4 +63797,4 @@ USE `vncontrol`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-06-02 13:11:36 +-- Dump completed on 2020-06-23 12:58:41 diff --git a/modules/ticket/back/methods/ticket-weekly/filter.js b/modules/ticket/back/methods/ticket-weekly/filter.js index 77f8ecc57..ef00aff9b 100644 --- a/modules/ticket/back/methods/ticket-weekly/filter.js +++ b/modules/ticket/back/methods/ticket-weekly/filter.js @@ -51,7 +51,7 @@ module.exports = Self => { stmt = new ParameterizedSQL( `SELECT t.id AS ticketFk, c.id AS clientFk, c.name AS clientName, tw.weekDay, - wh.name AS warehouseName, u.id AS workerFk, u.nickName, tw.agencyModeFk + wh.name AS warehouseName, u.id AS workerFk, u.name AS userName, u.nickName, tw.agencyModeFk FROM ticketWeekly tw JOIN ticket t ON t.id = tw.ticketFk JOIN client c ON c.id = t.clientFk diff --git a/modules/ticket/back/methods/ticket/specs/getTaxes.spec.js b/modules/ticket/back/methods/ticket/specs/getTaxes.spec.js index 74f336bbd..68010479c 100644 --- a/modules/ticket/back/methods/ticket/specs/getTaxes.spec.js +++ b/modules/ticket/back/methods/ticket/specs/getTaxes.spec.js @@ -4,6 +4,6 @@ describe('ticket getTaxes()', () => { it('should return the tax of a given ticket', async() => { let result = await app.models.Ticket.getTaxes(1); - expect(result[0].tax).toEqual(77.54); + expect(result[0].tax).toEqual(7.1); }); }); diff --git a/modules/ticket/front/routes.json b/modules/ticket/front/routes.json index cfb2d07c9..ac398c49e 100644 --- a/modules/ticket/front/routes.json +++ b/modules/ticket/front/routes.json @@ -189,28 +189,26 @@ "state": "ticket.weekly.index", "component": "vn-ticket-weekly-index", "description": "Weekly tickets" - }, { - "url": "/request", - "state": "ticket.card.request", - "abstract": true, - "component": "ui-view" }, { "url": "/service", "state": "ticket.card.service", "component": "vn-ticket-service", "description": "Service" + }, { + "url": "/request", + "state": "ticket.card.request", + "abstract": true, + "component": "ui-view" }, { "url" : "/index", "state": "ticket.card.request.index", "component": "vn-ticket-request-index", - "description": "Purchase request", - "acl": ["salesPerson"] + "description": "Purchase request" }, { "url" : "/create", "state": "ticket.card.request.create", "component": "vn-ticket-request-create", - "description": "New purchase request", - "acl": ["salesPerson"] + "description": "New purchase request" }, { "url": "/create?clientFk", "state": "ticket.create", diff --git a/modules/ticket/front/weekly/index.html b/modules/ticket/front/weekly/index.html index 92ee64478..b51a7a887 100644 --- a/modules/ticket/front/weekly/index.html +++ b/modules/ticket/front/weekly/index.html @@ -18,13 +18,13 @@ + class="vn-w-xl"> Ticket ID - Client + Client Weekday Agency Warehouse @@ -53,7 +53,7 @@ - - {{::weekly.nickName}} + {{::weekly.userName}} diff --git a/modules/ticket/front/weekly/locale/es.yml b/modules/ticket/front/weekly/locale/es.yml index 7c7c6a139..804467dae 100644 --- a/modules/ticket/front/weekly/locale/es.yml +++ b/modules/ticket/front/weekly/locale/es.yml @@ -3,4 +3,5 @@ Weekly tickets: Tickets programados You are going to delete this weekly ticket: Vas a eliminar este ticket programado This ticket will be removed from weekly tickets! Continue anyway?: Este ticket se eliminará de tickets programados! ¿Continuar de todas formas? Search weekly ticket by id or client id: Busca tickets programados por el identificador o el identificador del cliente -Search by weekly ticket: Buscar por tickets programados \ No newline at end of file +Search by weekly ticket: Buscar por tickets programados +weekDay: Dia \ No newline at end of file