+ *
+ */
+ INSERT IGNORE INTO `order`(
+ catalogueFk,
+ customerName,
+ email,
+ customerPhone,
+ message,
+ deliveryName,
+ address,
+ deliveryPhone
+ )
+ VALUES (JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.catalogueFk')),
+ JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.customerName')),
+ JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.email')),
+ JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.customerPhone')),
+ JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.message')),
+ JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.deliveryName')),
+ JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.address')),
+ JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.deliveryPhone'))
+ );
+
+ SELECT LAST_INSERT_ID() orderFk;
+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_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `sliders_get` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` PROCEDURE `sliders_get`()
+ READS SQL DATA
+BEGIN
+/**
+ * Returns list of url for sliders
+ */
+ SELECT
+ CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image) url,
+ i.longName
+ FROM vn.item i
+ JOIN vn.itemType it ON it.id = i.typeFk
+ WHERE it.code IN ('FNR','FNP')
+ LIMIT 3;
+
+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: `hedera`
--
@@ -11799,7 +12221,7 @@ DROP TABLE IF EXISTS `config`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `config` (
- `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
+ `id` tinyint(3) unsigned NOT NULL,
`defaultLang` char(2) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL COMMENT 'The default language if none is specified',
`https` tinyint(3) unsigned NOT NULL COMMENT 'Wether to force de use of HTTPS',
`cookieLife` smallint(5) unsigned NOT NULL COMMENT 'The cookies life, in days',
@@ -11813,7 +12235,8 @@ CREATE TABLE `config` (
`pdfsDir` varchar(255) NOT NULL COMMENT 'Directory where PDFs are allocated',
`dmsDir` varchar(255) DEFAULT NULL COMMENT 'Directory where documents are allocated',
PRIMARY KEY (`id`),
- KEY `jwtkey_IX` (`jwtKey`) COMMENT 'Prueba de Ernesto 3.8.2020. MySQL se queja de no tener indices. Si, se que solo tiene un registro pero molesta para depurar otros.'
+ KEY `jwtkey_IX` (`jwtKey`) COMMENT 'Prueba de Ernesto 3.8.2020. MySQL se queja de no tener indices. Si, se que solo tiene un registro pero molesta para depurar otros.',
+ CONSTRAINT `config_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Global configuration parameters';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -11906,11 +12329,12 @@ DROP TABLE IF EXISTS `imageConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `imageConfig` (
- `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Identifier',
+ `id` tinyint(3) unsigned NOT NULL,
`maxSize` int(10) unsigned NOT NULL COMMENT 'Maximun size for uploaded images in MB',
`useXsendfile` tinyint(4) NOT NULL COMMENT 'Whether to use the apache module XSendfile',
`url` varchar(255) NOT NULL COMMENT 'Public URL where image are hosted',
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `imageConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci COMMENT='Global image parameters';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -11977,7 +12401,7 @@ DROP TABLE IF EXISTS `mailConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `mailConfig` (
- `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Identifier',
+ `id` tinyint(3) unsigned NOT NULL,
`host` varchar(255) NOT NULL DEFAULT 'localhost' COMMENT 'SMTP host',
`port` smallint(6) NOT NULL DEFAULT 465 COMMENT 'SMTP port',
`secure` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Wether to use a secure connection',
@@ -11985,7 +12409,8 @@ CREATE TABLE `mailConfig` (
`senderName` varchar(75) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL COMMENT 'The sender name',
`user` varchar(50) DEFAULT NULL COMMENT 'SMTP user',
`password` varchar(100) DEFAULT NULL COMMENT 'SMTP password, base64 encoded',
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `mailConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -12432,7 +12857,7 @@ DROP TABLE IF EXISTS `orderConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `orderConfig` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`employeeFk` int(10) unsigned NOT NULL,
`defaultAgencyFk` int(11) DEFAULT NULL,
`guestMethod` varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
@@ -12448,7 +12873,8 @@ CREATE TABLE `orderConfig` (
CONSTRAINT `orderConfigCompany_Fk` FOREIGN KEY (`defaultCompanyFk`) REFERENCES `vn`.`company` (`id`) ON UPDATE CASCADE,
CONSTRAINT `orderConfig_ibfk_1` FOREIGN KEY (`employeeFk`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE,
CONSTRAINT `orderConfig_ibfk_3` FOREIGN KEY (`guestAgencyFk`) REFERENCES `vn`.`agencyMode` (`id`) ON UPDATE CASCADE,
- CONSTRAINT `orderConfig_ibfk_4` FOREIGN KEY (`defaultAgencyFk`) REFERENCES `vn`.`agencyMode` (`id`)
+ CONSTRAINT `orderConfig_ibfk_4` FOREIGN KEY (`defaultAgencyFk`) REFERENCES `vn`.`agencyMode` (`id`),
+ CONSTRAINT `orderConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -12699,7 +13125,7 @@ DROP TABLE IF EXISTS `tpvConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `tpvConfig` (
- `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
+ `id` tinyint(3) unsigned NOT NULL,
`currency` smallint(5) unsigned NOT NULL,
`terminal` tinyint(3) unsigned NOT NULL,
`transactionType` tinyint(3) unsigned NOT NULL,
@@ -12712,7 +13138,8 @@ CREATE TABLE `tpvConfig` (
`merchantUrl` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `employee_id` (`employeeFk`),
- CONSTRAINT `employee_id` FOREIGN KEY (`employeeFk`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE
+ CONSTRAINT `employee_id` FOREIGN KEY (`employeeFk`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `tpvConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Virtual TPV parameters';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -12738,14 +13165,15 @@ DROP TABLE IF EXISTS `tpvImapConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `tpvImapConfig` (
- `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
+ `id` tinyint(3) unsigned NOT NULL,
`host` varchar(150) NOT NULL,
`user` varchar(50) NOT NULL,
`pass` varchar(50) NOT NULL,
`cleanPeriod` varchar(15) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
`successFolder` varchar(150) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
`errorFolder` varchar(150) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `tpvImapConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='IMAP configuration parameters for virtual TPV';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -12942,14 +13370,14 @@ DELIMITER ;;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;;
-/*!50003 SET character_set_client = utf8mb3 */ ;;
-/*!50003 SET character_set_results = utf8mb3 */ ;;
-/*!50003 SET collation_connection = utf8mb3_general_ci */ ;;
+/*!50003 SET character_set_client = utf8mb4 */ ;;
+/*!50003 SET character_set_results = utf8mb4 */ ;;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;;
/*!50003 SET @saved_time_zone = @@time_zone */ ;;
/*!50003 SET time_zone = 'SYSTEM' */ ;;
-/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `order_doRecalc` ON SCHEDULE EVERY 10 SECOND STARTS '2019-08-29 14:18:04' ON COMPLETION PRESERVE ENABLE DO CALL order_doRecalc */ ;;
+/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `order_doRecalc` ON SCHEDULE EVERY 10 SECOND STARTS '2019-08-29 14:18:04' ON COMPLETION PRESERVE DISABLE DO CALL order_doRecalc */ ;;
/*!50003 SET time_zone = @saved_time_zone */ ;;
/*!50003 SET sql_mode = @saved_sql_mode */ ;;
/*!50003 SET character_set_client = @saved_cs_client */ ;;
@@ -13115,7 +13543,7 @@ BEGIN
WHERE c.available > 0
GROUP BY c.item_id;
- CALL vn.catalog_calculate(vDelivery, vAddress, vAgencyMode);
+ CALL vn.catalog_calculate(vDelivery, vAddress, vAgencyMode, FALSE);
DROP TEMPORARY TABLE tmp.item;
END ;;
@@ -13219,7 +13647,7 @@ BEGIN
ENGINE = MEMORY
SELECT vSelf itemFk;
- CALL vn.catalog_calculate(vLanded, vAddressFk, vAgencyModeFk);
+ CALL vn.catalog_calculate(vLanded, vAddressFk, vAgencyModeFk, FALSE);
SELECT l.warehouseFk, w.name warehouse,
p.`grouping`, p.price, p.rate, l.available
@@ -14395,7 +14823,7 @@ BEGIN
WHERE orderFk = vSelf
GROUP BY itemFk;
- CALL vn.catalog_calculate(vDate, vAddress, vAgencyMode);
+ CALL vn.catalog_calculate(vDate, vAddress, vAgencyMode, FALSE);
DROP TEMPORARY TABLE tmp.item;
END ;;
@@ -14477,7 +14905,7 @@ BEGIN
FROM `order`
WHERE id = vSelf;
- CALL vn.catalog_calculate(vDate, vAddress, vAgencyMode);
+ CALL vn.catalog_calculate(vDate, vAddress, vAgencyMode, FALSE);
IF account.myUser_getName() = 'visitor' THEN
UPDATE tmp.ticketCalculateItem
@@ -15296,7 +15724,8 @@ proc: BEGIN
LEAVE proc;
END IF;
- INSERT INTO orderRecalc SET orderFk = vSelf;
+ -- #4409 Disable order recalc
+ -- INSERT INTO orderRecalc SET orderFk = vSelf;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -15882,7 +16311,7 @@ p: BEGIN
FROM vn.`client` WHERE id = vCustomer;
SELECT account INTO vAccount
- FROM vn.bank WHERE id = vBank;
+ FROM vn.accounting WHERE id = vBank;
DELETE FROM vn.XDiario
WHERE SUBCTA = vSubaccount
@@ -16162,10 +16591,10 @@ DROP TABLE IF EXISTS `config`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `config` (
- `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
- `sundayFestive` tinyint(4) NOT NULL,
- `countryPrefix` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
- PRIMARY KEY (`id`)
+ `id` int(10) unsigned NOT NULL,
+ `defaultPrefix` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ CONSTRAINT `config_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Global configuration';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -16208,13 +16637,14 @@ DROP TABLE IF EXISTS `followmeConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `followmeConfig` (
- `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`music` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
`context` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
`takeCall` char(1) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
`declineCall` char(1) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
`timeout` int(11) NOT NULL,
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `followmeConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -16233,6 +16663,36 @@ SET character_set_client = utf8;
1 AS `timeout` */;
SET character_set_client = @saved_cs_client;
+--
+-- Table structure for table `holiday`
+--
+
+DROP TABLE IF EXISTS `holiday`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `holiday` (
+ `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `country` char(2) NOT NULL,
+ `day` date NOT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `holiday_country_IDX` (`country`,`day`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `prefix`
+--
+
+DROP TABLE IF EXISTS `prefix`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `prefix` (
+ `country` char(2) NOT NULL COMMENT 'Country code',
+ `prefix` varchar(100) NOT NULL COMMENT 'Country prefix',
+ PRIMARY KEY (`country`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `queue`
--
@@ -16350,13 +16810,11 @@ DROP TABLE IF EXISTS `schedule`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `schedule` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
- `weekDay` tinyint(3) unsigned NOT NULL COMMENT '0 = Monday, 6 = Sunday',
- `timeStart` time NOT NULL,
- `timeEnd` time NOT NULL,
- `queue` varchar(128) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
- PRIMARY KEY (`id`),
- KEY `queue` (`queue`),
- CONSTRAINT `schedule_ibfk_1` FOREIGN KEY (`queue`) REFERENCES `queue` (`name`)
+ `weekDays` set('mon','tue','wed','thu','fri','sat','sun') NOT NULL COMMENT '0 = Monday, 6 = Sunday',
+ `startTime` time NOT NULL,
+ `endTime` time NOT NULL,
+ `country` char(2) NOT NULL,
+ PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -16425,7 +16883,7 @@ DROP TABLE IF EXISTS `sipConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `sipConfig` (
- `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
+ `id` mediumint(8) unsigned NOT NULL,
`host` varchar(40) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
`deny` varchar(95) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
`permit` varchar(95) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
@@ -16446,7 +16904,8 @@ CREATE TABLE `sipConfig` (
`disallow` varchar(100) DEFAULT 'all',
`allow` varchar(100) DEFAULT 'g729;ilbc;gsm;ulaw;alaw',
`qualify` enum('yes','no') DEFAULT NULL,
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `sipConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Default values for SIP accounts';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -17456,13 +17915,14 @@ DROP TABLE IF EXISTS `config`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `config` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`pendingTaxAccount` varchar(100) DEFAULT NULL COMMENT 'Cuenta contable IVA pendiente',
`nontaxableTransactionTypeFk` tinyint(4) DEFAULT NULL COMMENT 'Transacción Operaciones exentas',
`pendingServiceTransactionTypeFk` tinyint(4) DEFAULT NULL COMMENT 'Transacción Import. bienes y serv. corrientes pdte. liquidar',
`definitiveExportTransactionTypeFk` tinyint(4) DEFAULT NULL COMMENT 'Transacción Exportaciones definitivas',
`shipmentTransactionTypeFk` tinyint(4) DEFAULT NULL COMMENT 'Transacción Envíos definitivos a Canarias, Ceuta y Melilla',
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `config_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -18130,9 +18590,9 @@ BEGIN
LIMIT 10000000000000000000
) sub GROUP BY ASIEN
)sub2 ON sub2.ASIEN = x.ASIEN
- LEFT JOIN ( SELECT DISTINCT(account),cu.code
- FROM vn.bank b
- JOIN vn.currency cu ON cu.id = b.currencyFk
+ LEFT JOIN ( SELECT DISTINCT(a.account),cu.code
+ FROM vn.accounting a
+ JOIN vn.currency cu ON cu.id = a.currencyFk
WHERE cu.code <> 'EUR' -- no se informa cuando la divisa en EUR
)sub3 ON sub3.account = x.SUBCTA
WHERE x.enlazadoSage = FALSE
@@ -19367,12 +19827,12 @@ BEGIN
FROM vn.expense e
UNION
SELECT company_getCode(vCompanyFk),
- b.account,
- UCASE(b.bank),
+ a.account,
+ UCASE(a.bank),
''
- FROM vn.bank b
- WHERE b.isActive
- AND b.`account`
+ FROM vn.accounting a
+ WHERE a.isActive
+ AND a.`account`
UNION
SELECT CodigoEmpresa,
CodigoCuenta,
@@ -19512,11 +19972,12 @@ DROP TABLE IF EXISTS `accessTokenConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `accessTokenConfig` (
- `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`renewPeriod` int(10) unsigned DEFAULT NULL,
`courtesyTime` int(10) unsigned DEFAULT NULL,
`renewInterval` int(10) unsigned DEFAULT NULL,
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `accessTokenConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -19588,10 +20049,11 @@ DROP TABLE IF EXISTS `printConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `printConfig` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`itRecipient` varchar(50) DEFAULT NULL COMMENT 'IT recipients for report mailing',
`incidencesEmail` varchar(50) DEFAULT NULL COMMENT 'CAU destinatary email',
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `printConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Print service config';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -19883,7 +20345,7 @@ CREATE TABLE `config` (
`bufferWidthMargin` int(11) NOT NULL DEFAULT 100 COMMENT 'margen mínimo para que una caja pueda entrar en un buffer',
`bufferDefault` int(11) NOT NULL DEFAULT 26 COMMENT 'buffer por defecto si no se encuentra otro',
`bufferLength` int(11) NOT NULL DEFAULT 13000 COMMENT 'Longitud de los buffers, en mm',
- `id` int(11) NOT NULL DEFAULT 1,
+ `id` int(10) unsigned NOT NULL,
`maxBoxesInBuffer` int(11) NOT NULL DEFAULT 8 COMMENT 'max numero de cajas por buffer para declararlo full',
`isEnteringBlocked` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'bloquea la entrada de nuevas cajas al sorter',
`isAuto` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'deja el sorter en auto por un buffer',
@@ -19901,7 +20363,8 @@ CREATE TABLE `config` (
`isBalanced` tinyint(1) NOT NULL DEFAULT 1,
`testMode` tinyint(1) NOT NULL DEFAULT 0,
`isAllowedUnloading` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Permite que se pueda cambiar el mode de los buffers a UNLOADING',
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `config_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -19984,6 +20447,8 @@ CREATE TABLE `expeditionLog` (
PRIMARY KEY (`id`),
KEY `expeditionLog_FK_1` (`bufferFk`),
KEY `expeditionLog_FK_2` (`antennaFk`),
+ KEY `expeditionLog_action_IDX` (`action`) USING BTREE,
+ KEY `expeditionLog_expeditionFk_IDX` (`expeditionFk`) USING BTREE,
CONSTRAINT `expeditionLog_FK_1` FOREIGN KEY (`bufferFk`) REFERENCES `buffer` (`id`) ON UPDATE CASCADE,
CONSTRAINT `expeditionLog_FK_2` FOREIGN KEY (`antennaFk`) REFERENCES `antenna` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
@@ -24447,7 +24912,7 @@ DROP TABLE IF EXISTS `config`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `config` (
- `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`dbVersion` char(11) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL COMMENT 'The current database version',
`hasTriggersDisabled` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Defines if triggers are disabled',
`environment` varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL COMMENT 'The current Database environment',
@@ -24455,7 +24920,8 @@ CREATE TABLE `config` (
`mockUtcTime` datetime DEFAULT NULL,
`mockTime` datetime DEFAULT NULL,
`mockEnabled` tinyint(3) unsigned NOT NULL DEFAULT 0,
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `config_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Global configuration table';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -24473,7 +24939,7 @@ CREATE TABLE `debug` (
`user` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
`host` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
`variable` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
- `value` varchar(255) DEFAULT NULL,
+ `value` text DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `created` (`created`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Log de depuración';
@@ -24519,7 +24985,7 @@ DROP TABLE IF EXISTS `notification`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `notification` (
- `id` int(11) NOT NULL,
+ `id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`description` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
@@ -24552,9 +25018,10 @@ DROP TABLE IF EXISTS `notificationConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `notificationConfig` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`cleanDays` mediumint(9) DEFAULT NULL,
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `notificationConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -24626,9 +25093,10 @@ DROP TABLE IF EXISTS `versionConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `versionConfig` (
- `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`realm` varchar(16) DEFAULT NULL COMMENT 'Data set on which the project runs',
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `versionConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -24824,6 +25292,33 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP FUNCTION IF EXISTS `checkPrintableChars` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` FUNCTION `checkPrintableChars`(vString VARCHAR(255)
+) RETURNS tinyint(1)
+ DETERMINISTIC
+BEGIN
+/**
+ * Validates whether the input string contains only printable characters
+ * and Spanish special characters (such as ¡, ÿ, etc.).
+ *
+ * @vString string to check
+ */
+ RETURN vString REGEXP '^[ -~¡-ÿ]*$';
+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_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP FUNCTION IF EXISTS `crypt` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -26202,16 +26697,24 @@ BEGIN
*/
DECLARE vSlowQueryLog INT DEFAULT @@slow_query_log;
DECLARE vSqlLogBin INT DEFAULT @@SESSION.sql_log_bin;
+ DECLARE vLogExists BOOL;
SET sql_log_bin = OFF;
SET GLOBAL slow_query_log = OFF;
- RENAME TABLE `mysql`.`slow_log` TO `mysql`.`slow_log_temp`;
+ SELECT COUNT(*) > 0 INTO vLogExists
+ FROM information_schema.TABLES
+ WHERE TABLE_SCHEMA = 'mysql' AND TABLE_NAME = 'slow_log';
- DELETE FROM `mysql`.`slow_log_temp`
+ IF vLogExists THEN
+ DROP TEMPORARY TABLE IF EXISTS mysql.slow_log_temp;
+ RENAME TABLE mysql.slow_log TO mysql.slow_log_temp;
+ END IF;
+
+ DELETE FROM mysql.slow_log_temp
WHERE start_time < TIMESTAMPADD(WEEK, -1, util.VN_NOW());
- RENAME TABLE `mysql`.`slow_log_temp` TO `mysql`.`slow_log`;
+ RENAME TABLE mysql.slow_log_temp TO mysql.slow_log;
SET GLOBAL slow_query_log = vSlowQueryLog;
SET sql_log_bin = vSqlLogBin;
@@ -26560,7 +27063,7 @@ CREATE TABLE `accountReconciliation` (
`valueDated` datetime NOT NULL,
`amount` double NOT NULL,
`concept` varchar(255) DEFAULT NULL,
- `debitCredit` smallint(6) NOT NULL,
+ `debitCredit` enum('debit','credit') DEFAULT NULL,
`calculatedCode` varchar(255) DEFAULT NULL,
`created` timestamp NULL DEFAULT current_timestamp(),
PRIMARY KEY (`id`),
@@ -26571,6 +27074,25 @@ CREATE TABLE `accountReconciliation` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `accountReconciliationConfig`
+--
+
+DROP TABLE IF EXISTS `accountReconciliationConfig`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `accountReconciliationConfig` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `currencyFk` tinyint(3) unsigned DEFAULT NULL,
+ `warehouseFk` smallint(6) unsigned DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ KEY `account_fk_currency` (`currencyFk`),
+ KEY `account_fk_warehouse` (`warehouseFk`),
+ CONSTRAINT `account_fk_currency` FOREIGN KEY (`currencyFk`) REFERENCES `currency` (`id`),
+ CONSTRAINT `account_fk_warehouse` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `accounting`
--
@@ -26606,10 +27128,11 @@ DROP TABLE IF EXISTS `accountingConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `accountingConfig` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`minDate` date NOT NULL,
`maxDate` date NOT NULL,
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `accountingConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -26917,7 +27440,9 @@ CREATE TABLE `agencyTermConfig` (
`expenseFk` varchar(10) DEFAULT NULL,
`vatAccountSupported` varchar(15) DEFAULT NULL,
`vatPercentage` decimal(28,10) DEFAULT NULL,
- `transaction` varchar(50) DEFAULT NULL
+ `transaction` varchar(50) DEFAULT NULL,
+ KEY `agencyTermConfig_expense_FK` (`expenseFk`),
+ CONSTRAINT `agencyTermConfig_expense_FK` FOREIGN KEY (`expenseFk`) REFERENCES `expense` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -27037,12 +27562,13 @@ DROP TABLE IF EXISTS `auctionConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `auctionConfig` (
- `id` int(11) NOT NULL,
+ `id` int(10) unsigned NOT NULL,
`conversionCoefficient` double NOT NULL DEFAULT 1 COMMENT 'value used to calculate the used space of an item in a container',
`warehouseFk` smallint(6) unsigned NOT NULL DEFAULT 7 COMMENT 'Default warehouse used for the calculation',
PRIMARY KEY (`id`),
KEY `auctionConfig_FK` (`warehouseFk`),
- CONSTRAINT `auctionConfig_FK` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`)
+ CONSTRAINT `auctionConfig_FK` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`),
+ CONSTRAINT `auctionConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -27054,13 +27580,14 @@ DROP TABLE IF EXISTS `autoRadioConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `autoRadioConfig` (
- `id` int(11) NOT NULL,
+ `id` int(10) unsigned NOT NULL,
`password` varchar(45) DEFAULT NULL,
`user` varchar(45) DEFAULT NULL,
`url` varchar(75) DEFAULT NULL,
`client` int(32) DEFAULT NULL,
`center` varchar(2) DEFAULT NULL,
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `autoRadioConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -27152,7 +27679,7 @@ CREATE TABLE `awb` (
KEY `awb_FK_3` (`invoiceInPaletizedFk`),
CONSTRAINT `awbInvoiceIn` FOREIGN KEY (`invoiceInFk`) REFERENCES `invoiceIn` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `awb_FK` FOREIGN KEY (`docFk`) REFERENCES `dms` (`id`) ON UPDATE CASCADE,
- CONSTRAINT `awb_FK_1` FOREIGN KEY (`flightFk`) REFERENCES `vn2008`.`flight` (`flight_id`) ON UPDATE CASCADE,
+ CONSTRAINT `awb_FK_1` FOREIGN KEY (`flightFk`) REFERENCES `flight` (`id`) ON UPDATE CASCADE,
CONSTRAINT `awb_FK_3` FOREIGN KEY (`invoiceInPaletizedFk`) REFERENCES `invoiceIn` (`id`) ON UPDATE CASCADE,
CONSTRAINT `awb_ibfk_1` FOREIGN KEY (`taxFk`) REFERENCES `taxCode` (`id`) ON UPDATE CASCADE,
CONSTRAINT `awb_supplierFk` FOREIGN KEY (`transitoryFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE
@@ -27341,25 +27868,6 @@ CREATE TABLE `balanceNestTree` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Temporary table structure for view `bank`
---
-
-DROP TABLE IF EXISTS `bank`;
-/*!50001 DROP VIEW IF EXISTS `bank`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE VIEW `bank` AS SELECT
- 1 AS `id`,
- 1 AS `bank`,
- 1 AS `account`,
- 1 AS `cash`,
- 1 AS `entityFk`,
- 1 AS `isActive`,
- 1 AS `currencyFk`,
- 1 AS `code` */;
-SET character_set_client = @saved_cs_client;
-
--
-- Table structure for table `bankEntity`
--
@@ -27386,10 +27894,11 @@ DROP TABLE IF EXISTS `bankEntityConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bankEntityConfig` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`bicLength` tinyint(4) DEFAULT 11 COMMENT 'Tamaño del campo bic',
`defaultBankId` int(11) NOT NULL DEFAULT 3117 COMMENT 'Id del banco por defecto',
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `bankEntityConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -27474,12 +27983,13 @@ DROP TABLE IF EXISTS `bionicConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bionicConfig` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`generalInflationCoeficient` double(10,2) NOT NULL,
`minimumDensityVolumetricWeight` double(10,2) NOT NULL,
`verdnaturaVolumeBox` int(11) NOT NULL,
`itemCarryBox` int(11) NOT NULL,
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `bionicConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -27780,9 +28290,9 @@ CREATE TABLE `buy` (
`freightValue` decimal(10,3) NOT NULL DEFAULT 0.000,
`isIgnored` tinyint(1) NOT NULL DEFAULT 0,
`stickers` int(11) NOT NULL DEFAULT 0,
- `packing` int(11) DEFAULT 0,
+ `packing` int(11) NOT NULL DEFAULT 1 CHECK (`packing` > 0),
`grouping` smallint(5) unsigned NOT NULL DEFAULT 1,
- `groupingMode` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0=sin obligar 1=groping 2=packing',
+ `groupingMode` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0=sin obligar 1=grouping 2=packing',
`containerFk` smallint(5) unsigned DEFAULT NULL,
`comissionValue` decimal(10,3) NOT NULL DEFAULT 0.000,
`packageValue` decimal(10,3) NOT NULL DEFAULT 0.000,
@@ -27803,7 +28313,7 @@ CREATE TABLE `buy` (
`deliveryFk` int(11) DEFAULT NULL,
`itemOriginalFk` int(11) DEFAULT NULL COMMENT 'Item original de la entrada',
`editorFk` int(10) unsigned DEFAULT NULL,
- `packageFk` varchar(10) GENERATED ALWAYS AS (`packagingFk`) VIRTUAL,
+ `buyerFk` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `CompresId_Trabajador` (`workerFk`),
KEY `Id_Cubo` (`packagingFk`),
@@ -27835,9 +28345,10 @@ DROP TABLE IF EXISTS `buyConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `buyConfig` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`monthsAgo` int(11) NOT NULL DEFAULT 6 COMMENT 'Meses desde la última compra',
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `buyConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -28007,6 +28518,7 @@ CREATE TABLE `category` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`description` varchar(45) NOT NULL,
`nick` varchar(3) NOT NULL,
+ `name` varchar(45) GENERATED ALWAYS AS (`description`) VIRTUAL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -28061,12 +28573,13 @@ DROP TABLE IF EXISTS `chatConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `chatConfig` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`host` varchar(255) NOT NULL,
`api` varchar(255) NOT NULL,
`user` varchar(50) NOT NULL,
`password` varchar(50) NOT NULL,
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `chatConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -28088,9 +28601,9 @@ 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,
+ `pickup` enum('agency','delivery') DEFAULT NULL,
`packages` smallint(10) unsigned DEFAULT 0 COMMENT 'packages received by the client',
- `rma` varchar(100) DEFAULT NULL,
+ `rma__` varchar(100) DEFAULT NULL,
`responsabilityRate` decimal(3,2) GENERATED ALWAYS AS ((5 - `responsibility`) / 4) VIRTUAL,
`editorFk` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
@@ -28137,9 +28650,10 @@ DROP TABLE IF EXISTS `claimConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `claimConfig` (
- `id` int(11) NOT NULL,
+ `id` int(10) unsigned NOT NULL,
`maxResponsibility` int(11) DEFAULT NULL,
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `claimConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -28377,19 +28891,19 @@ CREATE TABLE `claimResult` (
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `claimRma`
+-- Table structure for table `claimRma__`
--
-DROP TABLE IF EXISTS `claimRma`;
+DROP TABLE IF EXISTS `claimRma__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `claimRma` (
+CREATE TABLE `claimRma__` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`code` varchar(100) NOT NULL,
`created` timestamp NOT NULL DEFAULT current_timestamp(),
`workerFk` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='kkeada el 2024-02-26 por Pablo';
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -28427,7 +28941,7 @@ CREATE TABLE `client` (
`name` varchar(50) NOT NULL,
`defaultAddressFk` int(11) DEFAULT NULL,
`street` longtext DEFAULT NULL,
- `fi` varchar(14) DEFAULT NULL,
+ `fi` varchar(18) DEFAULT NULL,
`phone` varchar(15) DEFAULT NULL,
`email` varchar(255) DEFAULT NULL,
`dueDay` smallint(6) NOT NULL DEFAULT 5,
@@ -28458,7 +28972,7 @@ CREATE TABLE `client` (
`riskCalculated` date NOT NULL,
`hasCoreVnh` tinyint(1) DEFAULT 0,
`isRelevant` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Define los clientes cuyas ventas hay que tener en cuenta en los calculos estadisticos.',
- `clientTypeFk` int(11) NOT NULL DEFAULT 1,
+ `clientTypeFk__` int(11) NOT NULL DEFAULT 1 COMMENT '@deprecated 2024-02-20 refs #6784',
`creditInsurance` int(11) DEFAULT NULL,
`eypbc` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Email\\nYesterday\\nPurchases\\nBy\\nConsigna',
`hasToInvoiceByAddress` tinyint(1) DEFAULT 0,
@@ -28489,7 +29003,7 @@ CREATE TABLE `client` (
KEY `default_address` (`defaultAddressFk`),
KEY `Telefono` (`phone`),
KEY `movil` (`mobile`),
- KEY `tipos_de_cliente_idx` (`clientTypeFk`),
+ KEY `tipos_de_cliente_idx` (`clientTypeFk__`),
KEY `fk_Clientes_entity_idx` (`bankEntityFk`),
KEY `typeFk` (`typeFk`),
KEY `client_taxTypeSageFk_idx` (`taxTypeSageFk`),
@@ -28513,7 +29027,6 @@ CREATE TABLE `client` (
CONSTRAINT `client_ibfk_5` FOREIGN KEY (`provinceFk`) REFERENCES `province` (`id`) ON UPDATE CASCADE,
CONSTRAINT `client_taxTypeSageFk` FOREIGN KEY (`taxTypeSageFk`) REFERENCES `sage`.`TiposIva` (`CodigoIva`) ON UPDATE CASCADE,
CONSTRAINT `client_transactionTypeSageFk` FOREIGN KEY (`transactionTypeSageFk`) REFERENCES `sage`.`TiposTransacciones` (`CodigoTransaccion`) ON UPDATE CASCADE,
- CONSTRAINT `tipos_de_cliente` FOREIGN KEY (`clientTypeFk`) REFERENCES `clientType` (`id`) ON UPDATE CASCADE,
CONSTRAINT `typeFk` FOREIGN KEY (`typeFk`) REFERENCES `clientType` (`code`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -28545,7 +29058,7 @@ DROP TABLE IF EXISTS `clientConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `clientConfig` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`riskTolerance` int(11) DEFAULT NULL COMMENT 'Maximo riesgo de un cliente para preparar su pedido',
`maxCreditRows` int(11) DEFAULT NULL COMMENT 'Máximo número de registros a mantener en la tabla clientCredit',
`maxPriceIncreasingRatio` decimal(2,2) NOT NULL DEFAULT 0.25 COMMENT 'máximo recobro permitido',
@@ -28560,7 +29073,8 @@ CREATE TABLE `clientConfig` (
KEY `clientNewConfigPayMethod_FK` (`defaultPayMethodFk`),
KEY `clientNewConfigMandateType_FK` (`defaultMandateTypeFk`),
CONSTRAINT `clientNewConfigMandateType_FK` FOREIGN KEY (`defaultMandateTypeFk`) REFERENCES `mandateType` (`id`),
- CONSTRAINT `clientNewConfigPayMethod_FK` FOREIGN KEY (`defaultPayMethodFk`) REFERENCES `payMethod` (`id`)
+ CONSTRAINT `clientNewConfigPayMethod_FK` FOREIGN KEY (`defaultPayMethodFk`) REFERENCES `payMethod` (`id`),
+ CONSTRAINT `clientConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -28889,11 +29403,11 @@ DROP TABLE IF EXISTS `clientType`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `clientType` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
+ `id__` int(11) NOT NULL COMMENT '@deprecated 2024-02-20 refs #6784',
`code` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
`type` varchar(45) NOT NULL,
`isCreatedAsServed` tinyint(1) DEFAULT 0,
- PRIMARY KEY (`id`),
+ PRIMARY KEY (`code`),
UNIQUE KEY `code_UNIQUE` (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Establece categorias para poder agrupar las ventas';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -29190,7 +29704,7 @@ CREATE TABLE `company` (
`stamp` longblob DEFAULT NULL,
`created` timestamp NOT NULL ON UPDATE current_timestamp(),
`clientFk` int(11) DEFAULT NULL,
- `sage200Company` int(2) DEFAULT NULL,
+ `sage200Company__` int(2) DEFAULT NULL COMMENT '@deprecated 06/03/2024',
`supplierAccountFk` mediumint(8) unsigned DEFAULT NULL COMMENT 'Cuenta por defecto para ingresos desde este pais',
`isDefaulter` tinyint(4) NOT NULL DEFAULT 0,
`companyGroupFk` int(11) NOT NULL DEFAULT 1 COMMENT 'usado para calcular los greuges ',
@@ -29292,10 +29806,11 @@ DROP TABLE IF EXISTS `comparativeAddConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `comparativeAddConfig` (
- `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`period` int(10) unsigned DEFAULT NULL COMMENT 'The number of periods to be regressed for insertion in vn.comparative',
`week` int(10) unsigned DEFAULT NULL COMMENT 'The number of weeks to exceed for recalculating the last period',
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `comparativeAddConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -29307,12 +29822,13 @@ DROP TABLE IF EXISTS `comparativeConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `comparativeConfig` (
- `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`defaultDayRange` int(10) unsigned DEFAULT NULL COMMENT 'Rango de días predeterminado si no se especifica',
`weekRange` int(10) unsigned DEFAULT NULL COMMENT 'La cantidad de semanas que se restarán y sumarán',
`maxDayRange` int(10) unsigned DEFAULT NULL COMMENT 'El rango máximo de días antes de utilizar el rango de días predeterminado',
`minDayRange` int(10) unsigned DEFAULT NULL COMMENT 'El rango mínimo de días antes de utilizar el rango de días predeterminado',
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `comparativeConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -29423,7 +29939,7 @@ DROP TABLE IF EXISTS `config`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `config` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`ochoa` int(10) unsigned NOT NULL,
`invoiceOutFk` int(11) DEFAULT 0,
`inventoried` datetime DEFAULT NULL,
@@ -29462,7 +29978,8 @@ CREATE TABLE `config` (
`comparativeLastBuyScope` int(11) DEFAULT NULL COMMENT 'Rango en el que se busca la última entrada de un artículo',
`mainWarehouseFk` smallint(6) unsigned NOT NULL DEFAULT 60,
PRIMARY KEY (`id`),
- KEY `fechainv_idx` (`inventoried`)
+ KEY `fechainv_idx` (`inventoried`),
+ CONSTRAINT `config_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -29662,7 +30179,7 @@ CREATE TABLE `country` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`country` varchar(25) NOT NULL,
`CEE` tinyint(1) NOT NULL DEFAULT 1,
- `code` varchar(2) DEFAULT NULL,
+ `code` varchar(2) NOT NULL,
`currencyFk` tinyint(3) unsigned NOT NULL DEFAULT 1,
`politicalCountryFk__` mediumint(8) unsigned DEFAULT NULL COMMENT 'Pais Real(apaño por culpa del España Exento)',
`geoFk` int(11) DEFAULT NULL,
@@ -29673,6 +30190,7 @@ CREATE TABLE `country` (
`a3Code` int(11) DEFAULT NULL COMMENT 'Código país para a3',
`isSocialNameUnique` tinyint(1) NOT NULL DEFAULT 1,
PRIMARY KEY (`id`),
+ UNIQUE KEY `country_unique` (`code`),
KEY `Id_Paisreal` (`politicalCountryFk__`),
KEY `currency_id_fk_idx` (`currencyFk`),
KEY `country_Ix4` (`country`),
@@ -30054,6 +30572,8 @@ CREATE TABLE `department` (
`hasToMistake` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Indica si al departamento pueden serles puestos errores',
`clientFk` int(11) DEFAULT NULL COMMENT 'Cuenta de cliente que se utiliza para los compras de consumo departamental',
`twoFactor` enum('email') DEFAULT NULL COMMENT 'Default user two-factor auth type',
+ `pbxQueue` varchar(128) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
+ `workerActivityTypeFk` varchar(20) DEFAULT NULL COMMENT 'Indica la actitividad que desempeña por defecto ese departamento',
PRIMARY KEY (`id`),
UNIQUE KEY `name_UNIQUE` (`name`),
KEY `fk_department_Trabajadores1_idx` (`workerFk`),
@@ -30061,8 +30581,12 @@ CREATE TABLE `department` (
KEY `lft_rgt_depth_idx` (`lft`,`rgt`,`depth`),
KEY `department_FK` (`clientFk`),
KEY `department_FK_1` (`parentFk`),
+ KEY `department_queue_FK` (`pbxQueue`),
+ KEY `department_workerActivityType_FK` (`workerActivityTypeFk`),
CONSTRAINT `department_FK` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `department_FK_1` FOREIGN KEY (`parentFk`) REFERENCES `department` (`id`),
+ CONSTRAINT `department_queue_FK` FOREIGN KEY (`pbxQueue`) REFERENCES `pbx`.`queue` (`name`) ON UPDATE CASCADE,
+ CONSTRAINT `department_workerActivityType_FK` FOREIGN KEY (`workerActivityTypeFk`) REFERENCES `workerActivityType` (`code`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `fk_department_Trabajadores1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -30175,10 +30699,11 @@ DROP TABLE IF EXISTS `deviceProductionConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `deviceProductionConfig` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`isAllUsersallowed` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Permite que cualquier usuario pueda loguearse',
`isTractorHuntingMode` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Habilita el modo cazador para usuarios que no se han logeado un tractor para sacar',
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `deviceProductionConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -30397,10 +30922,11 @@ DROP TABLE IF EXISTS `docuwareConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `docuwareConfig` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`url` varchar(75) DEFAULT NULL,
`cookie` varchar(1000) DEFAULT NULL,
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `docuwareConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -30691,7 +31217,7 @@ CREATE TABLE `entry` (
`companyFk` int(10) unsigned NOT NULL DEFAULT 442,
`gestDocFk` int(11) DEFAULT NULL,
`invoiceInFk` mediumint(8) unsigned DEFAULT NULL,
- `isBlocked` tinyint(4) NOT NULL DEFAULT 0,
+ `isBlocked__` tinyint(4) NOT NULL DEFAULT 0 COMMENT '@deprecated 27/03/2024',
`loadPriority` int(11) DEFAULT NULL,
`kop` int(11) DEFAULT NULL,
`sub` mediumint(8) unsigned DEFAULT NULL,
@@ -30747,6 +31273,26 @@ CREATE TABLE `entryConfig` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `entryDms`
+--
+
+DROP TABLE IF EXISTS `entryDms`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `entryDms` (
+ `entryFk` int(11) NOT NULL,
+ `dmsFk` int(11) NOT NULL,
+ `editorFk` int(10) unsigned DEFAULT NULL,
+ PRIMARY KEY (`entryFk`,`dmsFk`),
+ KEY `gestdoc_id` (`dmsFk`),
+ KEY `entryDms_editor` (`editorFk`),
+ CONSTRAINT `entryDms_dms` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `entryDms_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`),
+ CONSTRAINT `entryDms_entry` FOREIGN KEY (`entryFk`) REFERENCES `entry` (`id`) ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `entryLog`
--
@@ -30784,7 +31330,7 @@ DROP TABLE IF EXISTS `entryObservation`;
CREATE TABLE `entryObservation` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`entryFk` int(11) NOT NULL,
- `observationTypeFk` tinyint(3) unsigned DEFAULT NULL,
+ `observationTypeFk` tinyint(3) unsigned NOT NULL,
`description` text DEFAULT NULL,
`editorFk` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
@@ -30950,27 +31496,35 @@ SET character_set_client = utf8;
SET character_set_client = @saved_cs_client;
--
--- Temporary table structure for view `exchangeInsurance`
+-- Table structure for table `exchangeInsurance`
--
DROP TABLE IF EXISTS `exchangeInsurance`;
-/*!50001 DROP VIEW IF EXISTS `exchangeInsurance`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE VIEW `exchangeInsurance` AS SELECT
- 1 AS `id`,
- 1 AS `amount`,
- 1 AS `dated`,
- 1 AS `finished`,
- 1 AS `entityFk`,
- 1 AS `ref`,
- 1 AS `rate`,
- 1 AS `companyFk`,
- 1 AS `financialProductTypefk`,
- 1 AS `upperBarrier`,
- 1 AS `lowerBarrier`,
- 1 AS `strike` */;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `exchangeInsurance` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `amount` decimal(10,2) NOT NULL,
+ `dated` date NOT NULL,
+ `dueDated` date NOT NULL,
+ `entityFk` int(10) unsigned NOT NULL,
+ `ref` varchar(45) DEFAULT NULL,
+ `rate` decimal(10,4) NOT NULL,
+ `companyFk` int(10) unsigned NOT NULL DEFAULT 442,
+ `financialProductTypefk` varchar(2) NOT NULL DEFAULT 'SC',
+ `pago_sdccol` varchar(45) DEFAULT NULL,
+ `upperBarrier` decimal(10,2) DEFAULT NULL,
+ `lowerBarrier` decimal(10,2) DEFAULT NULL,
+ `strike` decimal(10,2) DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ KEY `empresa_sdc_idx` (`companyFk`),
+ KEY `financial_type_fk_idx` (`financialProductTypefk`),
+ KEY `pago_sdc_entity_fk_idx` (`entityFk`),
+ CONSTRAINT `financial_type_fk` FOREIGN KEY (`financialProductTypefk`) REFERENCES `financialProductType` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `pago_sdcCompany_Fk` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `pago_sdc_entity_fk` FOREIGN KEY (`entityFk`) REFERENCES `bankEntity` (`id`) ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Seguros de cambio';
+/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Temporary table structure for view `exchangeInsuranceEntry`
@@ -31521,6 +32075,28 @@ CREATE TABLE `expense` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `expenseManual`
+--
+
+DROP TABLE IF EXISTS `expenseManual`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `expenseManual` (
+ `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `expenseFk` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
+ `year` int(4) NOT NULL,
+ `month` int(2) NOT NULL,
+ `amount` decimal(10,2) DEFAULT NULL,
+ `companyFk` int(10) unsigned DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `expenseManual_unique` (`expenseFk`,`year`,`month`,`companyFk`),
+ KEY `expenseManual_company_FK` (`companyFk`),
+ CONSTRAINT `expenseManual_company_FK` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `expenseManual_expense_FK` FOREIGN KEY (`expenseFk`) REFERENCES `expense` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Sirve para resumir los gastos que se ponen a mano en el contaplus';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `farming`
--
@@ -31605,6 +32181,22 @@ CREATE TABLE `farmingNotes` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `financialProductType`
+--
+
+DROP TABLE IF EXISTS `financialProductType`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `financialProductType` (
+ `id` varchar(2) NOT NULL,
+ `description` varchar(45) NOT NULL,
+ `isAcumulattor` tinyint(4) NOT NULL DEFAULT 0,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `description_UNIQUE` (`description`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Distintos tipos de productos financieros: seguros de cambio, polizas de credito, acumuladores....';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Temporary table structure for view `firstTicketShipped`
--
@@ -31618,6 +32210,27 @@ SET character_set_client = utf8;
1 AS `clientFk` */;
SET character_set_client = @saved_cs_client;
+--
+-- Table structure for table `flight`
+--
+
+DROP TABLE IF EXISTS `flight`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `flight` (
+ `id` varchar(10) NOT NULL,
+ `duration` tinyint(2) unsigned NOT NULL,
+ `flightPath` varchar(20) DEFAULT NULL,
+ `days` varchar(7) DEFAULT NULL,
+ `airlineFk` smallint(2) unsigned DEFAULT NULL,
+ `airportArrivalFk` varchar(3) NOT NULL,
+ `airportDepartureFk` varchar(3) NOT NULL,
+ PRIMARY KEY (`id`),
+ KEY `flight_airline_FK` (`airlineFk`),
+ CONSTRAINT `flight_airline_FK` FOREIGN KEY (`airlineFk`) REFERENCES `airline` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Temporary table structure for view `floraHollandBuyedItems`
--
@@ -31643,7 +32256,7 @@ DROP TABLE IF EXISTS `floramondoConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `floramondoConfig` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`nextLanded` datetime DEFAULT NULL,
`warehouseInFk` smallint(6) unsigned DEFAULT NULL,
`MaxLatestDeliveryHour` int(11) DEFAULT NULL,
@@ -31653,7 +32266,8 @@ CREATE TABLE `floramondoConfig` (
`daysToKeepItem` int(4) DEFAULT NULL COMMENT 'Número de dias para mantener artículos',
PRIMARY KEY (`id`),
KEY `floramondoConfigWarehouseIn_idx` (`warehouseInFk`),
- CONSTRAINT `floramondoConfigWarehouseInFk` FOREIGN KEY (`warehouseInFk`) REFERENCES `warehouse` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
+ CONSTRAINT `floramondoConfigWarehouseInFk` FOREIGN KEY (`warehouseInFk`) REFERENCES `warehouse` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
+ CONSTRAINT `floramondoConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -31688,9 +32302,10 @@ DROP TABLE IF EXISTS `franceExpressConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `franceExpressConfig` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`path` varchar(100) DEFAULT '\\\\server\\agencies\\franceexpress\\expeditions',
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `franceExpressConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -31784,7 +32399,7 @@ DROP TABLE IF EXISTS `glsConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `glsConfig` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`service` int(1) DEFAULT NULL,
`schedule` int(1) DEFAULT NULL,
`token` varchar(45) DEFAULT NULL,
@@ -31794,7 +32409,8 @@ CREATE TABLE `glsConfig` (
`refund` int(1) DEFAULT NULL,
`weight` int(1) DEFAULT NULL,
`density` int(11) NOT NULL DEFAULT 42,
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `glsConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -31857,12 +32473,14 @@ DROP TABLE IF EXISTS `greugeConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `greugeConfig` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`freightPickUpPrice` decimal(10,2) NOT NULL,
`yearsToDelete` int(11) DEFAULT NULL,
`maxPercentToWrong` decimal(10,2) DEFAULT NULL COMMENT 'Porcentaje del precio del ticket que es considerado error',
`lastNotifyCheck` timestamp NULL DEFAULT NULL COMMENT 'Última ejecución del procedimiento que revisa los greuges anormales',
- PRIMARY KEY (`id`)
+ `daysAgoOffset` int(11) NOT NULL,
+ PRIMARY KEY (`id`),
+ CONSTRAINT `greugeConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -32014,6 +32632,39 @@ SET character_set_client = utf8;
1 AS `name` */;
SET character_set_client = @saved_cs_client;
+--
+-- Table structure for table `integra2`
+--
+
+DROP TABLE IF EXISTS `integra2`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `integra2` (
+ `postCode` varchar(10) NOT NULL,
+ `frequency` decimal(10,2) NOT NULL,
+ `warehouseFk` smallint(6) unsigned NOT NULL,
+ PRIMARY KEY (`postCode`,`frequency`,`warehouseFk`),
+ KEY `postal_code` (`postCode`),
+ KEY `warehouse_id` (`warehouseFk`),
+ CONSTRAINT `integra2_warehouse_FK` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `integra2Province`
+--
+
+DROP TABLE IF EXISTS `integra2Province`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `integra2Province` (
+ `provinceFk` smallint(6) unsigned NOT NULL,
+ `franchise` varchar(65) NOT NULL,
+ PRIMARY KEY (`provinceFk`),
+ CONSTRAINT `integra2_province_id` FOREIGN KEY (`provinceFk`) REFERENCES `province` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `intrastat`
--
@@ -32040,7 +32691,7 @@ DROP TABLE IF EXISTS `inventoryConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `inventoryConfig` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`maxRecentInventories` int(11) DEFAULT NULL COMMENT 'The maximum number of recent inventories to retain without deletion',
`daysInPastForInventory` int(11) DEFAULT NULL COMMENT 'The number of days in the past to consider for inventory calculations',
`warehouseOutFk` smallint(6) unsigned DEFAULT NULL COMMENT 'The identifier for the inventory output warehouse',
@@ -32052,7 +32703,8 @@ CREATE TABLE `inventoryConfig` (
KEY `inventoryConfig_agencyMode_FK` (`agencyModeFk`),
CONSTRAINT `inventoryConfig_agencyMode_FK` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`),
CONSTRAINT `inventoryConfig_supplier_FK` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`),
- CONSTRAINT `inventoryConfig_warehouse_FK_1` FOREIGN KEY (`warehouseOutFk`) REFERENCES `warehouse` (`id`)
+ CONSTRAINT `inventoryConfig_warehouse_FK_1` FOREIGN KEY (`warehouseOutFk`) REFERENCES `warehouse` (`id`),
+ CONSTRAINT `inventoryConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -32231,7 +32883,7 @@ DROP TABLE IF EXISTS `invoiceInConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invoiceInConfig` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`retentionRate` int(3) NOT NULL,
`retentionName` varchar(25) NOT NULL,
`sageWithholdingFk` smallint(6) NOT NULL,
@@ -32239,7 +32891,8 @@ CREATE TABLE `invoiceInConfig` (
`taxRowLimit` int(11) DEFAULT 4 COMMENT 'Número máximo de líneas de IVA que puede tener una factura',
PRIMARY KEY (`id`),
KEY `invoiceInConfig_sageWithholdingFk` (`sageWithholdingFk`),
- CONSTRAINT `invoiceInConfig_sageWithholdingFk` FOREIGN KEY (`sageWithholdingFk`) REFERENCES `sage`.`TiposRetencion` (`CodigoRetencion`) ON DELETE CASCADE ON UPDATE CASCADE
+ CONSTRAINT `invoiceInConfig_sageWithholdingFk` FOREIGN KEY (`sageWithholdingFk`) REFERENCES `sage`.`TiposRetencion` (`CodigoRetencion`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `invoiceInConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -32512,10 +33165,11 @@ DROP TABLE IF EXISTS `invoiceOutConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invoiceOutConfig` (
- `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`parallelism` int(10) unsigned NOT NULL DEFAULT 1,
`refLen` tinyint(3) unsigned NOT NULL DEFAULT 5 COMMENT 'Invoice reference identifier length',
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `invoiceOutConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -32599,14 +33253,16 @@ CREATE TABLE `invoiceOutTaxConfig` (
`taxTypeSageFk` smallint(6) DEFAULT NULL,
`transactionTypeSageFk` tinyint(4) DEFAULT NULL,
`isService` tinyint(1) DEFAULT 0,
- `expenseFk` varchar(10) DEFAULT NULL,
+ `expenseFk` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `invoiceOutTaxConfig_FK` (`taxClassCodeFk`),
KEY `invoiceOutTaxConfig_FK_1` (`taxTypeSageFk`),
KEY `invoiceOutTaxConfig_FK_2` (`transactionTypeSageFk`),
+ KEY `invoiceOutTaxConfig_expense_FK` (`expenseFk`),
CONSTRAINT `invoiceOutTaxConfig_FK` FOREIGN KEY (`taxClassCodeFk`) REFERENCES `taxClass` (`code`),
CONSTRAINT `invoiceOutTaxConfig_FK_1` FOREIGN KEY (`taxTypeSageFk`) REFERENCES `sage`.`TiposIva` (`CodigoIva`),
- CONSTRAINT `invoiceOutTaxConfig_FK_2` FOREIGN KEY (`transactionTypeSageFk`) REFERENCES `sage`.`TiposTransacciones` (`CodigoTransaccion`)
+ CONSTRAINT `invoiceOutTaxConfig_FK_2` FOREIGN KEY (`transactionTypeSageFk`) REFERENCES `sage`.`TiposTransacciones` (`CodigoTransaccion`),
+ CONSTRAINT `invoiceOutTaxConfig_expense_FK` FOREIGN KEY (`expenseFk`) REFERENCES `expense` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -32861,7 +33517,7 @@ DROP TABLE IF EXISTS `itemConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `itemConfig` (
- `id` int(11) NOT NULL,
+ `id` int(10) unsigned NOT NULL,
`isItemTagTriggerDisabled` tinyint(1) NOT NULL DEFAULT 1,
`monthToDeactivate` int(3) NOT NULL DEFAULT 24,
`wasteRecipients` varchar(50) NOT NULL COMMENT 'Weekly waste report schedule recipients',
@@ -32872,7 +33528,8 @@ CREATE TABLE `itemConfig` (
`downloadMaxAttempts` tinyint(3) DEFAULT NULL COMMENT 'Intentos máximos para que se borre',
PRIMARY KEY (`id`),
KEY `itemConfig_FK` (`defaultTag`),
- CONSTRAINT `itemConfig_FK` FOREIGN KEY (`defaultTag`) REFERENCES `tag` (`id`)
+ CONSTRAINT `itemConfig_FK` FOREIGN KEY (`defaultTag`) REFERENCES `tag` (`id`),
+ CONSTRAINT `itemConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -33176,7 +33833,7 @@ CREATE TABLE `itemShelving` (
`visible` int(11) NOT NULL DEFAULT 0,
`created` timestamp NOT NULL DEFAULT current_timestamp(),
`grouping` smallint(5) unsigned DEFAULT NULL,
- `packing` int(11) unsigned DEFAULT NULL,
+ `packing` int(11) NOT NULL DEFAULT 1 CHECK (`packing` > 0),
`packagingFk` varchar(10) DEFAULT NULL,
`userFk` int(10) unsigned DEFAULT NULL,
`isChecked` tinyint(1) DEFAULT NULL COMMENT 'Este valor cambia al escanear un carro. True: Existe. False: Nuevo. Null: No escaneado',
@@ -33913,9 +34570,10 @@ DROP TABLE IF EXISTS `machineWorkerConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `machineWorkerConfig` (
- `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`maxHours` smallint(5) unsigned NOT NULL COMMENT 'Indicates how many hours a user record is reviewed to update or insert',
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `machineWorkerConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -34063,11 +34721,12 @@ DROP TABLE IF EXISTS `mdbConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `mdbConfig` (
- `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`issueTrackerUrl` varchar(255) NOT NULL,
`issueNumberRegex` varchar(255) NOT NULL,
`chatDestination` varchar(255) NOT NULL COMMENT 'User (@) or channel (#) to send the message',
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `mdbConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Global configuration parameters for Access';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -34290,13 +34949,14 @@ DROP TABLE IF EXISTS `mrwConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `mrwConfig` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`url` varchar(100) DEFAULT NULL,
`user` varchar(100) DEFAULT NULL,
`password` varchar(100) DEFAULT NULL,
`franchiseCode` varchar(100) DEFAULT NULL,
`subscriberCode` varchar(100) DEFAULT NULL,
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `mrwConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -34557,7 +35217,7 @@ DROP TABLE IF EXISTS `osTicketConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `osTicketConfig` (
- `id` int(11) NOT NULL,
+ `id` int(10) unsigned NOT NULL,
`host` varchar(100) DEFAULT NULL,
`user` varchar(100) DEFAULT NULL,
`password` varchar(100) DEFAULT NULL,
@@ -34572,7 +35232,8 @@ CREATE TABLE `osTicketConfig` (
`responseType` varchar(100) DEFAULT NULL,
`fromEmailId` int(11) DEFAULT NULL,
`replyTo` varchar(100) DEFAULT NULL,
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `osTicketConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -34689,7 +35350,7 @@ DROP TABLE IF EXISTS `packagingConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `packagingConfig` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`upperGap` int(11) NOT NULL,
`previousPreparationMinimumSize` int(11) NOT NULL,
`defaultConveyorBuildingClass` int(11) NOT NULL,
@@ -34702,7 +35363,8 @@ CREATE TABLE `packagingConfig` (
KEY `packagingConfig_FK` (`defaultSmallPackageFk`),
KEY `packagingConfig_FK_1` (`defaultBigPackageFk`),
CONSTRAINT `packagingConfig_FK` FOREIGN KEY (`defaultSmallPackageFk`) REFERENCES `packaging` (`id`) ON UPDATE CASCADE,
- CONSTRAINT `packagingConfig_FK_1` FOREIGN KEY (`defaultBigPackageFk`) REFERENCES `packaging` (`id`) ON UPDATE CASCADE
+ CONSTRAINT `packagingConfig_FK_1` FOREIGN KEY (`defaultBigPackageFk`) REFERENCES `packaging` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `packagingConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Altura mínima para preparar pedidos en preparacion previa';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -34828,12 +35490,13 @@ DROP TABLE IF EXISTS `packingSiteConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `packingSiteConfig` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`shinobiUrl` varchar(255) NOT NULL,
`shinobiToken` varchar(255) NOT NULL,
`shinobiGroupKey` varchar(255) NOT NULL,
`avgBoxingTime` int(3) DEFAULT NULL,
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `packingSiteConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -34936,6 +35599,7 @@ CREATE TABLE `parking` (
`sectorFk` int(11) NOT NULL DEFAULT 2,
`code` varchar(8) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
`pickingOrder` int(11) DEFAULT NULL,
+ `editorFk` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `code_UNIQUE` (`code`),
KEY `parking_fk1_idx` (`sectorFk`),
@@ -34943,6 +35607,34 @@ CREATE TABLE `parking` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Tabla con los parkings del altillo';
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `parkingLog`
+--
+
+DROP TABLE IF EXISTS `parkingLog`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `parkingLog` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `originFk` int(11) DEFAULT NULL,
+ `userFk` int(10) unsigned DEFAULT NULL,
+ `action` set('insert','update','delete','select') NOT NULL,
+ `creationDate` timestamp NULL DEFAULT current_timestamp(),
+ `description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
+ `changedModel` enum('Parking','SaleGroup','SaleGroupDetail') NOT NULL DEFAULT 'Parking',
+ `oldInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`oldInstance`)),
+ `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)),
+ `changedModelId` int(11) NOT NULL,
+ `changedModelValue` varchar(45) DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ KEY `logParkinguserFk` (`userFk`),
+ KEY `parkingLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`),
+ KEY `parkingLog_originFk` (`originFk`,`creationDate`),
+ CONSTRAINT `parkingOriginFk` FOREIGN KEY (`originFk`) REFERENCES `parking` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `parkingUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `payDem`
--
@@ -35082,15 +35774,72 @@ SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `payrollCenter` AS SELECT
1 AS `codCenter`,
- 1 AS `name`,
- 1 AS `nss`,
- 1 AS `street`,
- 1 AS `city`,
- 1 AS `postcode`,
- 1 AS `companyFk`,
1 AS `companyCode` */;
SET character_set_client = @saved_cs_client;
+--
+-- Table structure for table `payrollComponent`
+--
+
+DROP TABLE IF EXISTS `payrollComponent`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `payrollComponent` (
+ `id` int(11) NOT NULL,
+ `name` varchar(255) DEFAULT NULL,
+ `isSalaryAgreed` tinyint(1) NOT NULL DEFAULT 0,
+ `isVariable` tinyint(1) NOT NULL,
+ `isException` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Excepciones a tener en cuenta al importar conceptos en el proceso de importación de ficheros A3.',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `payrollWorkCenter`
+--
+
+DROP TABLE IF EXISTS `payrollWorkCenter`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `payrollWorkCenter` (
+ `workCenterFkA3` int(11) NOT NULL COMMENT 'Columna que hace referencia a A3.',
+ `Centro__` varchar(255) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024',
+ `nss_cotizacion__` varchar(15) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024',
+ `domicilio__` varchar(255) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024',
+ `poblacion__` varchar(45) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024',
+ `cp__` varchar(5) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024',
+ `empresa_id__` int(10) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024',
+ `companyFkA3` int(11) DEFAULT NULL COMMENT 'Columna que hace referencia a A3.',
+ PRIMARY KEY (`workCenterFkA3`,`empresa_id__`),
+ KEY `payroll_centros_ix1` (`empresa_id__`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `payrollWorker`
+--
+
+DROP TABLE IF EXISTS `payrollWorker`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `payrollWorker` (
+ `workerFkA3` int(11) NOT NULL COMMENT 'Columna que hace referencia a A3.',
+ `nss__` varchar(23) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024',
+ `codpuesto__` int(10) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024',
+ `companyFkA3` int(10) NOT NULL COMMENT 'Columna que hace referencia a A3.',
+ `codcontrato__` int(10) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024',
+ `FAntiguedad__` date NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024',
+ `grupotarifa__` int(10) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024',
+ `codcategoria__` int(10) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024',
+ `ContratoTemporal__` tinyint(1) NOT NULL DEFAULT 0 COMMENT '@Deprecated refs #6738 15/03/2024',
+ `workerFk` int(11) unsigned DEFAULT NULL,
+ PRIMARY KEY (`workerFkA3`,`companyFkA3`),
+ KEY `sajvgfh_idx` (`codpuesto__`),
+ KEY `payroll_employee_workerFk_idx` (`workerFk`),
+ CONSTRAINT `payroll_employee_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `pcs`
--
@@ -35442,20 +36191,6 @@ CREATE TABLE `ppePlan` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Plan de amortizacion para la tabla ppe';
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Temporary table structure for view `preparationException`
---
-
-DROP TABLE IF EXISTS `preparationException`;
-/*!50001 DROP VIEW IF EXISTS `preparationException`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE VIEW `preparationException` AS SELECT
- 1 AS `exceptionDay`,
- 1 AS `warehouseFk`,
- 1 AS `percentage` */;
-SET character_set_client = @saved_cs_client;
-
--
-- Table structure for table `priceFixed`
--
@@ -35643,7 +36378,7 @@ CREATE TABLE `productionConfig` (
`ticketTrolleyMax` int(10) unsigned NOT NULL DEFAULT 4 COMMENT 'numero máximo de tickets por carro para asignar baldas en una colección',
`rookieDays` int(11) NOT NULL DEFAULT 3 COMMENT 'dias en que se cuida con especial cuidado los pedidos de un cliente por ser nuevo o recuperado',
`notBuyingMonths` int(11) NOT NULL DEFAULT 3 COMMENT 'numero de meses que han de pasar desde su ultima compra para considerar nueva la siguiente compra',
- `id` int(11) NOT NULL DEFAULT 1,
+ `id` int(10) unsigned NOT NULL,
`isZoneClosedByExpeditionActivated` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'activa el procedimiento vn.zone_getClosed',
`maxNotReadyCollections` int(11) NOT NULL DEFAULT 5,
`minTicketsToCloseZone` int(11) DEFAULT 15 COMMENT 'mínimo numero de tickets que deben de tener expediciones para cerrar una zona',
@@ -35662,13 +36397,15 @@ CREATE TABLE `productionConfig` (
`clientSelfConsumptionFk` int(11) DEFAULT NULL COMMENT 'Cliente para crear el ticket de autoconsumo',
`itemPreviousDefaultSize` int(11) DEFAULT NULL COMMENT 'Altura por defecto para los artículos de previa',
`addressSelfConsumptionFk` int(11) DEFAULT 2613 COMMENT 'Consignatario para crear el ticket de autoconsumo',
+ `defaultFreightItemFk` int(10) unsigned NOT NULL DEFAULT 71 COMMENT 'Default value for expedition table',
PRIMARY KEY (`id`),
KEY `productionConfig_FK` (`shortageAddressFk`),
KEY `productionConfig_FK_1` (`clientSelfConsumptionFk`),
KEY `productionConfig_FK_2` (`addressSelfConsumptionFk`),
CONSTRAINT `productionConfig_FK` FOREIGN KEY (`shortageAddressFk`) REFERENCES `address` (`id`) ON UPDATE CASCADE,
CONSTRAINT `productionConfig_FK_1` FOREIGN KEY (`clientSelfConsumptionFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT `productionConfig_FK_2` FOREIGN KEY (`addressSelfConsumptionFk`) REFERENCES `address` (`id`) ON UPDATE CASCADE
+ CONSTRAINT `productionConfig_FK_2` FOREIGN KEY (`addressSelfConsumptionFk`) REFERENCES `address` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `productionConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Recoge los parámetros que condicionan la producción';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -35735,12 +36472,11 @@ DROP TABLE IF EXISTS `professionalCategory`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `professionalCategory` (
`id` int(11) NOT NULL AUTO_INCREMENT,
- `name` varchar(50) NOT NULL,
- `level` int(11) unsigned DEFAULT NULL,
- `dayBreak` int(11) unsigned DEFAULT NULL,
+ `description` varchar(50) NOT NULL,
`code` varchar(25) DEFAULT NULL,
PRIMARY KEY (`id`),
- UNIQUE KEY `prefessionalCategory_UN` (`name`)
+ UNIQUE KEY `prefessionalCategory_UN` (`description`),
+ UNIQUE KEY `code` (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -35964,7 +36700,7 @@ CREATE TABLE `province` (
KEY `province_FK` (`autonomyFk`),
CONSTRAINT `province_FK` FOREIGN KEY (`autonomyFk`) REFERENCES `autonomy` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `province_ibfk_1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE,
- CONSTRAINT `province_zone_fk` FOREIGN KEY (`zoneFk`) REFERENCES `vn2008`.`zones` (`zone_id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `province_zone_fk` FOREIGN KEY (`zoneFk`) REFERENCES `vn2008`.`zones__` (`zone_id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `warehouse_Id` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -35984,6 +36720,23 @@ CREATE TABLE `punchState` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Table for storing punches that have cars with errors';
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `quality`
+--
+
+DROP TABLE IF EXISTS `quality`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `quality` (
+ `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `name` varchar(50) DEFAULT NULL,
+ `isVisible` tinyint(1) NOT NULL DEFAULT 1,
+ `created` timestamp NULL DEFAULT current_timestamp(),
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `name_UNIQUE` (`name`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Valores usados en el tag calidad';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `queuePriority`
--
@@ -36044,12 +36797,13 @@ DROP TABLE IF EXISTS `rateConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `rateConfig` (
- `id` int(11) NOT NULL,
+ `id` int(10) unsigned NOT NULL,
`rate0` int(11) DEFAULT NULL,
`rate1` int(11) DEFAULT NULL,
`rate2` int(11) DEFAULT NULL,
`rate3` int(11) DEFAULT NULL,
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `rateConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -36509,7 +37263,8 @@ CREATE TABLE `routeConfig` (
`truckerBusinessProfessionalCategoryFk` int(11) NOT NULL DEFAULT 42,
PRIMARY KEY (`id`),
KEY `routeConfigCompany_Fk` (`defaultCompanyFk`),
- CONSTRAINT `routeConfigCompany_Fk` FOREIGN KEY (`defaultCompanyFk`) REFERENCES `company` (`id`)
+ CONSTRAINT `routeConfigCompany_Fk` FOREIGN KEY (`defaultCompanyFk`) REFERENCES `company` (`id`),
+ CONSTRAINT `routeConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -36864,6 +37619,7 @@ CREATE TABLE `saleGroupDetail` (
`created` timestamp NOT NULL DEFAULT current_timestamp(),
`saleFk` int(11) NOT NULL,
`saleGroupFk` int(11) NOT NULL,
+ `editorFk` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `saleGroupDetail_UN` (`saleFk`),
KEY `saleGroupDetail_FK_1` (`saleGroupFk`),
@@ -36872,19 +37628,21 @@ CREATE TABLE `saleGroupDetail` (
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Temporary table structure for view `saleLabel`
+-- Table structure for table `saleLabel`
--
DROP TABLE IF EXISTS `saleLabel`;
-/*!50001 DROP VIEW IF EXISTS `saleLabel`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE VIEW `saleLabel` AS SELECT
- 1 AS `saleFk`,
- 1 AS `label`,
- 1 AS `stem`,
- 1 AS `created` */;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `saleLabel` (
+ `saleFk` int(11) NOT NULL,
+ `label` mediumint(8) unsigned NOT NULL,
+ `stem` mediumint(8) unsigned NOT NULL,
+ `created` timestamp NULL DEFAULT current_timestamp(),
+ PRIMARY KEY (`saleFk`),
+ CONSTRAINT `saleLabel_sale_FK` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `saleMistake`
@@ -37016,7 +37774,7 @@ SET character_set_client = utf8;
/*!50001 CREATE VIEW `saleValue` AS SELECT
1 AS `warehouse`,
1 AS `client`,
- 1 AS `clientTypeFk`,
+ 1 AS `typeFk`,
1 AS `buyer`,
1 AS `itemTypeFk`,
1 AS `family`,
@@ -37171,13 +37929,14 @@ DROP TABLE IF EXISTS `salespersonConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `salespersonConfig` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`manaMaxRate` decimal(3,2) DEFAULT 0.05 COMMENT 'Valor máximo a recficar en una línea por el maná de un comercial',
`manaMinRate` decimal(3,2) DEFAULT -0.05 COMMENT 'Valor mínimo a recficar en una línea por el maná de un comercial',
`manaDateFrom` date NOT NULL DEFAULT '2023-01-01' COMMENT 'first date to count mana',
`manaFromDays` int(11) NOT NULL DEFAULT 90 COMMENT 'Range of days from mana calculation',
`manaToDays` int(11) NOT NULL DEFAULT 30 COMMENT 'Range of days to mana calculation',
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `salespersonConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -37383,10 +38142,11 @@ DROP TABLE IF EXISTS `sendingConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `sendingConfig` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`defaultWeight` int(11) NOT NULL DEFAULT 13,
`defaultPackages` int(11) NOT NULL DEFAULT 1,
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `sendingConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -37721,11 +38481,12 @@ DROP TABLE IF EXISTS `smsConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `smsConfig` (
- `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`uri` varchar(255) NOT NULL,
`title` varchar(50) NOT NULL,
`apiKey` varchar(50) DEFAULT NULL,
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `smsConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='SMS configuration parameters';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -37800,15 +38561,18 @@ DROP TABLE IF EXISTS `specialPrice`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `specialPrice` (
`id` int(11) NOT NULL AUTO_INCREMENT,
- `clientFk` int(11) NOT NULL DEFAULT 0,
- `itemFk` int(11) NOT NULL DEFAULT 0,
- `value` double NOT NULL DEFAULT 0,
+ `clientFk` int(11) DEFAULT NULL,
+ `itemFk` int(11) NOT NULL,
+ `value` decimal(10,2) NOT NULL,
+ `started` date NOT NULL DEFAULT '2024-01-01',
+ `ended` date DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `Id_Cliente_2` (`clientFk`,`itemFk`),
KEY `Id_Article` (`itemFk`),
KEY `Id_Cliente` (`clientFk`),
CONSTRAINT `sp_article_id` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE,
- CONSTRAINT `sp_customer_id` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE
+ CONSTRAINT `sp_customer_id` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `check_date_range` CHECK (`ended` is null or `ended` >= `started`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -38043,7 +38807,7 @@ CREATE TABLE `supplier` (
`payDay` tinyint(4) unsigned DEFAULT NULL,
`payDemFk` tinyint(3) unsigned NOT NULL DEFAULT 7,
`created` timestamp NOT NULL DEFAULT current_timestamp(),
- `isSerious` tinyint(1) unsigned NOT NULL DEFAULT 0,
+ `isReal` tinyint(1) unsigned NOT NULL DEFAULT 0,
`note` text CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL,
`postcodeFk` int(11) unsigned DEFAULT NULL,
`postCode` char(8) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL,
@@ -38232,9 +38996,15 @@ DROP TABLE IF EXISTS `supplierDms`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `supplierDms` (
- `supplierFk` int(11) NOT NULL,
+ `supplierFk` int(10) unsigned NOT NULL,
`dmsFk` int(11) NOT NULL,
- PRIMARY KEY (`supplierFk`,`dmsFk`)
+ `editorFk` int(10) unsigned DEFAULT NULL,
+ PRIMARY KEY (`supplierFk`,`dmsFk`),
+ KEY `user_Fk` (`editorFk`),
+ KEY `dms_Fk` (`dmsFk`),
+ CONSTRAINT `dms_Fk` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `supplier_Fk` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `user_Fk` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -38271,6 +39041,20 @@ CREATE TABLE `supplierExpense` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `supplierFreight`
+--
+
+DROP TABLE IF EXISTS `supplierFreight`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `supplierFreight` (
+ `supplierFk` int(10) unsigned NOT NULL,
+ PRIMARY KEY (`supplierFk`),
+ CONSTRAINT `Proveedores_cargueras_supplierFk` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Tabla de espcializacion para señalar las compañias que prestan servicio de transitario';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `supplierLog`
--
@@ -38285,7 +39069,7 @@ CREATE TABLE `supplierLog` (
`action` set('insert','update','delete') NOT NULL,
`creationDate` timestamp NULL DEFAULT current_timestamp(),
`description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
- `changedModel` enum('Supplier','SupplierAddress','SupplierAccount','SupplierContact') NOT NULL DEFAULT 'Supplier',
+ `changedModel` enum('Supplier','SupplierAddress','SupplierAccount','SupplierContact','SupplierDms') NOT NULL DEFAULT 'Supplier',
`oldInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`oldInstance`)),
`newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)),
`changedModelId` int(11) NOT NULL,
@@ -38659,13 +39443,14 @@ DROP TABLE IF EXISTS `ticketConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `ticketConfig` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`scopeDays` tinyint(3) DEFAULT NULL,
`pickingDelay` int(11) NOT NULL DEFAULT 10 COMMENT 'minutos de cortesia desde que se crea un ticket hasta que se puede preparar',
`packagingInvoicingDated` date NOT NULL DEFAULT '2017-11-21' COMMENT 'Fecha desde la cual se gestiona el registro de embalajes de tickets (tabla vn.ticketPackaging)',
`packingDelay` int(11) DEFAULT 1 COMMENT 'Horas que marcará el retraso respecto hora de cierre web del ticket',
`daysForWarningClaim` int(11) NOT NULL DEFAULT 2 COMMENT 'dias restantes hasta que salte el aviso de reclamación fuera de plazo',
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `ticketConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -38813,7 +39598,7 @@ CREATE TABLE `ticketLog` (
`action` set('insert','update','delete','select') NOT NULL,
`creationDate` timestamp NULL DEFAULT current_timestamp(),
`description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
- `changedModel` enum('Ticket','Sale','TicketWeekly','TicketTracking','TicketService','TicketRequest','TicketRefund','TicketPackaging','TicketObservation','TicketDms','Expedition','Sms','SaleGroup') NOT NULL DEFAULT 'Ticket',
+ `changedModel` enum('Ticket','Sale','TicketWeekly','TicketTracking','TicketService','TicketRequest','TicketRefund','TicketPackaging','TicketObservation','TicketDms','Expedition','Sms') NOT NULL DEFAULT 'Ticket',
`oldInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`oldInstance`)),
`newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)),
`changedModelId` int(11) NOT NULL,
@@ -39413,10 +40198,11 @@ DROP TABLE IF EXISTS `tillConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `tillConfig` (
- `id` int(11) NOT NULL,
+ `id` int(10) unsigned NOT NULL,
`openingBalance` decimal(10,2) NOT NULL,
`updated` timestamp NOT NULL DEFAULT current_timestamp(),
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `tillConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -39446,6 +40232,21 @@ CREATE TABLE `time` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Tabla de referencia para las semanas, años y meses';
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `timeSlots`
+--
+
+DROP TABLE IF EXISTS `timeSlots`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `timeSlots` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `section` time NOT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `Tramo` (`section`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `town`
--
@@ -39607,9 +40408,12 @@ DROP TABLE IF EXISTS `transitoryDuaUnified`;
CREATE TABLE `transitoryDuaUnified` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`supplierFk` int(10) unsigned DEFAULT NULL,
+ `countryCodeFk` varchar(2) NOT NULL DEFAULT 'EC',
PRIMARY KEY (`id`),
KEY `transitoryDuaUnified_FK` (`supplierFk`),
- CONSTRAINT `transitoryDuaUnified_FK` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+ KEY `transitoryDuaUnified_country_FK` (`countryCodeFk`),
+ CONSTRAINT `transitoryDuaUnified_FK` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `transitoryDuaUnified_country_FK` FOREIGN KEY (`countryCodeFk`) REFERENCES `country` (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Transitarios que al contabilizar sus entradas sólo generan un único DUA para todos los proveedores';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -39702,7 +40506,7 @@ DROP TABLE IF EXISTS `travelConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `travelConfig` (
- `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`warehouseInFk` smallint(6) unsigned NOT NULL DEFAULT 8 COMMENT 'Warehouse de origen',
`warehouseOutFk` smallint(6) unsigned NOT NULL DEFAULT 60 COMMENT 'Warehouse destino',
`agencyFk` int(11) NOT NULL DEFAULT 1378 COMMENT 'Agencia por defecto',
@@ -39715,7 +40519,8 @@ CREATE TABLE `travelConfig` (
CONSTRAINT `travelConfig_FK` FOREIGN KEY (`warehouseInFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `travelConfig_FK_1` FOREIGN KEY (`warehouseOutFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `travelConfig_FK_2` FOREIGN KEY (`agencyFk`) REFERENCES `agencyMode` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT `travelConfig_FK_3` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+ CONSTRAINT `travelConfig_FK_3` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `travelConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -39826,75 +40631,6 @@ CREATE TABLE `trolley` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Temporary table structure for view `unary`
---
-
-DROP TABLE IF EXISTS `unary`;
-/*!50001 DROP VIEW IF EXISTS `unary`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE VIEW `unary` AS SELECT
- 1 AS `id`,
- 1 AS `parent` */;
-SET character_set_client = @saved_cs_client;
-
---
--- Temporary table structure for view `unaryScan`
---
-
-DROP TABLE IF EXISTS `unaryScan`;
-/*!50001 DROP VIEW IF EXISTS `unaryScan`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE VIEW `unaryScan` AS SELECT
- 1 AS `unaryFk`,
- 1 AS `name`,
- 1 AS `created`,
- 1 AS `type` */;
-SET character_set_client = @saved_cs_client;
-
---
--- Temporary table structure for view `unaryScanLine`
---
-
-DROP TABLE IF EXISTS `unaryScanLine`;
-/*!50001 DROP VIEW IF EXISTS `unaryScanLine`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE VIEW `unaryScanLine` AS SELECT
- 1 AS `id`,
- 1 AS `code`,
- 1 AS `created`,
- 1 AS `unaryScanFk` */;
-SET character_set_client = @saved_cs_client;
-
---
--- Temporary table structure for view `unaryScanLineBuy`
---
-
-DROP TABLE IF EXISTS `unaryScanLineBuy`;
-/*!50001 DROP VIEW IF EXISTS `unaryScanLineBuy`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE VIEW `unaryScanLineBuy` AS SELECT
- 1 AS `unaryScanLineFk`,
- 1 AS `itemFk` */;
-SET character_set_client = @saved_cs_client;
-
---
--- Temporary table structure for view `unaryScanLineExpedition`
---
-
-DROP TABLE IF EXISTS `unaryScanLineExpedition`;
-/*!50001 DROP VIEW IF EXISTS `unaryScanLineExpedition`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE VIEW `unaryScanLineExpedition` AS SELECT
- 1 AS `unaryScanLineFk`,
- 1 AS `expeditionFk` */;
-SET character_set_client = @saved_cs_client;
-
--
-- Table structure for table `userConfig`
--
@@ -40194,7 +40930,7 @@ DROP TABLE IF EXISTS `viaexpressConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `viaexpressConfig` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`url` varchar(100) NOT NULL,
`client` varchar(100) NOT NULL,
`user` varchar(100) NOT NULL,
@@ -40204,7 +40940,8 @@ CREATE TABLE `viaexpressConfig` (
`agencyModeFk` int(11) DEFAULT NULL COMMENT 'Indica el agencyMode que es interdia',
PRIMARY KEY (`id`),
KEY `viaexpressConfig_agencyMode_Fk` (`agencyModeFk`),
- CONSTRAINT `viaexpressConfig_agencyMode_Fk` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`)
+ CONSTRAINT `viaexpressConfig_agencyMode_Fk` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`),
+ CONSTRAINT `viaexpressConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -40258,13 +40995,14 @@ DROP TABLE IF EXISTS `wagonConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `wagonConfig` (
- `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`width` int(11) unsigned DEFAULT 1350,
`height` int(11) unsigned DEFAULT 1900,
`maxWagonHeight` int(11) unsigned DEFAULT 200,
`minHeightBetweenTrays` int(11) unsigned DEFAULT 50,
`maxTrays` int(11) unsigned DEFAULT 6,
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `wagonConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -40409,6 +41147,23 @@ CREATE TABLE `warehouseAlias__` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='@deprecated 2024-01-23 refs #5167';
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `warehousePickup`
+--
+
+DROP TABLE IF EXISTS `warehousePickup`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `warehousePickup` (
+ `warehouseFk` smallint(5) unsigned NOT NULL,
+ `agencyModeFk` int(11) DEFAULT NULL,
+ PRIMARY KEY (`warehouseFk`),
+ UNIQUE KEY `agency_id` (`agencyModeFk`,`warehouseFk`),
+ CONSTRAINT `warehousePickup_ibfk_1` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `warehousePickup_ibfk_2` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Agencia de recogida para cada almacén';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `workCenter`
--
@@ -40503,6 +41258,43 @@ CREATE TABLE `worker` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `workerActivity`
+--
+
+DROP TABLE IF EXISTS `workerActivity`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `workerActivity` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `created` timestamp NULL DEFAULT current_timestamp(),
+ `model` enum('COM','ENT','TPV','ENC','LAB','ETI','APP') NOT NULL,
+ `workerFk` int(10) unsigned NOT NULL,
+ `event` enum('open','close','insert','delete','update','refresh') DEFAULT NULL,
+ `description` varchar(255) DEFAULT NULL,
+ `workerActivityTypeFk` varchar(20) DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ KEY `fk_workerActivity_worker` (`workerFk`),
+ KEY `workerActivity_workerActivityType_FK` (`workerActivityTypeFk`),
+ CONSTRAINT `fk_workerActivity_worker` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `workerActivity_workerActivityType_FK` FOREIGN KEY (`workerActivityTypeFk`) REFERENCES `workerActivityType` (`code`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `workerActivityType`
+--
+
+DROP TABLE IF EXISTS `workerActivityType`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `workerActivityType` (
+ `code` varchar(20) NOT NULL,
+ `description` varchar(45) NOT NULL,
+ PRIMARY KEY (`code`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `workerAppTester`
--
@@ -40615,7 +41407,7 @@ DROP TABLE IF EXISTS `workerConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `workerConfig` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`businessUpdated` date DEFAULT NULL,
`roleFk` int(10) unsigned NOT NULL COMMENT 'Rol por defecto al dar de alta un trabajador nuevo',
`businessTypeFk` varchar(100) DEFAULT NULL COMMENT 'Tipo de negocio por defecto al dar de alta un trabajador nuevo',
@@ -40624,7 +41416,8 @@ CREATE TABLE `workerConfig` (
KEY `workerConfig_FK` (`roleFk`),
KEY `workerConfig_FK_1` (`payMethodFk`),
CONSTRAINT `workerConfig_FK` FOREIGN KEY (`roleFk`) REFERENCES `account`.`role` (`id`) ON UPDATE CASCADE,
- CONSTRAINT `workerConfig_FK_1` FOREIGN KEY (`payMethodFk`) REFERENCES `payMethod` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
+ CONSTRAINT `workerConfig_FK_1` FOREIGN KEY (`payMethodFk`) REFERENCES `payMethod` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
+ CONSTRAINT `workerConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -40746,7 +41539,7 @@ CREATE TABLE `workerIncome` (
PRIMARY KEY (`id`),
KEY `income_employeeId_incomeType_idx` (`incomeTypeFk`),
KEY `income_employee_workerFk_idx` (`workerFk`),
- CONSTRAINT `income_employeeId_incomeType` FOREIGN KEY (`incomeTypeFk`) REFERENCES `vn2008`.`payroll_conceptos` (`conceptoid`) ON UPDATE CASCADE,
+ CONSTRAINT `income_employeeId_incomeType` FOREIGN KEY (`incomeTypeFk`) REFERENCES `payrollComponent` (`id`) ON UPDATE CASCADE,
CONSTRAINT `income_employee_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -41113,7 +41906,7 @@ DROP TABLE IF EXISTS `workerTimeControlConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `workerTimeControlConfig` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`dayBreak` int(11) NOT NULL,
`dayBreakDriver` int(11) NOT NULL,
`shortWeekBreak` int(11) NOT NULL,
@@ -41140,7 +41933,8 @@ CREATE TABLE `workerTimeControlConfig` (
`maxTimeToBreak` int(11) DEFAULT 3600,
`maxWorkShortCycle` int(10) unsigned DEFAULT 561600 COMMENT 'Máximo tiempo que un trabajador puede estar trabajando con el que adquirirá el derecho a un descanso semanal corto',
`maxWorkLongCycle` int(10) unsigned DEFAULT 950400 COMMENT 'Máximo tiempo que un trabajador puede estar trabajando con el que adquirirá el derecho a un descanso semanal largo',
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `workerTimeControlConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin COMMENT='All values in seconds';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -41331,9 +42125,10 @@ DROP TABLE IF EXISTS `zipConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `zipConfig` (
- `id` double(10,2) NOT NULL,
+ `id` int(10) unsigned NOT NULL,
`maxSize` int(11) DEFAULT NULL COMMENT 'in MegaBytes',
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `zipConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -41409,10 +42204,11 @@ DROP TABLE IF EXISTS `zoneConfig`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `zoneConfig` (
- `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `id` int(10) unsigned NOT NULL,
`scope` int(10) unsigned NOT NULL,
`forwardDays` int(10) NOT NULL DEFAULT 7 COMMENT 'days forward to show zone_upcomingDeliveries',
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ CONSTRAINT `zoneConfig_check` CHECK (`id` = 1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -41664,9 +42460,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 = utf8mb3 */ ;;
-/*!50003 SET character_set_results = utf8mb3 */ ;;
-/*!50003 SET collation_connection = utf8mb3_general_ci */ ;;
+/*!50003 SET character_set_client = utf8mb4 */ ;;
+/*!50003 SET character_set_results = utf8mb4 */ ;;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;;
/*!50003 SET @saved_time_zone = @@time_zone */ ;;
@@ -41674,9 +42470,8 @@ DELIMITER ;;
/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `clientsDisable` ON SCHEDULE EVERY 1 MONTH STARTS '2023-06-01 00:00:00' ON COMPLETION PRESERVE ENABLE DO BEGIN
UPDATE account.user u
JOIN client c ON c.id = u.id
- JOIN clientType ct ON ct.id = c.typeFk
SET u.active = FALSE
- WHERE ct.code = 'normal'
+ WHERE c.typeFk = 'normal'
AND u.id NOT IN (
SELECT DISTINCT c.id
FROM client c
@@ -41975,24 +42770,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 */ ;;
-/*!50106 DROP EVENT IF EXISTS `sale_checkWithoutComponents` */;;
-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 = utf8mb3 */ ;;
-/*!50003 SET character_set_results = utf8mb3 */ ;;
-/*!50003 SET collation_connection = utf8mb3_general_ci */ ;;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;;
-/*!50003 SET @saved_time_zone = @@time_zone */ ;;
-/*!50003 SET time_zone = 'SYSTEM' */ ;;
-/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `sale_checkWithoutComponents` ON SCHEDULE EVERY 10 MINUTE STARTS '2020-05-04 11:56:23' ON COMPLETION PRESERVE ENABLE DO call sale_checkNoComponents(DATE_ADD(util.VN_NOW(), INTERVAL -10 MINUTE),DATE_ADD(util.VN_NOW(), INTERVAL -1 MINUTE)) */ ;;
-/*!50003 SET time_zone = @saved_time_zone */ ;;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;;
-/*!50003 SET character_set_client = @saved_cs_client */ ;;
-/*!50003 SET character_set_results = @saved_cs_results */ ;;
-/*!50003 SET collation_connection = @saved_col_connection */ ;;
/*!50106 DROP EVENT IF EXISTS `ticket_doRecalc` */;;
DELIMITER ;;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;;
@@ -42155,6 +42932,7 @@ BEGIN
CALL vn.addressTaxArea();
SELECT areaFk INTO vTaxArea FROM tmp.addressTaxArea;
+
DROP TEMPORARY TABLE
tmp.addressCompany,
tmp.addressTaxArea;
@@ -43799,13 +44577,16 @@ BEGIN
SELECT rate3 INTO price
FROM vn.priceFixed
- WHERE itemFk = vItemFk
+ WHERE itemFk = vItemFk
AND util.VN_CURDATE() BETWEEN started AND ended ORDER BY created DESC LIMIT 1;
- SELECT `value` INTO price
+ SELECT `value` INTO price
FROM vn.specialPrice
- WHERE itemFk = vItemFk
- AND clientFk = vClientFk ;
+ WHERE itemFk = vItemFk
+ AND (clientFk = vClientFk OR clientFk IS NULL)
+ AND started <= util.VN_CURDATE()
+ AND (ended >= util.VN_CURDATE() OR ended IS NULL)
+ ORDER BY id DESC LIMIT 1;
RETURN price;
END ;;
DELIMITER ;
@@ -44363,44 +45144,6 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP FUNCTION IF EXISTS `isPalletHomogeneus` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` FUNCTION `isPalletHomogeneus`(vExpedition INT) RETURNS tinyint(1)
- READS SQL DATA
-BEGIN
- DECLARE vScanId INT;
- DECLARE vDistinctRoutesInThePallet INT;
-
- SELECT scan_id INTO vScanId
- FROM vn2008.scan_line
- WHERE code = vExpedition
- LIMIT 1;
-
- SELECT COUNT(*) INTO vDistinctRoutesInThePallet
- FROM (
- SELECT DISTINCT t.Id_Ruta
- FROM vn2008.scan_line sl
- JOIN expedition e ON e.id = sl.code
- JOIN vn2008.Tickets t ON t.Id_Ticket = e.ticketFk
- WHERE sl.scan_id = vScanId
- AND t.Id_Ruta
- ) t1;
-
- RETURN vDistinctRoutesInThePallet = 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 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP FUNCTION IF EXISTS `itemPacking` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -45973,7 +46716,7 @@ BEGIN
-- Inserta los asientos contables
SELECT account INTO vAccount
- FROM bank WHERE id = vBank;
+ FROM accounting WHERE id = vBank;
SELECT accountingAccount INTO vSubaccount
FROM `client` WHERE id = vClient;
@@ -46186,6 +46929,45 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP FUNCTION IF EXISTS `travel_hasUniqueAwb` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` FUNCTION `travel_hasUniqueAwb`(vSelf INT
+) RETURNS tinyint(1)
+ READS SQL DATA
+BEGIN
+/**
+ * Comprueba que el travel pasado tiene un AWB lógico,
+ * no se pueden tener varios AWB asociados al mismo DUA
+ *
+ * @param vSelf Id del travel
+ */
+ DECLARE vHasUniqueAwb BOOL DEFAULT TRUE;
+
+ SELECT NOT COUNT(t2.awbFk) INTO vHasUniqueAwb
+ FROM entry e
+ JOIN travel t ON t.id = e.travelFk
+ JOIN duaEntry de ON de.entryFk = e.id
+ JOIN duaEntry de2 ON de2.duaFk = de.duaFk
+ JOIN entry e2 ON e2.id = de2.entryFk
+ JOIN travel t2 ON t2.id = e2.travelFk
+ WHERE t.id = vSelf
+ AND t2.awbFk <> t.awbFk;
+
+ RETURN vHasUniqueAwb;
+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_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP FUNCTION IF EXISTS `validationCode` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -46599,6 +47381,200 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `absoluteInventoryHistory` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` PROCEDURE `absoluteInventoryHistory`(
+ vItemFk INT,
+ vWarehouseFk INT,
+ vDate DATETIME
+)
+BEGIN
+/**
+* Calcula y proporciona un historial de inventario absoluto
+* para un artículo específico en un almacén dado
+* hasta una fecha determinada.
+*
+* @param vItemFk Id de artículo
+* @param vWarehouseFk Id de almacén
+* @param vDate Fecha
+*/
+ DECLARE vCalculatedInventory INT;
+ DECLARE vToday DATETIME DEFAULT util.VN_CURDATE();
+ DECLARE vStartDate DATE DEFAULT '2001-01-01';
+
+ CREATE OR REPLACE TEMPORARY TABLE tHistoricalPast
+ ENGINE = MEMORY
+ SELECT *
+ FROM (
+ SELECT tr.landed `date`,
+ b.quantity input,
+ NULL `output`,
+ tr.isReceived ok,
+ s.name alias,
+ e.invoiceNumber reference,
+ e.id id,
+ tr.isDelivered f5
+ 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
+ WHERE tr.landed >= vStartDate
+ AND s.id <> (SELECT supplierFk FROM inventoryConfig)
+ AND vWarehouseFk IN (tr.warehouseInFk, 0)
+ AND b.itemFk = vItemFk
+ AND NOT e.isExcludedFromAvailable
+ AND NOT e.isRaid
+ UNION ALL
+ SELECT tr.shipped,
+ NULL,
+ b.quantity,
+ tr.isDelivered,
+ s.name,
+ e.invoiceNumber,
+ e.id,
+ tr.isDelivered
+ 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
+ WHERE tr.shipped >= vStartDate
+ AND vWarehouseFk = tr.warehouseOutFk
+ AND s.id <> (SELECT supplierFk FROM inventoryConfig)
+ AND b.itemFk = vItemFk
+ AND NOT e.isExcludedFromAvailable
+ AND NOT e.isRaid
+ UNION ALL
+ SELECT t.shipped,
+ NULL,
+ m.quantity,
+ (m.isPicked OR t.isLabeled OR t.refFk IS NOT NULL),
+ t.nickname,
+ t.refFk,
+ t.id,
+ t.isPrinted
+ FROM sale m
+ JOIN ticket t ON t.id = m.ticketFk
+ JOIN client c ON c.id = t.clientFk
+ WHERE t.shipped >= vStartDate
+ AND m.itemFk = vItemFk
+ AND vWarehouseFk IN (t.warehouseFk, 0)
+ ) t1
+ ORDER BY `date`, input DESC, ok DESC;
+
+ SELECT SUM(input) - SUM(`output`) INTO vCalculatedInventory
+ FROM tHistoricalPast
+ WHERE `date` < vDate;
+
+ SELECT p1.*, NULL v_virtual
+ FROM (
+ SELECT vDate `date`,
+ vCalculatedInventory input,
+ NULL `output`,
+ 1 ok,
+ 'Inventario calculado' alias,
+ '' reference,
+ 0 id,
+ 1 f5
+ UNION ALL
+ SELECT *
+ FROM tHistoricalPast
+ WHERE `date` >= vDate
+ ) p1;
+
+ DROP TEMPORARY TABLE tHistoricalPast;
+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_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `addAccountReconciliation` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` PROCEDURE `addAccountReconciliation`()
+BEGIN
+/**
+ * Updates duplicate records in the accountReconciliation table,
+ * by assigning them a new identifier and then inserts a new entry in the till table.
+ */
+ UPDATE accountReconciliation ar
+ JOIN (
+ SELECT id,
+ calculatedCode,
+ CONCAT(
+ calculatedCode,
+ '(',
+ ROW_NUMBER() OVER (PARTITION BY calculatedCode ORDER BY id),
+ ')'
+ ) newId
+ FROM accountReconciliation ar
+ WHERE calculatedCode IN (
+ SELECT calculatedCode
+ FROM accountReconciliation
+ GROUP BY calculatedCode
+ HAVING COUNT(*) > 1
+ )
+ ORDER BY calculatedCode, id
+ ) sub2 ON ar.id = sub2.id
+ SET ar.calculatedCode = sub2.newId;
+
+ INSERT INTO till(
+ dated,
+ isAccountable,
+ serie,
+ concept,
+ `in`,
+ `out`,
+ bankFk,
+ companyFk,
+ warehouseFk,
+ supplierAccountFk,
+ calculatedCode,
+ InForeignValue,
+ OutForeignValue,
+ workerFk
+ )
+ SELECT ar.operationDated,
+ TRUE,
+ 'MB',
+ ar.concept,
+ IF(ar.debitCredit = 'credit' AND a.currencyFk = arc.currencyFk, ar.amount, NULL),
+ IF(ar.debitCredit = 'debit' AND a.currencyFk = arc.currencyFk, ar.amount, NULL),
+ a.id,
+ sa.supplierFk,
+ arc.warehouseFk,
+ ar.supplierAccountFk,
+ ar.calculatedCode,
+ IF(ar.debitCredit = 'credit' AND NOT a.currencyFk = arc.currencyFk, ar.amount, NULL),
+ IF(ar.debitCredit = 'debit' AND NOT a.currencyFk = arc.currencyFk, ar.amount, NULL),
+ account.myUser_getId()
+ FROM accountReconciliation ar
+ JOIN supplierAccount sa ON sa.id = ar.supplierAccountFk
+ JOIN accounting a ON a.id = sa.accountingFk
+ LEFT JOIN till t ON t.calculatedCode = ar.calculatedCode
+ JOIN accountReconciliationConfig arc
+ WHERE t.id IS NULL;
+END ;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `addNoteFromDelivery` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -46883,6 +47859,57 @@ BEGIN
DROP TEMPORARY TABLE IF EXISTS tmp.agencyHourGetShipped;
+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_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `agencyVolume` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` PROCEDURE `agencyVolume`()
+BEGIN
+/**
+ * Calculates and presents information on shipment and packaging volumes
+ * for agencies that are not owned for a specific period.
+ */
+ DECLARE vStarted DATETIME DEFAULT util.VN_CURDATE();
+ DECLARE vEnded DATETIME DEFAULT util.dayEnd(util.VN_CURDATE());
+
+ SELECT ag.id agency_id,
+ CONCAT(RPAD(c.country, 16,' _') ,' ',ag.name) Agencia,
+ COUNT(*) expediciones,
+ SUM(t.packages) Bultos,
+ SUM(tpe.boxes) Faltan
+ FROM ticket t
+ JOIN warehouse w ON w.id = t.warehouseFk
+ JOIN country c ON w.countryFk = c.id
+ JOIN address a ON a.id = t.addressFk
+ JOIN agencyMode am ON am.id = t.agencyModeFk
+ JOIN agency ag ON ag.id = am.agencyFk
+ JOIN (
+ SELECT sv.ticketFk,
+ CEIL(1000 * SUM(sv.volume) / vc.standardFlowerBox) boxes
+ FROM ticket t
+ JOIN saleVolume sv ON sv.ticketFk = t.id
+ JOIN volumeConfig vc
+ WHERE t.shipped BETWEEN vStarted AND vEnded
+ AND (t.packages IS NULL OR NOT t.packages)
+ GROUP BY t.id
+ ) tpe ON tpe.ticketFk = t.id
+ WHERE t.shipped BETWEEN vStarted AND vEnded
+ AND NOT ag.isOwn
+ GROUP BY ag.id
+ ORDER BY Agencia;
+
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -46961,6 +47988,267 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `balanceNestTree_addChild` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` PROCEDURE `balanceNestTree_addChild`(
+ vSelf INT,
+ vName VARCHAR(45)
+)
+BEGIN
+/**
+ * Agrega un nuevo nodo hijo a un nodo existente dentro de la estructura
+ * de árbol de vn.balanceNestTree.
+ *
+ * @param vSelf Identificador del nodo
+ * @param vName Nombre del nuevo nodo hijo
+ */
+ DECLARE vTable VARCHAR(45) DEFAULT util.quoteIdentifier('balanceNestTree');
+ DECLARE vLeft INT;
+
+ CREATE OR REPLACE TEMPORARY TABLE tAux
+ SELECT 0 lft;
+
+ EXECUTE IMMEDIATE CONCAT(
+ 'UPDATE tAux
+ SET lft = (SELECT lft
+ FROM ', vTable,
+ ' WHERE id = ?)')
+ USING vSelf;
+
+ SELECT lft INTO vLeft FROM tAux;
+
+ EXECUTE IMMEDIATE CONCAT(
+ 'UPDATE ', vTable, '
+ SET rgt = rgt + 2
+ WHERE rgt > ?
+ ORDER BY rgt DESC')
+ USING vLeft;
+
+ EXECUTE IMMEDIATE CONCAT(
+ 'UPDATE ', vTable, '
+ SET lft = lft + 2
+ WHERE lft > ?
+ ORDER BY lft DESC')
+ USING vLeft;
+
+ EXECUTE IMMEDIATE CONCAT(
+ 'INSERT INTO ', vTable, ' (name, lft, rgt)
+ VALUES(?, ? + 1, ? + 2)')
+ USING vName,
+ vLeft,
+ vLeft;
+
+ DROP TEMPORARY TABLE tAux;
+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_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `balanceNestTree_delete` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` PROCEDURE `balanceNestTree_delete`(
+ vSelf INT
+)
+BEGIN
+/**
+ * Elimina un nodo dentro de la estructura de árbol de vn.balanceNestTree.
+ *
+ * @param vSelf Identificador del nodo
+ */
+ DECLARE vTable VARCHAR(45) DEFAULT util.quoteIdentifier('balanceNestTree');
+ DECLARE vRight INT;
+ DECLARE vLeft INT;
+ DECLARE vWidth INT;
+
+ CREATE OR REPLACE TEMPORARY TABLE tAux
+ SELECT 0 rgt, 0 lft, 0 wdt;
+
+ EXECUTE IMMEDIATE CONCAT(
+ 'UPDATE tAux a
+ JOIN ', vTable, ' t
+ SET a.rgt = t.rgt,
+ a.lft = t.lft,
+ a.wdt = t.rgt - t.lft + 1
+ WHERE t.id = ?')
+ USING vSelf;
+
+ SELECT rgt, lft, wdt
+ INTO vRight, vLeft, vWidth
+ FROM tAux;
+
+ EXECUTE IMMEDIATE CONCAT(
+ 'DELETE FROM ', vTable,
+ ' WHERE lft BETWEEN ? AND ?')
+ USING vLeft, vRight;
+
+ EXECUTE IMMEDIATE CONCAT(
+ 'UPDATE ', vTable,
+ ' SET rgt = rgt - ?
+ WHERE rgt > ?
+ ORDER BY rgt')
+ USING vWidth,vRight;
+
+ EXECUTE IMMEDIATE CONCAT(
+ 'UPDATE ', vTable,
+ ' SET lft = lft - ?
+ WHERE lft > ?
+ ORDER BY lft')
+ USING vWidth, vRight;
+
+ DROP TEMPORARY TABLE tAux;
+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_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `balanceNestTree_move` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` PROCEDURE `balanceNestTree_move`(
+ vSelf INT,
+ vFather INT
+)
+BEGIN
+/**
+ * Mueve un nodo dentro de la estructura de árbol de vn.balanceNestTree.
+ *
+ * @param vSelf Identificador del nodo
+ * @param vFather Identificador del nuevo padre del nodo
+ */
+ DECLARE vTable VARCHAR(45) DEFAULT util.quoteIdentifier('balanceNestTree');
+ DECLARE vRight INT;
+ DECLARE vLeft INT;
+ DECLARE vWidth INT;
+ DECLARE vFatherRight INT;
+ DECLARE vFatherLeft INT;
+ DECLARE vGap INT;
+
+ CREATE OR REPLACE TEMPORARY TABLE tAux
+ SELECT 0 rgt, 0 lft, 0 wdt, 0 frg, 0 flf;
+
+ -- Averiguamos el ancho de la rama
+ EXECUTE IMMEDIATE CONCAT(
+ 'UPDATE tAux a
+ JOIN ', vTable, ' t
+ SET a.wdt = t.rgt - t.lft + 1
+ WHERE t.id = ?')
+ USING vSelf;
+
+ -- Averiguamos la posicion del nuevo padre
+ EXECUTE IMMEDIATE CONCAT(
+ 'UPDATE tAux a
+ JOIN ', vTable, ' t
+ SET a.frg = t.rgt,
+ a.flf = t.lft
+ WHERE t.id = ?')
+ USING vFather;
+
+ SELECT wdt, frg, flf
+ INTO vWidth, vFatherRight, vFatherLeft
+ FROM tAux;
+
+ -- 1º Incrementamos los valores de todos los nodos a la derecha
+ -- del punto de inserción (vFatherRight) , para hacer sitio
+ EXECUTE IMMEDIATE CONCAT(
+ 'UPDATE ', vTable,
+ 'SET rgt = rgt + ?
+ WHERE rgt >= ?
+ ORDER BY rgt DESC')
+ USING vWidth,
+ vFatherRight;
+
+ EXECUTE IMMEDIATE CONCAT(
+ 'UPDATE ', vTable,
+ 'SET lft = lft + ?
+ WHERE lft >= ?
+ ORDER BY lft DESC')
+ USING vWidth,
+ vFatherRight;
+
+ -- Es preciso recalcular los valores del nodo en el
+ -- caso de que estuviera a la derecha del nuevo padre
+ EXECUTE IMMEDIATE CONCAT(
+ 'UPDATE tAux a
+ JOIN ', vTable, ' t
+ SET a.rgt = t.rgt,
+ a.lft = t.lft
+ WHERE t.id = ?')
+ USING vSelf;
+
+ SELECT lft, rgt, frg - lft
+ INTO vLeft, vRight, vGap
+ FROM tAux;
+
+ -- 2º Incrementamos el valor de todos los nodos a
+ -- trasladar hasta alcanzar su nueva posicion
+ EXECUTE IMMEDIATE CONCAT(
+ 'UPDATE ', vTable,
+ 'SET lft = lft + ?
+ WHERE lft BETWEEN ? AND ?
+ ORDER BY lft DESC')
+ USING vGap,
+ vLeft,
+ vRight;
+
+ EXECUTE IMMEDIATE CONCAT(
+ 'UPDATE ', vTable,
+ 'SET rgt = rgt + ?
+ WHERE rgt BETWEEN ? AND ?
+ ORDER BY rgt DESC')
+ USING vGap,
+ vLeft,
+ vRight;
+
+ -- 3º Restaremos a todos los nodos resultantes, a la derecha
+ -- de la posicion arrancada el ancho de la rama escindida
+ EXECUTE IMMEDIATE CONCAT(
+ 'UPDATE ', vTable,
+ 'SET lft = lft - ?
+ WHERE lft > ?
+ ORDER BY lft')
+ USING vWidth,
+ vLeft;
+
+ EXECUTE IMMEDIATE CONCAT(
+ 'UPDATE ', vTable,
+ 'SET rgt = rgt - ?
+ WHERE rgt > ?
+ ORDER BY rgt')
+ USING vWidth,
+ vRight;
+
+ DROP TEMPORARY TABLE tAux;
+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_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `bankEntity_checkBic` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -47012,13 +48300,11 @@ BEGIN
INSERT INTO mail (receiver,replyTo,subject,body)
SELECT 'administracion@verdnatura.es' receiver,
'noreply@verdnatura.es' replyTo,
- CONCAT('El seguro de la poliza ',b.id,' ',b.bank,' ha finalizado.') subject,
- CONCAT('El seguro de la poliza ',b.id,' ',b.bank,' ha finalizado.') body
- FROM vn.bankPolicy bp
- LEFT JOIN vn.supplier s
- ON s.id = bp.supplierFk
- LEFT JOIN vn.bank b
- ON b.id = bp.accountingFk
+ CONCAT('El seguro de la poliza ',a.id,' ',a.bank,' ha finalizado.') subject,
+ CONCAT('El seguro de la poliza ',a.id,' ',a.bank,' ha finalizado.') body
+ FROM bankPolicy bp
+ LEFT JOIN supplier s ON s.id = bp.supplierFk
+ LEFT JOIN accounting a ON a.id = bp.accountingFk
WHERE bp.insuranceExpired = util.VN_CURDATE();
END ;;
DELIMITER ;
@@ -47128,11 +48414,11 @@ BEGIN
WHERE t.landed BETWEEN vStarted AND vEnded
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
AND b.price2 > 0
- AND b.quantity > 0
ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC
LIMIT 10000000000000000000) sub
GROUP BY itemFk, warehouseFk;
+
INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
SELECT
b.itemFk,
@@ -47946,7 +49232,7 @@ BEGIN
ENGINE = MEMORY
SELECT vItemFk itemFk;
- CALL catalog_calculate(vLanded, vAddressFk, vAgencyModeFk);
+ CALL catalog_calculate(vLanded, vAddressFk, vAgencyModeFk, TRUE);
DROP TEMPORARY TABLE tmp.item;
END ;;
DELIMITER ;
@@ -47964,7 +49250,11 @@ DELIMITER ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_calculate`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT)
+CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_calculate`(
+ vLanded DATE,
+ vAddressFk INT,
+ vAgencyModeFk INT,
+ vShowExpiredZones BOOLEAN)
BEGIN
/**
* Calcula los articulos disponibles y sus precios
@@ -47990,7 +49280,7 @@ BEGIN
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
- CALL vn.zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, FALSE);
+ CALL vn.zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, vShowExpiredZones);
DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
CREATE TEMPORARY TABLE tmp.ticketLot(
@@ -48174,7 +49464,7 @@ BEGIN
* Calcula los componentes de los articulos de tmp.ticketLot
*
* @param vZoneFk para calcular el transporte
- * @param vAddressFk Consignatario
+ * @param vAddressFk Consignatario
* @param vShipped dia de salida del pedido
* @param vWarehouseFk warehouse de salida del pedido
* @table tmp.ticketLot (warehouseFk, available, itemFk, buyFk, zoneFk)
@@ -48188,7 +49478,20 @@ BEGIN
SELECT clientFk INTO vClientFK
FROM address
WHERE id = vAddressFk;
-
+
+ CREATE OR REPLACE TEMPORARY TABLE tSpecialPrice
+ (INDEX (itemFk))
+ ENGINE = MEMORY
+ SELECT * FROM (
+ SELECT *
+ FROM specialPrice
+ WHERE (clientFk = vClientFk OR clientFk IS NULL)
+ AND started <= vShipped
+ AND (ended >= vShipped OR ended IS NULL)
+ ORDER BY (clientFk = vClientFk) DESC, id DESC
+ LIMIT 10000000000000000000) t
+ GROUP BY itemFk;
+
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketComponentCalculate
(PRIMARY KEY (itemFk, warehouseFk))
ENGINE = MEMORY
@@ -48200,7 +49503,7 @@ BEGIN
IFNULL(pf.packing, GREATEST(b.grouping, b.packing)) packing,
IFNULL(pf.`grouping`, b.`grouping`) `grouping`,
ABS(IFNULL(pf.box, b.groupingMode)) groupingMode,
- tl.buyFk,
+ tl.buyFk,
i.typeFk,
IF(i.hasKgPrice, b.weight / b.packing, NULL) weightGrouping
FROM tmp.ticketLot tl
@@ -48208,8 +49511,7 @@ BEGIN
JOIN item i ON i.id = tl.itemFk
JOIN itemType it ON it.id = i.typeFk
JOIN itemCategory ic ON ic.id = it.categoryFk
- LEFT JOIN specialPrice sp ON sp.itemFk = i.id
- AND sp.clientFk = vClientFk
+ LEFT JOIN tSpecialPrice sp ON sp.itemFk = i.id
LEFT JOIN (
SELECT * FROM (
SELECT pf.itemFk,
@@ -48227,7 +49529,7 @@ BEGIN
LIMIT 10000000000000000000
) tpf
GROUP BY tpf.itemFk, tpf.warehouseFk
- ) pf ON pf.itemFk = tl.itemFk
+ ) pf ON pf.itemFk = tl.itemFk
AND pf.warehouseFk = tl.warehouseFk
WHERE b.buyingValue + b.freightValue + b.packageValue + b.comissionValue > 0.01
AND ic.merchandise
@@ -48259,10 +49561,10 @@ BEGIN
FROM tmp.ticketComponent tc
JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tc.itemFk AND tcc.warehouseFk = tc.warehouseFk
GROUP BY tc.itemFk, warehouseFk;
-
+
-- RECOBRO
INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost)
- SELECT tcb.warehouseFk, tcb.itemFk, c2.id,
+ SELECT tcb.warehouseFk, tcb.itemFk, c2.id,
ROUND(tcb.base *
LEAST(
MAX(GREATEST(IFNULL(cr.priceIncreasing,0),
@@ -48293,29 +49595,29 @@ BEGIN
ROUND(base * wm.pricesModifierRate, 3) manaAuto
FROM tmp.ticketComponentBase tcb
JOIN `client` c on c.id = vClientFk
- JOIN workerMana wm ON c.salesPersonFk = wm.workerFk
+ JOIN workerMana wm ON c.salesPersonFk = wm.workerFk
JOIN vn.component c2 ON c2.code = 'autoMana'
WHERE wm.isPricesModifierActivated
HAVING manaAuto <> 0;
-
+
-- Precios especiales
INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost)
SELECT tcb.warehouseFk,
tcb.itemFk,
c2.id,
GREATEST(
- IFNULL(ROUND(tcb.base * c2.tax, 4), 0),
+ IFNULL(ROUND(tcb.base * c2.tax, 4), 0),
IF(i.hasMinPrice, i.minPrice,0) - tcc.rate3
) cost
FROM tmp.ticketComponentBase tcb
JOIN vn.component c2 ON c2.code = 'lastUnitsDiscount'
- JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tcb.itemFk AND tcc.warehouseFk = tcb.warehouseFk
- LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk
+ JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tcb.itemFk AND tcc.warehouseFk = tcb.warehouseFk
+ LEFT JOIN tSpecialPrice sp ON sp.itemFk = tcc.itemFk
JOIN vn.item i ON i.id = tcb.itemFk
WHERE sp.value IS NULL
AND i.supplyResponseFk IS NULL;
- -- Individual
+ -- Individual
INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost)
SELECT tcb.warehouseFk,
tcb.itemFk,
@@ -48326,14 +49628,14 @@ BEGIN
JOIN vn.client c ON c.id = vClientFk
JOIN vn.businessType bt ON bt.code = c.businessTypeFk
WHERE bt.code = 'individual';
-
+
-- Venta por paquetes
INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost)
- SELECT tcc.warehouseFk, tcc.itemFk, c2.id, tcc.rate2 - tcc.rate3
+ SELECT tcc.warehouseFk, tcc.itemFk, c2.id, tcc.rate2 - tcc.rate3
FROM tmp.ticketComponentCalculate tcc
JOIN vn.component c2 ON c2.code = 'salePerPackage'
JOIN buy b ON b.id = tcc.buyFk
- LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk
+ LEFT JOIN tSpecialPrice sp ON sp.itemFk = tcc.itemFk
WHERE sp.value IS NULL;
CREATE OR REPLACE TEMPORARY TABLE tmp.`zone` (INDEX (id))
@@ -48341,7 +49643,7 @@ BEGIN
SELECT vZoneFk id;
CALL zone_getOptionsForShipment(vShipped, TRUE);
-
+
-- Reparto
INSERT INTO tmp.ticketComponent
SELECT tcc.warehouseFK,
@@ -48355,7 +49657,7 @@ BEGIN
JOIN agencyMode am ON am.id = z.agencyModeFk
JOIN vn.volumeConfig vc
JOIN vn.component c2 ON c2.code = 'delivery'
- LEFT JOIN itemCost ic ON ic.warehouseFk = tcc.warehouseFk
+ LEFT JOIN itemCost ic ON ic.warehouseFk = tcc.warehouseFk
AND ic.itemFk = tcc.itemFk
HAVING cost <> 0;
@@ -48372,7 +49674,7 @@ BEGIN
sp.value - SUM(tcc.cost) sumCost
FROM tmp.ticketComponentCopy tcc
JOIN component c ON c.id = tcc.componentFk
- JOIN specialPrice sp ON sp.clientFk = vClientFK AND sp.itemFk = tcc.itemFk
+ JOIN tSpecialPrice sp ON sp.itemFk = tcc.itemFk
JOIN vn.component c2 ON c2.code = 'specialPrices'
WHERE c.classRate IS NULL
AND tcc.warehouseFk = vWarehouseFk
@@ -48408,9 +49710,9 @@ BEGIN
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
+ JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk
AND tcs.warehouseFk = tcc.warehouseFk
- WHERE IFNULL(tcs.classRate, 1) = 1
+ 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;
@@ -48447,13 +49749,14 @@ BEGIN
SELECT * FROM tmp.ticketComponentRate ORDER BY price LIMIT 10000000000000000000
) t
GROUP BY itemFk, warehouseFk, `grouping`;
-
+
DROP TEMPORARY TABLE
tmp.ticketComponentCalculate,
tmp.ticketComponentSum,
tmp.ticketComponentBase,
tmp.ticketComponentRate,
- tmp.ticketComponentCopy;
+ tmp.ticketComponentCopy,
+ tSpecialPrice;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -48534,46 +49837,43 @@ DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `clean`()
BEGIN
- DECLARE vDateShort DATETIME;
- DECLARE vOneYearAgo DATE;
- DECLARE vFourYearsAgo DATE;
- DECLARE vFiveYearsAgo DATE;
- DECLARE v18Month DATE;
- DECLARE v26Month DATE;
- DECLARE v3Month DATE;
+/**
+ * Purges outdated data to optimize performance.
+ * Exercise caution when executing.
+ */
+ DECLARE v2Months DATE DEFAULT util.VN_CURDATE() - INTERVAL 2 MONTH;
+ DECLARE v3Months DATE DEFAULT util.VN_CURDATE() - INTERVAL 3 MONTH;
+ DECLARE v18Months DATE DEFAULT util.VN_CURDATE() - INTERVAL 18 MONTH;
+ DECLARE v26Months DATE DEFAULT util.VN_CURDATE() - INTERVAL 26 MONTH;
+ DECLARE v1Years DATE DEFAULT util.VN_CURDATE() - INTERVAL 1 YEAR;
+ DECLARE v2Years DATE DEFAULT util.VN_CURDATE() - INTERVAL 2 YEAR;
+ DECLARE v4Years DATE DEFAULT util.VN_CURDATE() - INTERVAL 4 YEAR;
+ DECLARE v5Years DATE DEFAULT util.VN_CURDATE() - INTERVAL 5 YEAR;
DECLARE vTrashId VARCHAR(15);
- DECLARE v2Years DATE;
- DECLARE v5Years DATE;
+ DECLARE vCompanyBlk INT;
- SET vDateShort = util.VN_CURDATE() - INTERVAL 2 MONTH;
- SET vOneYearAgo = util.VN_CURDATE() - INTERVAL 1 YEAR;
- SET vFourYearsAgo = util.VN_CURDATE() - INTERVAL 4 YEAR;
- SET vFiveYearsAgo = util.VN_CURDATE() - INTERVAL 5 YEAR;
- SET v18Month = util.VN_CURDATE() - INTERVAL 18 MONTH;
- SET v26Month = util.VN_CURDATE() - INTERVAL 26 MONTH;
- SET v3Month = util.VN_CURDATE() - INTERVAL 3 MONTH;
- SET v2Years = util.VN_CURDATE() - INTERVAL 2 YEAR;
- SET v5Years = util.VN_CURDATE() - INTERVAL 5 YEAR;
-
- DELETE FROM ticketParking WHERE created < vDateShort;
- DELETE FROM routesMonitor WHERE dated < vDateShort;
- DELETE FROM workerTimeControlLog WHERE created < vDateShort;
- DELETE FROM `message` WHERE sendDate < vDateShort;
- DELETE FROM messageInbox WHERE sendDate < vDateShort;
- DELETE FROM messageInbox WHERE sendDate < vDateShort;
- DELETE FROM workerTimeControl WHERE timed < vFourYearsAgo;
+ DELETE FROM workerActivity WHERE created < v2Years;
+ DELETE FROM ticketParking WHERE created < v2Months;
+ DELETE FROM routesMonitor WHERE dated < v2Months;
+ DELETE FROM workerTimeControlLog WHERE created < v2Months;
+ DELETE FROM `message` WHERE sendDate < v2Months;
+ DELETE FROM messageInbox WHERE sendDate < v2Months;
+ DELETE FROM messageInbox WHERE sendDate < v2Months;
+ DELETE FROM workerTimeControl WHERE timed < v4Years;
DELETE FROM itemShelving WHERE created < util.VN_CURDATE() AND visible = 0;
- DELETE FROM ticketDown WHERE created < TIMESTAMPADD(DAY,-1,util.VN_CURDATE());
- DELETE FROM entryLog WHERE creationDate < vDateShort;
- DELETE IGNORE FROM expedition WHERE created < v26Month;
- DELETE FROM sms WHERE created < v18Month;
- DELETE FROM saleTracking WHERE created < vOneYearAgo;
- DELETE FROM ticketTracking WHERE created < v18Month;
- DELETE tobs FROM ticketObservation tobs
- JOIN ticket t ON tobs.ticketFk = t.id WHERE t.shipped < TIMESTAMPADD(YEAR,-2,util.VN_CURDATE());
- DELETE sc.* FROM saleCloned sc JOIN sale s ON s.id = sc.saleClonedFk JOIN ticket t ON t.id = s.ticketFk WHERE t.shipped < vOneYearAgo;
- DELETE FROM sharingCart where ended < vDateShort;
- DELETE FROM sharingClient where ended < vDateShort;
+ DELETE FROM ticketDown WHERE created < util.yesterday();
+ DELETE FROM entryLog WHERE creationDate < v2Months;
+ DELETE IGNORE FROM expedition WHERE created < v26Months;
+ DELETE FROM sms WHERE created < v18Months;
+ DELETE FROM saleTracking WHERE created < v1Years;
+ DELETE FROM productionError WHERE dated < v1Years;
+ DELETE FROM ticketTracking WHERE created < v18Months;
+ DELETE tobs FROM ticketObservation tobs
+ JOIN ticket t ON tobs.ticketFk = t.id
+ WHERE t.shipped < v5Years;
+ DELETE sc.* FROM saleCloned sc JOIN sale s ON s.id = sc.saleClonedFk JOIN ticket t ON t.id = s.ticketFk WHERE t.shipped < v1Years;
+ DELETE FROM sharingCart where ended < v2Months;
+ DELETE FROM sharingClient where ended < v2Months;
DELETE tw.* FROM ticketWeekly tw
LEFT JOIN sale s ON s.ticketFk = tw.ticketFk
LEFT JOIN ticketRequest tr ON tr.ticketFk = tw.ticketFk
@@ -48581,145 +49881,183 @@ BEGIN
WHERE s.id IS NULL
AND tr.id IS NULL
AND ts.id IS NULL;
- DELETE FROM claim WHERE ticketCreated < vFourYearsAgo;
- DELETE FROM message WHERE sendDate < vDateShort;
- -- Robert ubicacion anterior de trevelLog comentario para debug
- DELETE FROM zoneEvent WHERE `type` = 'day' AND dated < v3Month;
+ DELETE FROM claim WHERE ticketCreated < v4Years;
+ -- Robert ubicacion anterior de travelLog comentario para debug
+ DELETE FROM zoneEvent WHERE `type` = 'day' AND dated < v3Months;
DELETE bm
FROM buyMark bm
JOIN buy b ON b.id = bm.id
JOIN entry e ON e.id = b.entryFk
JOIN travel t ON t.id = e.travelFk
- WHERE t.landed <= vDateShort;
- DELETE b FROM vn.buy b
- JOIN vn.entryConfig e ON e.defaultEntry = b.entryFk
- WHERE b.created < vDateShort;
- DELETE FROM vn.itemShelvingLog WHERE created < vDateShort;
- DELETE FROM vn.stockBuyed WHERE creationDate < vDateShort;
- DELETE FROM vn.itemCleanLog WHERE created < util.VN_NOW() - INTERVAL 1 YEAR;
- DELETE FROM printQueue WHERE statusCode = 'printed' AND created < vDateShort;
- DELETE FROM ticketLog WHERE creationDate <= vFiveYearsAgo;
+ WHERE t.landed <= v2Months;
+ DELETE b FROM buy b
+ JOIN entryConfig e ON e.defaultEntry = b.entryFk
+ WHERE b.created < v2Months;
+ DELETE FROM itemShelvingLog WHERE created < v2Months;
+ DELETE FROM stockBuyed WHERE creationDate < v2Months;
+ DELETE FROM itemCleanLog WHERE created < util.VN_NOW() - INTERVAL 1 YEAR;
+ DELETE FROM printQueue WHERE statusCode = 'printed' AND created < v2Months;
+ DELETE FROM ticketLog WHERE creationDate <= v5Years;
-- Equipos duplicados
DELETE w.*
FROM workerTeam w
- JOIN (SELECT id, team, workerFk, COUNT(*) - 1 as duplicated
+ JOIN (
+ SELECT id, team, workerFk, COUNT(*) - 1 duplicated
FROM workerTeam
GROUP BY team,workerFk
HAVING duplicated
- ) d ON d.team = w.team AND d.workerFk = w.workerFk AND d.id != w.id;
+ ) d ON d.team = w.team
+ AND d.workerFk = w.workerFk
+ AND d.id <> w.id;
DELETE sc
FROM saleComponent sc
JOIN sale s ON s.id= sc.saleFk
JOIN ticket t ON t.id= s.ticketFk
- WHERE t.shipped < v18Month;
+ WHERE t.shipped < v18Months;
DELETE c
- FROM vn.claim c
- JOIN vn.claimState cs ON cs.id = c.claimStateFk
- WHERE cs.description = "Anulado" AND
- c.created < vDateShort;
- DELETE
- FROM vn.expeditionTruck
- WHERE eta < v3Month;
+ FROM claim c
+ JOIN claimState cs ON cs.id = c.claimStateFk
+ WHERE cs.description = 'Anulado'
+ AND c.created < v2Months;
- DELETE FROM XDiario WHERE FECHA < v3Month OR FECHA IS NULL;
- -- borrar travels sin entradas
- DROP TEMPORARY TABLE IF EXISTS tmp.thermographToDelete;
- CREATE TEMPORARY TABLE tmp.thermographToDelete
+ DELETE FROM expeditionTruck WHERE eta < v3Months;
+ DELETE FROM XDiario WHERE FECHA < v3Months OR FECHA IS NULL;
+
+ -- Borrar travels sin entradas
+ CREATE OR REPLACE TEMPORARY TABLE tThermographToDelete
SELECT th.id,th.dmsFk
- FROM vn.travel t
- LEFT JOIN vn.entry e ON e.travelFk = t.id
- JOIN vn.travelThermograph th ON th.travelFk = t.id
- WHERE t.shipped < TIMESTAMPADD(MONTH, -3, util.VN_CURDATE()) AND e.travelFk IS NULL;
+ FROM travel t
+ LEFT JOIN entry e ON e.travelFk = t.id
+ JOIN travelThermograph th ON th.travelFk = t.id
+ WHERE t.shipped < v3Months
+ AND e.travelFk IS NULL;
SELECT dt.id INTO vTrashId
- FROM vn.dmsType dt
+ FROM dmsType dt
WHERE dt.code = 'trash';
- UPDATE tmp.thermographToDelete th
- JOIN vn.dms d ON d.id = th.dmsFk
+ UPDATE tThermographToDelete th
+ JOIN dms d ON d.id = th.dmsFk
SET d.dmsTypeFk = vTrashId;
DELETE th
- FROM tmp.thermographToDelete tmp
- JOIN vn.travelThermograph th ON th.id = tmp.id;
+ FROM tThermographToDelete tmp
+ JOIN travelThermograph th ON th.id = tmp.id;
DELETE t
- FROM vn.travel t
- LEFT JOIN vn.entry e ON e.travelFk = t.id
- WHERE t.shipped < TIMESTAMPADD(MONTH, -3, util.VN_CURDATE()) AND e.travelFk IS NULL;
-
+ FROM travel t
+ LEFT JOIN entry e ON e.travelFk = t.id
+ WHERE t.shipped < v3Months AND e.travelFk IS NULL;
+
UPDATE dms d
- JOIN dmsType dt ON dt.id = d.dmsTypeFk
- SET d.dmsTypeFk = vTrashId
- WHERE created < TIMESTAMPADD(MONTH, -dt.monthToDelete, util.VN_CURDATE());
-
+ JOIN dmsType dt ON dt.id = d.dmsTypeFk
+ SET d.dmsTypeFk = vTrashId
+ WHERE created < util.VN_CURDATE() - INTERVAL dt.monthToDelete MONTH;
+
-- borrar entradas sin compras
- DROP TEMPORARY TABLE IF EXISTS tmp.entryToDelete;
- CREATE TEMPORARY TABLE tmp.entryToDelete
+ CREATE OR REPLACE TEMPORARY TABLE tEntryToDelete
SELECT e.*
- FROM vn.entry e
- LEFT JOIN vn.buy b ON b.entryFk = e.id
- JOIN vn.entryConfig ec ON e.id != ec.defaultEntry
- WHERE e.dated < TIMESTAMPADD(MONTH, -3, util.VN_CURDATE()) AND b.entryFK IS NULL;
+ FROM entry e
+ LEFT JOIN buy b ON b.entryFk = e.id
+ JOIN entryConfig ec ON e.id <> ec.defaultEntry
+ WHERE e.dated < v3Months
+ AND b.entryFK IS NULL;
DELETE e
- FROM vn.entry e
- JOIN tmp.entryToDelete tmp ON tmp.id = e.id;
+ FROM entry e
+ JOIN tEntryToDelete tmp ON tmp.id = e.id;
-- borrar de route registros menores a 4 años
- DROP TEMPORARY TABLE IF EXISTS tmp.routeToDelete;
- CREATE TEMPORARY TABLE tmp.routeToDelete
+ CREATE OR REPLACE TEMPORARY TABLE tRouteToDelete
SELECT *
- FROM vn.route r
- WHERE created < TIMESTAMPADD(YEAR,-4,util.VN_CURDATE());
+ FROM route r
+ WHERE created < v4Years;
- UPDATE tmp.routeToDelete tmp
- JOIN vn.dms d ON d.id = tmp.gestdocFk
+ UPDATE tRouteToDelete tmp
+ JOIN dms d ON d.id = tmp.gestdocFk
SET d.dmsTypeFk = vTrashId;
DELETE r
- FROM tmp.routeToDelete tmp
- JOIN vn.route r ON r.id = tmp.id;
+ FROM tRouteToDelete tmp
+ JOIN route r ON r.id = tmp.id;
-- borrar registros de dua y awb menores a 2 años
- DROP TEMPORARY TABLE IF EXISTS tmp.duaToDelete;
- CREATE TEMPORARY TABLE tmp.duaToDelete
+ CREATE OR REPLACE TEMPORARY TABLE tDuaToDelete
SELECT *
- FROM vn.dua
- WHERE operated < TIMESTAMPADD(YEAR,-2,CURDATE());
+ FROM dua
+ WHERE operated < v2Years;
- UPDATE tmp.duaToDelete tm
- JOIN vn.dms d ON d.id = tm.gestdocFk
+ UPDATE tDuaToDelete tm
+ JOIN dms d ON d.id = tm.gestdocFk
SET d.dmsTypeFk = vTrashId;
DELETE d
- FROM tmp.duaToDelete tmp
- JOIN vn.dua d ON d.id = tmp.id;
+ FROM tDuaToDelete tmp
+ JOIN dua d ON d.id = tmp.id;
DELETE a
- FROM vn.awb a
- LEFT JOIN vn.travel t ON t.awbFk = a.id
+ FROM awb a
+ LEFT JOIN travel t ON t.awbFk = a.id
WHERE a.created < v2Years
AND t.id IS NULL;
-- Borra los registros de collection y ticketcollection
- DELETE FROM vn.collection WHERE created < vDateShort;
+ DELETE FROM collection WHERE created < v2Months;
+ DELETE FROM travelLog WHERE creationDate < v3Months;
- DROP TEMPORARY TABLE IF EXISTS tmp.thermographToDelete;
- DROP TEMPORARY TABLE IF EXISTS tmp.entryToDelete;
- DROP TEMPORARY TABLE IF EXISTS tmp.duaToDelete;
-
- DELETE FROM travelLog WHERE creationDate < v3Month;
-
- CALL shelving_clean;
+ CALL shelving_clean();
DELETE FROM chat WHERE dated < v5Years;
+ DELETE tt FROM ticketTracking tt
+ JOIN ticket t ON tt.ticketFk = t.id
+ WHERE t.shipped <= v2Months;
- DELETE tt FROM ticketTracking tt JOIN vn.ticket t ON tt.ticketFk = t.id
- WHERE t.shipped <= vDateShort;
+ DELETE FROM mail WHERE creationDate < v2Months;
+ DELETE FROM split WHERE dated < v18Months;
+ DELETE FROM remittance WHERE dated < v18Months;
+ CREATE OR REPLACE TEMPORARY TABLE tTicketDelete
+ SELECT DISTINCT tl.originFk ticketFk
+ FROM ticketLog tl
+ JOIN (
+ SELECT MAX(tl.id)ids
+ FROM ticket t
+ JOIN ticketLog tl ON tl.originFk = t.id
+ LEFT JOIN ticketWeekly tw ON tw.ticketFk = t.id
+ WHERE t.shipped BETWEEN '2000-01-01' AND '2000-12-31'
+ AND t.isDeleted
+ AND tw.ticketFk IS NULL
+ GROUP BY t.id
+ ) sub ON sub.ids = tl.id
+ WHERE tl.creationDate <= v2Months;
+ DELETE t
+ FROM ticket t
+ JOIN tTicketDelete tmp ON tmp.ticketFk = t.id;
+
+ DELETE sl
+ FROM saleLabel sl
+ JOIN sale s ON s.id = sl.saleFk
+ JOIN ticket t ON t.id = s.ticketFk
+ WHERE t.shipped < v2Months;
+
+ -- Tickets Nulos PAK 11/10/2016
+ SELECT id INTO vCompanyBlk FROM company WHERE code = 'BLK';
+ UPDATE ticket
+ SET companyFk = vCompanyBlk
+ WHERE clientFk = (SELECT id FROM client WHERE name = 'AUTOCONSUMO')
+ AND companyFk <> vCompanyBlk;
+
+ DROP TEMPORARY TABLE tTicketDelete,
+ tThermographToDelete,
+ tEntryToDelete,
+ tDuaToDelete,
+ tRouteToDelete;
+
+ -- Other schemas
+ DELETE FROM hedera.`order` WHERE date_send < v18Months;
+ DELETE FROM pbx.cdr WHERE call_date < v18Months;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -49701,7 +51039,8 @@ BEGIN
FROM receipt r
JOIN `client` c ON c.id = r.clientFk
JOIN tmp.client tc ON tc.id = c.id
- JOIN bank b ON r.bankFk = b.id AND b.code = 'mana'
+ JOIN accounting a ON r.bankFk = a.id
+ AND a.code = 'mana'
WHERE r.payed > vFromDated
AND r.payed <= util.VN_CURDATE()
UNION ALL
@@ -50165,6 +51504,13 @@ proc:BEGIN
DECLARE vHasTooMuchCollections BOOL;
DECLARE vLockTime INT DEFAULT 15;
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ BEGIN
+ DO RELEASE_LOCK('collection_assign');
+
+ RESIGNAL;
+ END;
+
-- Si hay colecciones sin terminar, sale del proceso
CALL collection_get(vUserFk);
@@ -50472,14 +51818,14 @@ DELIMITER ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `collection_new` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_new`(vUserFk INT, OUT vCollectionFk INT)
proc:BEGIN
@@ -50510,6 +51856,7 @@ proc:BEGIN
DECLARE vLockName VARCHAR(215);
DECLARE vLockTime INT DEFAULT 15;
DECLARE vFreeWagonFk INT;
+
DECLARE c1 CURSOR FOR
SELECT ticketFk, `lines`, m3
FROM tmp.productionBuffer
@@ -50526,13 +51873,21 @@ proc:BEGIN
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ BEGIN
+ IF vLockName IS NOT NULL THEN
+ DO RELEASE_LOCK(vLockName);
+ END IF;
+
+ RESIGNAL;
+ END;
+
SELECT pc.ticketTrolleyMax * o.numberOfWagons,
pc.hasUniqueCollectionTime,
w.code,
o.warehouseFk,
o.itemPackingTypeFk,
st.code,
- CONCAT('collection_new', o.warehouseFk, ':',o.itemPackingTypeFk),
o.numberOfWagons,
o.trainFk,
o.linesLimit,
@@ -50543,7 +51898,6 @@ proc:BEGIN
vWarehouseFk,
vItemPackingTypeFk,
vStateFk,
- vLockName,
vWagons,
vTrainFk,
vLinesLimit,
@@ -50553,6 +51907,12 @@ proc:BEGIN
JOIN state st ON st.`code` = 'ON_PREPARATION'
JOIN operator o ON o.workerFk = vUserFk;
+ SET vLockName = CONCAT_WS('/',
+ 'collection_new',
+ vWarehouseFk,
+ vItemPackingTypeFk
+ );
+
IF NOT GET_LOCK(vLockName, vLockTime) THEN
LEAVE proc;
END IF;
@@ -50690,7 +52050,8 @@ proc:BEGIN
@lines:= COUNT(*) + @lines,
COUNT(*) `lines`,
MAX(i.`size`) height,
- @volume := SUM(sv.volume) + @volume volume
+ @volume := SUM(sv.volume) + @volume,
+ SUM(sv.volume) volume
FROM saleVolume sv
JOIN sale s ON s.id = sv.saleFk
JOIN item i ON i.id = s.itemFk
@@ -50733,13 +52094,13 @@ proc:BEGIN
UPDATE tTrain
SET ticketFk = vFirstTicketFk
WHERE wagon = vFreeWagonFk;
-
+
-- Se anulan el resto de carros libres para que sólo uno lleve un pedido excesivo
DELETE tt.*
FROM tTrain tt
LEFT JOIN (
- SELECT DISTINCT wagon
- FROM tTrain
+ SELECT DISTINCT wagon
+ FROM tTrain
WHERE ticketFk IS NOT NULL
) nn ON nn.wagon = tt.wagon
WHERE nn.wagon IS NULL;
@@ -50754,7 +52115,7 @@ proc:BEGIN
FETCH c1 INTO vTicketFk, vTicketLines, vTicketVolume;
IF vDone THEN
LEAVE read_loop;
- END IF;
+ END IF;
END IF;
END LOOP;
CLOSE c1;
@@ -51027,21 +52388,21 @@ BEGIN
currencyFk
FROM (
SELECT p.supplierFk,
- p.companyFk,
- IF (p.currencyFk = vCurrencyEuroFk, p.amount, p.divisa) AS amount,
- p.dueDated < vStartingDate isBeforeStarting,
- p.currencyFk
- FROM payment p
+ p.companyFk,
+ IF (p.currencyFk = vCurrencyEuroFk, p.amount, p.divisa) AS amount,
+ p.dueDated < vStartingDate isBeforeStarting,
+ p.currencyFk
+ FROM payment p
WHERE p.received > vStartDate
AND p.companyFk = vSelf
UNION ALL
SELECT r.supplierFk,
- r.companyFk,
- - IF (r.currencyFk = vCurrencyEuroFk, rv.amount, rv.foreignValue) AS Total,
- rv.dueDated < vStartingDate isBeforeStarting,
- r.currencyFk
- FROM invoiceIn r
- INNER JOIN invoiceInDueDay rv ON r.id = rv.invoiceInFk
+ r.companyFk,
+ - IF (r.currencyFk = vCurrencyEuroFk, rv.amount, rv.foreignValue) AS Total,
+ rv.dueDated < vStartingDate isBeforeStarting,
+ r.currencyFk
+ FROM invoiceIn r
+ INNER JOIN invoiceInDueDay rv ON r.id = rv.invoiceInFk
WHERE r.issued > vStartDate
AND r.isBooked
AND r.companyFk = vSelf
@@ -51050,7 +52411,7 @@ BEGIN
DROP TEMPORARY TABLE IF EXISTS tPendingDuedates;
CREATE TEMPORARY TABLE tPendingDuedates (
id INT auto_increment,
- expirationId INT,
+ expirationId INT,
dated DATE,
supplierFk INT NOT NULL,
companyFk INT NOT NULL,
@@ -51075,35 +52436,35 @@ BEGIN
isPayment,
isReconciled
)SELECT p.id,
- p.dueDated,
- p.supplierFk,
- p.companyFk,
- IF (p.currencyFk = vCurrencyEuroFk, p.amount, p.divisa),
- p.currencyFk,
- TRUE isPayment,
- p.isConciliated
- FROM payment p
- WHERE p.dueDated >= vStartingDate
- AND p.companyFk = vSelf
- UNION ALL
- SELECT r.id,
- rv.dueDated,
- r.supplierFk,
- r.companyFk,
- -IF (r.currencyFk = vCurrencyEuroFk, rv.amount, rv.foreignValue),
- r.currencyFk,
- FALSE isPayment,
- TRUE
- FROM invoiceIn r
- LEFT JOIN tOpeningBalances si ON r.companyFk = si.companyFk
- AND r.supplierFk = si.supplierFk
- AND r.currencyFk = si.currencyFk
- JOIN invoiceInDueDay rv ON r.id = rv.invoiceInFk
- WHERE rv.dueDated >= vStartingDate
- AND (si.closingBalances IS NULL OR si.closingBalances <> 0)
- AND r.isBooked
- AND r.companyFk = vSelf
- ORDER BY supplierFk, companyFk, companyFk, dueDated, isPayment DESC, id;
+ p.dueDated,
+ p.supplierFk,
+ p.companyFk,
+ IF (p.currencyFk = vCurrencyEuroFk, p.amount, p.divisa),
+ p.currencyFk,
+ TRUE isPayment,
+ p.isConciliated
+ FROM payment p
+ WHERE p.dueDated >= vStartingDate
+ AND p.companyFk = vSelf
+ UNION ALL
+ SELECT r.id,
+ rv.dueDated,
+ r.supplierFk,
+ r.companyFk,
+ -IF (r.currencyFk = vCurrencyEuroFk, rv.amount, rv.foreignValue),
+ r.currencyFk,
+ FALSE isPayment,
+ TRUE
+ FROM invoiceIn r
+ LEFT JOIN tOpeningBalances si ON r.companyFk = si.companyFk
+ AND r.supplierFk = si.supplierFk
+ AND r.currencyFk = si.currencyFk
+ JOIN invoiceInDueDay rv ON r.id = rv.invoiceInFk
+ WHERE rv.dueDated >= vStartingDate
+ AND (si.closingBalances IS NULL OR si.closingBalances <> 0)
+ AND r.isBooked
+ AND r.companyFk = vSelf
+ ORDER BY supplierFk, companyFk, companyFk, dueDated, isPayment DESC, id;
-- Now, we calculate the outstanding amount for each receipt in descending order
SET @risk := 0.0;
SET @supplier := 0.0;
@@ -51152,7 +52513,7 @@ BEGIN
FROM tPendingDuedates
WHERE balance < vInvalidBalances
AND balance > - vInvalidBalances;
-
+
DELETE vp.*
FROM tPendingDuedates vp
JOIN tRowsToDelete rd ON (
@@ -51162,27 +52523,31 @@ BEGIN
AND vp.supplierFk = rd.supplierFk
AND vp.companyFk = rd.companyFk
AND vp.currencyFk = rd.currencyFk
- WHERE vp.isPayment = FALSE;
+ WHERE NOT vp.isPayment;
SELECT vp.expirationId,
vp.dated,
vp.supplierFk,
- vp.companyFk,
- vp.currencyFk,
- vp.amount,
- vp.pending,
- vp.balance,
- s.payMethodFk,
- vp.isPayment,
- vp.isReconciled,
- vp.endingBalance,
- cr.amount clientRiskAmount
+ vp.companyFk,
+ vp.currencyFk,
+ vp.amount,
+ vp.pending,
+ vp.balance,
+ s.payMethodFk,
+ vp.isPayment,
+ vp.isReconciled,
+ vp.endingBalance,
+ cr.amount clientRiskAmount,
+ co.CEE
FROM tPendingDuedates vp
- LEFT JOIN supplier s ON s.id = vp.supplierFk
+ LEFT JOIN supplier s ON s.id = vp.supplierFk
LEFT JOIN client c ON c.fi = s.nif
- LEFT JOIN clientRisk cr ON cr.clientFk = c.id
- AND cr.companyFk = vp.companyFk;
-
+ JOIN clientRisk cr ON cr.clientFk = c.id
+ AND cr.companyFk = vp.companyFk
+ LEFT JOIN supplierAccount sa ON sa.supplierFk = s.id
+ LEFT JOIN bankEntity be ON be.id = sa.bankEntityFk
+ LEFT JOIN country co ON co.id = be.countryFk;
+
DROP TEMPORARY TABLE tOpeningBalances;
DROP TEMPORARY TABLE tPendingDuedates;
DROP TEMPORARY TABLE tRowsToDelete;
@@ -51250,12 +52615,11 @@ BEGIN
JOIN itemCategory ic ON ic.id = tp.categoryFk
JOIN ticket t ON t.id = s.ticketFk
JOIN client c ON c.id = t.clientFk
- JOIN clientType ct ON ct.id = c.clientTypeFk
JOIN warehouse w ON w.id = t.warehouseFk
JOIN address ad ON ad.id = t.addressFk
LEFT JOIN province p ON p.id = ad.provinceFk
WHERE tm.period BETWEEN vMaxPeriod AND vPeriod
- AND ct.code <> 'loses'
+ AND c.typeFk <> 'loses'
AND NOT w.code = 'inv'
GROUP BY p.countryFk, s.itemFk, tm.period, t.warehouseFk;
END IF;
@@ -51267,6 +52631,122 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `confection_controlSource` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` PROCEDURE `confection_controlSource`(
+ vDated DATE,
+ vScopeDays INT,
+ vMaxAlertLevel INT,
+ vWarehouseFk INT
+)
+BEGIN
+/**
+ * Obtiene la información para el control de confección,
+ * ya sean tickets y/o entradas.
+ *
+ * @param vDated Fecha a calcular
+ * @param vScopeDays Número de días desde hoy en adelante que entran en el cálculo.
+ * @param vMaxAlertLevel Id nivel de alerta
+ * @param vWarehouseFk Id de almacén
+ */
+ DECLARE vEndingDate DATETIME DEFAULT util.dayEnd(vDated) + INTERVAL vScopeDays DAY;
+
+ SELECT t.shipped,
+ t.id ticketFk,
+ s.id saleFk,
+ s.quantity,
+ s.concept,
+ ABS(s.reserved) isReserved,
+ i.category,
+ it.name itemType,
+ t.nickname,
+ wh.name warehouse,
+ t.warehouseFk warehouseFk,
+ a.provinceFk,
+ am.agencyFk,
+ ct.description,
+ stock.visible,
+ stock.available
+ FROM ticket t
+ JOIN agencyMode am ON am.id = t.agencyModeFk
+ JOIN warehouse wh ON wh.id = t.warehouseFk
+ JOIN sale s ON s.ticketFk = t.id
+ JOIN item i ON i.id = s.itemFk
+ JOIN itemType it ON it.id = i.typeFk
+ JOIN confectionType ct ON ct.id = it.making
+ JOIN `address` a on a.id = t.addressFk
+ LEFT JOIN ticketState tls on tls.ticketFk = t.id
+ LEFT JOIN
+ (
+ SELECT item_id,
+ SUM(visible) visible,
+ SUM(available) available
+ FROM (
+ SELECT a.item_id,
+ 0 visible,
+ a.available
+ FROM cache.cache_calc cc
+ LEFT JOIN cache.available a ON a.calc_id = cc.id
+ WHERE cc.cache_id IN ('visible', 'available')
+ AND cc.params = CONCAT(vWarehouseFk, "/", util.VN_CURDATE())
+ UNION ALL
+ SELECT v.item_id,
+ v.visible,
+ 0
+ FROM cache.cache_calc cc
+ LEFT JOIN cache.visible v ON v.calc_id = cc.id
+ WHERE cc.cacheName IN ('visible', 'available')
+ AND cc.params = vWarehouseFk
+ ) sub
+ GROUP BY item_id
+ ) stock ON stock.item_id = s.itemFk
+ WHERE it.making
+ AND tls.alertLevel < vMaxAlertLevel
+ AND wh.hasConfectionTeam
+ AND t.shipped BETWEEN vDated AND vEndingDate
+ AND s.quantity > 0
+ UNION ALL
+ SELECT tr.shipped,
+ e.id,
+ NULL,
+ b.quantity,
+ i.name,
+ NULL,
+ i.category,
+ NULL,
+ whi.name,
+ who.name,
+ NULL,
+ NULL,
+ NULL,
+ ct.description,
+ NULL,
+ NULL
+ FROM buy b
+ JOIN `entry` e ON e.id = b.entryFk
+ JOIN travel tr ON tr.id = e.travelFk
+ JOIN warehouse whi ON whi.id = tr.warehouseInFk
+ JOIN warehouse who ON who.id = tr.warehouseOutFk
+ JOIN item i ON i.id = b.itemFk
+ JOIN itemType it ON it.id = i.typeFk
+ JOIN confectionType ct ON ct.id = it.making
+ WHERE who.hasConfectionTeam
+ AND it.making
+ AND tr.shipped BETWEEN vDated AND vEndingDate;
+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_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `conveyorExpedition_Add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -51401,6 +52881,61 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `creditInsurance_getRisk` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` PROCEDURE `creditInsurance_getRisk`()
+BEGIN
+/**
+ * Devuelve el riesgo de los clientes que estan asegurados
+ */
+ CREATE OR REPLACE TEMPORARY TABLE tmp.client_list
+ (PRIMARY KEY (Id_Cliente))
+ ENGINE = MEMORY
+ SELECT * FROM (
+ SELECT cc.client Id_Cliente, ci.grade
+ FROM creditClassification cc
+ JOIN creditInsurance ci ON cc.id = ci.creditClassification
+ WHERE dateEnd IS NULL
+ ORDER BY ci.creationDate DESC
+ LIMIT 10000000000000000000) t1
+ GROUP BY Id_Cliente;
+
+ CALL vn2008.risk_vs_client_list(util.VN_CURDATE());
+
+ SELECT
+ c.id,
+ c.name,
+ c.credit clientCredit,
+ c.creditInsurance solunion,
+ CAST(r.risk AS DECIMAL(10,0)) risk,
+ CAST(c.creditInsurance - r.risk AS DECIMAL(10,0)) riskAlive,
+ cac.invoiced billedAnnually,
+ c.dueDay,
+ ci.grade,
+ c2.country
+ FROM tmp.client_list ci
+ LEFT JOIN tmp.risk r ON r.Id_Cliente = ci.Id_Cliente
+ JOIN client c ON c.id = ci.Id_Cliente
+ JOIN bs.clientAnnualConsumption cac ON c.id = cac.clientFk
+ JOIN country c2 ON c2.id = c.countryFk
+ GROUP BY c.id;
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.risk;
+ DROP TEMPORARY TABLE IF EXISTS tmp.client_list;
+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_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `crypt` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -52070,6 +53605,7 @@ BEGIN
ii.operated = IFNULL(ii.operated,d.operated),
ii.issued = IFNULL(ii.issued,d.issued),
ii.bookEntried = IFNULL(ii.bookEntried,d.bookEntried),
+ e.isBooked = TRUE,
e.isConfirmed = TRUE
WHERE d.id = vDuaFk;
@@ -52659,6 +54195,41 @@ DELIMITER ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `entry_checkBooked` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_checkBooked`(
+ vSelf INT
+)
+BEGIN
+/**
+ * Comprueba si una entrada está contabilizada,
+ * y si lo está retorna un throw.
+ *
+ * @param vSelf Id de entrada
+ */
+ DECLARE vIsBooked BOOL;
+
+ SELECT isBooked INTO vIsBooked
+ FROM `entry`
+ WHERE id = vSelf;
+
+ IF vIsBooked AND NOT @isModeInventory THEN
+ CALL util.throw('Entry is already booked');
+ 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_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `entry_checkPackaging` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
@@ -53021,15 +54592,15 @@ BEGIN
DECLARE vWarehouseIn INT;
DECLARE vWarehouseOut INT;
DECLARE vCalcVisible INT;
- DECLARE vInventoryDate DATE DEFAULT vn.getInventoryDate();
+ DECLARE vInventoryDate DATE DEFAULT getInventoryDate();
SELECT shipped, landed, warehouseInFk, warehouseOutFk
INTO vDateShipped, vDateLanded, vWarehouseIn, vWarehouseOut
- FROM vn.travel t
- JOIN vn.entry e ON e.travelFk = t.id
+ FROM travel t
+ JOIN entry e ON e.travelFk = t.id
WHERE e.id = vSelf;
- CALL vn.rate_getPrices(vDateShipped, vWarehouseIn);
+ CALL rate_getPrices(vDateShipped, vWarehouseIn);
-- Traslado en almacen origen
CREATE OR REPLACE TEMPORARY TABLE tBuy
@@ -53092,7 +54663,7 @@ BEGIN
WHERE a.available
ON DUPLICATE KEY UPDATE availableLanding = a.available;
ELSE
- CALL vn.item_getStock(vWarehouseOut, vDateShipped, NULL);
+ CALL item_getStock(vWarehouseOut, vDateShipped, NULL);
CREATE OR REPLACE TEMPORARY TABLE tItem
(UNIQUE INDEX i USING HASH (itemFk))
@@ -53105,7 +54676,7 @@ BEGIN
FROM tmp.itemList;
END IF;
- CALL vn.buyUltimateFromInterval(vWarehouseIn,vInventoryDate, vDateLanded);
+ CALL buyUltimateFromInterval(vWarehouseIn,vInventoryDate, vDateLanded);
CREATE OR REPLACE TEMPORARY TABLE tTransfer
ENGINE = MEMORY
@@ -53153,26 +54724,26 @@ BEGIN
b.id buyFkOrigin,
pa.returnCost,
b.weight
- FROM vn.item i
+ FROM item i
JOIN tItem ti ON ti.itemFk = i.id
- LEFT JOIN vn.producer p ON p.id = i.producerFk
- LEFT JOIN vn.itemType it ON it.id = i.typeFk
- JOIN vn.itemCategory ic ON ic.id = it.categoryFk
- LEFT JOIN vn.origin o ON o.id = i.originFk
+ LEFT JOIN producer p ON p.id = i.producerFk
+ LEFT JOIN itemType it ON it.id = i.typeFk
+ JOIN itemCategory ic ON ic.id = it.categoryFk
+ LEFT JOIN origin o ON o.id = i.originFk
LEFT JOIN tBuy lb ON lb.itemFk = i.id
- LEFT JOIN vn.buy b ON b.id = lb.buyFk
- LEFT JOIN vn.packaging pa ON pa.id = b.packagingFk
- LEFT JOIN vn.entry e2 ON e2.id = b.entryFk
- LEFT JOIN vn.supplier s ON s.id = e2.supplierFk
- LEFT JOIN vn.entry e ON e.id = vSelf
- LEFT JOIN vn.travel tr ON tr.id = e.travelFk
- LEFT JOIN vn.agencyMode am ON am.id = tr.agencyModeFk
- LEFT JOIN vn.buy b2 ON b2.itemFk = i.id
+ LEFT JOIN buy b ON b.id = lb.buyFk
+ LEFT JOIN packaging pa ON pa.id = b.packagingFk
+ LEFT JOIN entry e2 ON e2.id = b.entryFk
+ LEFT JOIN supplier s ON s.id = e2.supplierFk
+ LEFT JOIN entry e ON e.id = vSelf
+ LEFT JOIN travel tr ON tr.id = e.travelFk
+ LEFT JOIN agencyMode am ON am.id = tr.agencyModeFk
+ LEFT JOIN buy b2 ON b2.itemFk = i.id
AND b2.entryFk = vSelf
- LEFT JOIN vn.packaging pa2 ON pa2.id = b.packagingFk
+ LEFT JOIN packaging pa2 ON pa2.id = b.packagingFk
LEFT JOIN tmp.rate r ON TRUE
LEFT JOIN tmp.buyUltimateFromInterval bufi ON bufi.itemFk = i.id
- LEFT JOIN vn.buy b3 ON b3.id = bufi.buyFk
+ LEFT JOIN buy b3 ON b3.id = bufi.buyFk
WHERE ic.display
AND NOT e.isRaid
AND (ti.visible OR ti.available)
@@ -53180,11 +54751,6 @@ BEGIN
CREATE INDEX tIndex USING HASH ON tTransfer (itemFk);
- SET @carriage := 0;
- SET @comission := 0;
- SET @packaging := 0;
- SET @rate3 := 0;
- SET @cost := 0;
SELECT *,
quantity - MOD(quantity , `grouping`) subQuantity,
MOD(quantity, `grouping`) soll,
@@ -55200,7 +56766,7 @@ BEGIN
quantity int(11) DEFAULT '0',
buyingValue decimal(10,4) DEFAULT '0.0000',
freightValue decimal(10,3) DEFAULT '0.000',
- packing int(11) DEFAULT '0',
+ packing int(11) DEFAULT '1',
`grouping` smallint(5) unsigned NOT NULL DEFAULT '1',
groupingMode tinyint(4) NOT NULL DEFAULT 0 ,
comissionValue decimal(10,3) DEFAULT '0.000',
@@ -55318,8 +56884,6 @@ BEGIN
CLOSE cWarehouses;
UPDATE config SET inventoried = vInventoryDate;
-
- SET @isModeInventory := FALSE;
CREATE OR REPLACE TEMPORARY TABLE tEntryToDelete
(INDEX(entryId)) ENGINE = MEMORY
@@ -55348,6 +56912,8 @@ BEGIN
FROM travel t
JOIN tEntryToDelete tmp ON tmp.travelId = t.id;
+ SET @isModeInventory := FALSE;
+
DROP TEMPORARY TABLE IF EXISTS tEntryToDelete;
COMMIT;
@@ -55383,14 +56949,14 @@ DELIMITER ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `inventory_repair` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb3 */ ;
-/*!50003 SET character_set_results = utf8mb3 */ ;
-/*!50003 SET collation_connection = utf8mb3_general_ci */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `inventory_repair`()
BEGIN
@@ -55430,7 +56996,7 @@ BEGIN
LEFT JOIN origin o ON o.id = i.originFk
) ON it.id = i.typeFk
LEFT JOIN edi.ekt ek ON b.ektFk = ek.id
- WHERE (b.packagingFk = "--" OR b.price2 = 0 OR b.packing = 0 OR b.buyingValue = 0) AND tr.landed > util.firstDayOfMonth(TIMESTAMPADD(MONTH,-1,util.VN_CURDATE())) AND s.name = 'INVENTARIO';
+ WHERE (b.packagingFk = "--" OR b.price2 = 0 OR b.buyingValue = 0) AND tr.landed > util.firstDayOfMonth(TIMESTAMPADD(MONTH,-1,util.VN_CURDATE())) AND s.name = 'INVENTARIO';
DROP TEMPORARY TABLE IF EXISTS tmp.lastEntryOk;
CREATE TEMPORARY TABLE tmp.lastEntryOk
@@ -55487,11 +57053,6 @@ BEGIN
JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk
SET b.price2 = eo.price2 WHERE b.price2 = 0 ;
- UPDATE buy b
- JOIN tmp.lastEntry lt ON lt.buyFk = b.id
- JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk
- SET b.packing = eo.packing WHERE b.packing = 0;
-
UPDATE buy b
JOIN tmp.lastEntry lt ON lt.buyFk = b.id
JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk
@@ -55763,10 +57324,13 @@ DELIMITER ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInTaxMakeByDua`(vDuaFk INT)
+CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInTaxMakeByDua`(
+ vDuaFk INT
+)
BEGIN
/**
- * Borra los valores de duaTax y sus vctos. y los vuelve a crear en base a la tabla duaEntry
+ * Borra los valores de duaTax y sus vctos. y los vuelve a
+ * crear en base a la tabla duaEntry.
*
* @param vDuaFk Id del dua a recalcular
*/
@@ -55790,7 +57354,7 @@ BEGIN
LEAVE l;
END IF;
- CALL vn2008.recibidaIvaInsert(vInvoiceInFk);
+ CALL invoiceInTax_recalc(vInvoiceInFk);
CALL invoiceInDueDay_recalc(vInvoiceInFk);
END LOOP;
@@ -55820,6 +57384,7 @@ BEGIN
*/
DECLARE vTaxRowLimit INT;
DECLARE vLines INT;
+ DECLARE vHasDistinctTransactions INT;
SELECT taxRowLimit INTO vTaxRowLimit FROM invoiceInConfig;
@@ -55830,7 +57395,19 @@ BEGIN
IF vLines >= vTaxRowLimit THEN
CALL util.throw (CONCAT('The maximum number of lines is ', vTaxRowLimit));
- END IF;
+ END IF;
+
+ SELECT COUNT(DISTINCT transactionTypeSageFk) INTO vHasDistinctTransactions
+ FROM invoiceIn ii
+ JOIN invoiceInTax iit ON iit.invoiceInFk = ii.id
+ JOIN invoiceInSerial iis ON iis.code = ii.serial
+ WHERE ii.id = vInvoiceInFk
+ AND iis.taxAreaFk = 'CEE'
+ AND transactionTypeSageFk;
+
+ IF vHasDistinctTransactions > 1 THEN
+ CALL util.throw ('This invoice does not allow different types of transactions');
+ END IF;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -55954,6 +57531,76 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `invoiceInTax_recalc` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInTax_recalc`(
+ vInvoiceInFk INT
+)
+BEGIN
+/**
+ * Recalcula y actualiza los impuestos de la factura
+ * usando la última tasa de cambio y detalles de compra.
+ *
+ * @param vInvoiceInFk Id de factura recibida
+ */
+ DECLARE vRate DOUBLE DEFAULT 1;
+ DECLARE vExpenseFk VARCHAR(10);
+
+ SELECT `value` INTO vRate
+ FROM referenceRate rr
+ JOIN invoiceIn ii ON ii.id = vInvoiceInFk
+ WHERE rr.dated <= ii.issued
+ AND rr.currencyFk = ii.currencyFk
+ ORDER BY dated DESC
+ LIMIT 1;
+
+ DELETE FROM invoiceInTax WHERE invoiceInFk = vInvoiceInFk;
+
+ SELECT id INTO vExpenseFk
+ FROM expense
+ WHERE code = 'extraCommGoodsAcquisition';
+
+ IF vExpenseFk IS NULL THEN
+ CALL util.throw('Expense extraCommGoodsAcquisition not exists');
+ END IF;
+
+ INSERT INTO invoiceInTax(
+ invoiceInFk,
+ taxableBase,
+ expenseFk,
+ foreignValue,
+ taxTypeSageFk,
+ transactionTypeSageFk
+ )
+ SELECT ii.id,
+ SUM(b.buyingValue * b.quantity) / vRate bi,
+ vExpenseFk,
+ IF(c.code = 'EUR', NULL, SUM(b.buyingValue * b.quantity)),
+ s.taxTypeSageFk,
+ s.transactionTypeSageFk
+ FROM invoiceIn ii
+ JOIN currency c ON c.id = ii.currencyFk
+ JOIN `entry` e ON e.invoiceInFk = ii.id
+ JOIN supplier s ON s.id = e.supplierFk
+ JOIN buy b ON b.entryFk = e.id
+ LEFT JOIN referenceRate rr ON rr.currencyFk = ii.currencyFk
+ AND rr.dated = ii.issued
+ WHERE ii.id = vInvoiceInFk
+ HAVING bi IS NOT NULL;
+END ;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `invoiceIn_booking` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -56838,16 +58485,21 @@ BEGIN
DELETE ti.*
FROM tmp.ticketToInvoice ti
JOIN ticket t ON t.id = ti.id
+ LEFT JOIN address a ON a.id = t.addressFk
JOIN sale s ON s.ticketFk = t.id
JOIN item i ON i.id = s.itemFk
JOIN supplier su ON su.id = t.companyFk
JOIN client c ON c.id = t.clientFk
- LEFT JOIN itemTaxCountry itc ON itc.itemFk = i.id AND itc.countryFk = su.countryFk
+ LEFT JOIN itemTaxCountry itc ON itc.itemFk = i.id
+ AND itc.countryFk = su.countryFk
WHERE (YEAR(t.shipped) < 2001 AND t.isDeleted)
OR c.isTaxDataChecked = FALSE
OR t.isDeleted
OR c.hasToInvoice = FALSE
- OR itc.id IS NULL;
+ OR itc.id IS NULL
+ OR a.id IS NULL
+ OR (vTaxArea = 'WORLD'
+ AND (a.customsAgentFk IS NULL OR a.incotermsFk IS NULL));
SELECT SUM(s.quantity * s.price * (100 - s.discount)/100) <> 0
INTO vIsAnySaleToInvoice
@@ -57530,278 +59182,6 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `itemProposal` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemProposal`(vItemFk INT, vTicketFk INT,vShowType BOOL)
-BEGIN
-
-/**
- * Propone articulos disponible ordenado, con la cantidad de veces usado y segun sus caracteristicas
- *
- * @param vItemFk item id
- * @param vTicketFk ticket id
- * @param vShowType mostrar tipos
- */
-
- DECLARE vWarehouseFk INT;
- DECLARE vShipped DATE;
- DECLARE vCalcFk INT;
- DECLARE vTypeFk INT;
-
- DECLARE vTag1 VARCHAR(25);
- DECLARE vTag5 VARCHAR(25);
- DECLARE vTag6 VARCHAR(25);
- DECLARE vTag7 VARCHAR(25);
- DECLARE vTag8 VARCHAR(25);
-
- DECLARE vValue1 VARCHAR(50);
- DECLARE vValue5 VARCHAR(50);
- DECLARE vValue6 VARCHAR(50);
- DECLARE vValue7 VARCHAR(50);
- DECLARE vValue8 VARCHAR(50);
-
- SELECT warehouseFk, shipped INTO vWarehouseFk, vShipped
- FROM vn.ticket
- WHERE id = vTicketFk;
-
- SELECT typeFk, tag5, value5, tag6, value6, tag7, value7, tag8, value8, t1.name, it1.value
- INTO vTypeFk, vTag5, vValue5, vTag6, vValue6, vTag7, vValue7, vTag8, vValue8, vTag1, vValue1
- FROM vn.item i
- LEFT JOIN vn.itemTag it1 ON it1.itemFk = i.id AND it1.priority = 1
- LEFT JOIN vn.tag t1 ON t1.id = it1.tagFk
- WHERE i.id = vItemFk;
-
- CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vShipped);
-
- SELECT i.id itemFk,
- i.longName,
- i.subName,
- i.tag5,
- i.value5,
- (i.value5 <=> vValue5 COLLATE utf8_general_ci) match5,
- i.tag6,
- i.value6,
- (i.value6 <=> vValue6 COLLATE utf8_general_ci) match6,
- i.tag7,
- i.value7,
- (i.value7 <=> vValue7 COLLATE utf8_general_ci) match7,
- i.tag8,
- i.value8,
- (i.value8 <=> vValue8 COLLATE utf8_general_ci) match8,
- a.available,
- IFNULL(ip.counter,0) counter,
- IF(b.groupingMode = 1, b.grouping, b.packing) as minQuantity,
- iss.visible located
- FROM item i
- JOIN cache.available a ON a.item_id = i.id
- LEFT JOIN itemProposal ip ON ip.mateFk = i.id AND ip.itemFk = vItemFk
- LEFT JOIN itemTag it1 ON it1.itemFk = i.id AND it1.priority = 1
- LEFT JOIN tag t1 ON t1.id = it1.tagFk
- LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = vWarehouseFk
- LEFT JOIN buy b ON b.id = lb.buy_id
- LEFT JOIN itemShelvingStock iss ON iss.itemFk = i.id AND iss.warehouseFk = vWarehouseFk
- WHERE a.calc_id = vCalcFk
- AND available > 0
- AND IF(vShowType,i.typeFk = vTypeFk,true)
- AND i.id != vItemFk
- ORDER BY counter DESC,
- (t1.name = vTag1 COLLATE utf8_general_ci) DESC,
- (it1.value = vValue1 COLLATE utf8_general_ci) DESC,
- (i.tag5 = vTag5 COLLATE utf8_general_ci) DESC,
- (i.value5 = vValue5 COLLATE utf8_general_ci) DESC,
- (i.tag6 = vTag6 COLLATE utf8_general_ci) DESC,
- (i.value6 = vValue6 COLLATE utf8_general_ci) DESC,
- (i.tag7 = vTag7 COLLATE utf8_general_ci) DESC,
- (i.value7 = vValue7 COLLATE utf8_general_ci) DESC,
- (i.tag8 = vTag8 COLLATE utf8_general_ci) DESC,
- (i.value8 = vValue8 COLLATE utf8_general_ci) DESC;
-
-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_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `itemProposal_Add` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemProposal_Add`(vSaleFk INT, vMateFk INT, vQuantity INT)
-BEGIN
-/**
- * Añade un nuevo articulo para sustituir a otro, y actualiza la memoria de sustituciones.
- *
- * @param vSaleFk id de la tabla sale
- * @param vMateFk articulo sustituto
- * @ param vQuantity cantidad que se va a sustituir
- */
- DECLARE vTicketFk INT;
- DECLARE vItemFk INT;
- DECLARE vWarehouseFk SMALLINT;
- DECLARE vDate DATE;
- DECLARE vGrouping INT;
- DECLARE vBox INT;
- DECLARE vPacking INT;
- DECLARE vRoundQuantity INT DEFAULT 1;
-
- DECLARE EXIT HANDLER FOR SQLEXCEPTION
- BEGIN
- ROLLBACK;
- RESIGNAL;
- END;
-
- SELECT s.ticketFk, LEAST(s.quantity, vQuantity), s.itemFk,t.shipped,t.warehouseFk
- INTO vTicketFk, vQuantity, vItemFk,vDate,vWarehouseFk
- FROM sale s
- JOIN ticket t ON t.id = s.ticketFk
- WHERE s.id = vSaleFk;
-
- CALL buyUltimate(vWarehouseFk, vDate);
-
- SELECT `grouping`, groupingMode, packing INTO vGrouping, vBox, vPacking
- FROM buy b
- JOIN tmp.buyUltimate tmp ON b.id = tmp.buyFk
- WHERE tmp.itemFk = vMateFk AND tmp.WarehouseFk = vWarehouseFk;
-
- IF vBox = 2 AND vPacking > 0 THEN
- SET vRoundQuantity = vPacking;
- END IF;
- IF vBox = 1 AND vGrouping > 0 THEN
- SET vRoundQuantity = vGrouping;
- END IF;
-
- START TRANSACTION;
-
- UPDATE sale
- SET quantity = quantity - vQuantity
- WHERE id = vSaleFk;
-
- INSERT INTO sale(ticketFk, itemFk, quantity, concept)
- SELECT vTicketFk,
- vMateFk,
- CEIL(vQuantity / vRoundQuantity) * vRoundQuantity,
- CONCAT('+ ',i.longName)
- FROM item i
- WHERE id = vMateFk;
-
- SELECT LAST_INSERT_ID() INTO vSaleFk;
-
- CALL sale_calculateComponent(vSaleFk, NULL);
-
- INSERT INTO itemProposal(itemFk, mateFk, counter)
- VALUES(vItemFk, vMateFk, 1)
- ON DUPLICATE KEY UPDATE counter = counter + 1;
-
- COMMIT;
-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_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `itemProposal_beta` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `itemProposal_beta`(vItemFk INT, vTicketFk INT)
-BEGIN
-
- DECLARE vWarehouseFk INT;
- DECLARE vShipped DATE;
- DECLARE vCalcFk INT;
- DECLARE vTypeFk INT;
- DECLARE vResultsMax INT DEFAULT 10;
-
- DECLARE vTag1 VARCHAR(25);
- DECLARE vTag5 VARCHAR(25);
- DECLARE vTag6 VARCHAR(25);
- DECLARE vTag7 VARCHAR(25);
- DECLARE vTag8 VARCHAR(25);
-
- DECLARE vValue1 VARCHAR(50);
- DECLARE vValue5 VARCHAR(50);
- DECLARE vValue6 VARCHAR(50);
- DECLARE vValue7 VARCHAR(50);
- DECLARE vValue8 VARCHAR(50);
-
- SELECT warehouseFk, shipped INTO vWarehouseFk, vShipped
- FROM vn.ticket
- WHERE id = vTicketFk;
-
- SELECT typeFk, tag5, value5, tag6, value6, tag7, value7, tag8, value8, t1.name, it1.value
- INTO vTypeFk, vTag5, vValue5, vTag6, vValue6, vTag7, vValue7, vTag8, vValue8, vTag1, vValue1
- FROM vn.item i
- LEFT JOIN vn.itemTag it1 ON it1.itemFk = i.id AND it1.priority = 1
- LEFT JOIN vn.tag t1 ON t1.id = it1.tagFk
- WHERE i.id = vItemFk;
-
- CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vShipped);
-
- SELECT i.id itemFk,
- i.longName,
- i.subName,
- i.tag5,
- i.value5,
- (i.value5 <=> vValue5 COLLATE utf8_general_ci) match5,
- i.tag6,
- i.value6,
- (i.value6 <=> vValue6 COLLATE utf8_general_ci) match6,
- i.tag7,
- i.value7,
- (i.value7 <=> vValue7 COLLATE utf8_general_ci) match7,
- i.tag8,
- i.value8,
- (i.value8 <=> vValue8 COLLATE utf8_general_ci) match8,
- a.available,
- IFNULL(ip.counter,0) counter
- FROM vn.item i
- JOIN cache.available a ON a.item_id = i.id
- LEFT JOIN vn.itemProposal ip ON ip.mateFk = i.id AND ip.itemFk = vItemFk
- LEFT JOIN vn.itemTag it1 ON it1.itemFk = i.id AND it1.priority = 1
- LEFT JOIN vn.tag t1 ON t1.id = it1.tagFk
- WHERE a.calc_id = vCalcFk
- AND available > 0
- AND i.typeFk = vTypeFk
- AND i.id != vItemFk
- ORDER BY counter DESC,
- (t1.name = vTag1 COLLATE utf8_general_ci) DESC,
- (it1.value = vValue1 COLLATE utf8_general_ci) DESC,
- (i.tag5 = vTag5 COLLATE utf8_general_ci) DESC,
- (i.value5 = vValue5 COLLATE utf8_general_ci) DESC,
- (i.tag6 = vTag6 COLLATE utf8_general_ci) DESC,
- (i.value6 = vValue6 COLLATE utf8_general_ci) DESC,
- (i.tag7 = vTag7 COLLATE utf8_general_ci) DESC,
- (i.value7 = vValue7 COLLATE utf8_general_ci) DESC,
- (i.tag8 = vTag8 COLLATE utf8_general_ci) DESC,
- (i.value8 = vValue8 COLLATE utf8_general_ci) DESC
- LIMIT vResultsMax;
-
-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_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemRefreshTags` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -58954,14 +60334,14 @@ DELIMITER ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `itemShelving_add` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb3 */ ;
-/*!50003 SET character_set_results = utf8mb3 */ ;
-/*!50003 SET collation_connection = utf8mb3_general_ci */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_add`(IN vShelvingFk VARCHAR(8), IN vBarcode VARCHAR(22), IN vQuantity INT, IN vPackagingFk VARCHAR(10), IN vGrouping INT, IN vPacking INT, IN vWarehouseFk INT)
BEGIN
@@ -58983,6 +60363,9 @@ BEGIN
DECLARE vItemFk INT;
SELECT barcodeToItem(vBarcode) INTO vItemFk;
+
+ SET vPacking = COALESCE(vPacking, GREATEST(vn.itemPacking(vBarcode,vWarehouseFk), 1));
+ SET vQuantity = vQuantity * vPacking;
IF (SELECT COUNT(*) FROM shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN
@@ -59187,10 +60570,9 @@ proc:BEGIN
LEFT JOIN saleTracking st ON st.saleFk = s.id
JOIN ticket t ON t.id = s.ticketFk
JOIN client c on c.id = t.clientFk
- JOIN clientType ct ON ct.id = c.clientTypeFk
WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())
AND st.saleFk IS NULL
- AND ct.code IN ('normal', 'trust')
+ AND c.typeFk IN ('normal', 'trust')
GROUP BY s.itemFk
) sub2 ON sub2.itemFk = sub.itemFk
UNION ALL
@@ -59213,10 +60595,9 @@ proc:BEGIN
LEFT JOIN saleTracking st ON st.saleFk = s.id
JOIN ticket t ON t.id = s.ticketFk
JOIN client c on c.id = t.clientFk
- JOIN clientType ct ON ct.id = c.clientTypeFk
WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())
AND st.saleFk IS NULL
- AND ct.code IN ('normal', 'trust')
+ AND c.typeFk IN ('normal', 'trust')
GROUP BY s.itemFk
) sub5 ON sub5.itemFk = v.item_id
WHERE v.calc_id = vCalcVisibleFk
@@ -59562,10 +60943,11 @@ BEGIN
ish.visible,
p.sectorFk,
it.workerFk buyer,
- CONCAT('http:',ic.url, '/catalog/1600x900/',i.image) urlImage,
+ ic.url,
+ i.image,
ish.isChecked,
CASE
- WHEN s.notPrepared > sm.parked THEN 0
+ WHEN IFNULL (s.notPrepared, 0) > sm.parked THEN 0
WHEN sm.visible > sm.parked THEN 1
ELSE 2
END priority
@@ -59575,7 +60957,7 @@ BEGIN
JOIN tmp.stockMisfit sm ON sm.itemFk = ish.itemFk
JOIN shelving sh ON sh.code = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
- JOIN (
+ LEFT JOIN (
SELECT s.itemFk, sum(s.quantity) notPrepared
FROM sale s
JOIN ticket t ON t.id = s.ticketFk
@@ -60888,7 +62270,7 @@ BEGIN
TRUE,
s.id,
st.`order`,
- ct.`code`,
+ c.typeFk,
cb.claimFk,
NULL
FROM sale s
@@ -60896,7 +62278,6 @@ BEGIN
LEFT JOIN ticketState ts ON ts.ticketFk = t.id
LEFT JOIN state st ON st.`code` = ts.`code`
JOIN client c ON c.id = t.clientFk
- JOIN clientType ct ON ct.id = c.clientTypeFk
JOIN state st2 ON st2.`code` = IF(t.shipped < util.VN_CURDATE(),
'DELIVERED',
IF (t.shipped > util.dayEnd(util.VN_CURDATE()),
@@ -61288,87 +62669,102 @@ DELIMITER ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getSimilar`(vItemFk INT, vWarehouseFk INT, vDate DATE, vIsShowedByType BOOL)
+CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getSimilar`(
+ vSelf INT,
+ vWarehouseFk INT,
+ vDated DATE,
+ vShowType BOOL
+)
BEGIN
-
/**
- * Propone articulos similares para posible cambio,
- * ordenado con la cantidad de veces usado y segun sus caracteristicas
- *
- * @param vItemFk item id
- * @param vWarehouseFk warehouse id
- * @param vDate fecha para revisar disponible
- * @param vIsShowedByType para mostrar solo artículos de ese tipo
- */
+* Propone articulos disponibles ordenados, con la cantidad
+* de veces usado y segun sus caracteristicas.
+*
+* @param vSelf Id de artículo
+* @param vWarehouseFk Id de almacen
+* @param vDated Fecha
+* @param vShowType Mostrar tipos
+*/
+ DECLARE vCalcFk INT;
+ DECLARE vTypeFk INT;
+ DECLARE vPriority INT DEFAULT 1;
- DECLARE vCalcFk INT;
- DECLARE vTypeFk INT;
-
- DECLARE vTag1 VARCHAR(25) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
- DECLARE vTag5 VARCHAR(25) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
- DECLARE vTag6 VARCHAR(25) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
- DECLARE vTag7 VARCHAR(25) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
- DECLARE vTag8 VARCHAR(25) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
-
- DECLARE vValue1 VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
- DECLARE vValue5 VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
- DECLARE vValue6 VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
- DECLARE vValue7 VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
- DECLARE vValue8 VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
+ CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vDated);
-
- SELECT typeFk, tag5, value5, tag6, value6, tag7, value7, tag8, value8, t1.name, it1.value
- INTO vTypeFk, vTag5, vValue5, vTag6, vValue6, vTag7, vValue7, vTag8, vValue8, vTag1, vValue1
- FROM vn.item i
- LEFT JOIN vn.itemTag it1 ON it1.itemFk = i.id AND it1.priority = 1
- LEFT JOIN vn.tag t1 ON t1.id = it1.tagFk
- WHERE i.id = vItemFk;
-
- CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vDate);
-
- SELECT i.id itemFk,
- i.longName,
- i.subName,
- i.tag5,
- i.value5,
- (i.value5 <=> vValue5) match5,
- i.tag6,
- i.value6,
- (i.value6 <=> vValue6) match6,
- i.tag7,
- i.value7,
- (i.value7 <=> vValue7) match7,
- i.tag8,
- i.value8,
- (i.value8 <=> vValue8) match8,
- a.available,
- IFNULL(ip.counter,0) counter,
- IF(b.groupingMode = 1, b.grouping, b.packing) as minQuantity
- FROM vn.item i
- JOIN cache.available a ON a.item_id = i.id
- LEFT JOIN vn.itemProposal ip ON ip.mateFk = i.id AND ip.itemFk = vItemFk
- LEFT JOIN vn.itemTag it1 ON it1.itemFk = i.id AND it1.priority = 1
- LEFT JOIN vn.tag t1 ON t1.id = it1.tagFk
- LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = vWarehouseFk
+ -- Añadido temporalmente para ver si ya no sucede el cuelgue de db
+ SET vShowType = TRUE;
+
+ WITH itemTags AS (
+ SELECT i.id,
+ typeFk,
+ tag5,
+ value5,
+ tag6,
+ value6,
+ tag7,
+ value7,
+ tag8,
+ value8,
+ t.name,
+ it.value
+ FROM vn.item i
+ LEFT JOIN vn.itemTag it ON it.itemFk = i.id
+ AND it.priority = vPriority
+ LEFT JOIN vn.tag t ON t.id = it.tagFk
+ WHERE i.id = vSelf
+ )
+ SELECT i.id itemFk,
+ i.longName,
+ i.subName,
+ i.tag5,
+ i.value5,
+ (i.value5 <=> its.value5) match5,
+ i.tag6,
+ i.value6,
+ (i.value6 <=> its.value6) match6,
+ i.tag7,
+ i.value7,
+ (i.value7 <=> its.value7) match7,
+ i.tag8,
+ i.value8,
+ (i.value8 <=> its.value8) match8,
+ a.available,
+ IFNULL(ip.counter, 0) `counter`,
+ CASE
+ WHEN b.groupingMode = 1 THEN b.grouping
+ WHEN b.groupingMode = 2 THEN b.packing
+ ELSE 1
+ END AS minQuantity,
+ iss.visible located
+ FROM vn.item i
+ JOIN cache.available a ON a.item_id = i.id
+ AND a.calc_id = vCalcFk
+ LEFT JOIN vn.itemProposal ip ON ip.mateFk = i.id
+ AND ip.itemFk = vSelf
+ LEFT JOIN vn.itemTag it ON it.itemFk = i.id
+ AND it.priority = vPriority
+ LEFT JOIN vn.tag t ON t.id = it.tagFk
+ LEFT JOIN cache.last_buy lb ON lb.item_id = i.id
+ AND lb.warehouse_id = vWarehouseFk
LEFT JOIN vn.buy b ON b.id = lb.buy_id
- WHERE a.calc_id = vCalcFk
- AND available > 0
- AND IF(vIsShowedByType, i.typeFk = vTypeFk, TRUE)
- AND i.id != vItemFk
- ORDER BY counter DESC,
- (t1.name = vTag1) DESC,
- (it1.value = vValue1) DESC,
- (i.tag6 = vTag6) DESC,
- (i.value6 = vValue6) DESC,
- (i.tag5 = vTag5) DESC,
- (i.value5 = vValue5) DESC,
- (i.tag7 = vTag7) DESC,
- (i.value7 = vValue7) DESC,
- (i.tag8 = vTag8) DESC,
- (i.value8 = vValue8) DESC
- LIMIT 30;
-
-
+ LEFT JOIN vn.itemShelvingStock iss ON iss.itemFk = i.id
+ AND iss.warehouseFk = vWarehouseFk
+ JOIN itemTags its
+ WHERE a.available > 0
+ AND IF(vShowType, i.typeFk = its.typeFk, TRUE)
+ AND i.id <> vSelf
+ ORDER BY `counter` DESC,
+ (t.name = its.name) DESC,
+ (it.value = its.value) DESC,
+ (i.tag5 = its.tag5) DESC,
+ match5 DESC,
+ (i.tag6 = its.tag6) DESC,
+ match6 DESC,
+ (i.tag7 = its.tag7) DESC,
+ match7 DESC,
+ (i.tag8 = its.tag8) DESC,
+ match8 DESC
+ LIMIT 100;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -62990,6 +64386,28 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `multipleInventoryHistory` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` PROCEDURE `multipleInventoryHistory`(
+ vItemFk INT)
+BEGIN
+ DECLARE vDateInventory DATETIME;
+ SELECT inventoried INTO vDateInventory FROM config;
+
+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_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `mysqlConnectionsSorter_kill` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -63757,6 +65175,103 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `payment_add` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` PROCEDURE `payment_add`(
+ vDated DATE,
+ vSupplierFk INT,
+ vAmount DOUBLE,
+ vCurrencyFk INT,
+ vForeignValue DOUBLE,
+ vBankFk INT,
+ vPayMethodFk INT,
+ vExpenseFk DOUBLE,
+ vConcept VARCHAR(40),
+ vCompanyFk INT)
+BEGIN
+/**
+ * Registra un pago realizado a un proveedor y
+ * su correspondiente registro en caja.
+ *
+ * @param vDated Fecha del pago
+ * @param vSupplierFk Id del proveedor
+ * @param vAmount Cantidad a pagar
+ * @param vCurrencyFk Id de la moneda
+ * @param vForeignValue Tipo de cambio utilizado
+ * @param vBankFk Id del banco
+ * @param vPayMethodFk Id del método de pago
+ * @param vExpenseFk Id de gasto
+ * @param vConcept Concepto del pago
+ * @param vCompanyFk Id de la empresa
+ * @return paymentFk Id de pago insertado
+ */
+ INSERT INTO till(
+ concept,
+ serie,
+ `number`,
+ `out`,
+ dated,
+ isAccountable,
+ bankFk,
+ workerFk,
+ companyFk,
+ isConciliate
+ )
+ SELECT CONCAT('n/pago a ', `name`),
+ 'R',
+ vSupplierFk,
+ vAmount,
+ vDated,
+ 1,
+ vBankFk,
+ account.myUser_getId(),
+ vCompanyFk,
+ 1
+ FROM supplier
+ WHERE id = vSupplierFk;
+
+ INSERT INTO payment(
+ received,
+ dueDated,
+ supplierFk,
+ amount,
+ currencyFk,
+ divisa,
+ bankFk,
+ payMethodFk,
+ bankingFees,
+ concept,
+ companyFk
+ )
+ VALUES(
+ vDated,
+ vDated,
+ vSupplierFk,
+ vAmount,
+ vCurrencyFk,
+ IF(NOT vForeignValue, NULL, vForeignValue),
+ vBankFk,
+ vPayMethodFk,
+ vExpenseFk,
+ vConcept,
+ vCompanyFk
+ );
+
+ SELECT LAST_INSERT_ID() paymentFk;
+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_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `prepareClientList` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -64246,16 +65761,22 @@ BEGIN
-- Rellena la tabla tmp.errorsByChecker con fallos de revisores
CREATE OR REPLACE TEMPORARY TABLE tmp.errorsByChecker
ENGINE = MEMORY
- SELECT st.workerFk,
- COUNT(t.id) errors
- FROM saleMistake sm
- JOIN saleTracking st ON sm.saleFk = st.saleFk
- JOIN `state` s2 ON s2.id = st.stateFk
- JOIN sale s ON s.id = sm.saleFk
- JOIN ticket t on t.id = s.ticketFk
- WHERE (t.shipped BETWEEN vDatedFrom AND vDatedTo)
- AND s2.code IN ('OK','PREVIOUS_PREPARATION','PREPARED','CHECKED')
- GROUP BY st.workerFk;
+ WITH rankedWorkers AS (
+ SELECT sm.id,
+ st.workerFk,
+ ROW_NUMBER() OVER(PARTITION BY sm.id ORDER BY s2.`order`) rnk
+ FROM vn.saleMistake sm
+ JOIN vn.saleTracking st ON sm.saleFk = st.saleFk
+ JOIN vn.`state` s2 ON s2.id = st.stateFk
+ JOIN vn.sale s ON s.id = sm.saleFk
+ JOIN vn.ticket t ON t.id = s.ticketFk
+ WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo
+ AND s2.code IN ('OK', 'PREVIOUS_PREPARATION', 'PREPARED', 'CHECKED')
+ )
+ SELECT workerFk, COUNT(*) errors
+ FROM rankedWorkers
+ WHERE rnk = 1
+ GROUP BY workerFk;
-- Rellena la tabla tmp.expeditionErrors con fallos de expediciones
CREATE OR REPLACE TEMPORARY TABLE tmp.expeditionErrors
@@ -64798,6 +66319,89 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `remittance_calc` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` PROCEDURE `remittance_calc`(
+ vDated DATE
+)
+BEGIN
+/**
+* Calcula los datos de remesa, incluyendo el importe,
+* el vencimiento, y otros datos relevantes.
+*
+* @param vDated Fecha a calcular
+* @return tmp.remittance
+*/
+ CREATE OR REPLACE TEMPORARY TABLE tmp.remittance
+ SELECT CONCAT(s.nif, REPEAT('0', 12 - LENGTH(s.nif))) cif,
+ c.id clientFk,
+ c.name client,
+ c.fi,
+ sub.paymentDate,
+ 0 invoiceAmount,
+ CAST(sub.receipt AS DECIMAL(10,2)) receiptAmount,
+ 0 currentAmount,
+ sub.companyFk,
+ c.socialName,
+ CAST(sub.receipt AS DECIMAL(10,2)) totalAmount,
+ CAST(sub.receipt AS DECIMAL(10,2)) balance,
+ s.name company,
+ co.code companyCode,
+ c.accountingAccount,
+ c.iban,
+ c.hasSepaVnl,
+ c.hasCoreVnl,
+ c.hasLcr,
+ be.bic,
+ be.`name` entityName
+ FROM client c
+ JOIN (
+ SELECT risk.companyFk,
+ c.id,
+ SUM(risk.amount) receipt,
+ IF((c.dueDay + graceDays) MOD 30.001 <= DAY(vDated),
+ LAST_DAY(vDated - INTERVAL 1 MONTH) + INTERVAL (c.dueDay + graceDays) MOD 30.001 DAY,
+ LAST_DAY(vDated - INTERVAL 2 MONTH) + INTERVAL (c.dueDay + graceDays) MOD 30.001 DAY
+ ) paymentDate
+ FROM client c
+ JOIN payMethod pm ON pm.id = c.payMethodFk
+ JOIN (
+ SELECT cr.companyFk, cr.clientFk, cr.amount
+ FROM client c
+ JOIN clientRisk cr ON cr.clientFk = c.id
+ JOIN payMethod pm ON pm.id = c.payMethodFk
+ WHERE pm.code = 'bankDraft'
+ UNION ALL
+ SELECT io.companyFk, io.clientFk, - io.amount
+ FROM invoiceOut io
+ JOIN client c ON c.id = io.clientFk
+ JOIN payMethod pm ON pm.id = c.payMethodFk
+ WHERE io.dued > vDated
+ AND pm.code = 'bankDraft'
+ AND pm.outstandingDebt
+ AND io.amount > 0
+
+ ) risk ON risk.clientFk = c.id
+ GROUP BY risk.companyFk, c.id
+ HAVING receipt > 10
+ ) sub ON sub.id = c.id
+ JOIN supplier s ON s.id = sub.companyFk
+ JOIN company co ON co.id = sub.companyFk
+ LEFT JOIN bankEntity be ON be.id = c.bankEntityFk;
+END ;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `reportLabelCollection_get` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -66085,6 +67689,304 @@ 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 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `sale_boxPickingPrint` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_boxPickingPrint`(
+ IN vPrinterFk INT,
+ IN vSaleFk INT,
+ IN vPacking INT,
+ IN vSectorFk INT,
+ IN vUserFk INT,
+ IN vPackagingFk VARCHAR(10),
+ IN vPackingSiteFk INT)
+BEGIN
+/** Splits a line of sale to a different ticket and prints the transport sticker
+ */
+ DECLARE vAgencyModeFk INT;
+ DECLARE vConcept VARCHAR(30);
+ DECLARE vExpeditionFk INT;
+ DECLARE vItemFk INT;
+ DECLARE vItemShelvingFk INT;
+ DECLARE vItemShelvingSaleFk INT;
+ DECLARE vItemShelvingSaleFk_old INT;
+ DECLARE vLastExpeditionTimeStamp DATETIME;
+ DECLARE vMaxPhoneLength INT DEFAULT 11;
+ DECLARE vMaxStreetLength INT DEFAULT 36;
+ DECLARE vNewSaleFk INT;
+ DECLARE vNewTicketFk INT;
+ DECLARE vParkingCode VARCHAR(10);
+ DECLARE vQuantity INT;
+ DECLARE vRemainder INT DEFAULT 0;
+ DECLARE vRemainderSaleFk INT;
+ DECLARE vShelving VARCHAR(10);
+ DECLARE vTicketFk INT;
+
+ SELECT s.quantity,
+ s.quantity MOD vPacking,
+ s.ticketFk,
+ s.itemFk,
+ s.concept
+ INTO vQuantity,
+ vRemainder,
+ vTicketFk,
+ vItemFk,
+ vConcept
+ FROM sale s
+ WHERE s.id = vSaleFk;
+
+ IF vRemainder THEN
+ UPDATE sale SET quantity = quantity - vRemainder WHERE id = vSaleFk;
+
+ INSERT INTO sale(ticketFk, itemFk, quantity, price, discount, concept)
+ SELECT ticketFk, itemFk, vRemainder, price, discount, concept
+ FROM sale
+ WHERE id = vSaleFk;
+
+ SET vRemainderSaleFk = LAST_INSERT_ID();
+
+ INSERT INTO saleComponent(saleFk, componentFk, value)
+ SELECT vRemainderSaleFk, componentFk, value
+ FROM saleComponent
+ WHERE saleFk = vSaleFk;
+ END IF;
+
+w1: WHILE vQuantity >= vPacking DO
+
+ SET vQuantity = vQuantity - vPacking;
+
+ SET vItemShelvingFk = NULL;
+
+ SELECT sub.id
+ INTO vItemShelvingFk
+ FROM productionConfig pc
+ JOIN (
+ SELECT ish.id,
+ ish.visible - IFNULL(SUM(iss.quantity),0) available,
+ p.pickingOrder,
+ ish.created
+ FROM itemShelving ish
+ JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN parking p ON p.id = sh.parkingFk
+ LEFT JOIN itemShelvingSale iss
+ ON iss.itemShelvingFk = ish.id
+ AND iss.created >= CURDATE()
+ AND iss.isPicked = FALSE
+ WHERE ish.itemFk = vItemFk
+ AND p.sectorFk = vSectorFk
+ GROUP BY ish.id
+ HAVING available >= vPacking) sub
+ ORDER BY IF(pc.orderMode = 'Location',sub.pickingOrder, sub.created)
+ LIMIT 1;
+
+ IF vItemShelvingFk THEN
+ INSERT INTO itemShelvingSale
+ SET itemShelvingFk = vItemShelvingFk,
+ saleFk = vSaleFk,
+ quantity = vPacking,
+ userFk = vUserFk,
+ isPicked = TRUE;
+
+ SET vItemShelvingSaleFk = LAST_INSERT_ID();
+
+ UPDATE sale SET isPicked = FALSE WHERE id = vSaleFk;
+ ELSE
+ LEAVE w1;
+ END IF;
+
+ SET vNewTicketFk = NULL;
+
+ SELECT MAX(t.id) INTO vNewTicketFk
+ FROM ticket t
+ JOIN ticketLastState tls ON tls.ticketFk = t.id
+ JOIN (SELECT addressFk, clientFk, date(shipped) shipped, warehouseFk
+ FROM ticket
+ WHERE id = vTicketFk) tt
+ ON tt.addressFk = t.addressFk
+ AND tt.clientFk = t.clientFk
+ AND t.shipped BETWEEN tt.shipped AND util.dayend(tt.shipped)
+ AND t.warehouseFk = tt.warehouseFk
+ WHERE tls.name = 'Encajado' ;
+
+ IF ISNULL(vNewTicketFk) THEN
+ INSERT INTO ticket( clientFk,
+ shipped,
+ addressFk,
+ agencyModeFk,
+ nickname,
+ warehouseFk,
+ companyFk,
+ landed,
+ zoneFk,
+ zonePrice,
+ zoneBonus,
+ routeFk,
+ priority,
+ hasPriority,
+ clonedFrom)
+ SELECT clientFk,
+ shipped,
+ addressFk,
+ agencyModeFk,
+ nickname,
+ warehouseFk,
+ companyFk,
+ landed,
+ zoneFk,
+ zonePrice,
+ zoneBonus,
+ routeFk,
+ priority,
+ hasPriority,
+ id
+ FROM ticket
+ WHERE id = vTicketFk;
+
+ SET vNewTicketFk = LAST_INSERT_ID();
+
+ INSERT INTO ticketTracking(ticketFk, stateFk, userFk)
+ SELECT vNewTicketFk, id, vUserFk
+ FROM state
+ WHERE code = 'PACKED';
+ END IF;
+
+ UPDATE sale SET quantity = quantity - vPacking WHERE id = vSaleFk;
+
+ UPDATE itemShelving SET visible = visible - vPacking WHERE id = vItemShelvingFk;
+
+ SET vNewSaleFk = NULL;
+
+ SELECT MAX(id) INTO vNewSaleFk
+ FROM sale
+ WHERE ticketFk = vNewTicketFk
+ AND itemFk = vItemFk;
+
+ IF vNewSaleFk THEN
+ UPDATE sale
+ SET quantity = quantity + vPacking
+ WHERE id = vNewSaleFk;
+
+ SET vItemShelvingSaleFk_old = NULL;
+
+ SELECT MAX(id) INTO vItemShelvingSaleFk_old
+ FROM itemShelvingSale
+ WHERE itemShelvingFk = vItemShelvingFk
+ AND saleFk = vNewSaleFk;
+
+ IF vItemShelvingSaleFk_old THEN
+ UPDATE itemShelvingSale
+ SET quantity = quantity + vPacking
+ WHERE id = vItemShelvingSaleFk_old;
+
+ DELETE FROM itemShelvingSale
+ WHERE id = vItemShelvingSaleFk;
+
+ SET vItemShelvingSaleFk = vItemShelvingSaleFk_old;
+ ELSE
+ UPDATE itemShelvingSale
+ SET saleFk = vNewSaleFk
+ WHERE id = vItemShelvingSaleFk;
+ END IF;
+ ELSE
+ INSERT INTO sale(ticketFk, itemFk, concept, quantity, discount, price)
+ SELECT vNewTicketFk, itemFk, concept, vPacking, discount, price
+ FROM sale
+ WHERE id = vSaleFk;
+
+ SET vNewSaleFk = LAST_INSERT_ID();
+
+ INSERT INTO saleComponent(saleFk, componentFk, value, isGreuge)
+ SELECT vNewSaleFk, componentFk, value, isGreuge
+ FROM saleComponent
+ WHERE saleFk = vSaleFk;
+
+ UPDATE itemShelvingSale
+ SET saleFk = vNewSaleFk
+ WHERE id = vItemShelvingSaleFk;
+
+ END IF;
+
+ INSERT IGNORE INTO saleTracking(saleFk, isChecked, workerFk, stateFk)
+ SELECT vNewSaleFk, TRUE, vUserFk, id
+ FROM state
+ WHERE code = 'PREPARED';
+
+ SELECT agencyModeFk INTO vAgencyModeFk
+ FROM ticket
+ WHERE id = vNewTicketFk;
+
+ INSERT INTO expedition(
+ agencyModeFk,
+ ticketFk,
+ freightItemFk,
+ workerFk,
+ packagingFk,
+ itemPackingTypeFk,
+ hostFk,
+ packingSiteFk,
+ monitorId,
+ started,
+ ended
+ )
+ SELECT vAgencyModeFk,
+ vNewTicketFk,
+ pc.defaultFreightItemFk,
+ vUserFk,
+ vPackagingFk,
+ ps.code,
+ h.code,
+ vPackingSiteFk,
+ ps.monitorId,
+ IFNULL(vLastExpeditionTimeStamp, NOW()),
+ NOW()
+ FROM packingSite ps
+ JOIN host h ON h.id = ps.hostFk
+ JOIN productionConfig pc
+ WHERE ps.id = vPackingSiteFk;
+
+ SET vExpeditionFk = LAST_INSERT_ID();
+
+ SET vLastExpeditionTimeStamp = NOW();
+
+ CALL dipole.expedition_Add(vExpeditionFk,vPrinterFk, TRUE);
+
+ SELECT shelvingFk, p.code
+ INTO vShelving, vParkingCode
+ FROM itemShelving ish
+ JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN parking p ON p.id = sh.parkingFk
+ WHERE ish.id = vItemShelvingFk;
+
+ UPDATE dipole.expedition_PrintOut
+ SET isPrinted = FALSE,
+ itemFk = vItemFk,
+ quantity = vPacking,
+ longName = vConcept,
+ shelvingFk = vShelving,
+ parkingCode = vParkingCode,
+ phone = RIGHT(phone,vMaxPhoneLength),
+ street = RIGHT(street, vMAxStreetLength)
+ WHERE expeditionFk = vExpeditionFk;
+
+ DELETE FROM sale
+ WHERE quantity = 0
+ AND id = vSaleFk;
+
+ END WHILE;
+
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -66124,89 +68026,6 @@ DELIMITER ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `sale_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 = utf8mb3 */ ;
-/*!50003 SET character_set_results = utf8mb3 */ ;
-/*!50003 SET collation_connection = utf8mb3_general_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_checkNoComponents`(vCreatedFrom DATETIME, vCreatedTo DATETIME)
-BEGIN
-/**
- * Comprueba que las ventas creadas entre un rango de fechas tienen componentes
- *
- * @param vCreatedFrom inicio del rango
- * @param vCreatedTo fin del rango
- */
- DECLARE v_done BOOL DEFAULT FALSE;
- DECLARE vSaleFk INTEGER;
- DECLARE vTicketFk INTEGER;
- DECLARE vConcept VARCHAR(50);
- DECLARE vCur CURSOR FOR
- SELECT s.id
- FROM sale s
- JOIN ticket t ON t.id = s.ticketFk
- JOIN item i ON i.id = s.itemFk
- JOIN itemType tp ON tp.id = i.typeFk
- JOIN itemCategory ic ON ic.id = tp.categoryFk
- LEFT JOIN tmp.coste c ON c.id = s.id
- WHERE s.created >= vCreatedFrom AND s.created <= vCreatedTo
- AND c.id IS NULL
- AND t.agencyModeFk IS NOT NULL
- AND t.isDeleted IS FALSE
- AND t.warehouseFk = 60
- AND ic.merchandise != FALSE
- GROUP BY s.id;
-
- 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 sale s
- 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 = 6
- WHERE s.created >= vCreatedFrom
- AND ic.merchandise != FALSE;
-
- OPEN vCur;
-
- l: LOOP
- SET v_done = FALSE;
- FETCH vCur INTO vSaleFk;
-
- IF v_done THEN
- LEAVE l;
- END IF;
-
- SELECT ticketFk, concept
- INTO vTicketFk, vConcept
- FROM sale
- WHERE id = vSaleFk;
-
- CALL sale_calculateComponent(vSaleFk, 'renewPrices');
- 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 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `sale_getBoxPickingList` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
@@ -66234,7 +68053,6 @@ BEGIN
CALL productionControl(vWarehouseFk, 0);
- -- Products with vn.item.isBoxPickingMode = TRUE, pay atention to vn.itemShelving.packing
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
(saleFk INT PRIMARY KEY)
SELECT
@@ -66245,8 +68063,8 @@ BEGIN
s.quantity,
MAKETIME(pb.HH,pb.mm,0) etd,
pb.routeFk,
- FLOOR(s.quantity / ish.packing) stickers,
- ish.packing,
+ FLOOR(s.quantity / IF(i.isBoxPickingMode, ish.packing, i.packingOut)) stickers,
+ IF(i.isBoxPickingMode, ish.packing, i.packingOut) packing,
b.packagingFk
FROM sale s
JOIN item i ON i.id = s.itemFk
@@ -66264,13 +68082,14 @@ BEGIN
JOIN parking p ON p.id = sh.parkingFk
JOIN tmp.productionBuffer pb ON pb.ticketFk = s.ticketFk
JOIN agencyMode am ON am.id = pb.agencyModeFk
+ JOIN agency a ON a .id = am.agencyFk
LEFT JOIN routesMonitor rm ON rm.routeFk = pb.routeFk
LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = s.id
LEFT JOIN ticketState ts ON ts.ticketFk = s.ticketFk
LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = vWarehouseFk
LEFT JOIN buy b ON b.id = lb.buy_id
- WHERE s.quantity BETWEEN ish.packing AND (ish.visible - IFNULL(tISS.reserve,0))
- AND i.isBoxPickingMode
+ WHERE IF(i.isBoxPickingMode, ish.packing, i.packingOut)
+ <= LEAST(s.quantity, ish.visible - IFNULL(tISS.reserve,0))
AND NOT pb.problem
AND sgd.saleFk IS NULL
AND p.sectorFk = vSectorFk
@@ -66278,48 +68097,13 @@ BEGIN
AND ((rm.bufferFk AND rm.isPickingAllowed)
OR am.code = 'REC_ALG')
AND pb.shipped = vDated
+ AND a.isOwn
GROUP BY s.id
ORDER BY etd;
- -- Remaining products, vn.item.packingOut
- INSERT IGNORE INTO tmp.sale
- SELECT
- s.ticketFk,
- s.id saleFk,
- s.itemFk,
- s.concept,
- s.quantity,
- MAKETIME(pb.HH,pb.mm,0) etd,
- pb.routeFk,
- s.quantity / i.packingOut stickers,
- i.packingOut,
- pc.defaultBigPackageFk
- FROM sale s
- JOIN item i ON i.id = s.itemFk
- JOIN itemShelving ish ON ish.itemFk = s.itemFk
- JOIN shelving sh ON sh.code = ish.shelvingFk
- JOIN parking p ON p.id = sh.parkingFk
- JOIN tmp.productionBuffer pb ON pb.ticketFk = s.ticketFk
- JOIN agencyMode am ON am.id = pb.agencyModeFk
- JOIN packagingConfig pc
- LEFT JOIN routesMonitor rm ON rm.routeFk = pb.routeFk
- LEFT JOIN itemShelvingStock iss ON iss.itemFk = s.itemFk AND iss.sectorFk = p.sectorFk
- LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = s.id
- LEFT JOIN ticketState ts ON ts.ticketFk = s.ticketFk
- WHERE s.quantity >= i.packingOut
- AND NOT pb.problem
- AND s.quantity > 0
- AND sgd.saleFk IS NULL
- AND p.sectorFk = vSectorFk
- AND ts.isPreviousPreparable
- AND iss.visible >= s.quantity
- AND ((rm.bufferFk AND rm.isPickingAllowed)
- OR am.code = 'REC_ALG')
- AND pb.shipped = vDated
- GROUP BY s.id
- ORDER BY etd;
-
- SELECT * FROM tmp.sale;
+ SELECT *
+ FROM tmp.sale
+ WHERE stickers;
DROP TEMPORARY TABLE tmp.productionBuffer;
DROP TEMPORARY TABLE tmp.sale;
@@ -66419,7 +68203,10 @@ DECLARE vIsCollection BOOL;
IF(SUM(iss.quantity) IS NULL, 0, SUM(iss.quantity)) pickedQuantity,
MIN(iss.created) picked,
IF(sm.id, TRUE, FALSE) hasMistake,
- sg.sectorFk
+ sg.sectorFk,
+ b.packing,
+ b.grouping,
+ o.code
FROM tmp.ticket t
JOIN sale s ON s.ticketFk = t.id
JOIN ticket tt ON tt.id = t.id
@@ -66971,14 +68758,14 @@ DELIMITER ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `sale_replaceItem` */;
/*!50003 SET @saved_cs_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 collation_connection = utf8mb4_unicode_ci */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_replaceItem`(vSaleFk INT, vNewItemFk INT, vQuantity INT)
BEGIN
@@ -67058,11 +68845,9 @@ BEGIN
vNewItemFk);
SELECT price INTO vNewPrice
- FROM tmp.ticketCalculateItem;
-
- IF vNewPrice IS NULL THEN
- CALL util.throw('price retrieval failed');
- END IF;
+ FROM tmp.ticketComponentPrice
+ ORDER BY (vQuantity % `grouping`) ASC
+ LIMIT 1;
IF vNewPrice > vOldPrice THEN
SET vFinalPrice = vOldPrice;
@@ -67085,7 +68870,7 @@ BEGIN
price)
SELECT vTicketFk,
vNewItemFk,
- CEIL(vQuantity / vRoundQuantity) * vRoundQuantity, CONCAT('+ ',i.longName),
+ CEIL(vQuantity / vRoundQuantity) * vRoundQuantity, CONCAT('+ ', i.name),
vFinalPrice
FROM vn.item i
WHERE id = vNewItemFk;
@@ -67132,6 +68917,25 @@ BEGIN
* @param vSaleGroupFk Identificador de vn.saleGroup
* @param vSectorCollectionFk Identificador de vn.sectorCollection
*/
+ DECLARE vHasSaleGroup INT;
+ DECLARE vHasSectorCollection INT;
+
+ SELECT COUNT(id) INTO vHasSaleGroup
+ FROM saleGroup
+ WHERE id = vSaleGroupFk;
+
+ IF !vHasSaleGroup THEN
+ CALL util.throw ("invalid saleGroup");
+ END IF;
+
+ SELECT COUNT(id) INTO vHasSectorCollection
+ FROM sectorCollection
+ WHERE id = vSectorCollectionFk;
+
+ IF !vHasSectorCollection THEN
+ CALL util.throw ("invalid sectorCollection");
+ END IF;
+
REPLACE sectorCollectionSaleGroup
SET sectorCollectionFk = vSectorCollectionFk,
saleGroupFk = vSaleGroupFk;
@@ -67374,32 +69178,6 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `sector_get` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `sector_get`()
-BEGIN
-
-/**
- * Obtiene los sectores
-*/
-
- SELECT s.id,s.description,s.warehouseFk
- FROM vn.sector s;
-
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `sector_getWarehouse` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -67813,50 +69591,6 @@ DELIMITER ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `solunionRiskRequest` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `solunionRiskRequest`()
-BEGIN
-
- DROP TEMPORARY TABLE IF EXISTS tmp.client_list;
- CREATE TEMPORARY TABLE tmp.client_list
- (PRIMARY KEY (Id_Cliente))
- ENGINE = MEMORY
- SELECT * FROM (SELECT cc.client Id_Cliente, ci.grade FROM vn.creditClassification cc
- JOIN vn.creditInsurance ci ON cc.id = ci.creditClassification
- WHERE dateEnd IS NULL
- ORDER BY ci.creationDate DESC
- LIMIT 10000000000000000000) t1 GROUP BY Id_Cliente;
-
- CALL vn2008.risk_vs_client_list(util.VN_CURDATE());
-
- SELECT
- c.Id_Cliente, c.Cliente, c.Credito credito_vn, c.creditInsurance solunion, cast(r.risk as DECIMAL(10,0)) riesgo_vivo,
- cast(c.creditInsurance - r.risk as decimal(10,0)) margen_vivo,
- f.Consumo consumo_anual, c.Vencimiento, ci.grade
- FROM
- vn2008.Clientes c
- JOIN tmp.risk r ON r.Id_Cliente = c.Id_Cliente
- JOIN tmp.client_list ci ON c.Id_Cliente = ci.Id_Cliente
- JOIN bi.facturacion_media_anual f ON c.Id_Cliente = f.Id_Cliente
- GROUP BY Id_cliente;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.risk;
- DROP TEMPORARY TABLE IF EXISTS tmp.client_list;
-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_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `stockBuyedByWorker` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
@@ -68590,7 +70324,7 @@ BEGIN
'payment'
FROM payment p
LEFT JOIN currency c ON c.id = p.currencyFk
- LEFT JOIN bank b ON b.id = p.bankFk
+ LEFT JOIN accounting a ON a.id = p.bankFk
LEFT JOIN payMethod pm ON pm.id = p.payMethodFk
LEFT JOIN promissoryNote pn ON pn.paymentFk = p.id
WHERE p.received > '2014-12-31'
@@ -68798,7 +70532,7 @@ BEGIN
SELECT id itemFk FROM vn.item
WHERE typeFk = vTypeFk;
- CALL catalog_calculate(vLanded, vAddressFk, vAgencyModeFk);
+ CALL catalog_calculate(vLanded, vAddressFk, vAgencyModeFk, FALSE);
DROP TEMPORARY TABLE tmp.item;
DROP TEMPORARY TABLE tmp.ticketLot;
END ;;
@@ -68843,56 +70577,11 @@ DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketClon`(vTicketFk INT, vNewShipped DATE)
BEGIN
-
- DECLARE done INT DEFAULT FALSE;
- DECLARE vNewTicketFk INT;
- DECLARE vOldSaleFk INT;
- DECLARE vNewSaleFk INT;
-
- DECLARE cur1 CURSOR FOR
- SELECT id
- FROM vn.sale
- WHERE ticketFk = vTicketFk;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
-
- SET vNewShipped = IFNULL(vNewShipped, util.VN_CURDATE());
-
- CALL vn.ticket_Clone(vTicketFk, vNewTicketFk);
-
- UPDATE vn.ticket
- SET landed = TIMESTAMPADD(DAY, DATEDIFF(vNewShipped, shipped), landed),
- shipped = vNewShipped
- WHERE id = vNewTicketFk;
-
- OPEN cur1;
-
- read_loop: LOOP
-
- FETCH cur1 INTO vOldSaleFk;
-
- IF done THEN
- LEAVE read_loop;
- END IF;
-
- INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed)
- SELECT vNewTicketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed
- FROM vn.sale
- WHERE id = vOldSaleFk;
-
- SELECT max(id) INTO vNewSaleFk
- FROM vn.sale
- WHERE ticketFk = vNewTicketFk;
-
- INSERT INTO vn.saleComponent(saleFk, componentFk, value, isGreuge)
- SELECT vNewSaleFk, componentFk, value, isGreuge
- FROM vn.saleComponent
- WHERE saleFk = vOldSaleFk;
-
- END LOOP;
- CLOSE cur1;
-
+ DECLARE vNewTicketFk INT;
+
+ CALL ticket_cloneAll(vTicketFk, vNewShipped, TRUE, vNewTicketFk);
+
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -70700,6 +72389,74 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `ticket_cloneAll` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_cloneAll`(vTicketFk INT, vNewShipped DATE, vWithWarehouse BOOLEAN, OUT vNewTicketFk INT)
+BEGIN
+
+ DECLARE vDone BOOLEAN DEFAULT FALSE;
+ DECLARE vOldSaleFk INT;
+ DECLARE vNewSaleFk INT;
+
+ DECLARE cur1 CURSOR FOR
+ SELECT id
+ FROM sale
+ WHERE ticketFk = vTicketFk;
+
+ DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
+
+ SET vNewShipped = IFNULL(vNewShipped, util.VN_CURDATE());
+
+ CALL ticket_Clone(vTicketFk, vNewTicketFk);
+
+ UPDATE ticket
+ SET landed = TIMESTAMPADD(DAY, DATEDIFF(vNewShipped, shipped), landed),
+ shipped = vNewShipped,
+ warehouseFk = IF(vWithWarehouse, warehouseFk, NULL)
+ WHERE id = vNewTicketFk;
+
+ OPEN cur1;
+
+ read_loop: LOOP
+
+ FETCH cur1 INTO vOldSaleFk;
+
+ IF vDone THEN
+ LEAVE read_loop;
+ END IF;
+
+ INSERT INTO sale(ticketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed)
+ SELECT vNewTicketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed
+ FROM sale
+ WHERE id = vOldSaleFk;
+
+ SELECT max(id) INTO vNewSaleFk
+ FROM sale
+ WHERE ticketFk = vNewTicketFk;
+
+ INSERT INTO saleComponent(saleFk, componentFk, value, isGreuge)
+ SELECT vNewSaleFk, componentFk, value, isGreuge
+ FROM saleComponent
+ WHERE saleFk = vOldSaleFk;
+
+ END LOOP;
+
+ CLOSE cur1;
+
+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_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_cloneWeekly` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -71055,10 +72812,11 @@ BEGIN
JOIN agencyMode am ON am.id = t.agencyModeFk
LEFT JOIN ticketState ts ON ts.ticketFk = t.id
JOIN alertLevel al ON al.id = ts.alertLevel
- WHERE al.code = 'PACKED' OR (am.code = 'refund' AND al.code != 'delivered')
+ WHERE (al.code = 'PACKED' OR (am.code = 'refund' AND al.code != 'delivered'))
AND t.id = vTicketFk
AND t.refFk IS NULL
- GROUP BY t.id);
+ GROUP BY t.id
+ );
CALL ticket_close();
@@ -71450,7 +73208,6 @@ BEGIN
JOIN province p ON p.id = a.provinceFk
JOIN country co ON co.id = p.countryFk
JOIN agencyMode am ON am.id = t.agencyModeFk
- JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
JOIN warehouse w ON w.id = t.warehouseFk
JOIN company com ON com.id = t.companyFk
JOIN client c2 ON c2.id = com.clientFk
@@ -71459,12 +73216,10 @@ BEGIN
LEFT JOIN route r ON r.id = t.routeFk
LEFT JOIN worker wo ON wo.id = r.workerFk
LEFT JOIN vehicle v ON v.id = r.vehicleFk
- WHERE t.shipped BETWEEN util.yesterday() AND util.dayEnd(util.VN_CURDATE())
- AND al.code IN ('PACKED', 'DELIVERED')
+ WHERE al.code IN ('PACKED', 'DELIVERED')
AND co.code <> 'ES'
AND am.name <> 'ABONO'
AND w.code = 'ALG'
- AND dm.code = 'DELIVERY'
AND t.id = vSelf
GROUP BY t.id;
@@ -72040,6 +73795,8 @@ BEGIN
* @return tmp.ticketAmount (ticketFk, taxableBase, tax, code)
* @return tmp.ticketTax (ticketFk, pgcFk, taxableBase, rate, code) Impuesto desglosado para cada ticket.
*/
+ -- Mantengo el drop porque si no da error en los tests de back de salix
+ -- Table 'addressCompany' was locked with a READ lock and can't be updated'
DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany;
CREATE TEMPORARY TABLE tmp.addressCompany
(INDEX (addressFk, companyFk))
@@ -72048,24 +73805,24 @@ BEGIN
FROM tmp.ticket tmpTicket
JOIN ticket t ON t.id = tmpTicket.ticketFk;
- CALL addressTaxArea ();
+ CALL addressTaxArea();
IF vTaxArea IS NOT NULL THEN
UPDATE tmp.addressTaxArea
SET areaFk = vTaxArea;
END IF;
- /* Solo se calcula la base imponible (taxableBase) y el impuesto se calculará posteriormente
- * No se debería cambiar el sistema por problemas con los decimales
- */
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketTax;
- CREATE TEMPORARY TABLE tmp.ticketTax
+ -- Solo se calcula la base imponible (taxableBase) y
+ -- el impuesto se calculará posteriormente
+ -- No se debería cambiar el sistema por problemas con los decimales
+
+ CREATE OR REPLACE TEMPORARY TABLE tmp.ticketTax
(PRIMARY KEY (ticketFk, code, rate))
ENGINE = MEMORY
SELECT * FROM (
SELECT tmpTicket.ticketFk,
bp.pgcFk,
- SUM(s.quantity * s.price * (100 - s.discount)/100 ) taxableBase,
+ SUM(s.quantity * s.price * (100 - s.discount) / 100 ) taxableBase,
pgc.rate,
tc.code,
bp.priority
@@ -72074,22 +73831,21 @@ BEGIN
JOIN item i ON i.id = s.itemFk
JOIN ticket t ON t.id = tmpTicket.ticketFk
JOIN supplier su ON su.id = t.companyFk
- JOIN tmp.addressTaxArea ata
- ON ata.addressFk = t.addressFk AND ata.companyFk = t.companyFk
- JOIN itemTaxCountry itc
- ON itc.itemFk = i.id AND itc.countryFk = su.countryFk
- JOIN bookingPlanner bp
- ON bp.countryFk = su.countryFk
- AND bp.taxAreaFk = ata.areaFk
- AND bp.taxClassFk = itc.taxClassFk
+ JOIN tmp.addressTaxArea ata ON ata.addressFk = t.addressFk
+ AND ata.companyFk = t.companyFk
+ JOIN itemTaxCountry itc ON itc.itemFk = i.id
+ AND itc.countryFk = su.countryFk
+ JOIN bookingPlanner bp ON bp.countryFk = su.countryFk
+ AND bp.taxAreaFk = ata.areaFk
+ AND bp.taxClassFk = itc.taxClassFk
JOIN pgc ON pgc.code = bp.pgcFk
JOIN taxClass tc ON tc.id = bp.taxClassFk
GROUP BY tmpTicket.ticketFk, pgc.code, pgc.rate
- HAVING taxableBase <> 0) t3
+ HAVING taxableBase
+ ) t3
ORDER BY priority;
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketServiceTax;
- CREATE TEMPORARY TABLE tmp.ticketServiceTax
+ CREATE OR REPLACE TEMPORARY TABLE tmp.ticketServiceTax
(PRIMARY KEY (ticketFk, code, rate))
ENGINE = MEMORY
SELECT tt.ticketFk,
@@ -72101,24 +73857,22 @@ BEGIN
JOIN ticketService ts ON ts.ticketFk = tt.ticketFk
JOIN ticket t ON t.id = tt.ticketFk
JOIN supplier su ON su.id = t.companyFk
- JOIN tmp.addressTaxArea ata
- ON ata.addressFk = t.addressFk AND ata.companyFk = t.companyFk
- JOIN bookingPlanner bp
- ON bp.countryFk = su.countryFk
- AND bp.taxAreaFk = ata.areaFk
- AND bp.taxClassFk = ts.taxClassFk
+ JOIN tmp.addressTaxArea ata ON ata.addressFk = t.addressFk
+ AND ata.companyFk = t.companyFk
+ JOIN bookingPlanner bp ON bp.countryFk = su.countryFk
+ AND bp.taxAreaFk = ata.areaFk
+ AND bp.taxClassFk = ts.taxClassFk
JOIN pgc ON pgc.code = bp.pgcFk
JOIN taxClass tc ON tc.id = bp.taxClassFk
GROUP BY tt.ticketFk, pgc.code
- HAVING taxableBase <> 0;
+ HAVING taxableBase;
INSERT INTO tmp.ticketTax (ticketFk, pgcFk, taxableBase, rate, code)
SELECT ts.ticketFk, ts.pgcFk, ts.taxableBase, ts.rate, ts.code
FROM tmp.ticketServiceTax ts
ON DUPLICATE KEY UPDATE ticketTax.taxableBase = VALUES (taxableBase) + ticketTax.taxableBase ;
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketAmount;
- CREATE TEMPORARY TABLE tmp.ticketAmount
+ CREATE OR REPLACE TEMPORARY TABLE tmp.ticketAmount
(INDEX (ticketFk))
ENGINE = MEMORY
SELECT ticketFk,
@@ -72128,8 +73882,9 @@ BEGIN
FROM tmp.ticketTax
GROUP BY ticketFk, code;
- DROP TEMPORARY TABLE tmp.addressCompany;
- DROP TEMPORARY TABLE tmp.addressTaxArea;
+ DROP TEMPORARY TABLE
+ tmp.addressCompany,
+ tmp.addressTaxArea;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -76213,7 +77968,7 @@ BEGIN
SET vDated = DATE(vTimed);
- SELECT IF(pc.code = 'driveCE',
+ SELECT IF(pc.code = 'driverCE',
wc.dayBreakDriver,
wc.dayBreak),
wc.shortWeekBreak,
@@ -77216,6 +78971,12 @@ BEGIN
IF vOldBusinessFk IS NULL THEN
CALL account.account_enable(vSelf);
+
+ UPDATE client c
+ JOIN payMethod pm ON pm.code = 'bankDraft'
+ SET c.payMethodFk = pm.id
+ WHERE c.id = vSelf
+ AND c.iban;
END IF;
END ;;
DELIMITER ;
@@ -77875,7 +79636,7 @@ BEGIN
SELECT c.id clientFk,
c.name,
c.phone,
- c.mobile,
+ bt.description,
c.salesPersonFk,
u.name username,
aai.invoiced,
@@ -77891,10 +79652,11 @@ BEGIN
LEFT JOIN bs.clientNewBorn cnb ON cnb.clientFk = c.id
LEFT JOIN vn.annualAverageInvoiced aai ON aai.clientFk = c.id
JOIN vn.clientType ct ON ct.code = c.typeFk
+ JOIN vn.businessType bt ON bt.code = c.businessTypeFk
WHERE a.isActive
AND c.isActive
AND ct.code = 'normal'
- AND c.businessTypeFk <> 'worker'
+ AND bt.code <> 'worker'
GROUP BY c.id;
DROP TEMPORARY TABLE tmp.zoneNodes;
@@ -78039,7 +79801,7 @@ DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getCollisions`()
BEGIN
/**
- * Calcula si para un mismo codigo postal y dia
+ * Calcula si para un mismo codigo postal y dia
* hay mas de una zona configurada y manda correo
*
*/
@@ -78047,17 +79809,18 @@ BEGIN
DECLARE vZoneFk INT;
DECLARE vIsDone INT DEFAULT FALSE;
DECLARE vTableCollisions TEXT;
+ DECLARE json_data JSON;
DECLARE cur1 CURSOR FOR SELECT zoneFk from tmp.zoneOption;
-
+
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE;
DROP TEMPORARY TABLE IF EXISTS tmp.zone;
CREATE TEMPORARY TABLE tmp.zone
- SELECT z.id
+ SELECT z.id
FROM zone z
JOIN agencyMode am ON am.id = z.agencyModeFk
JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
- WHERE dm.code IN ('AGENCY','DELIVERY');
+ WHERE dm.code IN ('AGENCY','DELIVERY');
CALL zone_getOptionsForShipment(util.VN_CURDATE(),FALSE);
@@ -78072,7 +79835,7 @@ BEGIN
PRIMARY KEY zoneFkk (zoneFk, geoFk),
INDEX(geoFk))
ENGINE = MyISAM;
-
+
OPEN cur1;
cur1Loop: LOOP
SET vIsDone = FALSE;
@@ -78080,82 +79843,63 @@ BEGIN
IF vIsDone THEN
LEAVE cur1Loop;
END IF;
-
+
CALL zone_getLeaves(vZoneFk, NULL, NULL, TRUE);
- myLoop: LOOP
+ myLoop: LOOP
SET vGeoFk = NULL;
- SELECT geoFk INTO vGeoFk
+ SELECT geoFk INTO vGeoFk
FROM tmp.zoneNodes zn
WHERE NOT isChecked
LIMIT 1;
-
+
IF vGeoFk IS NULL THEN
LEAVE myLoop;
END IF;
-
+
CALL zone_getLeaves(vZoneFk, vGeoFk, NULL, TRUE);
UPDATE tmp.zoneNodes
- SET isChecked = TRUE
+ SET isChecked = TRUE
WHERE geoFk = vGeoFk;
END LOOP;
END LOOP;
CLOSE cur1;
- DELETE FROM tmp.zoneNodes
+ DELETE FROM tmp.zoneNodes
WHERE sons > 0;
-
+
DROP TEMPORARY TABLE IF EXISTS geoCollision;
CREATE TEMPORARY TABLE geoCollision
SELECT z.agencyModeFk, zn.geoFk, zw.warehouseFk
FROM tmp.zoneNodes zn
JOIN zone z ON z.id = zn.zoneFk
- JOIN zoneWarehouse zw ON z.id = zw.zoneFk
+ JOIN zoneWarehouse zw ON z.id = zw.zoneFk
GROUP BY z.agencyModeFk, zn.geoFk, zw.warehouseFk
HAVING count(*) > 1;
-
- SELECT '
-
- C.Postal |
- Número de zona |
- Precio |
- Zona |
- Almacén |
- Salix |
-
' INTO vTableCollisions;
-
- INSERT INTO mail (receiver,replyTo,subject,body)
- SELECT 'pepe@verdnatura.es' receiver,
- 'noreply@verdnatura.es' replyTo,
- CONCAT('Colisiones en zonas ', util.VN_CURDATE()) subject,
- CONCAT(vTableCollisions,
- GROUP_CONCAT(sub.td SEPARATOR ''),
- '
') body
- FROM(SELECT
- CONCAT('
- ', zn.name, ' |
- ', zoneFk,' |
- ', z.price,' |
- ', z.name,' |
- ', w.name, ' |
- ', CONCAT(''
- 'https://salix.verdnatura.es/#!/zone/',
- zoneFk,
- '/location?q=%7B%22search%22:%22',
- zn.name,
- '%22%7D'),' |
-
') td
- FROM tmp.zoneNodes zn
- JOIN zone z ON z.id = zn.zoneFk
- JOIN geoCollision gc ON gc.agencyModeFk = z.agencyModeFk AND zn.geoFk = gc.geoFk
- JOIN warehouse w ON w.id = gc.warehouseFk) sub;
-
- DROP TEMPORARY TABLE
- geoCollision,
+
+ -- Recojo los datos de la zona que ha dado conflicto
+ SELECT JSON_ARRAYAGG(
+ JSON_OBJECT(
+ 'zoneFk', zoneFk,
+ 'zn', JSON_OBJECT('name', zn.name),
+ 'z', JSON_OBJECT('name', z.name,'price', z.price),
+ 'w', JSON_OBJECT('name', w.name)
+ )
+ ) FROM tmp.zoneNodes zn
+ JOIN zone z ON z.id = zn.zoneFk
+ JOIN geoCollision gc ON gc.agencyModeFk = z.agencyModeFk AND zn.geoFk = gc.geoFk
+ JOIN warehouse w ON w.id = gc.warehouseFk
+ INTO json_data;
+
+ -- Creo un registro de la notificacion 'zone-included' para reportar via email
+ SELECT util.notification_send(
+ 'zone-included',
+ JSON_OBJECT('zoneCollisions',json_data),
+ account.myUser_getId()
+ );
+
+ DROP TEMPORARY TABLE
+ geoCollision,
tmp.zone,
tmp.zoneNodes;
END ;;
@@ -79274,7 +81018,6 @@ SET character_set_client = utf8;
1 AS `hasLcr`,
1 AS `default_address`,
1 AS `risk_calculated`,
- 1 AS `clientes_tipo_id`,
1 AS `invoiceByAddress`,
1 AS `contabilizado`,
1 AS `congelado`,
@@ -80089,18 +81832,16 @@ SET character_set_client = utf8;
SET character_set_client = @saved_cs_client;
--
--- Table structure for table `Proveedores_cargueras`
+-- Temporary table structure for view `Proveedores_cargueras`
--
DROP TABLE IF EXISTS `Proveedores_cargueras`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `Proveedores_cargueras` (
- `Id_Proveedor` int(10) unsigned NOT NULL,
- PRIMARY KEY (`Id_Proveedor`),
- CONSTRAINT `Proveedores_cargueras_supplierFk` FOREIGN KEY (`Id_Proveedor`) REFERENCES `vn`.`supplier` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Tabla de espcializacion para señalar las compañias que prestan servicio de transitario';
-/*!40101 SET character_set_client = @saved_cs_client */;
+/*!50001 DROP VIEW IF EXISTS `Proveedores_cargueras`*/;
+SET @saved_cs_client = @@character_set_client;
+SET character_set_client = utf8;
+/*!50001 CREATE VIEW `Proveedores_cargueras` AS SELECT
+ 1 AS `Id_Proveedor` */;
+SET character_set_client = @saved_cs_client;
--
-- Table structure for table `Proveedores_comunicados__`
@@ -80486,19 +82227,17 @@ SET character_set_client = utf8;
SET character_set_client = @saved_cs_client;
--
--- Table structure for table `Tramos__`
+-- Temporary table structure for view `Tramos`
--
-DROP TABLE IF EXISTS `Tramos__`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `Tramos__` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `Tramo` time NOT NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY `Tramo` (`Tramo`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11';
-/*!40101 SET character_set_client = @saved_cs_client */;
+DROP TABLE IF EXISTS `Tramos`;
+/*!50001 DROP VIEW IF EXISTS `Tramos`*/;
+SET @saved_cs_client = @@character_set_client;
+SET character_set_client = utf8;
+/*!50001 CREATE VIEW `Tramos` AS SELECT
+ 1 AS `id`,
+ 1 AS `Tramo` */;
+SET character_set_client = @saved_cs_client;
--
-- Temporary table structure for view `V_edi_item_track`
@@ -81581,7 +83320,7 @@ CREATE TABLE `dock__` (
`yPos` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `code_UNIQUE` (`code`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11';
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-03-05';
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -81726,7 +83465,6 @@ SET character_set_client = utf8;
1 AS `abbreviation`,
1 AS `Id_Proveedores_account`,
1 AS `gerente_id`,
- 1 AS `digito_factura`,
1 AS `phytosanitary`,
1 AS `CodigoEmpresa`,
1 AS `empresa_grupo`,
@@ -81842,193 +83580,171 @@ CREATE TABLE `expeditions_pictures__` (
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `filtros`
+-- Table structure for table `filtros__`
--
-DROP TABLE IF EXISTS `filtros`;
+DROP TABLE IF EXISTS `filtros__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `filtros` (
+CREATE TABLE `filtros__` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(45) NOT NULL,
`sql` varchar(255) NOT NULL,
`Estanteria` tinyint(1) DEFAULT 0,
PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-21;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `financialProductType`
+-- Temporary table structure for view `financialProductType`
--
DROP TABLE IF EXISTS `financialProductType`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `financialProductType` (
- `id` varchar(2) NOT NULL,
- `description` varchar(45) NOT NULL,
- `isAcumulattor` tinyint(4) NOT NULL DEFAULT 0,
- PRIMARY KEY (`id`),
- UNIQUE KEY `description_UNIQUE` (`description`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Distintos tipos de productos financieros: seguros de cambio, polizas de credito, acumuladores....';
-/*!40101 SET character_set_client = @saved_cs_client */;
+/*!50001 DROP VIEW IF EXISTS `financialProductType`*/;
+SET @saved_cs_client = @@character_set_client;
+SET character_set_client = utf8;
+/*!50001 CREATE VIEW `financialProductType` AS SELECT
+ 1 AS `id`,
+ 1 AS `description`,
+ 1 AS `isAcumulattor` */;
+SET character_set_client = @saved_cs_client;
--
--- Table structure for table `flight`
+-- Temporary table structure for view `flight`
--
DROP TABLE IF EXISTS `flight`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `flight` (
- `flight_id` varchar(10) NOT NULL,
- `duration` tinyint(2) unsigned NOT NULL,
- `route` varchar(20) DEFAULT NULL,
- `days` varchar(7) DEFAULT NULL,
- `airline_id` smallint(2) unsigned DEFAULT NULL,
- `airport_out` varchar(3) NOT NULL,
- `airport_in` varchar(3) NOT NULL,
- PRIMARY KEY (`flight_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
-/*!40101 SET character_set_client = @saved_cs_client */;
+/*!50001 DROP VIEW IF EXISTS `flight`*/;
+SET @saved_cs_client = @@character_set_client;
+SET character_set_client = utf8;
+/*!50001 CREATE VIEW `flight` AS SELECT
+ 1 AS `flight_id`,
+ 1 AS `duration`,
+ 1 AS `route`,
+ 1 AS `days`,
+ 1 AS `airline_id`,
+ 1 AS `airport_out`,
+ 1 AS `airport_in` */;
+SET character_set_client = @saved_cs_client;
--
--- Table structure for table `form_query`
+-- Table structure for table `form_query__`
--
-DROP TABLE IF EXISTS `form_query`;
+DROP TABLE IF EXISTS `form_query__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `form_query` (
+CREATE TABLE `form_query__` (
`form_query_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
`query` varchar(50) NOT NULL,
`response1` varchar(10) NOT NULL,
`response2` varchar(10) NOT NULL,
`type_id` enum('gest_doc') NOT NULL,
PRIMARY KEY (`form_query_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-21;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `gastos_resumen`
+-- Temporary table structure for view `gastos_resumen`
--
DROP TABLE IF EXISTS `gastos_resumen`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `gastos_resumen` (
- `Id_Gasto` varchar(10) NOT NULL,
- `year` int(4) NOT NULL,
- `month` int(2) NOT NULL,
- `importe` decimal(10,2) DEFAULT NULL,
- `empresa_id` int(11) NOT NULL,
- PRIMARY KEY (`Id_Gasto`,`year`,`month`,`empresa_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Sirve para resumir los gastos que se ponen a mano en el contaplus';
-/*!40101 SET character_set_client = @saved_cs_client */;
+/*!50001 DROP VIEW IF EXISTS `gastos_resumen`*/;
+SET @saved_cs_client = @@character_set_client;
+SET character_set_client = utf8;
+/*!50001 CREATE VIEW `gastos_resumen` AS SELECT
+ 1 AS `id`,
+ 1 AS `Id_Gasto`,
+ 1 AS `year`,
+ 1 AS `month`,
+ 1 AS `importe`,
+ 1 AS `empresa_id` */;
+SET character_set_client = @saved_cs_client;
--
--- Table structure for table `guillen`
+-- Table structure for table `guillen__`
--
-DROP TABLE IF EXISTS `guillen`;
+DROP TABLE IF EXISTS `guillen__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `guillen` (
+CREATE TABLE `guillen__` (
`bulto` tinyint(3) unsigned NOT NULL,
`1` float unsigned NOT NULL,
`2` float unsigned NOT NULL,
`re_exp` float unsigned NOT NULL,
PRIMARY KEY (`bulto`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `guillen_carry`
+-- Table structure for table `guillen_carry__`
--
-DROP TABLE IF EXISTS `guillen_carry`;
+DROP TABLE IF EXISTS `guillen_carry__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `guillen_carry` (
+CREATE TABLE `guillen_carry__` (
`carry` tinyint(3) unsigned NOT NULL,
`1` float unsigned NOT NULL,
`2` float unsigned NOT NULL,
`re_exp` float unsigned NOT NULL,
PRIMARY KEY (`carry`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `integra2`
+-- Temporary table structure for view `integra2`
--
DROP TABLE IF EXISTS `integra2`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `integra2` (
- `postal_code` mediumint(8) unsigned NOT NULL,
- `frequency` tinyint(3) unsigned NOT NULL,
- `warehouse_id` smallint(5) unsigned NOT NULL,
- PRIMARY KEY (`postal_code`,`frequency`,`warehouse_id`),
- KEY `postal_code` (`postal_code`),
- KEY `warehouse_id` (`warehouse_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
-/*!40101 SET character_set_client = @saved_cs_client */;
+/*!50001 DROP VIEW IF EXISTS `integra2`*/;
+SET @saved_cs_client = @@character_set_client;
+SET character_set_client = utf8;
+/*!50001 CREATE VIEW `integra2` AS SELECT
+ 1 AS `postal_code`,
+ 1 AS `frequency`,
+ 1 AS `warehouse_id` */;
+SET character_set_client = @saved_cs_client;
--
--- Table structure for table `integra2_escala`
+-- Table structure for table `integra2_escala__`
--
-DROP TABLE IF EXISTS `integra2_escala`;
+DROP TABLE IF EXISTS `integra2_escala__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `integra2_escala` (
+CREATE TABLE `integra2_escala__` (
`province_id` smallint(6) unsigned NOT NULL,
`warehouse_id` smallint(6) unsigned NOT NULL,
PRIMARY KEY (`province_id`,`warehouse_id`),
KEY `warehouse_escala_idx` (`warehouse_id`),
CONSTRAINT `province_escala` FOREIGN KEY (`province_id`) REFERENCES `vn`.`province` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `warehouse_escala` FOREIGN KEY (`warehouse_id`) REFERENCES `vn`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `integra2_province`
+-- Temporary table structure for view `integra2_province`
--
DROP TABLE IF EXISTS `integra2_province`;
+/*!50001 DROP VIEW IF EXISTS `integra2_province`*/;
+SET @saved_cs_client = @@character_set_client;
+SET character_set_client = utf8;
+/*!50001 CREATE VIEW `integra2_province` AS SELECT
+ 1 AS `province_id`,
+ 1 AS `franquicia` */;
+SET character_set_client = @saved_cs_client;
+
+--
+-- Table structure for table `invoice_observation__`
+--
+
+DROP TABLE IF EXISTS `invoice_observation__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `integra2_province` (
- `province_id` smallint(6) unsigned NOT NULL,
- `franquicia` varchar(65) NOT NULL,
- PRIMARY KEY (`province_id`),
- CONSTRAINT `integra2_province_id` FOREIGN KEY (`province_id`) REFERENCES `vn`.`province` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Table structure for table `intervalos__`
---
-
-DROP TABLE IF EXISTS `intervalos__`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `intervalos__` (
- `id` int(11) NOT NULL,
- `hour` time NOT NULL,
- PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Deprecated 27-02-2023';
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Table structure for table `invoice_observation`
---
-
-DROP TABLE IF EXISTS `invoice_observation`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `invoice_observation` (
+CREATE TABLE `invoice_observation__` (
`invoice_observation_id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`desde` date NOT NULL,
`hasta` date NOT NULL,
@@ -82036,7 +83752,7 @@ CREATE TABLE `invoice_observation` (
`empresa_id` smallint(5) unsigned NOT NULL DEFAULT 0,
`text` text NOT NULL,
PRIMARY KEY (`invoice_observation_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -82055,36 +83771,36 @@ CREATE TABLE `jerarquia` (
KEY `jerarquiaBossFk_idx` (`boss_id`),
CONSTRAINT `jerarquiaBossFk` FOREIGN KEY (`boss_id`) REFERENCES `account`.`account` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `jerarquiaWorkerFk` FOREIGN KEY (`worker_id`) REFERENCES `account`.`account` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `language`
+-- Table structure for table `language__`
--
-DROP TABLE IF EXISTS `language`;
+DROP TABLE IF EXISTS `language__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `language` (
+CREATE TABLE `language__` (
`code` varchar(10) NOT NULL,
`name` varchar(20) NOT NULL,
`active` tinyint(1) NOT NULL DEFAULT 0,
PRIMARY KEY (`code`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `link`
+-- Table structure for table `link__`
--
-DROP TABLE IF EXISTS `link`;
+DROP TABLE IF EXISTS `link__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `link` (
+CREATE TABLE `link__` (
`Id_Cliente` int(11) NOT NULL,
`Id_Proveedor` int(11) NOT NULL,
PRIMARY KEY (`Id_Cliente`,`Id_Proveedor`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -82110,24 +83826,6 @@ SET character_set_client = utf8;
1 AS `error` */;
SET character_set_client = @saved_cs_client;
---
--- Table structure for table `mail_templates__`
---
-
-DROP TABLE IF EXISTS `mail_templates__`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `mail_templates__` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `countryCode` char(2) NOT NULL DEFAULT 'ES',
- `name` varchar(25) NOT NULL,
- `subject` varchar(50) NOT NULL,
- `body` text NOT NULL,
- `attachment` text DEFAULT NULL,
- PRIMARY KEY (`id`,`countryCode`,`name`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Deprecated 27-02-2023';
-/*!40101 SET character_set_client = @saved_cs_client */;
-
--
-- Temporary table structure for view `mandato`
--
@@ -82160,33 +83858,16 @@ SET character_set_client = utf8;
SET character_set_client = @saved_cs_client;
--
--- Table structure for table `movement_label`
+-- Table structure for table `nichos__`
--
-DROP TABLE IF EXISTS `movement_label`;
+DROP TABLE IF EXISTS `nichos__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `movement_label` (
- `Id_movimiento` int(11) NOT NULL,
- `label` mediumint(8) unsigned NOT NULL,
- `stem` mediumint(8) unsigned NOT NULL,
- `created` timestamp NULL DEFAULT current_timestamp(),
- PRIMARY KEY (`Id_movimiento`),
- CONSTRAINT `movement_label_ibfk_1` FOREIGN KEY (`Id_movimiento`) REFERENCES `vn`.`sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Table structure for table `nichos`
---
-
-DROP TABLE IF EXISTS `nichos`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `nichos` (
+CREATE TABLE `nichos__` (
`id` varchar(5) NOT NULL,
PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -82215,35 +83896,27 @@ SET character_set_client = utf8;
SET character_set_client = @saved_cs_client;
--
--- Table structure for table `pago_sdc`
+-- Temporary table structure for view `pago_sdc`
--
DROP TABLE IF EXISTS `pago_sdc`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `pago_sdc` (
- `pago_sdc_id` int(11) NOT NULL AUTO_INCREMENT,
- `importe` decimal(10,2) NOT NULL,
- `fecha` date NOT NULL,
- `vencimiento` date NOT NULL,
- `entity_id` int(10) unsigned NOT NULL,
- `ref` varchar(45) DEFAULT NULL,
- `rate` decimal(10,4) NOT NULL,
- `empresa_id` int(10) unsigned NOT NULL DEFAULT 442,
- `financialProductTypefk` varchar(2) NOT NULL DEFAULT 'SC',
- `pago_sdccol` varchar(45) DEFAULT NULL,
- `upperBarrier` decimal(10,2) DEFAULT NULL,
- `lowerBarrier` decimal(10,2) DEFAULT NULL,
- `strike` decimal(10,2) DEFAULT NULL,
- PRIMARY KEY (`pago_sdc_id`),
- KEY `empresa_sdc_idx` (`empresa_id`),
- KEY `financial_type_fk_idx` (`financialProductTypefk`),
- KEY `pago_sdc_entity_fk_idx` (`entity_id`),
- CONSTRAINT `financial_type_fk` FOREIGN KEY (`financialProductTypefk`) REFERENCES `financialProductType` (`id`) ON UPDATE CASCADE,
- CONSTRAINT `pago_sdcCompany_Fk` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`company` (`id`) ON UPDATE CASCADE,
- CONSTRAINT `pago_sdc_entity_fk` FOREIGN KEY (`entity_id`) REFERENCES `vn`.`bankEntity` (`id`) ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Seguros de cambio';
-/*!40101 SET character_set_client = @saved_cs_client */;
+/*!50001 DROP VIEW IF EXISTS `pago_sdc`*/;
+SET @saved_cs_client = @@character_set_client;
+SET character_set_client = utf8;
+/*!50001 CREATE VIEW `pago_sdc` AS SELECT
+ 1 AS `pago_sdc_id`,
+ 1 AS `importe`,
+ 1 AS `fecha`,
+ 1 AS `vencimiento`,
+ 1 AS `entity_id`,
+ 1 AS `ref`,
+ 1 AS `rate`,
+ 1 AS `empresa_id`,
+ 1 AS `financialProductTypefk`,
+ 1 AS `upperBarrier`,
+ 1 AS `lowerBarrier`,
+ 1 AS `strike` */;
+SET character_set_client = @saved_cs_client;
--
-- Temporary table structure for view `pay_dem`
@@ -82289,13 +83962,13 @@ SET character_set_client = utf8;
SET character_set_client = @saved_cs_client;
--
--- Table structure for table `payroll_basess`
+-- Table structure for table `payroll_basess__`
--
-DROP TABLE IF EXISTS `payroll_basess`;
+DROP TABLE IF EXISTS `payroll_basess__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `payroll_basess` (
+CREATE TABLE `payroll_basess__` (
`id_payroll_Basess` int(11) NOT NULL AUTO_INCREMENT,
`empresa_id` int(10) NOT NULL,
`id_tipobasess` int(11) NOT NULL,
@@ -82306,25 +83979,25 @@ CREATE TABLE `payroll_basess` (
PRIMARY KEY (`id_payroll_Basess`),
KEY `payroll_basess_1_idx` (`id_tipobasess`),
KEY `payroll_basess_2_idx` (`empresa_id`),
- CONSTRAINT `payroll_basess_1` FOREIGN KEY (`id_tipobasess`) REFERENCES `payroll_tipobasess` (`id_payroll_tipobasess`) ON DELETE NO ACTION ON UPDATE CASCADE,
- CONSTRAINT `payroll_basess_2` FOREIGN KEY (`empresa_id`) REFERENCES `payroll_centros` (`empresa_id`) ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+ CONSTRAINT `payroll_basess_1` FOREIGN KEY (`id_tipobasess`) REFERENCES `payroll_tipobasess__` (`id_payroll_tipobasess`) ON DELETE NO ACTION ON UPDATE CASCADE,
+ CONSTRAINT `payroll_basess_2` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`payrollWorkCenter` (`empresa_id__`) ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `payroll_bonificaciones`
+-- Table structure for table `payroll_bonificaciones__`
--
-DROP TABLE IF EXISTS `payroll_bonificaciones`;
+DROP TABLE IF EXISTS `payroll_bonificaciones__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `payroll_bonificaciones` (
+CREATE TABLE `payroll_bonificaciones__` (
`codtrabajador` int(11) NOT NULL,
`codempresa` int(11) NOT NULL,
`Fecha` date NOT NULL,
`bonificacionSS` double NOT NULL,
PRIMARY KEY (`codtrabajador`,`codempresa`,`Fecha`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -82342,51 +84015,42 @@ SET character_set_client = utf8;
SET character_set_client = @saved_cs_client;
--
--- Table structure for table `payroll_centros`
+-- Temporary table structure for view `payroll_centros`
--
DROP TABLE IF EXISTS `payroll_centros`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `payroll_centros` (
- `cod_centro` int(11) NOT NULL,
- `Centro` varchar(255) NOT NULL,
- `nss_cotizacion` varchar(15) NOT NULL,
- `domicilio` varchar(255) NOT NULL,
- `poblacion` varchar(45) NOT NULL,
- `cp` varchar(5) NOT NULL,
- `empresa_id` int(10) NOT NULL,
- `codempresa` int(11) DEFAULT NULL,
- PRIMARY KEY (`cod_centro`,`empresa_id`),
- KEY `payroll_centros_ix1` (`empresa_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
-/*!40101 SET character_set_client = @saved_cs_client */;
+/*!50001 DROP VIEW IF EXISTS `payroll_centros`*/;
+SET @saved_cs_client = @@character_set_client;
+SET character_set_client = utf8;
+/*!50001 CREATE VIEW `payroll_centros` AS SELECT
+ 1 AS `cod_centro`,
+ 1 AS `codempresa` */;
+SET character_set_client = @saved_cs_client;
--
--- Table structure for table `payroll_conceptos`
+-- Temporary table structure for view `payroll_conceptos`
--
DROP TABLE IF EXISTS `payroll_conceptos`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `payroll_conceptos` (
- `conceptoid` int(11) NOT NULL,
- `concepto` varchar(255) DEFAULT NULL,
- `isSalaryAgreed` tinyint(1) NOT NULL DEFAULT 0,
- `isVariable` tinyint(1) NOT NULL,
- `isException` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Excepciones a tener en cuenta al importar conceptos en el proceso de importación de ficheros A3.',
- PRIMARY KEY (`conceptoid`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
-/*!40101 SET character_set_client = @saved_cs_client */;
+/*!50001 DROP VIEW IF EXISTS `payroll_conceptos`*/;
+SET @saved_cs_client = @@character_set_client;
+SET character_set_client = utf8;
+/*!50001 CREATE VIEW `payroll_conceptos` AS SELECT
+ 1 AS `conceptoid`,
+ 1 AS `concepto`,
+ 1 AS `isSalaryAgreed`,
+ 1 AS `isVariable`,
+ 1 AS `isException` */;
+SET character_set_client = @saved_cs_client;
--
--- Table structure for table `payroll_datos`
+-- Table structure for table `payroll_datos__`
--
-DROP TABLE IF EXISTS `payroll_datos`;
+DROP TABLE IF EXISTS `payroll_datos__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `payroll_datos` (
+CREATE TABLE `payroll_datos__` (
`codtrabajador` int(11) NOT NULL,
`codempresa` int(10) NOT NULL,
`Fecha` date NOT NULL,
@@ -82399,18 +84063,18 @@ CREATE TABLE `payroll_datos` (
`TributaIRPF` tinyint(4) NOT NULL,
PRIMARY KEY (`codtrabajador`,`codempresa`,`conceptoid`,`Fecha`),
KEY `fgkey_payrolldatos_1_idx` (`conceptoid`),
- CONSTRAINT `fgkey_payrolldatos_1` FOREIGN KEY (`conceptoid`) REFERENCES `payroll_conceptos` (`conceptoid`) ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+ CONSTRAINT `fgkey_payrolldatos_1` FOREIGN KEY (`conceptoid`) REFERENCES `vn`.`payrollComponent` (`id`) ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `payroll_embargos`
+-- Table structure for table `payroll_embargos__`
--
-DROP TABLE IF EXISTS `payroll_embargos`;
+DROP TABLE IF EXISTS `payroll_embargos__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `payroll_embargos` (
+CREATE TABLE `payroll_embargos__` (
`codtrabajador` int(11) NOT NULL,
`codempresa` int(10) NOT NULL,
`conceptoid` int(11) NOT NULL,
@@ -82419,56 +84083,44 @@ CREATE TABLE `payroll_embargos` (
`pendiente` double DEFAULT NULL,
`total` double NOT NULL,
PRIMARY KEY (`codtrabajador`,`codempresa`,`Fecha`,`conceptoid`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `payroll_employee`
+-- Temporary table structure for view `payroll_employee`
--
DROP TABLE IF EXISTS `payroll_employee`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `payroll_employee` (
- `CodTrabajador` int(11) NOT NULL,
- `nss` varchar(23) NOT NULL,
- `codpuesto` int(10) NOT NULL,
- `codempresa` int(10) NOT NULL,
- `codcontrato` int(10) NOT NULL,
- `FAntiguedad` date NOT NULL,
- `grupotarifa` int(10) NOT NULL,
- `codcategoria` int(10) NOT NULL,
- `ContratoTemporal` tinyint(1) NOT NULL DEFAULT 0,
- `workerFk` int(11) unsigned DEFAULT NULL,
- PRIMARY KEY (`CodTrabajador`,`codempresa`),
- KEY `sajvgfh_idx` (`codpuesto`),
- KEY `payroll_employee_workerFk_idx` (`workerFk`),
- CONSTRAINT `payroll_employee_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
-/*!40101 SET character_set_client = @saved_cs_client */;
+/*!50001 DROP VIEW IF EXISTS `payroll_employee`*/;
+SET @saved_cs_client = @@character_set_client;
+SET character_set_client = utf8;
+/*!50001 CREATE VIEW `payroll_employee` AS SELECT
+ 1 AS `CodTrabajador`,
+ 1 AS `codempresa` */;
+SET character_set_client = @saved_cs_client;
--
--- Table structure for table `payroll_tipobasess`
+-- Table structure for table `payroll_tipobasess__`
--
-DROP TABLE IF EXISTS `payroll_tipobasess`;
+DROP TABLE IF EXISTS `payroll_tipobasess__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `payroll_tipobasess` (
+CREATE TABLE `payroll_tipobasess__` (
`id_payroll_tipobasess` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id_payroll_tipobasess`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `payrroll_apEmpresarial`
+-- Table structure for table `payrroll_apEmpresarial__`
--
-DROP TABLE IF EXISTS `payrroll_apEmpresarial`;
+DROP TABLE IF EXISTS `payrroll_apEmpresarial__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `payrroll_apEmpresarial` (
+CREATE TABLE `payrroll_apEmpresarial__` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`codTrabajador` int(11) NOT NULL,
`Fecha` date NOT NULL,
@@ -82479,7 +84131,7 @@ CREATE TABLE `payrroll_apEmpresarial` (
`costeEmpresaFogasa` decimal(8,2) NOT NULL,
`costeEmpresaExtra` decimal(8,2) NOT NULL,
PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -82512,19 +84164,19 @@ SET character_set_client = utf8;
SET character_set_client = @saved_cs_client;
--
--- Table structure for table `preparation_exception`
+-- Table structure for table `preparation_exception__`
--
-DROP TABLE IF EXISTS `preparation_exception`;
+DROP TABLE IF EXISTS `preparation_exception__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `preparation_exception` (
+CREATE TABLE `preparation_exception__` (
`exception_day` date NOT NULL COMMENT 'preparation day',
`warehouse_id` smallint(6) unsigned DEFAULT NULL,
`percentage` tinyint(2) NOT NULL DEFAULT 0,
UNIQUE KEY `exception_day_UNIQUE` (`exception_day`),
UNIQUE KEY `warehouse_id_UNIQUE` (`warehouse_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -82599,19 +84251,19 @@ SET character_set_client = utf8;
SET character_set_client = @saved_cs_client;
--
--- Table structure for table `rec_translator`
+-- Table structure for table `rec_translator__`
--
-DROP TABLE IF EXISTS `rec_translator`;
+DROP TABLE IF EXISTS `rec_translator__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `rec_translator` (
+CREATE TABLE `rec_translator__` (
`Id_Article` int(11) NOT NULL,
`denominacion` varchar(85) NOT NULL,
PRIMARY KEY (`Id_Article`,`denominacion`),
KEY `id_article_rec_idx` (`Id_Article`),
CONSTRAINT `id_article_rec` FOREIGN KEY (`Id_Article`) REFERENCES `vn`.`item` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Equipara las denominaciones de las fincas de ecuador con nuestro Id_Article';
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -82648,18 +84300,18 @@ SET character_set_client = utf8;
SET character_set_client = @saved_cs_client;
--
--- Table structure for table `recibida_agricola`
+-- Table structure for table `recibida_agricola__`
--
-DROP TABLE IF EXISTS `recibida_agricola`;
+DROP TABLE IF EXISTS `recibida_agricola__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `recibida_agricola` (
+CREATE TABLE `recibida_agricola__` (
`recibida_id` mediumint(8) unsigned NOT NULL,
`num` smallint(5) unsigned NOT NULL,
PRIMARY KEY (`recibida_id`),
- CONSTRAINT `recibida_agricola_ibfk_1` FOREIGN KEY (`recibida_id`) REFERENCES `vn`.`invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+ CONSTRAINT `recibida_agricola___ibfk_1` FOREIGN KEY (`recibida_id`) REFERENCES `vn`.`invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -82765,60 +84417,43 @@ SET character_set_client = utf8;
SET character_set_client = @saved_cs_client;
--
--- Table structure for table `rounding`
+-- Table structure for table `rounding__`
--
-DROP TABLE IF EXISTS `rounding`;
+DROP TABLE IF EXISTS `rounding__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `rounding` (
+CREATE TABLE `rounding__` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`amount` double NOT NULL DEFAULT 0,
`price` double DEFAULT 0,
`discount` double NOT NULL DEFAULT 0,
PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `route`
+-- Table structure for table `route__`
--
-DROP TABLE IF EXISTS `route`;
+DROP TABLE IF EXISTS `route__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `route` (
+CREATE TABLE `route__` (
`agency_id` smallint(5) unsigned NOT NULL,
`week_day` tinyint(3) unsigned NOT NULL COMMENT 'weekday de access el domingo = 1, sabado = 7. Intentar cambiar al de Mysql Lunes = 0',
PRIMARY KEY (`agency_id`,`week_day`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `scan`
+-- Table structure for table `scanTree__`
--
-DROP TABLE IF EXISTS `scan`;
+DROP TABLE IF EXISTS `scanTree__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `scan` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `lft` int(11) NOT NULL,
- `rgt` int(11) NOT NULL,
- `name` varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
- `odbc_date` timestamp NOT NULL DEFAULT current_timestamp(),
- PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Se borra automaticamente 8 dias en el pasado desde vn2008.clean';
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Table structure for table `scanTree`
---
-
-DROP TABLE IF EXISTS `scanTree`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `scanTree` (
+CREATE TABLE `scanTree__` (
`id` int(11) NOT NULL DEFAULT 0,
`name` varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
`lft` int(11) NOT NULL,
@@ -82832,35 +84467,52 @@ CREATE TABLE `scanTree` (
`scanned` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `lft_rgt_depth` (`lft`,`rgt`,`depth`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `scan_line`
+-- Table structure for table `scan__`
--
-DROP TABLE IF EXISTS `scan_line`;
+DROP TABLE IF EXISTS `scan__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `scan_line` (
+CREATE TABLE `scan__` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `lft` int(11) NOT NULL,
+ `rgt` int(11) NOT NULL,
+ `name` varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
+ `odbc_date` timestamp NOT NULL DEFAULT current_timestamp(),
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `scan_line__`
+--
+
+DROP TABLE IF EXISTS `scan_line__`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `scan_line__` (
`scan_line_id` int(11) NOT NULL AUTO_INCREMENT,
`scan_id` int(11) NOT NULL,
`code` varchar(45) NOT NULL,
`odbc_date` timestamp NOT NULL DEFAULT current_timestamp(),
PRIMARY KEY (`scan_line_id`),
KEY `id_scan_id_idx` (`scan_id`),
- CONSTRAINT `id_scan_id` FOREIGN KEY (`scan_id`) REFERENCES `scan` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+ CONSTRAINT `id_scan_id` FOREIGN KEY (`scan_id`) REFERENCES `scan__` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `sort_merge_results_ernesto`
+-- Table structure for table `sort_merge_results_ernesto__`
--
-DROP TABLE IF EXISTS `sort_merge_results_ernesto`;
+DROP TABLE IF EXISTS `sort_merge_results_ernesto__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `sort_merge_results_ernesto` (
+CREATE TABLE `sort_merge_results_ernesto__` (
`hora` datetime NOT NULL,
`uptime` int(11) DEFAULT NULL,
`log_output` varchar(5) DEFAULT NULL,
@@ -82905,7 +84557,7 @@ CREATE TABLE `sort_merge_results_ernesto` (
PRIMARY KEY (`hora`),
UNIQUE KEY `hora_UNIQUE` (`hora`),
KEY `uptime` (`uptime`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -83023,13 +84675,13 @@ SET character_set_client = utf8;
SET character_set_client = @saved_cs_client;
--
--- Table structure for table `tblIVA`
+-- Table structure for table `tblIVA__`
--
-DROP TABLE IF EXISTS `tblIVA`;
+DROP TABLE IF EXISTS `tblIVA__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `tblIVA` (
+CREATE TABLE `tblIVA__` (
`tipoiva` varchar(50) NOT NULL,
`iva` smallint(6) NOT NULL DEFAULT 0,
`cuenta` double DEFAULT 0,
@@ -83037,34 +84689,34 @@ CREATE TABLE `tblIVA` (
`cuentaivaRE` double DEFAULT 0,
`REQ` double DEFAULT 0,
PRIMARY KEY (`tipoiva`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `template_bionic_component`
+-- Table structure for table `template_bionic_component__`
--
-DROP TABLE IF EXISTS `template_bionic_component`;
+DROP TABLE IF EXISTS `template_bionic_component__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `template_bionic_component` (
+CREATE TABLE `template_bionic_component__` (
`warehouse_id` smallint(5) unsigned NOT NULL,
`item_id` int(11) NOT NULL,
`component_id` int(10) unsigned NOT NULL,
`cost` decimal(10,4) NOT NULL,
UNIQUE KEY `item_warehouse_component` (`item_id`,`warehouse_id`,`component_id`) USING HASH,
KEY `item_warehouse` (`item_id`,`warehouse_id`) USING BTREE
-) ENGINE=MEMORY DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=MEMORY DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `template_bionic_lot`
+-- Table structure for table `template_bionic_lot__`
--
-DROP TABLE IF EXISTS `template_bionic_lot`;
+DROP TABLE IF EXISTS `template_bionic_lot__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `template_bionic_lot` (
+CREATE TABLE `template_bionic_lot__` (
`warehouse_id` smallint(5) unsigned NOT NULL,
`item_id` int(11) NOT NULL,
`available` double DEFAULT NULL,
@@ -83072,17 +84724,17 @@ CREATE TABLE `template_bionic_lot` (
`fix` tinyint(3) unsigned DEFAULT 0,
UNIQUE KEY `warehouse_id` (`warehouse_id`,`item_id`),
KEY `item_id` (`item_id`)
-) ENGINE=MEMORY DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
+) ENGINE=MEMORY DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci COMMENT='refs #6372 @deprecated 2023-11-28;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `template_bionic_price`
+-- Table structure for table `template_bionic_price__`
--
-DROP TABLE IF EXISTS `template_bionic_price`;
+DROP TABLE IF EXISTS `template_bionic_price__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `template_bionic_price` (
+CREATE TABLE `template_bionic_price__` (
`warehouse_id` smallint(5) unsigned NOT NULL,
`item_id` int(11) NOT NULL,
`rate` tinyint(3) unsigned NOT NULL,
@@ -83091,7 +84743,7 @@ CREATE TABLE `template_bionic_price` (
`price` decimal(10,2) DEFAULT NULL,
UNIQUE KEY `warehouse_id` (`warehouse_id`,`item_id`,`rate`),
KEY `item_id` (`item_id`) USING BTREE
-) ENGINE=MEMORY DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
+) ENGINE=MEMORY DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci COMMENT='refs #6372 @deprecated 2023-11-28;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -83107,22 +84759,6 @@ SET character_set_client = utf8;
1 AS `model` */;
SET character_set_client = @saved_cs_client;
---
--- Table structure for table `ticket_location__`
---
-
-DROP TABLE IF EXISTS `ticket_location__`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `ticket_location__` (
- `Id_Ticket` int(11) NOT NULL,
- `longitude` decimal(11,7) DEFAULT NULL,
- `latitude` decimal(11,7) DEFAULT NULL,
- PRIMARY KEY (`Id_Ticket`),
- CONSTRAINT `Id_Ticket_Location` FOREIGN KEY (`Id_Ticket`) REFERENCES `vn`.`ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
--
-- Temporary table structure for view `ticket_observation`
--
@@ -83170,28 +84806,28 @@ SET character_set_client = utf8;
SET character_set_client = @saved_cs_client;
--
--- Table structure for table `tipsa`
+-- Table structure for table `tipsa__`
--
-DROP TABLE IF EXISTS `tipsa`;
+DROP TABLE IF EXISTS `tipsa__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `tipsa` (
+CREATE TABLE `tipsa__` (
`kilos` tinyint(3) unsigned NOT NULL,
`importe` double unsigned NOT NULL,
`zona` tinyint(3) unsigned NOT NULL,
PRIMARY KEY (`kilos`,`zona`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `tmpNEWTARIFAS`
+-- Table structure for table `tmpNEWTARIFAS__`
--
-DROP TABLE IF EXISTS `tmpNEWTARIFAS`;
+DROP TABLE IF EXISTS `tmpNEWTARIFAS__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `tmpNEWTARIFAS` (
+CREATE TABLE `tmpNEWTARIFAS__` (
`Id_Cliente` int(11) NOT NULL,
`Cliente` varchar(50) NOT NULL,
`Consumo_medio_mensual` double(17,0) DEFAULT NULL,
@@ -83199,20 +84835,20 @@ CREATE TABLE `tmpNEWTARIFAS` (
`Nueva_Tarifa` int(11) DEFAULT NULL,
`Id_Trabajador` int(11) DEFAULT 20,
PRIMARY KEY (`Id_Cliente`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `transport`
+-- Table structure for table `transport__`
--
-DROP TABLE IF EXISTS `transport`;
+DROP TABLE IF EXISTS `transport__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `transport` (
+CREATE TABLE `transport__` (
`wday` tinyint(4) NOT NULL,
PRIMARY KEY (`wday`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -83244,13 +84880,13 @@ SET character_set_client = utf8;
SET character_set_client = @saved_cs_client;
--
--- Table structure for table `travel_pattern`
+-- Table structure for table `travel_pattern__`
--
-DROP TABLE IF EXISTS `travel_pattern`;
+DROP TABLE IF EXISTS `travel_pattern__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `travel_pattern` (
+CREATE TABLE `travel_pattern__` (
`travel_pattern_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
`week_start` tinyint(3) unsigned NOT NULL,
`week_end` tinyint(3) unsigned NOT NULL,
@@ -83270,21 +84906,21 @@ CREATE TABLE `travel_pattern` (
KEY `travel_pattern_ibfk_6_idx` (`cargoSupplierFk`),
KEY `travel_pattern_FK` (`travelFk`),
CONSTRAINT `travel_pattern_FK` FOREIGN KEY (`travelFk`) REFERENCES `vn`.`travel` (`id`) ON UPDATE CASCADE,
- CONSTRAINT `travel_pattern_ibfk_3` FOREIGN KEY (`warehouse_out`) REFERENCES `vn`.`warehouse` (`id`) ON UPDATE CASCADE,
- CONSTRAINT `travel_pattern_ibfk_4` FOREIGN KEY (`agency_id`) REFERENCES `vn`.`agencyMode` (`id`) ON UPDATE CASCADE,
- CONSTRAINT `travel_pattern_ibfk_5` FOREIGN KEY (`warehouse_in`) REFERENCES `vn`.`warehouse` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `travel_pattern___ibfk_3` FOREIGN KEY (`warehouse_out`) REFERENCES `vn`.`warehouse` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `travel_pattern___ibfk_4` FOREIGN KEY (`agency_id`) REFERENCES `vn`.`agencyMode` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `travel_pattern___ibfk_5` FOREIGN KEY (`warehouse_in`) REFERENCES `vn`.`warehouse` (`id`) ON UPDATE CASCADE,
CONSTRAINT `travel_pattern_supplierFk` FOREIGN KEY (`cargoSupplierFk`) REFERENCES `vn`.`supplier` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `travel_reserve`
+-- Table structure for table `travel_reserve__`
--
-DROP TABLE IF EXISTS `travel_reserve`;
+DROP TABLE IF EXISTS `travel_reserve__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `travel_reserve` (
+CREATE TABLE `travel_reserve__` (
`travel_reserve_id` int(11) NOT NULL AUTO_INCREMENT,
`travel_id` int(11) unsigned NOT NULL,
`Id_Trabajador` int(11) NOT NULL,
@@ -83297,37 +84933,23 @@ CREATE TABLE `travel_reserve` (
UNIQUE KEY `travel_reserve_id_UNIQUE` (`travel_reserve_id`),
KEY `travel_travel_reserve_idx` (`travel_id`),
KEY `traveL_buyer_id_idx` (`Id_Trabajador`),
- CONSTRAINT `travel_reserve_ibfk_1` FOREIGN KEY (`travel_id`) REFERENCES `vn`.`travel` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='En esta tabla almacenamos los m3 que cada comprador tiene asignados, por travel.';
+ CONSTRAINT `travel_reserve___ibfk_1` FOREIGN KEY (`travel_id`) REFERENCES `vn`.`travel` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `trolley`
+-- Table structure for table `trolley__`
--
-DROP TABLE IF EXISTS `trolley`;
+DROP TABLE IF EXISTS `trolley__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `trolley` (
+CREATE TABLE `trolley__` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`fecha` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`ref` varchar(4) DEFAULT NULL,
PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Table structure for table `turn__`
---
-
-DROP TABLE IF EXISTS `turn__`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `turn__` (
- `number` int(11) NOT NULL,
- `odbc_date` timestamp NOT NULL DEFAULT current_timestamp(),
- PRIMARY KEY (`number`,`odbc_date`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -83344,32 +84966,32 @@ CREATE TABLE `unary` (
UNIQUE KEY `idunary_UNIQUE` (`id`),
KEY `unary_parent_idx` (`parent`),
CONSTRAINT `unary_parent` FOREIGN KEY (`parent`) REFERENCES `unary` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `unaryScanFilter`
+-- Table structure for table `unaryScanFilter__`
--
-DROP TABLE IF EXISTS `unaryScanFilter`;
+DROP TABLE IF EXISTS `unaryScanFilter__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `unaryScanFilter` (
+CREATE TABLE `unaryScanFilter__` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`filter` text NOT NULL,
PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `unary_scan`
+-- Table structure for table `unary_scan__`
--
-DROP TABLE IF EXISTS `unary_scan`;
+DROP TABLE IF EXISTS `unary_scan__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `unary_scan` (
+CREATE TABLE `unary_scan__` (
`unary_id` int(11) NOT NULL,
`name` varchar(45) DEFAULT NULL,
`odbc_date` timestamp NOT NULL DEFAULT current_timestamp(),
@@ -83377,17 +84999,17 @@ CREATE TABLE `unary_scan` (
PRIMARY KEY (`unary_id`),
KEY `scan_unary_idx` (`unary_id`),
CONSTRAINT `unary_scan` FOREIGN KEY (`unary_id`) REFERENCES `unary` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `unary_scan_line`
+-- Table structure for table `unary_scan_line__`
--
-DROP TABLE IF EXISTS `unary_scan_line`;
+DROP TABLE IF EXISTS `unary_scan_line__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `unary_scan_line` (
+CREATE TABLE `unary_scan_line__` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`code` varchar(45) NOT NULL,
`odbc_date` timestamp NOT NULL DEFAULT current_timestamp(),
@@ -83395,56 +85017,56 @@ CREATE TABLE `unary_scan_line` (
PRIMARY KEY (`id`),
UNIQUE KEY `id_UNIQUE` (`id`),
KEY `unary_line_idx` (`unary_id`),
- CONSTRAINT `unary_line` FOREIGN KEY (`unary_id`) REFERENCES `unary_scan` (`unary_id`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+ CONSTRAINT `unary_line` FOREIGN KEY (`unary_id`) REFERENCES `unary_scan__` (`unary_id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `unary_scan_line_buy`
+-- Table structure for table `unary_scan_line_buy__`
--
-DROP TABLE IF EXISTS `unary_scan_line_buy`;
+DROP TABLE IF EXISTS `unary_scan_line_buy__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `unary_scan_line_buy` (
+CREATE TABLE `unary_scan_line_buy__` (
`scan_line_id` int(11) NOT NULL,
`Id_Article` int(11) NOT NULL,
PRIMARY KEY (`scan_line_id`),
UNIQUE KEY `scan_line_id_UNIQUE` (`scan_line_id`),
KEY `Id_Article_buy_idx` (`Id_Article`),
CONSTRAINT `Id_Article_buy` FOREIGN KEY (`Id_Article`) REFERENCES `vn`.`item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT `scan_line_id_patriarcal` FOREIGN KEY (`scan_line_id`) REFERENCES `unary_scan_line` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+ CONSTRAINT `scan_line_id_patriarcal` FOREIGN KEY (`scan_line_id`) REFERENCES `unary_scan_line__` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `unary_scan_line_expedition`
+-- Table structure for table `unary_scan_line_expedition__`
--
-DROP TABLE IF EXISTS `unary_scan_line_expedition`;
+DROP TABLE IF EXISTS `unary_scan_line_expedition__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `unary_scan_line_expedition` (
+CREATE TABLE `unary_scan_line_expedition__` (
`scan_line_id` int(11) NOT NULL,
`expedition_id` int(11) NOT NULL,
PRIMARY KEY (`scan_line_id`),
UNIQUE KEY `scan_line_id_UNIQUE` (`scan_line_id`),
KEY `expedition_id_scan_idx` (`expedition_id`),
CONSTRAINT `expedition_id_scan` FOREIGN KEY (`expedition_id`) REFERENCES `vn`.`expedition` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `unary_source`
+-- Table structure for table `unary_source__`
--
-DROP TABLE IF EXISTS `unary_source`;
+DROP TABLE IF EXISTS `unary_source__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `unary_source` (
+CREATE TABLE `unary_source__` (
`name` varchar(100) NOT NULL,
PRIMARY KEY (`name`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -83552,19 +85174,6 @@ SET character_set_client = utf8;
1 AS `abbreviation` */;
SET character_set_client = @saved_cs_client;
---
--- Temporary table structure for view `v_jerarquia`
---
-
-DROP TABLE IF EXISTS `v_jerarquia`;
-/*!50001 DROP VIEW IF EXISTS `v_jerarquia`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE VIEW `v_jerarquia` AS SELECT
- 1 AS `Id_Trabajador`,
- 1 AS `boss_id` */;
-SET character_set_client = @saved_cs_client;
-
--
-- Temporary table structure for view `versiones`
--
@@ -83580,78 +85189,78 @@ SET character_set_client = utf8;
SET character_set_client = @saved_cs_client;
--
--- Table structure for table `viaxpress`
+-- Table structure for table `viaxpress__`
--
-DROP TABLE IF EXISTS `viaxpress`;
+DROP TABLE IF EXISTS `viaxpress__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `viaxpress` (
+CREATE TABLE `viaxpress__` (
`codigo_postal` varchar(5) NOT NULL,
`zona` tinyint(4) NOT NULL DEFAULT 2,
`m_t` tinyint(4) NOT NULL DEFAULT 0,
`POBLACION` varchar(25) NOT NULL,
`PROVINCIA` varchar(20) NOT NULL,
PRIMARY KEY (`codigo_postal`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `warehouse_filtro`
+-- Table structure for table `warehouse_filtro__`
--
-DROP TABLE IF EXISTS `warehouse_filtro`;
+DROP TABLE IF EXISTS `warehouse_filtro__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `warehouse_filtro` (
+CREATE TABLE `warehouse_filtro__` (
`warehouse_id` smallint(6) unsigned NOT NULL,
`Id_Trabajador` int(11) NOT NULL,
`ok` tinyint(3) unsigned DEFAULT 1,
PRIMARY KEY (`Id_Trabajador`,`warehouse_id`),
KEY `wh_worker_idx` (`Id_Trabajador`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Tabla que permite filtrar los almacenes que muestra la comparativa, recordando la selección personal del usuario';
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `warehouse_group`
+-- Table structure for table `warehouse_group__`
--
-DROP TABLE IF EXISTS `warehouse_group`;
+DROP TABLE IF EXISTS `warehouse_group__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `warehouse_group` (
+CREATE TABLE `warehouse_group__` (
`warehouse_alias_id` smallint(5) unsigned NOT NULL DEFAULT 22,
`warehouse_id` smallint(5) unsigned NOT NULL,
PRIMARY KEY (`warehouse_alias_id`,`warehouse_id`),
KEY `warehosue_group_ware_idx` (`warehouse_id`),
CONSTRAINT `warehosue_group_ware` FOREIGN KEY (`warehouse_id`) REFERENCES `vn`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `warehouse_group_alias` FOREIGN KEY (`warehouse_alias_id`) REFERENCES `vn`.`warehouseAlias__` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Agrupa warehouses ';
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `warehouse_joined`
+-- Table structure for table `warehouse_joined__`
--
-DROP TABLE IF EXISTS `warehouse_joined`;
+DROP TABLE IF EXISTS `warehouse_joined__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `warehouse_joined` (
+CREATE TABLE `warehouse_joined__` (
`warehouse_id` smallint(5) unsigned NOT NULL,
`warehouse_alias_id` smallint(5) unsigned NOT NULL,
PRIMARY KEY (`warehouse_id`,`warehouse_alias_id`),
- CONSTRAINT `warehouse_joined_ibfk_3` FOREIGN KEY (`warehouse_id`) REFERENCES `vn`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+ CONSTRAINT `warehouse_joined___ibfk_3` FOREIGN KEY (`warehouse_id`) REFERENCES `vn`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `warehouse_lc`
+-- Table structure for table `warehouse_lc__`
--
-DROP TABLE IF EXISTS `warehouse_lc`;
+DROP TABLE IF EXISTS `warehouse_lc__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `warehouse_lc` (
+CREATE TABLE `warehouse_lc__` (
`whin` smallint(6) unsigned NOT NULL,
`whout` smallint(6) unsigned NOT NULL,
`m3` double NOT NULL DEFAULT 15,
@@ -83660,34 +85269,30 @@ CREATE TABLE `warehouse_lc` (
KEY `whout_wh_idx` (`whout`),
CONSTRAINT `whin_wh` FOREIGN KEY (`whin`) REFERENCES `vn`.`warehouse` (`id`) ON UPDATE CASCADE,
CONSTRAINT `whout_wh` FOREIGN KEY (`whout`) REFERENCES `vn`.`warehouse` (`id`) ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Warehouses cost for linking';
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `warehouse_pickup`
+-- Temporary table structure for view `warehouse_pickup`
--
DROP TABLE IF EXISTS `warehouse_pickup`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `warehouse_pickup` (
- `warehouse_id` smallint(5) unsigned NOT NULL,
- `agency_id` int(11) DEFAULT NULL,
- PRIMARY KEY (`warehouse_id`),
- UNIQUE KEY `agency_id` (`agency_id`,`warehouse_id`),
- CONSTRAINT `warehouse_pickup_ibfk_1` FOREIGN KEY (`warehouse_id`) REFERENCES `vn`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT `warehouse_pickup_ibfk_2` FOREIGN KEY (`agency_id`) REFERENCES `vn`.`agencyMode` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
-/*!40101 SET character_set_client = @saved_cs_client */;
+/*!50001 DROP VIEW IF EXISTS `warehouse_pickup`*/;
+SET @saved_cs_client = @@character_set_client;
+SET character_set_client = utf8;
+/*!50001 CREATE VIEW `warehouse_pickup` AS SELECT
+ 1 AS `warehouse_id`,
+ 1 AS `agency_id` */;
+SET character_set_client = @saved_cs_client;
--
--- Table structure for table `wh_selection`
+-- Table structure for table `wh_selection__`
--
-DROP TABLE IF EXISTS `wh_selection`;
+DROP TABLE IF EXISTS `wh_selection__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `wh_selection` (
+CREATE TABLE `wh_selection__` (
`Id_Trabajador` int(10) unsigned NOT NULL,
`warehouse_id` smallint(6) unsigned NOT NULL,
PRIMARY KEY (`Id_Trabajador`,`warehouse_id`),
@@ -83695,54 +85300,54 @@ CREATE TABLE `wh_selection` (
KEY `Warehouse` (`warehouse_id`),
CONSTRAINT `Trabajadores` FOREIGN KEY (`Id_Trabajador`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE,
CONSTRAINT `Warehouse` FOREIGN KEY (`warehouse_id`) REFERENCES `vn`.`warehouse` (`id`) ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Permite que los usuarios seleccionen los almacenes que van a';
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `widget`
+-- Table structure for table `widget__`
--
-DROP TABLE IF EXISTS `widget`;
+DROP TABLE IF EXISTS `widget__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `widget` (
+CREATE TABLE `widget__` (
`widget_id` int(11) NOT NULL,
`chr` int(11) NOT NULL,
PRIMARY KEY (`widget_id`),
UNIQUE KEY `chr_UNIQUE` (`chr`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `wks`
+-- Table structure for table `wks__`
--
-DROP TABLE IF EXISTS `wks`;
+DROP TABLE IF EXISTS `wks__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `wks` (
+CREATE TABLE `wks__` (
`wk` int(10) unsigned NOT NULL,
`yr` int(10) unsigned NOT NULL,
`vwk` int(10) unsigned NOT NULL,
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`comments` text DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `zones`
+-- Table structure for table `zones__`
--
-DROP TABLE IF EXISTS `zones`;
+DROP TABLE IF EXISTS `zones__`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `zones` (
+CREATE TABLE `zones__` (
`zone_id` tinyint(4) NOT NULL,
`name` varchar(45) NOT NULL,
`printingOrder` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`zone_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Zonas de reparto';
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;';
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -83775,274 +85380,6 @@ DELIMITER ;
--
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `account_conciliacion_add` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `account_conciliacion_add`()
-BEGIN
- UPDATE account_conciliacion ac
- JOIN
- (
- SELECT idaccount_conciliacion, @c:= if(@id = id_calculated, @c + 1, 1) contador,
- @id:= id_calculated as id_calculated, concat(id_calculated,'(',@c,')') as new_id
- FROM account_conciliacion
- JOIN
- (
- select id_calculated, count(*) rep, @c:= 0, @id:= concat('-',id_calculated)
- from account_conciliacion
- group by id_calculated
- having rep > 1
- ) sub using(id_calculated)
- ) sub2 using(idaccount_conciliacion)
- SET ac.id_calculated = sub2.new_id;
-
- INSERT INTO Cajas(Cajafecha, Partida, Serie, Concepto, Entrada,
- Salida, Id_Banco,empresa_id, warehouse_id,
- Proveedores_account_id, id_calculated, InForeignValue, OutForeignValue, Id_Trabajador)
- SELECT Fechaoperacion, TRUE, 'MB', ac.Concepto, IF(DebeHaber = 2 AND currencyFk = 1, importe,null),
- IF(DebeHaber = 1 AND currencyFk = 1, importe, null), a.id, sa.supplierFk, 1,
- ac.Id_Proveedores_account, ac.id_calculated, IF(DebeHaber = 2 AND NOT currencyFk = 1, importe, null),
- IF(DebeHaber = 1 AND NOT currencyFk = 1, importe, null), account.myUser_getId()
- FROM account_conciliacion ac
- JOIN vn.supplierAccount sa on sa.id = ac.Id_Proveedores_account
- JOIN vn.accounting a ON a.id = sa.accountingFk
- LEFT JOIN Cajas c on c.id_calculated = ac.id_calculated
- WHERE c.Id_Caja IS NULL;
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `add_awb_component` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `add_awb_component`(IN vAwbFk SMALLINT)
-BEGIN
-
- DECLARE vShipped DATE;
- DECLARE vHasStems BOOLEAN;
-
- SELECT t.shipped, IF(a.stems, TRUE, FALSE)
- INTO vShipped, vHasStems
- FROM vn.travel t
- JOIN vn.awb a ON a.id = t.awbFk
- WHERE awbFk = vAwbFk
- LIMIT 1;
-
- INSERT IGNORE INTO awb_component (awb_id,Id_Proveedor,awb_component_type_id,awb_role_id,awb_unit_id,value,Id_Moneda)
- SELECT id, Id_Proveedor, awb_component_type_id, awb_role_id,awb_unit_id, LEAST(GREATEST(value1, IFNULL(min_value, value1)), IFNULL(max_value, value1)), Id_Moneda
- FROM (
- SELECT a.id,
- IFNULL(act.carguera_id,
- CASE awb_role_id
- WHEN 1 THEN a.carguera_id
- WHEN 2 THEN a.transitario_id
- WHEN 3 THEN f.airline_id
- END
- ) Id_Proveedor,
- act.awb_component_type_id,
- act.awb_role_id,
- act.awb_unit_id,
- value *
- CASE awb_unit_id
- WHEN '1000Tj-20' THEN ((CAST(stems AS SIGNED) - 20000)/1000) + (min_value / value)
- WHEN '1000Tj-10' THEN ((CAST(stems AS SIGNED) - 10000)/1000) + (min_value / value)
- WHEN '100GW' THEN peso/100
- WHEN 'AWB' THEN 1 -- No action
- WHEN 'FB' THEN hb/2
- WHEN 'GW' THEN peso
- WHEN 'TW' THEN GREATEST(peso,volume_weight)
- WHEN 'PN' THEN LEAST(90, value + a.propertyNumber * 10)
- END value1,
- value,
- act.Id_Moneda,
- act.min_value,
- act.max_value
- FROM awb a
- JOIN flight f ON f.flight_id = a.flight_id
- LEFT JOIN awb_component_template act ON
- ((IFNULL(act.carguera_id, a.carguera_id) = a.carguera_id AND awb_role_id = 1)
- OR (IFNULL(act.carguera_id, a.transitario_id) = a.transitario_id AND awb_role_id = 2)
- OR (IFNULL(act.airline_id, f.airline_id) = f.airline_id AND awb_role_id = 3)
- OR (awb_role_id = 4))
- AND IFNULL(act.airport_out, f.airport_out) = f.airport_out
- AND IFNULL(act.airport_in, f.airport_in) = f.airport_in
- AND IFNULL(act.airline_id, f.airline_id) = f.airline_id
- AND INSTR(IFNULL(act.days, WEEKDAY(vShipped) + 1),WEEKDAY(vShipped) + 1)
- JOIN awb_component_type acty ON acty.awb_component_type_id = act.awb_component_type_id
- WHERE a.id = vAwbFk AND Fecha <= vShipped
- AND (vHasStems = TRUE OR acty.hasStems)
- ORDER BY Fecha DESC, act.days DESC LIMIT 10000000000000000000
- ) t;
-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_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `agencia_volume` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `agencia_volume`()
-BEGIN
- DECLARE vStarted DATETIME DEFAULT TIMESTAMP(util.VN_CURDATE());
- DECLARE vEnded DATETIME DEFAULT TIMESTAMP(util.VN_CURDATE(), '23:59:59');
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticket_PackagingEstimated;
- CREATE TEMPORARY TABLE tmp.ticket_PackagingEstimated
- (
- ticketFk INT PRIMARY KEY
- ,boxes INT DEFAULT 0
- );
-
- INSERT INTO tmp.ticket_PackagingEstimated(ticketFk, boxes)
- SELECT sv.ticketFk, CEIL(1000 * sum(sv.volume) / vc.standardFlowerBox)
- FROM vn.ticket t
- JOIN vn.saleVolume sv ON sv.ticketFk = t.id
- JOIN vn.volumeConfig vc
- WHERE t.shipped BETWEEN vStarted AND vEnded
- AND IFNULL(t.packages,0) = 0
- GROUP BY t.id;
- SELECT * FROM
- (
- SELECT ag.id agency_id,
- CONCAT(RPAD(c.country, 16,' _') ,' ',ag.name) Agencia,
- count(*) expediciones,
- sum(t.packages) Bultos,
- sum(tpe.boxes) Faltan
- FROM vn.ticket t
- JOIN vn.warehouse w ON w.id = t.warehouseFk
- JOIN vn.country c ON w.countryFk = c.id
- JOIN vn.address a ON a.id = t.addressFk
- JOIN vn.agencyMode am ON am.id = t.agencyModeFk
- JOIN vn.agency ag ON ag.id = am.agencyFk
- JOIN tmp.ticket_PackagingEstimated tpe ON tpe.ticketFk = t.id
- WHERE t.shipped BETWEEN vStarted AND vEnded
- AND ag.isOwn = FALSE
- GROUP BY ag.id
- ) sub
- ORDER BY Agencia;
-
- DROP TEMPORARY TABLE tmp.ticket_PackagingEstimated;
-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_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `agencyModeImbalance` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `agencyModeImbalance`(vStarted DATE, vEnded DATE)
-BEGIN
-/**
- * Devuelve el valor de los precios teorico, practico de las agencias
- * y si ademas es de mrw lo compara con su fichero previamente procesado
- *
- * @param vEktFk Identificador de edi.ekt
- */
- DECLARE vEndedDayEnd DATETIME;
-
- SET vEndedDayEnd = util.dayEnd(vEnded);
-
- SELECT t.id ticketFk,t.addressFk,
- CAST(v.amount AS DECIMAL (10,2)) AS VN,
- CAST(v.amount - e.shipping_charge AS DECIMAL (10,2)) AS Difer,
- CAST(mrwPrice AS DECIMAL (10,2)) mrwPrice,
- CAST(e.shipping_charge - mrwPrice AS DECIMAL (10,2)) mrwDifference,
- CAST(e.shipping_charge AS DECIMAL (10,2)) AS teorico,
- CAST(e.extraCharge AS DECIMAL (10,2)) AS extraCharge,
- t.packages, t.clientFk,
- t.zoneFk, a.provinceFk, mrwCount
- FROM vn.ticket t
- LEFT JOIN
- (SELECT ticketFk, SUM(amount) amount, fc.shipped
- FROM vn.sale_freightComponent fc
- JOIN vn.ticket t ON t.id = fc.ticketFk
- JOIN tmp.agencyMode am ON am.agencyModeFk = t.agencyModeFk
- WHERE fc.shipped BETWEEN vStarted AND vEndedDayEnd
- GROUP BY ticketFk) v ON t.id = v.ticketFk
- LEFT JOIN (SELECT t.id,
- SUM(t.zonePrice) shipping_charge,
- SUM(IFNULL(aex.price,0)) extraCharge
- FROM vn.ticket t
- LEFT JOIN vn.expedition e ON e.ticketFk = t.id
- LEFT JOIN vn.packaging p ON p.id = e.packagingFk
- JOIN tmp.agencyMode amc ON amc.agencyModeFk = t.agencyModeFk
- JOIN vn.agencyMode am ON am.id = amc.agencyModeFk
- LEFT JOIN vn.agencyExtraCharge aex ON p.width+p.depth+p.height BETWEEN aex.sizeMin AND aex.sizeMax AND aex.agencyFk = am.agencyFk
- WHERE t.shipped BETWEEN vStarted AND vEndedDayEnd
- GROUP BY t.id
- ) e ON t.id = e.id
- LEFT JOIN (SELECT ticketFk, SUM(price) mrwPrice, COUNT(*) mrwCount
- FROM vn.mrw
- GROUP BY ticketFk) mrw ON mrw.ticketFk = t.id
- JOIN vn.address a ON a.id = t.addressFk
- JOIN tmp.agencyMode am ON am.agencyModeFk = t.agencyModeFk
- WHERE t.shipped BETWEEN vStarted AND vEndedDayEnd;
-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_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `article` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `article`()
-BEGIN
-/**
- * Crea la tabla temporal: article_inventory
- */
- DROP TEMPORARY TABLE IF EXISTS article_inventory;
- CREATE TEMPORARY TABLE article_inventory
- (
- `article_id` INT(11) NOT NULL PRIMARY KEY,
- `future` DATETIME
- )
- ENGINE = MEMORY;
-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_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `article_multiple_buy` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -84486,1599 +85823,6 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `cacheReset` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `cacheReset`(vCacheName VARCHAR(10), vParams VARCHAR(15))
-BEGIN
-
- UPDATE cache.cache_calc
- SET expires = util.VN_NOW()
- WHERE cacheName = vCacheName collate utf8_unicode_ci
- AND params = vParams collate utf8_unicode_ci;
-
-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_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `CalculoRemesas` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `CalculoRemesas`(IN vFechaRemesa DATE)
-BEGIN
-
- DROP TEMPORARY TABLE IF EXISTS TMP_REMESAS;
- CREATE TEMPORARY TABLE TMP_REMESAS
- SELECT
- CONCAT(p.NIF,REPEAT('0', 12-LENGTH(p.NIF))) as CIF1,
- cli.Id_Cliente,
- cli.Cliente,
- cli.`IF` as NIF,
- c.PaymentDate as Vencimiento,
- 0 ImporteFac,
- cast(c.Recibo as decimal(10,2)) as ImporteRec,
- 0 as ImporteActual,
- c.companyFk empresa_id,
- cli.RazonSocial,
- cast(c.Recibo as decimal(10,2)) as ImporteTotal,
- cast(c.Recibo as decimal(10,2)) as Saldo,
- p.Proveedor as Empresa,
- e.abbreviation as EMP,
- cli.cuenta,
- iban AS Iban,
- CONVERT(SUBSTRING(iban,5,4),UNSIGNED INT) AS nrbe,
- sepavnl as SEPA,
- corevnl as RecibidoCORE,
- hasLcr,
- be.bic,
- be.`name` entityName
- FROM Clientes cli
- JOIN
- (SELECT risk.companyFk,
- c.Id_Cliente,
- sum(risk.amount) as Recibo,
- IF((c.Vencimiento + graceDays) mod 30.001 <= day(vFechaRemesa)
- ,TIMESTAMPADD(DAY, (c.Vencimiento + graceDays) MOD 30.001, LAST_DAY(TIMESTAMPADD(MONTH,-1,vFechaRemesa)))
- ,TIMESTAMPADD(DAY, (c.Vencimiento + graceDays) MOD 30.001, LAST_DAY(TIMESTAMPADD(MONTH,-2,vFechaRemesa)))
- ) as PaymentDate
- FROM Clientes c
- JOIN pay_met pm on pm.id = pay_met_id
- JOIN
- (
- SELECT companyFk, clientFk, amount
- FROM Clientes c
- JOIN vn.clientRisk cr ON cr.clientFk = c.Id_Cliente
- WHERE pay_met_id = 4
-
- UNION ALL
-
- SELECT io.companyFk, io.clientFk Id_Cliente, - io.amount
- FROM vn.invoiceOut io
- JOIN Clientes c ON c.Id_Cliente = io.clientFk
- JOIN pay_met pm on pm.id = pay_met_id
- WHERE io.dued > vFechaRemesa
- AND pay_met_id = 4 AND pm.deudaviva
- AND io.amount > 0
-
- ) risk ON c.Id_Cliente = risk.clientFk
- GROUP BY risk.companyFk, Id_Cliente
- HAVING Recibo > 10
- ) c on c.Id_Cliente = cli.Id_Cliente
- JOIN Proveedores p on p.Id_Proveedor = c.companyFk
- JOIN empresa e on e.id = c.companyFk
- LEFT JOIN vn.bankEntity be ON be.id = cli.bankEntityFk;
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `camiones` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `camiones`(vWarehouse INT, vDate DATE)
-BEGIN
- SELECT Temperatura
- ,ROUND(SUM(Etiquetas * volume)) AS cm3
- ,ROUND(SUM(IF(scanned, Etiquetas, 0) * volume)) AS cm3s
- ,ROUND(SUM(Vida * volume)) AS cm3e
- FROM (
- SELECT t.Temperatura, c.Etiquetas, b.scanned, c.Vida,
- IF(cu.Volumen > 0, cu.Volumen, cu.x * cu.y * IF(cu.z > 0, cu.z, a.Medida + 10)) volume
- FROM Compres c
- LEFT JOIN buy_edi b ON b.id = c.buy_edi_id
- JOIN Articles a ON a.Id_Article = c.Id_Article
- JOIN Tipos t ON t.tipo_id = a.tipo_id
- JOIN Entradas e ON e.Id_Entrada = c.Id_Entrada
- JOIN travel tr ON tr.id = e.travel_id
- JOIN Cubos cu ON cu.Id_Cubo = c.Id_Cubo
- WHERE tr.warehouse_id = vWarehouse
- AND tr.landing = vDate
- ) sub
- GROUP BY Temperatura;
-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_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `clean` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `clean`(IN `v_full` TINYINT(1))
-proc: BEGIN
- DECLARE vDate DATETIME;
- DECLARE vDate18 DATETIME;
- DECLARE vDate26 DATETIME;
- DECLARE vDate8 DATE;
- DECLARE vDate6 DATE;
- DECLARE vDate3 DATE;
- DECLARE vDate2000 DATE;
- DECLARE vRangeDeleteTicket INT;
- DECLARE vStrtable VARCHAR(15) DEFAULT NULL;
-
- SET vDate = util.VN_CURDATE() - INTERVAL 2 MONTH;
- SET vDate18 = util.VN_CURDATE() - INTERVAL 18 MONTH;
- SET vDate26 = util.VN_CURDATE() - INTERVAL 26 MONTH;
- SET vDate3 = util.VN_CURDATE() - INTERVAL 3 MONTH;
- SET vDate8 = util.VN_CURDATE() - INTERVAL 8 DAY;
- SET vDate6 = util.VN_CURDATE() - INTERVAL 6 DAY;
- SET vDate2000 = util.VN_CURDATE() + INTERVAL (2000 - YEAR(util.VN_CURDATE())) YEAR;
- SET vRangeDeleteTicket = 60;
-
- DELETE FROM cdr WHERE calldate < vDate18;
- DELETE FROM mail WHERE DATE_ODBC < vDate;
- DELETE FROM Movimientos_mark WHERE odbc_date < vDate;
- DELETE FROM Splits WHERE Fecha < vDate18;
-
- DELETE tobs
- FROM ticket_observation tobs
- JOIN Tickets t ON tobs.Id_Ticket = t.Id_Ticket
- WHERE t.Fecha < vDate;
-
- DELETE tobs
- FROM movement_label tobs
- JOIN Movimientos m ON tobs.Id_Movimiento = m.Id_Movimiento
- JOIN Tickets t ON m.Id_Ticket = t.Id_Ticket WHERE t.Fecha < vDate;
-
- DELETE FROM Remesas WHERE `Fecha Remesa` < vDate18;
-
- DELETE tt.*
- FROM Tickets_turno tt
- LEFT JOIN Movimientos m USING(Id_Ticket)
- WHERE m.Id_Article IS NULL;
-
- DELETE FROM cl_main WHERE Fecha < vDate18;
- DELETE FROM hedera.`order` WHERE date_send < vDate18;
- DELETE FROM vn.message WHERE sendDate < vDate;
- DELETE FROM travel_reserve WHERE odbc_date < vDate;
-
- DELETE FROM cache.departure_limit WHERE Fecha < util.VN_CURDATE() - INTERVAL 1 MONTH;
-
- DELETE cm
- FROM Compres_mark cm
- JOIN Compres c ON c.Id_Compra = cm.Id_Compra
- JOIN Entradas e ON e.Id_Entrada = c.Id_Entrada
- JOIN travel t ON t.id = e.travel_id
- WHERE t.landing <= vDate;
-
- IF v_full THEN
- CREATE OR REPLACE TEMPORARY TABLE tTicketDelete
- SELECT DISTINCT tl.originFk ticketFk
- FROM vn.ticketLog tl
- JOIN (SELECT MAX(tl.id)ids
- FROM vn.ticket t
- JOIN vn.ticketLog tl ON tl.originFk = t.id
- WHERE t.shipped BETWEEN '2000-01-01' AND '2000-12-31'
- AND t.isDeleted
- GROUP BY t.id
- )sub ON sub.ids = tl.id
- WHERE tl.creationDate <= util.VN_CURDATE() - INTERVAL 60 DAY;
-
- DELETE t
- FROM vn.ticket t
- JOIN tTicketDelete tmp ON tmp.ticketFk = t.id;
-
- DROP TEMPORARY TABLE tTicketDelete;
- END IF;
-
- -- Tickets Nulos PAK 11/10/2016
- UPDATE Tickets
- SET empresa_id = 965
- WHERE Id_Cliente = 31
- AND empresa_id != 965;
-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_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `clean_launcher` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `clean_launcher`()
-BEGIN
- CALL clean(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 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `cobro` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `cobro`(IN datFEC DATE
- , IN idCLI INT
- , IN dblIMPORTE DOUBLE
- , IN idCAJA INT
- , IN idPAYMET INT
- , IN strCONCEPTO VARCHAR(40)
- , IN idEMP INT
- , IN idWH INT
- , IN idTRABAJADOR INT)
-BEGIN
-
- DECLARE bolCASH BOOLEAN;
- DECLARE cuenta_banco BIGINT;
- DECLARE cuenta_cliente BIGINT;
- DECLARE max_asien INT;
- -- XDIARIO
- -- No se asientan los cobros directamente, salvo en el caso de las cajas de CASH
- SELECT (at2.code = 'cash') INTO bolCASH FROM Bancos b JOIN vn.accountingType at2 ON at2.id = b.cash WHERE b.Id_Banco = idCAJA;
- IF bolCASH THEN
- SELECT Cuenta INTO cuenta_banco
- FROM Bancos
- WHERE Id_Banco = idCAJA;
- SELECT Cuenta INTO cuenta_cliente
- FROM Clientes
- WHERE Id_Cliente = idCLI;
- CALL vn.ledger_next(max_asien);
- INSERT INTO vn.XDiario (ASIEN,FECHA,SUBCTA,CONTRA,CONCEPTO,EURODEBE,EUROHABER,empresa_id)
- SELECT max_asien,datFEC,SUBCTA,CONTRA,strCONCEPTO,EURODEBE,EUROHABER,idEMP
- FROM(SELECT cuenta_banco SUBCTA, cuenta_cliente CONTRA, 0 EURODEBE, dblIMPORTE EUROHABER
- UNION ALL
- SELECT cuenta_cliente SUBCTA, cuenta_banco CONTRA, dblIMPORTE EURODEBE, 0 EUROHABER
- ) gf;
- END IF;
-
- -- CAJERA
- INSERT INTO Cajas(Id_Trabajador,
- Id_Banco,
- Entrada,
- Concepto,
- Cajafecha,
- Serie,
- Partida,
- Numero,
- empresa_id,
- warehouse_id
- )
- VALUES (idTRABAJADOR,
- idCAJA,
- dblIMPORTE,
- strCONCEPTO,
- datFEC,
- 'A',
- TRUE,
- idCLI,
- idEMP,
- idWH
- );
-
- -- RECIBO
- INSERT INTO Recibos(Entregado,
- Fechacobro,
- Id_Trabajador,
- Id_Banco,
- Id_Cliente,
- Id_Factura,
- empresa_id
- )
- VALUES ( dblIMPORTE,
- datFEC,
- idTRABAJADOR,
- idCAJA,
- idCLI,
- strCONCEPTO,
- idEMP
- );
-
-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_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `confection_control_source` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `confection_control_source`(vDated DATE, vScopeDays TINYINT)
-BEGIN
-
- DECLARE vMidnight DATETIME DEFAULT TIMESTAMP(vDated,'23:59:59');
- DECLARE vEndingDate DATETIME DEFAULT TIMESTAMPADD(DAY,vScopeDays,vMidnight);
- DECLARE maxAlertLevel INT DEFAULT 2;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.production_buffer;
-
- CREATE TEMPORARY TABLE tmp.production_buffer
- ENGINE = MEMORY
- SELECT
- date(t.Fecha) as Fecha,
- hour(t.Fecha) as Hora,
- hour(t.Fecha) as Departure,
- t.Id_Ticket,
- m.Id_Movimiento,
- m.Cantidad,
- m.Concepte,
- ABS(m.Reservado) Reservado,
- i.Categoria,
- tp.Tipo,
- t.Alias as Cliente,
- wh.name as Almacen,
- t.warehouse_id,
- cs.province_id,
- a.agency_id,
- ct.description as Taller,
- stock.visible,
- stock.available
- FROM vn2008.Tickets t
- JOIN vn2008.Agencias a ON a.Id_Agencia = t.Id_Agencia
- JOIN vn.warehouse wh ON wh.id = t.warehouse_id
- JOIN vn2008.Movimientos m ON m.Id_Ticket = t.Id_Ticket
- JOIN vn2008.Articles i ON i.Id_Article = m.Id_Article
- JOIN vn2008.Tipos tp ON tp.tipo_id = i.tipo_id
- JOIN vn.confectionType ct ON ct.id = tp.confeccion
- JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.Id_Consigna
- LEFT JOIN vn.ticketState tls on tls.ticketFk = t.Id_Ticket
- LEFT JOIN
- (
- SELECT item_id, sum(visible) visible, sum(available) available
- FROM
- (
- SELECT a.item_id, 0 as visible, a.available
- FROM cache.cache_calc cc
- LEFT JOIN cache.available a ON a.calc_id = cc.id
- WHERE cc.cache_id IN (2,8)
- AND cc.params IN (concat("1/", util.VN_CURDATE()),concat("44/", util.VN_CURDATE()))
-
- UNION ALL
-
- SELECT v.item_id, v.visible, 0 as available
- FROM cache.cache_calc cc
- LEFT JOIN cache.visible v ON v.calc_id = cc.id
- where cc.cache_id IN (2,8) and cc.params IN ("1","44")
- ) sub
- GROUP BY item_id
- ) stock ON stock.item_id = m.Id_Article
- WHERE tp.confeccion
- AND tls.alertLevel < maxAlertLevel
- AND wh.hasConfectionTeam
- AND t.Fecha BETWEEN vDated AND vEndingDate
- AND m.Cantidad > 0;
-
- -- Entradas
-
- INSERT INTO tmp.production_buffer(
- Fecha,
- Id_Ticket,
- Cantidad,
- Concepte,
- Categoria,
- Cliente,
- Almacen,
- Taller
- )
- SELECT
- tr.shipment AS Fecha,
- e.Id_Entrada AS Id_Ticket,
- c.Cantidad,
- a.Article,
- a.Categoria,
- whi.name as Cliente,
- who.name as Almacen,
- ct.description as Taller
- FROM vn2008.Compres c
- JOIN vn2008.Entradas e ON e.Id_Entrada = c.Id_Entrada
- JOIN vn2008.travel tr ON tr.id = e.travel_id
- JOIN vn.warehouse whi ON whi.id = tr.warehouse_id
- JOIN vn.warehouse who ON who.id = tr.warehouse_id_out
- JOIN vn2008.Articles a ON a.Id_Article = c.Id_Article
- JOIN vn2008.Tipos tp ON tp.tipo_id = a.tipo_id
- JOIN vn.confectionType ct ON ct.id = tp.confeccion
- WHERE who.hasConfectionTeam
- AND tp.confeccion
- AND tr.shipment BETWEEN vDated AND vEndingDate;
-
-
- SELECT * FROM tmp.production_buffer;
-
-
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `customerDebtEvolution` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `customerDebtEvolution`(IN vCustomer INT)
-BEGIN
-
-SELECT * FROM
-(
- SELECT day, date, @s:= round(IFNULL(Euros,0) + @s,2) as Saldo, Euros, Credito, 0 as Cero
- FROM
- (
- SELECT day, date, IFNULL(Euros,0) as Euros, Credito
- FROM time
- JOIN (SELECT @s:= 0, - Credito as Credito FROM Clientes WHERE Id_Cliente = vCustomer) c
- LEFT JOIN
- (SELECT Euros, date(Fecha) as Fecha FROM
- (
- SELECT Fechacobro as Fecha, Entregado as Euros
- FROM Recibos
- WHERE Id_Cliente = vCustomer
- AND Fechacobro >= '2017-01-01'
- UNION ALL
- SELECT vn.getDueDate(io.issued,c.Vencimiento), - io.amount
- FROM vn.invoiceOut io
- JOIN Clientes c ON io.clientFk = c.Id_Cliente
- WHERE io.clientFk = vCustomer
- AND io.issued >= '2017-01-01'
- UNION ALL
- SELECT '2016-12-31', Debt
- FROM bi.customerDebtInventory
- WHERE Id_Cliente = vCustomer
- UNION ALL
- SELECT Fecha, - SUM(Cantidad * Preu * (100 - Descuento ) * 1.10 / 100)
- FROM Tickets t
- JOIN Movimientos m on m.Id_Ticket = t.Id_Ticket
- WHERE Id_Cliente = vCustomer
- AND Factura IS NULL
- AND Fecha >= '2017-01-01'
- GROUP BY Fecha
- ) sub2
- ORDER BY Fecha
- )sub ON time.date = sub.Fecha
- WHERE time.date BETWEEN '2016-12-31' AND util.VN_CURDATE()
- ORDER BY date
- ) sub3
-)sub4
-;
-
-
-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_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `emailYesterdayPurchasesByConsigna` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `emailYesterdayPurchasesByConsigna`(IN v_Date DATE, IN v_Client_Id INT)
-BEGIN
-
- DECLARE MyIdTicket BIGINT;
- DECLARE MyAlias VARCHAR(50);
- DECLARE MyDomicilio VARCHAR(255);
- DECLARE MyPoblacion VARCHAR(25);
- DECLARE MyImporte DOUBLE;
- DECLARE MyMailTo VARCHAR(250);
- DECLARE MyMailReplyTo VARCHAR(250);
- DECLARE done INT DEFAULT FALSE;
- DECLARE emptyList INT DEFAULT 0;
- DECLARE txt TEXT;
-
- DECLARE rs CURSOR FOR
- SELECT t.Id_Ticket, Alias, cast(amount as decimal(10,2)) Importe, Domicilio, POBLACION
- FROM Tickets t
- JOIN Consignatarios cs ON t.Id_Consigna = cs.Id_Consigna
- JOIN (
- SELECT `Movimientos`.`Id_Ticket` AS `Id_Ticket`,
- sum(
- `Movimientos`.`Cantidad` * `Movimientos`.`Preu` * (100 - `Movimientos`.`Descuento`) / 100
- ) AS `amount`
- FROM (
- `vn2008`.`Movimientos`
- JOIN `vn2008`.`Tickets` ON(
- `Movimientos`.`Id_Ticket` = `Tickets`.`Id_Ticket`
- )
- )
- WHERE `Tickets`.`Fecha` >= `util`.`VN_CURDATE`() + INTERVAL -6 MONTH
- GROUP BY `Movimientos`.`Id_Ticket`
- ) v ON v.Id_Ticket = t.Id_Ticket
- WHERE t.Fecha BETWEEN v_Date AND util.dayEnd(v_Date)
- AND t.Id_Cliente = v_Client_Id;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
-
- SET v_Date = IFNULL(v_Date, util.yesterday());
-
- OPEN rs;
-
- FETCH rs INTO MyIdTicket, MyAlias, MyImporte, MyDomicilio, MyPoblacion;
-
- SET emptyList = done;
-
- SET txt = CONCAT('',
- ' Relación de envíos.
',
- 'Dia: ', v_Date, '
');
-
- WHILE NOT done DO
-
- SET txt = CONCAT(txt, '
',
- ''
- , ' ', MyAlias, '
'
- , ' ', MyDomicilio, '(', MyPoblacion, ')');
-
- FETCH rs INTO MyIdTicket, MyAlias, MyImporte, MyDomicilio, MyPoblacion;
-
- END WHILE;
-
- SET txt = CONCAT(
- txt,
- '',
- '
Puede acceder al detalle de los albaranes haciendo click sobre el número de Ticket',
- '
Muchas gracias por su confianza
',
- '
');
-
- -- Envío del email
- IF emptyList = 0 THEN
-
- SELECT CONCAT(`e-mail`,',pako@verdnatura.es') INTO MyMailTo
- FROM Clientes
- WHERE Id_Cliente = v_Client_Id AND `e-mail`>'';
-
- IF v_Client_Id = 7818 THEN -- LOEWE
- SET MyMailTo = 'isabel@elisabethblumen.com,emunozca@loewe.es,pako@verdnatura.es';
- END IF;
-
- CALL vn.mail_insert(
- IFNULL(MyMailTo,'pako.natek@gmail.com'),
- 'pako@verdnatura.es',
- 'Resumen de pedidos preparados',
- txt
- );
-
- 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_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `emailYesterdayPurchasesLauncher` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `emailYesterdayPurchasesLauncher`()
-BEGIN
-
-DECLARE done INT DEFAULT 0;
-DECLARE vMyClientId INT;
-
-DECLARE rs CURSOR FOR
-SELECT Id_Cliente
-FROM Clientes
-WHERE EYPBC != 0;
-
-DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
-
-OPEN rs;
-
-FETCH rs INTO vMyClientId;
-
-WHILE NOT done DO
-
- CALL emailYesterdayPurchasesByConsigna(util.yesterday(), vMyClientId);
-
- FETCH rs INTO vMyClientId;
-
-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 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `embalajes_stocks` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `embalajes_stocks`(IN idPEOPLE INT, IN bolCLIENT BOOLEAN)
-BEGIN
-
-if bolCLIENT then
-
- select m.Id_Article, Article, - cast(sum(m.Cantidad) as decimal) as Saldo
- from Movimientos m
- join Articles a on m.Id_Article = a.Id_Article
- join Tipos tp on tp.tipo_id = a.tipo_id
- join Tickets t using(Id_Ticket)
- join Consignatarios cs using(Id_Consigna)
- where cs.Id_Cliente = idPEOPLE
- and Tipo = 'Contenedores'
- and t.Fecha > '2010-01-01'
- group by m.Id_Article;
-
-else
-
-select Id_Article, Article, sum(Cantidad) as Saldo
-from
-(select Id_Article, Cantidad
-from Compres c
-join Articles a using(Id_Article)
-join Tipos tp using(tipo_id)
-join Entradas e using(Id_Entrada)
-join travel tr on tr.id = travel_id
-where Id_Proveedor = idPEOPLE
-and landing >= '2010-01-01'
-and reino_id = 6
-
-union all
-
-select Id_Article, - Cantidad
-from Movimientos m
-join Articles a using(Id_Article)
-join Tipos tp using(tipo_id)
-join Tickets t using(Id_Ticket)
-join Consignatarios cs using(Id_Consigna)
-join proveedores_clientes pc on pc.Id_Cliente = cs.Id_Cliente
-where Id_Proveedor = idPEOPLE
-and reino_id = 6
-and t.Fecha > '2010-01-01') mov
-
-join Articles a using(Id_Article)
-group by Id_Article;
-
-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_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `embalajes_stocks_detalle` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `embalajes_stocks_detalle`(IN idPEOPLE INT, IN idARTICLE INT, IN bolCLIENT BOOLEAN)
-BEGIN
-
-
-if bolCLIENT then
-
- select m.Id_Article
- , Article
- , IF(Cantidad < 0, - Cantidad, NULL) as Entrada
- , IF(Cantidad < 0, NULL, Cantidad) as Salida
- , 'T' as Tabla
- , t.Id_Ticket as Registro
- , t.Fecha
- , w.name as Almacen
- , cast(Preu as Decimal(5,2)) Precio
- , c.Cliente as Proveedor
- , abbreviation as Empresa
- from Movimientos m
- join Articles a using(Id_Article)
- join Tickets t using(Id_Ticket)
- join empresa e on e.id = t.empresa_id
- join warehouse w on w.id = t.warehouse_id
- join Consignatarios cs using(Id_Consigna)
- join Clientes c on c.Id_Cliente = cs.Id_Cliente
- where cs.Id_Cliente = idPEOPLE
- and m.Id_Article = idARTICLE
- and t.Fecha > '2010-01-01';
-
-else
-
-select Id_Article, Tabla, Registro, Fecha, Article
-, w.name as Almacen, Entrada, Salida, Proveedor, cast(Precio as Decimal(5,2)) Precio
-
-from
-
-(select Id_Article
- , IF(Cantidad > 0, Cantidad, NULL) as Entrada
- , IF(Cantidad > 0, NULL,- Cantidad) as Salida
- , 'E' as Tabla
- , Id_Entrada as Registro
- , landing as Fecha
- , tr.warehouse_id
- , Costefijo as Precio
-from Compres c
-join Entradas e using(Id_Entrada)
-join travel tr on tr.id = travel_id
-where Id_Proveedor = idPEOPLE
-and Id_Article = idARTICLE
-and landing >= '2010-01-01'
-
-union all
-
-select Id_Article
- , IF(Cantidad < 0, - Cantidad, NULL) as Entrada
- , IF(Cantidad < 0, NULL, Cantidad) as Salida
- , 'T'
- , Id_Ticket
- , Fecha
- , t.warehouse_id
- , Preu
-from Movimientos m
-join Tickets t using(Id_Ticket)
-join Consignatarios cs using(Id_Consigna)
-join proveedores_clientes pc on pc.Id_Cliente = cs.Id_Cliente
-where Id_Proveedor = idPEOPLE
-and Id_Article = idARTICLE
-and t.Fecha > '2010-01-01') mov
-
-join Articles a using(Id_Article)
-join Proveedores p on Id_Proveedor = idPEOPLE
-join warehouse w on w.id = mov.warehouse_id
-;
-
-end if;
-
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `historico_absoluto` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `historico_absoluto`(IN idART INT, IN wh INT, IN datfecha DATETIME)
-BEGIN
-
- DECLARE inv_calculado INT;
- DECLARE inv INT;
- DECLARE today DATETIME;
- DECLARE fecha_inv DATETIME;
-
- SET today = util.VN_CURDATE();
-
- CREATE OR REPLACE TEMPORARY TABLE historico_pasado
- SELECT *
- FROM (
- SELECT TR.landing Fecha,
- C.Cantidad Entrada,
- NULL Salida,
- (TR.received != FALSE) OK,
- P.Proveedor Alias,
- E.Referencia Referencia,
- E.Id_Entrada id,
- TR.delivered F5
- FROM Compres C -- mirar perque no entra en received
- INNER JOIN Entradas E USING (Id_Entrada)
- INNER JOIN travel TR ON TR.id = E.travel_id
- INNER JOIN Proveedores P USING (Id_Proveedor)
- WHERE TR.landing >= '2001-01-01'
- AND Id_proveedor <> 4
- AND wh IN (TR.warehouse_id , 0)
- AND C.Id_Article = idART
- AND E.Inventario = 0
- AND E.Redada = 0
- UNION ALL
- SELECT TR.shipment Fecha,
- NULL Entrada,
- C.Cantidad Salida,
- TR.delivered OK,
- P.Proveedor Alias,
- E.Referencia Referencia,
- E.Id_Entrada id,
- TR.delivered F5
- FROM Compres C
- INNER JOIN Entradas E USING (Id_Entrada)
- INNER JOIN travel TR ON TR.id = E.travel_id
- INNER JOIN Proveedores P USING (Id_Proveedor)
- WHERE TR.shipment >= '2001-01-01'
- AND wh = TR.warehouse_id_out
- AND Id_Proveedor <> 4
- AND C.Id_Article = idART
- AND E.Inventario = 0
- AND E.Redada = 0
- UNION ALL
- SELECT T.Fecha Fecha,
- NULL Entrada,
- M.Cantidad Salida,
- (M.OK <> 0 OR T.Etiquetasemitidas <> 0 OR T.Factura IS NOT NULL) OK,
- T.Alias Alias,
- T.Factura Referencia,
- T.Id_Ticket,
- T.PedidoImpreso
- FROM Movimientos M
- INNER JOIN Tickets T USING (Id_Ticket)
- JOIN Clientes C ON C.Id_Cliente = T.Id_Cliente
- WHERE T.Fecha >= '2001-01-01'
- AND M.Id_Article = idART
- AND wh IN (T.warehouse_id , 0)
- ) t1
- ORDER BY Fecha, Entrada DESC, OK DESC;
-
- SELECT sum(Entrada) - sum(Salida) INTO inv_calculado
- FROM historico_pasado
- WHERE Fecha < datfecha;
-
- SELECT p1.*, NULL v_virtual
- FROM(
- SELECT datfecha Fecha,
- inv_calculado Entrada,
- NULL Salida,
- 1 OK,
- 'Inventario calculado' Alias,
- '' Referencia, 0 id,
- 1 F5
- UNION ALL
- SELECT *
- FROM historico_pasado
- WHERE Fecha >= datfecha
- ) p1;
-
- DROP TEMPORARY TABLE historico_pasado;
-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_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `historico_multiple` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `historico_multiple`(IN vItemFk INT)
-BEGIN
-
- DECLARE vDateInventory DATETIME;
-
- SELECT Fechainventario INTO vDateInventory FROM tblContadores;
-
- SET @a = 0;
-
- DROP TEMPORARY TABLE IF EXISTS hm1;
-
- CREATE TEMPORARY TABLE hm1
- SELECT DATE(Fecha) as Fecha,
- Entrada,
- Salida,
- OK,
- Referencia,
- Historia.id,
-
- wh,
-
- `name` as wh_name
-
- FROM
-
- ( SELECT TR.landing as Fecha,
- C.Cantidad as Entrada,
- NULL as Salida,
-
- IF(warehouse_id = 44, 1, warehouse_id) as wh,
- (TR.received != FALSE) as OK,
- E.Referencia as Referencia,
- E.Id_Entrada as id
-
-
-
- FROM Compres C
- INNER JOIN Entradas E USING (Id_Entrada)
- INNER JOIN travel TR ON TR.id = E.travel_id
- WHERE TR.landing >= vDateInventory
- AND C.Id_Article = vItemFk
- AND E.Redada = 0
-
- AND C.Cantidad <> 0
-
- UNION ALL
-
- SELECT TR.shipment as Fecha,
- NULL as Entrada,
- C.Cantidad as Salida,
- warehouse_id_out as wh,
- TR.delivered as OK,
- E.Referencia as Referencia,
- E.Id_Entrada as id
-
- FROM Compres C
- INNER JOIN Entradas E USING (Id_Entrada)
- INNER JOIN travel TR ON TR.id = E.travel_id
- WHERE TR.shipment >= vDateInventory
- AND C.Id_Article = vItemFk
-
- AND E.Redada = 0
-
- AND C.Cantidad <> 0
-
- UNION ALL
-
- SELECT T.Fecha as Fecha,
- NULL as Entrada,
- M.Cantidad as Salida,
- warehouse_id as wh,
- (M.OK <> 0 OR T.Etiquetasemitidas <> 0 OR T.Factura IS NOT NULL) as OK,
- T.Factura as Referencia,
- T.Id_Ticket as id
-
- FROM Movimientos M
- INNER JOIN Tickets T USING (Id_Ticket)
- WHERE T.Fecha >= vDateInventory
- AND M.Id_Article = vItemFk
-
- ) AS Historia
-
- INNER JOIN warehouse ON warehouse.id = Historia.wh
- ORDER BY Fecha, Entrada DESC, OK DESC;
-
-
- DROP TEMPORARY TABLE IF EXISTS hm2;
- DROP TEMPORARY TABLE IF EXISTS hm3;
- DROP TEMPORARY TABLE IF EXISTS hm4;
- DROP TEMPORARY TABLE IF EXISTS hm5;
- DROP TEMPORARY TABLE IF EXISTS hm6;
- DROP TEMPORARY TABLE IF EXISTS hm7;
- DROP TEMPORARY TABLE IF EXISTS hm8;
- CREATE TEMPORARY TABLE hm2 SELECT * FROM hm1 WHERE wh = 19;
- CREATE TEMPORARY TABLE hm3 SELECT * FROM hm1 WHERE wh = 7;
- CREATE TEMPORARY TABLE hm4 SELECT * FROM hm1 WHERE wh = 60;
- CREATE TEMPORARY TABLE hm5 SELECT * FROM hm1 WHERE wh = 5;
- CREATE TEMPORARY TABLE hm6 SELECT * FROM hm1 WHERE wh = 17;
- CREATE TEMPORARY TABLE hm7 SELECT * FROM hm1 WHERE wh = 37;
- CREATE TEMPORARY TABLE hm8 SELECT * FROM hm1 WHERE wh = 55;
-
- SELECT * FROM
-
- (
-
- SELECT Fecha, Entrada as BOGEntrada, Salida as BOGSalida, OK as BOGOK, Referencia as BOGReferencia, id as BOGid,
-
- NULL AS VNHEntrada, NULL AS VNHSalida, NULL AS VNHOK, NULL AS VNHReferencia, NULL AS VNHid,
-
- NULL AS ALGEntrada, NULL AS ALGSalida, NULL AS ALGOK, NULL AS ALGReferencia, NULL AS ALGid,
-
- NULL AS MADEntrada, NULL AS MADSalida, NULL AS MADOK, NULL AS MADReferencia, NULL AS MADid,
-
- NULL AS MCFEntrada, NULL AS MCFSalida, NULL AS MCFOK, NULL AS MCFReferencia, NULL AS MCFid,
-
- NULL AS VILEntrada, NULL AS VILSalida, NULL AS VILOK, NULL AS VILReferencia, NULL AS VILid,
-
- NULL AS BAREntrada, NULL AS BARSalida, NULL AS BAROK, NULL AS BARReferencia, NULL AS BARid
-
- FROM hm2
-
-
- UNION ALL
-
- SELECT Fecha
- , NULL, NULL, NULL, NULL, NULL
- ,Entrada, Salida, OK, Referencia, id
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- FROM hm3
-
-
-
- UNION ALL
-
- SELECT Fecha
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , Entrada, Salida, OK, Referencia, id
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- FROM hm4
-
- UNION ALL
-
- SELECT Fecha
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , Entrada, Salida, OK, Referencia, id
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- FROM hm5
-
- UNION ALL
-
- SELECT Fecha
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , Entrada, Salida, OK, Referencia, id
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- FROM hm6
-
- UNION ALL
-
- SELECT Fecha
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , Entrada, Salida, OK, Referencia, id
- , NULL, NULL, NULL, NULL, NULL
-
-
- FROM hm7
-
- UNION ALL
-
- SELECT Fecha
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , Entrada, Salida, OK, Referencia, id
-
- FROM hm8
-
- ) sub
-
- ORDER BY Fecha, BOGEntrada IS NULL, VNHEntrada IS NULL, ALGEntrada IS NULL, MADEntrada IS NULL, MCFEntrada IS NULL, VILEntrada IS NULL, BAREntrada IS NULL;
-
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `ListaTicketsEncajados` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `ListaTicketsEncajados`(IN intId_Trabajador int)
-BEGIN
-
-SELECT Agencia,
- Consignatario,
- ti.Id_Ticket,
- ts.userFk Id_Trabajador,
- IFNULL(ncajas,0) AS ncajas,
- IFNULL(nbultos,0) AS nbultos,
- IFNULL(notros,0) AS notros,
- ts.code AS Estado
- FROM Tickets ti
- INNER JOIN Consignatarios ON ti.Id_Consigna = Consignatarios.Id_consigna
- INNER JOIN Agencias ON ti.Id_Agencia = Agencias.Id_Agencia
- LEFT JOIN (SELECT ticketFk,count(*) AS ncajas FROM vn.expedition WHERE packagingFk=94 GROUP BY ticketFk) sub1 ON ti.Id_Ticket=sub1.ticketFk
- LEFT JOIN (SELECT ticketFk,count(*) AS nbultos FROM vn.expedition WHERE packagingFk IS NULL GROUP BY ticketFk) sub2 ON ti.Id_Ticket=sub2.ticketFk
- LEFT JOIN (SELECT ticketFk,count(*) AS notros FROM vn.expedition WHERE packagingFk >0 GROUP BY ticketFk) sub3 ON ti.Id_Ticket=sub3.ticketFk
- INNER JOIN vn.ticketState ts ON ti.Id_ticket = ts.ticketFk
- WHERE ti.Fecha=util.VN_CURDATE() AND
- ts.userFk=intId_Trabajador
- GROUP BY ti.Id_Ticket;
-
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `nest_child_add` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `nest_child_add`(
- vTable VARCHAR(45)
- ,vChild VARCHAR(45)
- ,vFatherId INT
-)
-BEGIN
- DECLARE vMyLeft INT;
-
- SET vTable = util.quoteIdentifier(vTable);
-
- DROP TEMPORARY TABLE IF EXISTS aux;
- CREATE TEMPORARY TABLE aux
- SELECT 0 as lft;
-
- EXECUTE IMMEDIATE CONCAT(
- 'UPDATE aux
- SET lft = (SELECT lft
- FROM ', vTable,
- ' WHERE id = ?)')
- USING vFatherId;
-
- SELECT lft INTO vMyLeft FROM aux;
- DROP TEMPORARY TABLE aux;
-
- EXECUTE IMMEDIATE CONCAT(
- 'UPDATE ', vTable, '
- SET rgt = rgt + 2
- WHERE rgt > ?
- ORDER BY rgt DESC')
- USING vMyLeft;
-
- EXECUTE IMMEDIATE CONCAT(
- 'UPDATE ', vTable, '
- SET lft = lft + 2
- WHERE lft > ?
- ORDER BY lft DESC')
- USING vMyLeft;
-
- EXECUTE IMMEDIATE CONCAT(
- 'INSERT INTO ', vTable, ' (name, lft, rgt)
- VALUES(?, ? + 1, ? + 2)')
- USING vChild,
- vMyLeft,
- vMyLeft;
-
-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_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `nest_delete` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `nest_delete`(
- vTable VARCHAR(45)
- ,vNodeId INT
-)
-BEGIN
- DECLARE vMyRight INT;
- DECLARE vMyLeft INT;
- DECLARE vMyWidth INT;
-
- DROP TEMPORARY TABLE IF EXISTS aux;
- CREATE TEMPORARY TABLE aux
- SELECT 0 rgt, 0 lft, 0 wdt;
-
- SET vTable = util.quoteIdentifier(vTable);
-
- EXECUTE IMMEDIATE CONCAT(
- 'UPDATE aux a
- JOIN ', vTable, ' t
- SET a.rgt = t.rgt,
- a.lft = t.lft,
- a.wdt = t.rgt - t.lft + 1
- WHERE t.id = ?')
- USING vNodeId;
-
- SELECT rgt, lft, wdt
- INTO vMyRight, vMyLeft, vMyWidth
- FROM aux;
-
- DROP TEMPORARY TABLE aux;
-
- EXECUTE IMMEDIATE CONCAT(
- 'DELETE FROM ', vTable,
- ' WHERE lft BETWEEN ? AND ?')
- USING vMyLeft, vMyRight;
-
- EXECUTE IMMEDIATE CONCAT(
- 'UPDATE ', vTable,
- ' SET rgt = rgt - ?
- WHERE rgt > ?
- ORDER BY rgt')
- USING vMyWidth,vMyRight;
-
- EXECUTE IMMEDIATE CONCAT(
- 'UPDATE ', vTable,
- ' SET lft = lft - ?
- WHERE lft > ?
- ORDER BY lft')
- USING vMyWidth, vMyRight;
-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_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `nest_move` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `nest_move`(
- vTable VARCHAR(45)
- ,idNODE INT
- ,idFATHER INT
-)
-BEGIN
- DECLARE myRight INT;
- DECLARE myLeft INT;
- DECLARE myWidth INT;
- DECLARE fatherRight INT;
- DECLARE fatherLeft INT;
- DECLARE gap INT;
-
- SET vTable = util.quoteIdentifier(vTable);
-
- DROP TEMPORARY TABLE IF EXISTS aux;
- CREATE TEMPORARY TABLE aux
- SELECT 0 as rgt, 0 as lft, 0 as wdt, 0 as frg, 0 as flf;
-
- -- Averiguamos el ancho de la rama
- EXECUTE IMMEDIATE CONCAT(
- 'UPDATE aux a
- JOIN ', vTable, ' t
- SET a.wdt = t.rgt - t.lft + 1
- WHERE t.id = ?')
- USING idNODE;
-
- -- Averiguamos la posicion del nuevo padre
- EXECUTE IMMEDIATE CONCAT(
- 'UPDATE aux a
- JOIN ', vTable, ' t
- SET a.frg = t.rgt,
- a.flf = t.lft
- WHERE t.id = ?')
- USING idFATHER;
-
- SELECT wdt, frg, flf INTO myWidth, fatherRight, fatherLeft
- FROM aux;
-
- -- 1º Incrementamos los valores de todos los nodos a la derecha del punto de inserción (fatherRight) , para hacer sitio
- EXECUTE IMMEDIATE CONCAT(
- 'UPDATE ', vTable,
- 'SET rgt = rgt + ?
- WHERE rgt >= ?
- ORDER BY rgt DESC')
- USING myWidth,
- fatherRight;
-
- EXECUTE IMMEDIATE CONCAT(
- 'UPDATE ', vTable,
- 'SET lft = lft + ?
- WHERE lft >= ?
- ORDER BY lft DESC')
- USING myWidth,
- fatherRight;
-
- -- Es preciso recalcular los valores del nodo en el caso de que estuviera a la derecha del nuevo padre
- EXECUTE IMMEDIATE CONCAT(
- 'UPDATE aux a
- JOIN ', vTable, ' t
- SET a.rgt = t.rgt,
- a.lft = t.lft
- WHERE t.id = ?')
- USING idNODE;
-
- SELECT lft, rgt, frg - lft INTO myLeft, myRight, gap
- FROM aux;
-
- -- 2º Incrementamos el valor de todos los nodos a trasladar hasta alcanzar su nueva posicion
- EXECUTE IMMEDIATE CONCAT(
- 'UPDATE ', vTable,
- 'SET lft = lft + ?
- WHERE lft BETWEEN ? AND ?
- ORDER BY lft DESC')
- USING gap,
- myLeft,
- myRight;
-
- EXECUTE IMMEDIATE CONCAT(
- 'UPDATE ', vTable,
- 'SET rgt = rgt + ?
- WHERE rgt BETWEEN ? AND ?
- ORDER BY rgt DESC')
- USING gap,
- myLeft,
- myRight;
-
- -- 3º Restaremos a todos los nodos resultantes, a la derecha de la posicion arrancada el ancho de la rama escindida
- EXECUTE IMMEDIATE CONCAT(
- 'UPDATE ', vTable,
- 'SET lft = lft - ?
- WHERE lft > ?
- ORDER BY lft')
- USING myWidth,
- myLeft;
-
- EXECUTE IMMEDIATE CONCAT(
- 'UPDATE ', vTable,
- 'SET rgt = rgt - ?
- WHERE rgt > ?
- ORDER BY rgt')
- USING myWidth,
- myRight;
-
- DROP TEMPORARY TABLE aux;
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `pay` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `pay`(IN datFEC DATE
- , IN idPROV INT
- , IN dblIMPORTE DOUBLE
- , IN idMONEDA INT
- , IN dblDIVISA DOUBLE
- , IN idCAJA INT
- , IN idPAYMET INT
- , IN dblGASTOS DOUBLE
- , IN strCONCEPTO VARCHAR(40)
- , IN idEMP INT)
-BEGIN
-
- -- Registro en la tabla Cajas
- INSERT INTO Cajas ( Concepto
- , Serie
- , Numero
- , Salida
- , Cajafecha
- , Partida
- , Id_Banco
- , Id_Trabajador
- ,empresa_id
- ,conciliado)
-
- SELECT CONCAT('n/pago a ', Proveedor)
- , 'R'
- , idPROV
- , dblIMPORTE
- , datFEC
- , 1
- , idCAJA
- , account.myUser_getId()
- , idEMP
- , 1
- FROM Proveedores
- WHERE Id_Proveedor = idPROV;
-
- -- Registro en la tabla pago
- INSERT INTO pago(fecha
- , dueDated
- , id_proveedor
- , importe
- , id_moneda
- , divisa
- , id_banco
- , pay_met_id
- , g_bancarios
- , concepte
- , empresa_id)
-
- VALUES(datFEC
- , datFEC
- , idPROV
- , dblIMPORTE
- , idMONEDA
- , IF(dblDIVISA = 0, NULL, dblDIVISA)
- , idCAJA
- , idPAYMET
- , dblGASTOS
- , strCONCEPTO
- , idEMP);
-
- SELECT LAST_INSERT_ID() as pago_id;
-
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `preOrdenarRuta` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `preOrdenarRuta`(IN vRutaId INT)
-BEGIN
-/* Usa los valores del ultimo año para adivinar el orden de los tickets en la ruta
- * vRutaId id ruta
- * DEPRECATED use vn.routeGressPriority
-*/
-
-UPDATE Tickets mt
-JOIN (
- SELECT tt.Id_Consigna, round(ifnull(avg(t.Prioridad),0),0) as Prioridad
- from Tickets t
- JOIN Tickets tt on tt.Id_Consigna = t.Id_Consigna
- where t.Fecha > TIMESTAMPADD(YEAR,-1,util.VN_CURDATE())
- AND tt.Id_Ruta = vRutaId
- GROUP BY Id_Consigna
- ) sub ON sub.Id_Consigna = mt.Id_Consigna
- SET mt.Prioridad = sub.Prioridad
- WHERE mt.Id_Ruta = vRutaId;
-
-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_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `prepare_ticket_list` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `prepare_ticket_list`(vStartingDate DATETIME, vEndingDate DATETIME)
-BEGIN
- DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list;
- CREATE TEMPORARY TABLE tmp.ticket_list
- (PRIMARY KEY (Id_Ticket))
- ENGINE = MEMORY
- SELECT t.Id_Ticket, c.Id_Cliente
- FROM Tickets t
- LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.Id_Ticket
- JOIN Clientes c ON c.Id_Cliente = t.Id_Cliente
- WHERE c.typeFk IN ('normal','handMaking','internalUse')
- AND (
- Fecha BETWEEN util.today() AND vEndingDate
- OR (
- ts.alertLevel < 3
- AND t.Fecha >= vStartingDate
- AND t.Fecha < util.today()
- )
- );
-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_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `raidUpdate` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -86162,58 +85906,6 @@ BEGIN
AND bi
GROUP BY t.year, t.month;
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `recibidaIvaInsert` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `recibidaIvaInsert`(IN vId INT)
-BEGIN
-
- DECLARE vRate DOUBLE DEFAULT 1;
- DECLARE vDated DATE;
-
- SELECT MAX(rr.date) INTO vDated
- FROM reference_rate rr
- JOIN recibida r ON r.id = vId
- WHERE rr.date <= r.fecha
- AND rr.moneda_id = r.moneda_id ;
-
- IF vDated THEN
-
- SELECT rate INTO vRate
- FROM reference_rate
- WHERE `date` = vDated;
- END IF;
-
- DELETE FROM recibida_iva WHERE recibida_id = vId;
-
- INSERT INTO recibida_iva(recibida_id, bi, gastos_id, divisa, taxTypeSageFk, transactionTypeSageFk)
- SELECT r.id,
- SUM(Costefijo * Cantidad) / IFNULL(vRate,1) bi,
- 6003000000,
- IF(r.moneda_id = 1,NULL,SUM(Costefijo * Cantidad )) divisa,
- taxTypeSageFk,
- transactionTypeSageFk
- FROM recibida r
- JOIN Entradas e ON e.recibida_id = r.id
- JOIN Proveedores p ON p.Id_Proveedor = e.Id_Proveedor
- JOIN Compres c ON c.Id_Entrada = e.Id_Entrada
- LEFT JOIN reference_rate rr ON rr.moneda_id = r.moneda_id AND rr.date = r.fecha
- WHERE r.id = vId
- HAVING bi IS NOT NULL;
-
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -86375,109 +86067,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 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `unary_leaves` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `unary_leaves`(v_top INT)
-BEGIN
-/**
- * A partir de un nodo devuelve todos sus descendientes.
- *
- * @table tmp.tree Tabla con los ids de los nodos descendientes;
- **/
- DECLARE v_count INT;
- DECLARE v_parent INT;
- DECLARE v_depth INT DEFAULT 0;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.tree;
- CREATE TEMPORARY TABLE tmp.tree
- (INDEX (id))
- ENGINE = MEMORY
- SELECT v_top id, v_parent parent, v_depth depth;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.parent;
- CREATE TEMPORARY TABLE tmp.parent
- ENGINE = MEMORY
- SELECT v_top id;
-
- l: LOOP
-
- SET v_depth = v_depth + 1;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.child;
- CREATE TEMPORARY TABLE tmp.child
- ENGINE = MEMORY
- SELECT c.`id`, c.parent
- FROM `unary` c
- JOIN tmp.parent p ON c.`parent` = p.id;
-
- DROP TEMPORARY TABLE tmp.parent;
- CREATE TEMPORARY TABLE tmp.parent
- ENGINE = MEMORY
- SELECT c.id, c.parent
- FROM tmp.child c
- LEFT JOIN tmp.tree t ON t.id = c.id
- WHERE t.id IS NULL;
-
- INSERT INTO tmp.tree
- SELECT id, parent, v_depth FROM tmp.parent;
-
- SELECT COUNT(*) INTO v_count
- FROM tmp.parent;
-
- IF v_count = 0 THEN
- LEAVE l;
- END IF;
- END LOOP;
-
- DROP TEMPORARY TABLE
- tmp.parent,
- tmp.child;
-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_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `unary_tops` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `unary_tops`()
-BEGIN
-/**
- * Devuelve todos los nodos que no tienen padre.
- *
- * @table tmp.tree Tabla con los ids de los nodos que no tienen padre;
- **/
-
- DROP TEMPORARY TABLE IF EXISTS tmp.tree;
- CREATE TEMPORARY TABLE tmp.tree
- ENGINE = MEMORY
- SELECT s.`unary_id` AS id, s.name, s.odbc_date, s.type
- FROM `unary_scan` s
- INNER JOIN `unary` u ON s.unary_id = u.id
- WHERE u.parent IS NULL;
-
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
--
-- Current Database: `account`
@@ -86744,24 +86333,6 @@ USE `bi`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
---
--- Final view structure for view `v_clientes_jerarquia`
---
-
-/*!50001 DROP VIEW IF EXISTS `v_clientes_jerarquia`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `v_clientes_jerarquia` AS select `c`.`id_cliente` AS `Id_Cliente`,`c`.`cliente` AS `Cliente`,`t`.`CodigoTrabajador` AS `Comercial`,`tj`.`CodigoTrabajador` AS `Jefe` from (((`vn2008`.`Clientes` `c` join `vn2008`.`Trabajadores` `t` on(`t`.`Id_Trabajador` = `c`.`Id_Trabajador`)) join `vn2008`.`jerarquia` on(`vn2008`.`jerarquia`.`worker_id` = `c`.`Id_Trabajador`)) join `vn2008`.`Trabajadores` `tj` on(`tj`.`Id_Trabajador` = `vn2008`.`jerarquia`.`boss_id`)) */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
--
-- Final view structure for view `v_ventas_contables`
--
@@ -87038,6 +86609,12 @@ USE `edi`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
+--
+-- Current Database: `floranet`
+--
+
+USE `floranet`;
+
--
-- Current Database: `hedera`
--
@@ -87920,24 +87497,6 @@ USE `vn`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
---
--- Final view structure for view `bank`
---
-
-/*!50001 DROP VIEW IF EXISTS `bank`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `bank` AS select `a`.`id` AS `id`,`a`.`bank` AS `bank`,`a`.`account` AS `account`,`a`.`accountingTypeFk` AS `cash`,`a`.`entityFk` AS `entityFk`,`a`.`isActive` AS `isActive`,`a`.`currencyFk` AS `currencyFk`,`a`.`code` AS `code` from `accounting` `a` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
--
-- Final view structure for view `businessCalendar`
--
@@ -88154,24 +87713,6 @@ USE `vn`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
---
--- Final view structure for view `exchangeInsurance`
---
-
-/*!50001 DROP VIEW IF EXISTS `exchangeInsurance`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `exchangeInsurance` AS select `vn2008`.`pago_sdc`.`pago_sdc_id` AS `id`,`vn2008`.`pago_sdc`.`importe` AS `amount`,`vn2008`.`pago_sdc`.`fecha` AS `dated`,`vn2008`.`pago_sdc`.`vencimiento` AS `finished`,`vn2008`.`pago_sdc`.`entity_id` AS `entityFk`,`vn2008`.`pago_sdc`.`ref` AS `ref`,`vn2008`.`pago_sdc`.`rate` AS `rate`,`vn2008`.`pago_sdc`.`empresa_id` AS `companyFk`,`vn2008`.`pago_sdc`.`financialProductTypefk` AS `financialProductTypefk`,`vn2008`.`pago_sdc`.`upperBarrier` AS `upperBarrier`,`vn2008`.`pago_sdc`.`lowerBarrier` AS `lowerBarrier`,`vn2008`.`pago_sdc`.`strike` AS `strike` from `vn2008`.`pago_sdc` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
--
-- Final view structure for view `exchangeInsuranceEntry`
--
@@ -88203,7 +87744,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `exchangeInsuranceIn` AS select `exchangeInsuranceInPrevious`.`dated` AS `dated`,sum(`exchangeInsuranceInPrevious`.`amount`) AS `amount`,cast(sum(`exchangeInsuranceInPrevious`.`amount` * `exchangeInsuranceInPrevious`.`rate`) / sum(`exchangeInsuranceInPrevious`.`amount`) as decimal(10,4)) AS `rate` from `vn`.`exchangeInsuranceInPrevious` group by `exchangeInsuranceInPrevious`.`dated` */;
+/*!50001 VIEW `exchangeInsuranceIn` AS select `exchangeInsuranceInPrevious`.`dated` AS `dated`,sum(`exchangeInsuranceInPrevious`.`amount`) AS `amount`,cast(sum(`exchangeInsuranceInPrevious`.`amount` * `exchangeInsuranceInPrevious`.`rate`) / sum(`exchangeInsuranceInPrevious`.`amount`) as decimal(10,4)) AS `rate` from `exchangeInsuranceInPrevious` group by `exchangeInsuranceInPrevious`.`dated` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -88221,7 +87762,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `exchangeInsuranceInPrevious` AS select `ei`.`finished` AS `dated`,`ei`.`amount` AS `amount`,`ei`.`rate` AS `rate` from `vn`.`exchangeInsurance` `ei` where `ei`.`amount` <> 0 and `ei`.`financialProductTypefk` = 'SC' */;
+/*!50001 VIEW `exchangeInsuranceInPrevious` AS select `ei`.`dueDated` AS `dated`,`ei`.`amount` AS `amount`,`ei`.`rate` AS `rate` from `exchangeInsurance` `ei` where `ei`.`amount` <> 0 and `ei`.`financialProductTypefk` = 'SC' */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -88239,7 +87780,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `exchangeInsuranceOut` AS select `p`.`received` AS `received`,sum(`p`.`divisa`) AS `divisa`,sum(`p`.`divisa`) / sum(`p`.`amount`) AS `rate` from ((`payment` `p` join `bank` `b` on(`b`.`id` = `p`.`bankFk`)) join `accountingType` `at2` on(`at2`.`id` = `b`.`cash`)) where `p`.`currencyFk` = 2 and `at2`.`code` = 'wireTransfer' and `p`.`supplierFk` <> 2213 group by `p`.`received` */;
+/*!50001 VIEW `exchangeInsuranceOut` AS select `p`.`received` AS `received`,sum(`p`.`divisa`) AS `divisa`,sum(`p`.`divisa`) / sum(`p`.`amount`) AS `rate` from ((`payment` `p` join `accounting` `a` on(`a`.`id` = `p`.`bankFk`)) join `accountingType` `at2` on(`at2`.`id` = `a`.`accountingTypeFk`)) where `p`.`currencyFk` = 2 and `at2`.`code` = 'wireTransfer' and `p`.`supplierFk` <> 2213 group by `p`.`received` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -88257,7 +87798,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `exchangeReportSource` AS select `e`.`dated` AS `dated`,cast(sum(`e`.`amountIn`) as decimal(10,2)) AS `amountIn`,cast(sum(`e`.`rateIn`) as decimal(10,4)) AS `rateIn`,cast(sum(`e`.`amountOut`) as decimal(10,2)) AS `amountOut`,cast(sum(`e`.`rateOut`) as decimal(10,4)) AS `rateOut`,cast(sum(`e`.`amountEntry`) as decimal(10,2)) AS `amountEntry`,cast(sum(`e`.`rateEntry`) as decimal(10,4)) AS `rateEntry`,cast(ifnull(`rr`.`value`,`rrc`.`simulatedValue`) as decimal(10,4)) AS `rateECB` from ((`vn`.`exchangeReportSourcePrevious` `e` left join `vn`.`referenceRate` `rr` on(`rr`.`dated` = `e`.`dated`)) join `vn`.`referenceRateConfig` `rrc` on(1)) group by `e`.`dated` order by `e`.`dated` */;
+/*!50001 VIEW `exchangeReportSource` AS select `e`.`dated` AS `dated`,cast(sum(`e`.`amountIn`) as decimal(10,2)) AS `amountIn`,cast(sum(`e`.`rateIn`) as decimal(10,4)) AS `rateIn`,cast(sum(`e`.`amountOut`) as decimal(10,2)) AS `amountOut`,cast(sum(`e`.`rateOut`) as decimal(10,4)) AS `rateOut`,cast(sum(`e`.`amountEntry`) as decimal(10,2)) AS `amountEntry`,cast(sum(`e`.`rateEntry`) as decimal(10,4)) AS `rateEntry`,cast(ifnull(`rr`.`value`,`rrc`.`simulatedValue`) as decimal(10,4)) AS `rateECB` from ((`exchangeReportSourcePrevious` `e` left join `referenceRate` `rr` on(`rr`.`dated` = `e`.`dated`)) join `referenceRateConfig` `rrc` on(1)) group by `e`.`dated` order by `e`.`dated` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -88275,7 +87816,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `exchangeReportSourcePrevious` AS select `exchangeInsuranceIn`.`dated` AS `dated`,`exchangeInsuranceIn`.`amount` AS `amountIn`,`exchangeInsuranceIn`.`rate` AS `rateIn`,0.00 AS `amountOut`,0.00 AS `rateOut`,0.00 AS `amountEntry`,0.00 AS `rateEntry` from `vn`.`exchangeInsuranceIn` union all select `exchangeInsuranceOut`.`received` AS `received`,0.00 AS `amountIn`,0.00 AS `ratedIn`,`exchangeInsuranceOut`.`divisa` AS `amountOut`,`exchangeInsuranceOut`.`rate` AS `ratedOut`,0.00 AS `amountEntry`,0.00 AS `rateEntry` from `vn`.`exchangeInsuranceOut` union all select `exchangeInsuranceEntry`.`dated` AS `dated`,0.00 AS `amountIn`,0.00 AS `ratedIn`,0.00 AS `amountOut`,0.00 AS `ratedOut`,`exchangeInsuranceEntry`.`Dolares` AS `amountEntry`,`exchangeInsuranceEntry`.`rate` AS `rateEntry` from `vn`.`exchangeInsuranceEntry` */;
+/*!50001 VIEW `exchangeReportSourcePrevious` AS select `exchangeInsuranceIn`.`dated` AS `dated`,`exchangeInsuranceIn`.`amount` AS `amountIn`,`exchangeInsuranceIn`.`rate` AS `rateIn`,0.00 AS `amountOut`,0.00 AS `rateOut`,0.00 AS `amountEntry`,0.00 AS `rateEntry` from `exchangeInsuranceIn` union all select `exchangeInsuranceOut`.`received` AS `received`,0.00 AS `amountIn`,0.00 AS `ratedIn`,`exchangeInsuranceOut`.`divisa` AS `amountOut`,`exchangeInsuranceOut`.`rate` AS `ratedOut`,0.00 AS `amountEntry`,0.00 AS `rateEntry` from `exchangeInsuranceOut` union all select `exchangeInsuranceEntry`.`dated` AS `dated`,0.00 AS `amountIn`,0.00 AS `ratedIn`,0.00 AS `amountOut`,0.00 AS `ratedOut`,`exchangeInsuranceEntry`.`Dolares` AS `amountEntry`,`exchangeInsuranceEntry`.`rate` AS `rateEntry` from `exchangeInsuranceEntry` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -89139,7 +88680,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `payrollCenter` AS select `b`.`cod_centro` AS `codCenter`,`b`.`Centro` AS `name`,`b`.`nss_cotizacion` AS `nss`,`b`.`domicilio` AS `street`,`b`.`poblacion` AS `city`,`b`.`cp` AS `postcode`,`b`.`empresa_id` AS `companyFk`,`b`.`codempresa` AS `companyCode` from `vn2008`.`payroll_centros` `b` */;
+/*!50001 VIEW `payrollCenter` AS select `b`.`workCenterFkA3` AS `codCenter`,`b`.`companyFkA3` AS `companyCode` from `payrollWorkCenter` `b` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -89180,24 +88721,6 @@ USE `vn`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
---
--- Final view structure for view `preparationException`
---
-
-/*!50001 DROP VIEW IF EXISTS `preparationException`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `preparationException` AS select `p`.`exception_day` AS `exceptionDay`,`p`.`warehouse_id` AS `warehouseFk`,`p`.`percentage` AS `percentage` from `vn2008`.`preparation_exception` `p` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
--
-- Final view structure for view `productionVolume`
--
@@ -89288,24 +88811,6 @@ USE `vn`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
---
--- Final view structure for view `saleLabel`
---
-
-/*!50001 DROP VIEW IF EXISTS `saleLabel`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `saleLabel` AS select `ml`.`Id_movimiento` AS `saleFk`,`ml`.`label` AS `label`,`ml`.`stem` AS `stem`,`ml`.`created` AS `created` from `vn2008`.`movement_label` `ml` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
--
-- Final view structure for view `saleMistakeList`
--
@@ -89373,7 +88878,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `saleValue` AS select `wh`.`name` AS `warehouse`,`c`.`name` AS `client`,`c`.`typeFk` AS `clientTypeFk`,`u`.`name` AS `buyer`,`it`.`id` AS `itemTypeFk`,`it`.`name` AS `family`,`s`.`itemFk` AS `itemFk`,`s`.`concept` AS `concept`,`s`.`quantity` AS `quantity`,`b`.`buyingValue` + `b`.`freightValue` + `b`.`comissionValue` + `b`.`packageValue` AS `cost`,(`b`.`buyingValue` + `b`.`freightValue` + `b`.`comissionValue` + `b`.`packageValue`) * `s`.`quantity` AS `value`,`tm`.`year` AS `year`,`tm`.`week` AS `week` from (((((((((`vn`.`sale` `s` join `vn`.`item` `i` on(`i`.`id` = `s`.`itemFk`)) join `vn`.`itemType` `it` on(`it`.`id` = `i`.`typeFk`)) join `account`.`user` `u` on(`u`.`id` = `it`.`workerFk`)) join `vn`.`ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) join `vn`.`client` `c` on(`c`.`id` = `t`.`clientFk`)) join `vn`.`warehouse` `wh` on(`wh`.`id` = `t`.`warehouseFk`)) join `vn`.`time` `tm` on(`tm`.`dated` = cast(`t`.`shipped` as date))) join `cache`.`last_buy` `lb` on(`lb`.`item_id` = `i`.`id` and `lb`.`warehouse_id` = `wh`.`id`)) join `vn`.`buy` `b` on(`b`.`id` = `lb`.`buy_id`)) where `wh`.`isManaged` <> 0 */;
+/*!50001 VIEW `saleValue` AS select `wh`.`name` AS `warehouse`,`c`.`name` AS `client`,`c`.`typeFk` AS `typeFk`,`u`.`name` AS `buyer`,`it`.`id` AS `itemTypeFk`,`it`.`name` AS `family`,`s`.`itemFk` AS `itemFk`,`s`.`concept` AS `concept`,`s`.`quantity` AS `quantity`,`b`.`buyingValue` + `b`.`freightValue` + `b`.`comissionValue` + `b`.`packageValue` AS `cost`,(`b`.`buyingValue` + `b`.`freightValue` + `b`.`comissionValue` + `b`.`packageValue`) * `s`.`quantity` AS `value`,`tm`.`year` AS `year`,`tm`.`week` AS `week` from (((((((((`vn`.`sale` `s` join `vn`.`item` `i` on(`i`.`id` = `s`.`itemFk`)) join `vn`.`itemType` `it` on(`it`.`id` = `i`.`typeFk`)) join `account`.`user` `u` on(`u`.`id` = `it`.`workerFk`)) join `vn`.`ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) join `vn`.`client` `c` on(`c`.`id` = `t`.`clientFk`)) join `vn`.`warehouse` `wh` on(`wh`.`id` = `t`.`warehouseFk`)) join `vn`.`time` `tm` on(`tm`.`dated` = cast(`t`.`shipped` as date))) join `cache`.`last_buy` `lb` on(`lb`.`item_id` = `i`.`id` and `lb`.`warehouse_id` = `wh`.`id`)) join `vn`.`buy` `b` on(`b`.`id` = `lb`.`buy_id`)) where `wh`.`isManaged` <> 0 */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -89445,7 +88950,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `salesPersonSince` AS select `b`.`workerFk` AS `workerFk`,min(`b`.`started`) AS `started` from ((`business` `b` join `worker` `w` on(`w`.`id` = `b`.`workerFk`)) left join `professionalCategory` `pc` on(`pc`.`id` = `b`.`workerBusinessProfessionalCategoryFk`)) where `pc`.`name` = 'Aux ventas' group by `b`.`workerFk` */;
+/*!50001 VIEW `salesPersonSince` AS select `b`.`workerFk` AS `workerFk`,min(`b`.`started`) AS `started` from ((`business` `b` join `worker` `w` on(`w`.`id` = `b`.`workerFk`)) left join `professionalCategory` `pc` on(`pc`.`id` = `b`.`workerBusinessProfessionalCategoryFk`)) where `pc`.`description` = 'Aux ventas' group by `b`.`workerFk` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -89774,96 +89279,6 @@ USE `vn`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
---
--- Final view structure for view `unary`
---
-
-/*!50001 DROP VIEW IF EXISTS `unary`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `unary` AS select `a`.`id` AS `id`,`a`.`parent` AS `parent` from `vn2008`.`unary` `a` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `unaryScan`
---
-
-/*!50001 DROP VIEW IF EXISTS `unaryScan`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `unaryScan` AS select `u`.`unary_id` AS `unaryFk`,`u`.`name` AS `name`,`u`.`odbc_date` AS `created`,`u`.`type` AS `type` from `vn2008`.`unary_scan` `u` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `unaryScanLine`
---
-
-/*!50001 DROP VIEW IF EXISTS `unaryScanLine`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `unaryScanLine` AS select `u`.`id` AS `id`,`u`.`code` AS `code`,`u`.`odbc_date` AS `created`,`u`.`unary_id` AS `unaryScanFk` from `vn2008`.`unary_scan_line` `u` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `unaryScanLineBuy`
---
-
-/*!50001 DROP VIEW IF EXISTS `unaryScanLineBuy`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `unaryScanLineBuy` AS select `u`.`scan_line_id` AS `unaryScanLineFk`,`u`.`Id_Article` AS `itemFk` from `vn2008`.`unary_scan_line_buy` `u` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
---
--- Final view structure for view `unaryScanLineExpedition`
---
-
-/*!50001 DROP VIEW IF EXISTS `unaryScanLineExpedition`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `unaryScanLineExpedition` AS select `u`.`scan_line_id` AS `unaryScanLineFk`,`u`.`expedition_id` AS `expeditionFk` from `vn2008`.`unary_scan_line_expedition` `u` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
--
-- Final view structure for view `workerBusinessDated`
--
@@ -90117,7 +89532,7 @@ USE `vn2008`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `Bancos` AS select `b`.`id` AS `Id_Banco`,`b`.`bank` AS `Banco`,`b`.`account` AS `Cuenta`,`b`.`cash` AS `cash`,`b`.`entityFk` AS `entity_id`,`b`.`isActive` AS `activo`,`b`.`currencyFk` AS `currencyFk` from `vn`.`bank` `b` */;
+/*!50001 VIEW `Bancos` AS select `a`.`id` AS `Id_Banco`,`a`.`bank` AS `Banco`,`a`.`account` AS `Cuenta`,`a`.`accountingTypeFk` AS `cash`,`a`.`entityFk` AS `entity_id`,`a`.`isActive` AS `activo`,`a`.`currencyFk` AS `currencyFk` from `vn`.`accounting` `a` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -90171,7 +89586,7 @@ USE `vn2008`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `Clientes` AS select `c`.`id` AS `id_cliente`,`c`.`name` AS `cliente`,`c`.`fi` AS `if`,`c`.`socialName` AS `razonSocial`,`c`.`contact` AS `contacto`,`c`.`street` AS `domicilio`,`c`.`city` AS `poblacion`,`c`.`postcode` AS `codPostal`,`c`.`phone` AS `telefono`,`c`.`mobile` AS `movil`,`c`.`isRelevant` AS `real`,`c`.`email` AS `e-mail`,`c`.`iban` AS `iban`,`c`.`dueDay` AS `vencimiento`,`c`.`accountingAccount` AS `Cuenta`,`c`.`isEqualizated` AS `RE`,`c`.`provinceFk` AS `province_id`,`c`.`hasToInvoice` AS `invoice`,`c`.`credit` AS `credito`,`c`.`countryFk` AS `Id_Pais`,`c`.`isActive` AS `activo`,`c`.`gestdocFk` AS `gestdoc_id`,`c`.`quality` AS `calidad`,`c`.`payMethodFk` AS `pay_met_id`,`c`.`created` AS `created`,`c`.`isToBeMailed` AS `mail`,`c`.`contactChannelFk` AS `chanel_id`,`c`.`hasSepaVnl` AS `sepaVnl`,`c`.`hasCoreVnl` AS `coreVnl`,`c`.`hasCoreVnh` AS `coreVnh`,`c`.`hasLcr` AS `hasLcr`,`c`.`defaultAddressFk` AS `default_address`,`c`.`riskCalculated` AS `risk_calculated`,`c`.`clientTypeFk` AS `clientes_tipo_id`,`c`.`hasToInvoiceByAddress` AS `invoiceByAddress`,`c`.`isTaxDataChecked` AS `contabilizado`,`c`.`isFreezed` AS `congelado`,`c`.`creditInsurance` AS `creditInsurance`,`c`.`isCreatedAsServed` AS `isCreatedAsServed`,`c`.`hasInvoiceSimplified` AS `hasInvoiceSimplified`,`c`.`salesPersonFk` AS `Id_Trabajador`,`c`.`isVies` AS `vies`,`c`.`eypbc` AS `EYPBC`,`c`.`bankEntityFk` AS `bankEntityFk`,`c`.`typeFk` AS `typeFk` from `vn`.`client` `c` */;
+/*!50001 VIEW `Clientes` AS select `c`.`id` AS `id_cliente`,`c`.`name` AS `cliente`,`c`.`fi` AS `if`,`c`.`socialName` AS `razonSocial`,`c`.`contact` AS `contacto`,`c`.`street` AS `domicilio`,`c`.`city` AS `poblacion`,`c`.`postcode` AS `codPostal`,`c`.`phone` AS `telefono`,`c`.`mobile` AS `movil`,`c`.`isRelevant` AS `real`,`c`.`email` AS `e-mail`,`c`.`iban` AS `iban`,`c`.`dueDay` AS `vencimiento`,`c`.`accountingAccount` AS `Cuenta`,`c`.`isEqualizated` AS `RE`,`c`.`provinceFk` AS `province_id`,`c`.`hasToInvoice` AS `invoice`,`c`.`credit` AS `credito`,`c`.`countryFk` AS `Id_Pais`,`c`.`isActive` AS `activo`,`c`.`gestdocFk` AS `gestdoc_id`,`c`.`quality` AS `calidad`,`c`.`payMethodFk` AS `pay_met_id`,`c`.`created` AS `created`,`c`.`isToBeMailed` AS `mail`,`c`.`contactChannelFk` AS `chanel_id`,`c`.`hasSepaVnl` AS `sepaVnl`,`c`.`hasCoreVnl` AS `coreVnl`,`c`.`hasCoreVnh` AS `coreVnh`,`c`.`hasLcr` AS `hasLcr`,`c`.`defaultAddressFk` AS `default_address`,`c`.`riskCalculated` AS `risk_calculated`,`c`.`hasToInvoiceByAddress` AS `invoiceByAddress`,`c`.`isTaxDataChecked` AS `contabilizado`,`c`.`isFreezed` AS `congelado`,`c`.`creditInsurance` AS `creditInsurance`,`c`.`isCreatedAsServed` AS `isCreatedAsServed`,`c`.`hasInvoiceSimplified` AS `hasInvoiceSimplified`,`c`.`salesPersonFk` AS `Id_Trabajador`,`c`.`isVies` AS `vies`,`c`.`eypbc` AS `EYPBC`,`c`.`bankEntityFk` AS `bankEntityFk`,`c`.`typeFk` AS `typeFk` from `vn`.`client` `c` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -90531,7 +89946,25 @@ USE `vn2008`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `Proveedores` AS select `s`.`id` AS `Id_Proveedor`,`s`.`name` AS `Proveedor`,`s`.`account` AS `cuenta`,`s`.`countryFk` AS `pais_id`,`s`.`nif` AS `NIF`,`s`.`isFarmer` AS `Agricola`,`s`.`phone` AS `Telefono`,`s`.`retAccount` AS `cuentaret`,`s`.`commission` AS `ComisionProveedor`,`s`.`created` AS `odbc_time`,`s`.`postcodeFk` AS `postcode_id`,`s`.`isActive` AS `active`,`s`.`street` AS `Domicilio`,`s`.`city` AS `Localidad`,`s`.`provinceFk` AS `province_id`,`s`.`postCode` AS `codpos`,`s`.`payMethodFk` AS `pay_met_id`,`s`.`payDemFk` AS `pay_dem_id`,`s`.`nickname` AS `Alias`,`s`.`isOfficial` AS `oficial`,`s`.`workerFk` AS `workerFk`,`s`.`payDay` AS `pay_day`,`s`.`isSerious` AS `serious`,`s`.`note` AS `notas`,`s`.`taxTypeSageFk` AS `taxTypeSageFk`,`s`.`withholdingSageFk` AS `withholdingSageFk`,`s`.`isTrucker` AS `isTrucker`,`s`.`transactionTypeSageFk` AS `transactionTypeSageFk`,`s`.`supplierActivityFk` AS `supplierActivityFk`,`s`.`healthRegister` AS `healthRegister`,`s`.`isPayMethodChecked` AS `isPayMethodChecked` from `vn`.`supplier` `s` */;
+/*!50001 VIEW `Proveedores` AS select `s`.`id` AS `Id_Proveedor`,`s`.`name` AS `Proveedor`,`s`.`account` AS `cuenta`,`s`.`countryFk` AS `pais_id`,`s`.`nif` AS `NIF`,`s`.`isFarmer` AS `Agricola`,`s`.`phone` AS `Telefono`,`s`.`retAccount` AS `cuentaret`,`s`.`commission` AS `ComisionProveedor`,`s`.`created` AS `odbc_time`,`s`.`postcodeFk` AS `postcode_id`,`s`.`isActive` AS `active`,`s`.`street` AS `Domicilio`,`s`.`city` AS `Localidad`,`s`.`provinceFk` AS `province_id`,`s`.`postCode` AS `codpos`,`s`.`payMethodFk` AS `pay_met_id`,`s`.`payDemFk` AS `pay_dem_id`,`s`.`nickname` AS `Alias`,`s`.`isOfficial` AS `oficial`,`s`.`workerFk` AS `workerFk`,`s`.`payDay` AS `pay_day`,`s`.`isReal` AS `serious`,`s`.`note` AS `notas`,`s`.`taxTypeSageFk` AS `taxTypeSageFk`,`s`.`withholdingSageFk` AS `withholdingSageFk`,`s`.`isTrucker` AS `isTrucker`,`s`.`transactionTypeSageFk` AS `transactionTypeSageFk`,`s`.`supplierActivityFk` AS `supplierActivityFk`,`s`.`healthRegister` AS `healthRegister`,`s`.`isPayMethodChecked` AS `isPayMethodChecked` from `vn`.`supplier` `s` */;
+/*!50001 SET character_set_client = @saved_cs_client */;
+/*!50001 SET character_set_results = @saved_cs_results */;
+/*!50001 SET collation_connection = @saved_col_connection */;
+
+--
+-- Final view structure for view `Proveedores_cargueras`
+--
+
+/*!50001 DROP VIEW IF EXISTS `Proveedores_cargueras`*/;
+/*!50001 SET @saved_cs_client = @@character_set_client */;
+/*!50001 SET @saved_cs_results = @@character_set_results */;
+/*!50001 SET @saved_col_connection = @@collation_connection */;
+/*!50001 SET character_set_client = utf8mb4 */;
+/*!50001 SET character_set_results = utf8mb4 */;
+/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `Proveedores_cargueras` AS select `fs`.`supplierFk` AS `Id_Proveedor` from `vn`.`supplierFreight` `fs` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -90770,6 +90203,24 @@ USE `vn2008`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
+--
+-- Final view structure for view `Tramos`
+--
+
+/*!50001 DROP VIEW IF EXISTS `Tramos`*/;
+/*!50001 SET @saved_cs_client = @@character_set_client */;
+/*!50001 SET @saved_cs_results = @@character_set_results */;
+/*!50001 SET @saved_col_connection = @@collation_connection */;
+/*!50001 SET character_set_client = utf8mb4 */;
+/*!50001 SET character_set_results = utf8mb4 */;
+/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `Tramos` AS select `s`.`id` AS `id`,`s`.`section` AS `Tramo` from `vn`.`timeSlots` `s` */;
+/*!50001 SET character_set_client = @saved_cs_client */;
+/*!50001 SET character_set_results = @saved_cs_results */;
+/*!50001 SET collation_connection = @saved_col_connection */;
+
--
-- Final view structure for view `V_edi_item_track`
--
@@ -91593,7 +91044,7 @@ USE `vn2008`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `empresa` AS select `c`.`id` AS `id`,`c`.`code` AS `abbreviation`,`c`.`supplierAccountFk` AS `Id_Proveedores_account`,`c`.`workerManagerFk` AS `gerente_id`,`c`.`sage200Company` AS `digito_factura`,`c`.`phytosanitary` AS `phytosanitary`,`c`.`companyCode` AS `CodigoEmpresa`,`c`.`companyGroupFk` AS `empresa_grupo`,`c`.`isDefaulter` AS `morosidad`,`c`.`expired` AS `baja`,`c`.`register` AS `registro`,`c`.`registered` AS `alta`,`c`.`logo` AS `logo`,`c`.`isOfficial` AS `oficial`,`c`.`hasCyc` AS `cyc`,`c`.`rgb` AS `rgb`,`c`.`email` AS `mail`,`c`.`stamp` AS `cuno`,`c`.`created` AS `ODBC_DATE`,`c`.`clientFk` AS `Id_Cliente` from `vn`.`company` `c` */;
+/*!50001 VIEW `empresa` AS select `c`.`id` AS `id`,`c`.`code` AS `abbreviation`,`c`.`supplierAccountFk` AS `Id_Proveedores_account`,`c`.`workerManagerFk` AS `gerente_id`,`c`.`phytosanitary` AS `phytosanitary`,`c`.`companyCode` AS `CodigoEmpresa`,`c`.`companyGroupFk` AS `empresa_grupo`,`c`.`isDefaulter` AS `morosidad`,`c`.`expired` AS `baja`,`c`.`register` AS `registro`,`c`.`registered` AS `alta`,`c`.`logo` AS `logo`,`c`.`isOfficial` AS `oficial`,`c`.`hasCyc` AS `cyc`,`c`.`rgb` AS `rgb`,`c`.`email` AS `mail`,`c`.`stamp` AS `cuno`,`c`.`created` AS `ODBC_DATE`,`c`.`clientFk` AS `Id_Cliente` from `vn`.`company` `c` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -91634,6 +91085,96 @@ USE `vn2008`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
+--
+-- Final view structure for view `financialProductType`
+--
+
+/*!50001 DROP VIEW IF EXISTS `financialProductType`*/;
+/*!50001 SET @saved_cs_client = @@character_set_client */;
+/*!50001 SET @saved_cs_results = @@character_set_results */;
+/*!50001 SET @saved_col_connection = @@collation_connection */;
+/*!50001 SET character_set_client = utf8mb4 */;
+/*!50001 SET character_set_results = utf8mb4 */;
+/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `financialProductType` AS select `vn`.`financialProductType`.`id` AS `id`,`vn`.`financialProductType`.`description` AS `description`,`vn`.`financialProductType`.`isAcumulattor` AS `isAcumulattor` from `vn`.`financialProductType` */;
+/*!50001 SET character_set_client = @saved_cs_client */;
+/*!50001 SET character_set_results = @saved_cs_results */;
+/*!50001 SET collation_connection = @saved_col_connection */;
+
+--
+-- Final view structure for view `flight`
+--
+
+/*!50001 DROP VIEW IF EXISTS `flight`*/;
+/*!50001 SET @saved_cs_client = @@character_set_client */;
+/*!50001 SET @saved_cs_results = @@character_set_results */;
+/*!50001 SET @saved_col_connection = @@collation_connection */;
+/*!50001 SET character_set_client = utf8mb4 */;
+/*!50001 SET character_set_results = utf8mb4 */;
+/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `flight` AS select `f`.`id` AS `flight_id`,`f`.`duration` AS `duration`,`f`.`flightPath` AS `route`,`f`.`days` AS `days`,`f`.`airlineFk` AS `airline_id`,`f`.`airportArrivalFk` AS `airport_out`,`f`.`airportDepartureFk` AS `airport_in` from `vn`.`flight` `f` */;
+/*!50001 SET character_set_client = @saved_cs_client */;
+/*!50001 SET character_set_results = @saved_cs_results */;
+/*!50001 SET collation_connection = @saved_col_connection */;
+
+--
+-- Final view structure for view `gastos_resumen`
+--
+
+/*!50001 DROP VIEW IF EXISTS `gastos_resumen`*/;
+/*!50001 SET @saved_cs_client = @@character_set_client */;
+/*!50001 SET @saved_cs_results = @@character_set_results */;
+/*!50001 SET @saved_col_connection = @@collation_connection */;
+/*!50001 SET character_set_client = utf8mb4 */;
+/*!50001 SET character_set_results = utf8mb4 */;
+/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `gastos_resumen` AS select `es`.`id` AS `id`,`es`.`expenseFk` AS `Id_Gasto`,`es`.`year` AS `year`,`es`.`month` AS `month`,`es`.`amount` AS `importe`,`es`.`companyFk` AS `empresa_id` from `vn`.`expenseManual` `es` */;
+/*!50001 SET character_set_client = @saved_cs_client */;
+/*!50001 SET character_set_results = @saved_cs_results */;
+/*!50001 SET collation_connection = @saved_col_connection */;
+
+--
+-- Final view structure for view `integra2`
+--
+
+/*!50001 DROP VIEW IF EXISTS `integra2`*/;
+/*!50001 SET @saved_cs_client = @@character_set_client */;
+/*!50001 SET @saved_cs_results = @@character_set_results */;
+/*!50001 SET @saved_col_connection = @@collation_connection */;
+/*!50001 SET character_set_client = utf8mb4 */;
+/*!50001 SET character_set_results = utf8mb4 */;
+/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `integra2` AS select `i2`.`postCode` AS `postal_code`,`i2`.`frequency` AS `frequency`,`i2`.`warehouseFk` AS `warehouse_id` from `vn`.`integra2` `i2` */;
+/*!50001 SET character_set_client = @saved_cs_client */;
+/*!50001 SET character_set_results = @saved_cs_results */;
+/*!50001 SET collation_connection = @saved_col_connection */;
+
+--
+-- Final view structure for view `integra2_province`
+--
+
+/*!50001 DROP VIEW IF EXISTS `integra2_province`*/;
+/*!50001 SET @saved_cs_client = @@character_set_client */;
+/*!50001 SET @saved_cs_results = @@character_set_results */;
+/*!50001 SET @saved_col_connection = @@collation_connection */;
+/*!50001 SET character_set_client = utf8mb4 */;
+/*!50001 SET character_set_results = utf8mb4 */;
+/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `integra2_province` AS select `ip`.`provinceFk` AS `province_id`,`ip`.`franchise` AS `franquicia` from `vn`.`integra2Province` `ip` */;
+/*!50001 SET character_set_client = @saved_cs_client */;
+/*!50001 SET character_set_results = @saved_cs_results */;
+/*!50001 SET collation_connection = @saved_col_connection */;
+
--
-- Final view structure for view `mail`
--
@@ -91706,6 +91247,24 @@ USE `vn2008`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
+--
+-- Final view structure for view `pago_sdc`
+--
+
+/*!50001 DROP VIEW IF EXISTS `pago_sdc`*/;
+/*!50001 SET @saved_cs_client = @@character_set_client */;
+/*!50001 SET @saved_cs_results = @@character_set_results */;
+/*!50001 SET @saved_col_connection = @@collation_connection */;
+/*!50001 SET character_set_client = utf8mb4 */;
+/*!50001 SET character_set_results = utf8mb4 */;
+/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `pago_sdc` AS select `ei`.`id` AS `pago_sdc_id`,`ei`.`amount` AS `importe`,`ei`.`dated` AS `fecha`,`ei`.`dueDated` AS `vencimiento`,`ei`.`entityFk` AS `entity_id`,`ei`.`ref` AS `ref`,`ei`.`rate` AS `rate`,`ei`.`companyFk` AS `empresa_id`,`ei`.`financialProductTypefk` AS `financialProductTypefk`,`ei`.`upperBarrier` AS `upperBarrier`,`ei`.`lowerBarrier` AS `lowerBarrier`,`ei`.`strike` AS `strike` from `vn`.`exchangeInsurance` `ei` */;
+/*!50001 SET character_set_client = @saved_cs_client */;
+/*!50001 SET character_set_results = @saved_cs_results */;
+/*!50001 SET collation_connection = @saved_col_connection */;
+
--
-- Final view structure for view `pay_dem`
--
@@ -91778,6 +91337,60 @@ USE `vn2008`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
+--
+-- Final view structure for view `payroll_centros`
+--
+
+/*!50001 DROP VIEW IF EXISTS `payroll_centros`*/;
+/*!50001 SET @saved_cs_client = @@character_set_client */;
+/*!50001 SET @saved_cs_results = @@character_set_results */;
+/*!50001 SET @saved_col_connection = @@collation_connection */;
+/*!50001 SET character_set_client = utf8mb4 */;
+/*!50001 SET character_set_results = utf8mb4 */;
+/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `payroll_centros` AS select `pwc`.`workCenterFkA3` AS `cod_centro`,`pwc`.`companyFkA3` AS `codempresa` from `vn`.`payrollWorkCenter` `pwc` */;
+/*!50001 SET character_set_client = @saved_cs_client */;
+/*!50001 SET character_set_results = @saved_cs_results */;
+/*!50001 SET collation_connection = @saved_col_connection */;
+
+--
+-- Final view structure for view `payroll_conceptos`
+--
+
+/*!50001 DROP VIEW IF EXISTS `payroll_conceptos`*/;
+/*!50001 SET @saved_cs_client = @@character_set_client */;
+/*!50001 SET @saved_cs_results = @@character_set_results */;
+/*!50001 SET @saved_col_connection = @@collation_connection */;
+/*!50001 SET character_set_client = utf8mb4 */;
+/*!50001 SET character_set_results = utf8mb4 */;
+/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `payroll_conceptos` AS select `pc`.`id` AS `conceptoid`,`pc`.`name` AS `concepto`,`pc`.`isSalaryAgreed` AS `isSalaryAgreed`,`pc`.`isVariable` AS `isVariable`,`pc`.`isException` AS `isException` from `vn`.`payrollComponent` `pc` */;
+/*!50001 SET character_set_client = @saved_cs_client */;
+/*!50001 SET character_set_results = @saved_cs_results */;
+/*!50001 SET collation_connection = @saved_col_connection */;
+
+--
+-- Final view structure for view `payroll_employee`
+--
+
+/*!50001 DROP VIEW IF EXISTS `payroll_employee`*/;
+/*!50001 SET @saved_cs_client = @@character_set_client */;
+/*!50001 SET @saved_cs_results = @@character_set_results */;
+/*!50001 SET @saved_col_connection = @@collation_connection */;
+/*!50001 SET character_set_client = utf8mb4 */;
+/*!50001 SET character_set_results = utf8mb4 */;
+/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `payroll_employee` AS select `pw`.`workerFkA3` AS `CodTrabajador`,`pw`.`companyFkA3` AS `codempresa` from `vn`.`payrollWorker` `pw` */;
+/*!50001 SET character_set_client = @saved_cs_client */;
+/*!50001 SET character_set_results = @saved_cs_results */;
+/*!50001 SET collation_connection = @saved_col_connection */;
+
--
-- Final view structure for view `plantpassport`
--
@@ -92246,24 +91859,6 @@ USE `vn2008`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
---
--- Final view structure for view `v_jerarquia`
---
-
-/*!50001 DROP VIEW IF EXISTS `v_jerarquia`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `v_jerarquia` AS select `jerarquia`.`worker_id` AS `Id_Trabajador`,`jerarquia`.`boss_id` AS `boss_id` from `jerarquia` union all select distinct `jerarquia`.`boss_id` AS `Id_Trabajador`,`jerarquia`.`boss_id` AS `boss_id` from `jerarquia` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
--
-- Final view structure for view `versiones`
--
@@ -92281,6 +91876,24 @@ USE `vn2008`;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
+
+--
+-- Final view structure for view `warehouse_pickup`
+--
+
+/*!50001 DROP VIEW IF EXISTS `warehouse_pickup`*/;
+/*!50001 SET @saved_cs_client = @@character_set_client */;
+/*!50001 SET @saved_cs_results = @@character_set_results */;
+/*!50001 SET @saved_col_connection = @@collation_connection */;
+/*!50001 SET character_set_client = utf8mb4 */;
+/*!50001 SET character_set_results = utf8mb4 */;
+/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `warehouse_pickup` AS select `wp`.`warehouseFk` AS `warehouse_id`,`wp`.`agencyModeFk` AS `agency_id` from `vn`.`warehousePickup` `wp` */;
+/*!50001 SET character_set_client = @saved_cs_client */;
+/*!50001 SET character_set_results = @saved_cs_results */;
+/*!50001 SET collation_connection = @saved_col_connection */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -92291,4 +91904,4 @@ USE `vn2008`;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2024-02-23 11:43:22
+-- Dump completed on 2024-04-18 7:15:58
diff --git a/db/dump/.dump/triggers.sql b/db/dump/.dump/triggers.sql
index 9da5f32fc..f8923508a 100644
--- a/db/dump/.dump/triggers.sql
+++ b/db/dump/.dump/triggers.sql
@@ -820,6 +820,12 @@ DELIMITER ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
+--
+-- Current Database: `floranet`
+--
+
+USE `floranet`;
+
--
-- Current Database: `hedera`
--
@@ -2289,17 +2295,26 @@ trig: BEGIN
DECLARE vGroupingMode TINYINT;
DECLARE vGenericFk INT;
DECLARE vGenericInDate BOOL;
+ DECLARE vBuyerFk INT;
IF @isModeInventory THEN
LEAVE trig;
END IF;
+ CALL entry_checkBooked(NEW.entryFk);
IF NEW.printedStickers <> 0 THEN
CALL util.throw('it is not possible to create buy lines with printedstickers other than 0');
END IF;
SET NEW.editorFk = account.myUser_getId();
+ SELECT it.workerFk INTO vBuyerFk
+ FROM item i
+ JOIN itemType it ON it.id = i.typeFk
+ WHERE i.id = NEW.itemFk;
+
+ SET NEW.buyerFk = vBuyerFk;
+
CALL buy_checkGrouping(NEW.`grouping`);
SELECT t.warehouseInFk, t.landed
@@ -2409,11 +2424,13 @@ trig:BEGIN
DECLARE vGenericInDate BOOL;
DECLARE vIsInventory BOOL;
DECLARE vDefaultEntry INT;
+ DECLARE vBuyerFk INT;
IF @isTriggerDisabled THEN
LEAVE trig;
END IF;
+ CALL entry_checkBooked(OLD.entryFk);
SET NEW.editorFk = account.myUser_getId();
SELECT defaultEntry INTO vDefaultEntry
@@ -2467,6 +2484,15 @@ trig:BEGIN
SET NEW.isIgnored = TRUE;
END IF;
+ IF NOT (NEW.itemFk <=> OLD.itemFk) THEN
+ SELECT it.workerFk INTO vBuyerFk
+ FROM item i
+ JOIN itemType it ON it.id = i.typeFk
+ WHERE i.id = NEW.itemFk;
+
+ SET NEW.buyerFk = vBuyerFk;
+ END IF;
+
IF NOT (NEW.itemFk <=> OLD.itemFk) OR
NOT (OLD.entryFk <=> NEW.entryFk) THEN
CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck
@@ -2557,10 +2583,11 @@ DELIMITER ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`buy_beforeDelete`
- BEFORE DELETE ON buy
- FOR EACH ROW
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`buy_beforeDelete`
+ BEFORE DELETE ON `buy`
+ FOR EACH ROW
BEGIN
+ CALL entry_checkBooked(OLD.entryFk);
IF OLD.printedStickers <> 0 THEN
CALL util.throw("it is not possible to delete buys with printed labels ");
END IF;
@@ -4629,7 +4656,9 @@ BEGIN
CALL supplier_checkIsActive(NEW.supplierFk);
SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk);
SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk,NEW.supplierFk);
-
+ IF NEW.travelFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.travelFk) THEN
+ CALL util.throw('The travel is incorrect, there is a different AWB in the associated entries');
+ END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -4672,15 +4701,24 @@ BEGIN
DECLARE vIsVirtual BOOL;
DECLARE vPrintedCount INT;
DECLARE vHasDistinctWarehouses BOOL;
+
+ IF NEW.isBooked = OLD.isBooked THEN
+ CALL entry_checkBooked(OLD.id);
+ END IF;
SET NEW.editorFk = account.myUser_getId();
- IF !(NEW.travelFk <=> OLD.travelFk) THEN
+ IF NOT (NEW.travelFk <=> OLD.travelFk) THEN
+
+ IF NEW.travelFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.travelFk) THEN
+ CALL util.throw('The travel is incorrect, there is a different AWB in the associated entries');
+ END IF;
+
SELECT COUNT(*) > 0 INTO vIsVirtual
FROM entryVirtual WHERE entryFk = NEW.id;
- SELECT !(o.warehouseInFk <=> n.warehouseInFk)
- OR !(o.warehouseOutFk <=> n.warehouseOutFk)
+ SELECT NOT (o.warehouseInFk <=> n.warehouseInFk)
+ OR NOT (o.warehouseOutFk <=> n.warehouseOutFk)
INTO vHasDistinctWarehouses
FROM travel o, travel n
WHERE o.id = OLD.travelFk
@@ -4709,9 +4747,8 @@ BEGIN
SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk);
END IF;
- IF NOT (NEW.travelFk <=> OLD.travelFk)
- OR NOT (NEW.currencyFk <=> OLD.currencyFk) THEN
- SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk,NEW.supplierFk);
+ IF NOT (NEW.travelFk <=> OLD.travelFk) OR NOT (NEW.currencyFk <=> OLD.currencyFk) THEN
+ SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk, NEW.supplierFk);
END IF;
END */;;
DELIMITER ;
@@ -4771,6 +4808,7 @@ DELIMITER ;;
BEFORE DELETE ON `entry`
FOR EACH ROW
BEGIN
+ CALL entry_checkBooked(OLD.id);
DELETE FROM buy WHERE entryFk = OLD.id;
END */;;
DELIMITER ;
@@ -4813,6 +4851,70 @@ DELIMITER ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`entryDms_beforeInsert`
+ BEFORE INSERT ON `entryDms`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+END */;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`entryDms_beforeUpdate`
+ BEFORE UPDATE ON `entryDms`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+END */;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`entryDms_afterDelete`
+ AFTER DELETE ON `entryDms`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO entryLog
+ SET `action` = 'delete',
+ `changedModel` = 'EntryDms',
+ `changedModelId` = OLD.entryFk,
+ `userFk` = account.myUser_getId();
+END */;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`entryObservation_beforeInsert`
BEFORE INSERT ON `entryObservation`
FOR EACH ROW
@@ -5267,6 +5369,10 @@ BEGIN
DECLARE vActive TINYINT;
DECLARE vWithholdingSageFk INT;
+ IF NOT util.checkPrintableChars(NEW.supplierRef) THEN
+ CALL util.throw('The invoiceIn reference contains invalid characters');
+ END IF;
+
SET NEW.editorFk = account.myUser_getId();
SELECT withholdingSageFk INTO vWithholdingSageFk
@@ -5325,9 +5431,12 @@ DELIMITER ;;
BEFORE UPDATE ON `invoiceIn`
FOR EACH ROW
BEGIN
-
DECLARE vWithholdingSageFk INT;
+ IF NOT (NEW.supplierRef <=> OLD.supplierRef) AND NOT util.checkPrintableChars(NEW.supplierRef) THEN
+ CALL util.throw('The invoiceIn reference contains invalid characters');
+ END IF;
+
SET NEW.editorFk = account.myUser_getId();
IF (SELECT COUNT(*) FROM vn.invoiceIn
@@ -6714,7 +6823,7 @@ DELIMITER ;;
BEFORE INSERT ON `parking`
FOR EACH ROW
BEGIN
-
+ SET NEW.editorFk = account.myUser_getId();
-- SET new.`code` = CONCAT(new.`column`,' - ',new.`row`) ;
END */;;
@@ -6736,7 +6845,7 @@ DELIMITER ;;
BEFORE UPDATE ON `parking`
FOR EACH ROW
BEGIN
-
+ SET NEW.editorFk = account.myUser_getId();
-- SET new.`code` = CONCAT(new.`column`,' - ',new.`row`) ;
END */;;
@@ -6750,11 +6859,37 @@ DELIMITER ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `payment_beforeInsert` BEFORE INSERT ON `payment` FOR EACH ROW
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`parking_afterDelete`
+ AFTER DELETE ON `parking`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO parkingLog
+ SET `action` = 'delete',
+ `changedModel` = 'Parking',
+ `changedModelId` = OLD.id,
+ `userFk` = account.myUser_getId();
+END */;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`payment_beforeInsert`
+ BEFORE INSERT ON `payment`
+ FOR EACH ROW
BEGIN
DECLARE cuenta_banco,cuenta_proveedor DOUBLE;
DECLARE vNewBookEntry INT;
@@ -6763,21 +6898,21 @@ BEGIN
-- PAK 10/02/15 No se asientan los pagos directamente, salvo en el caso de las cajas de CASH
SELECT (at2.code = 'cash') INTO bolCASH
- FROM vn.bank b
- JOIN vn.accountingType at2 ON at2.id = b.cash
- WHERE b.id = NEW.bankFk;
+ FROM accounting a
+ JOIN accountingType at2 ON at2.id = a.accountingTypeFk
+ WHERE a.id = NEW.bankFk;
IF bolCASH THEN
SELECT account INTO cuenta_banco
- FROM bank
+ FROM accounting
WHERE id = NEW.bankFk;
SELECT account INTO cuenta_proveedor
FROM supplier
WHERE id = NEW.supplierFk;
- CALL vn.ledger_next(vNewBookEntry);
+ CALL ledger_next(vNewBookEntry);
INSERT INTO XDiario ( ASIEN,
FECHA,
@@ -8044,6 +8179,26 @@ DELIMITER ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`saleLabel_afterUpdate`
+ AFTER UPDATE ON `vn`.`saleLabel`
+ FOR EACH ROW
+IF NEW.stem >= (SELECT s.quantity FROM sale s WHERE s.id = NEW.saleFk) THEN
+ UPDATE sale s SET s.isPicked = TRUE WHERE s.id = NEW.saleFk;
+END IF */;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`saleTracking_afterInsert`
AFTER INSERT ON `saleTracking`
FOR EACH ROW
@@ -8683,6 +8838,70 @@ DELIMITER ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierDms_beforeInsert`
+ BEFORE INSERT ON `supplierDms`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+END */;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierDms_beforeUpdate`
+ BEFORE UPDATE ON `supplierDms`
+ FOR EACH ROW
+BEGIN
+ SET NEW.editorFk = account.myUser_getId();
+END */;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+DELIMITER ;;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierDms_afterDelete`
+ AFTER DELETE ON `supplierDms`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO clientLog
+ SET `action` = 'delete',
+ `changedModel` = 'supplierDms',
+ `changedModelId` = OLD.dmsFk,
+ `userFk` = account.myUser_getId();
+END */;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`tag_beforeInsert`
BEFORE INSERT ON `tag`
FOR EACH ROW
@@ -8780,7 +8999,6 @@ DELIMITER ;;
FOR EACH ROW
BEGIN
DECLARE vNewTime TIME;
- DECLARE vHasTicketRefund BOOL;
SET NEW.editorFk = account.myUser_getId();
@@ -8840,15 +9058,6 @@ BEGIN
CALL vn.routeUpdateM3(NEW.routeFk);
END IF;
-
- SELECT COUNT(*) INTO vHasTicketRefund
- FROM ticketRefund
- WHERE originalTicketFk = NEW.id
- OR refundTicketFk = NEW.id;
-
- IF vHasTicketRefund AND NEW.clientFk <> OLD.clientFk THEN
- CALL util.throw('The ticket has a refund associated');
- END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -9858,6 +10067,10 @@ BEGIN
CALL travel_checkDates(NEW.shipped, NEW.landed);
CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk);
+
+ IF NEW.awbFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.id) THEN
+ CALL util.throw('The AWB is incorrect, there is a different AWB in the associated entries');
+ END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -9877,9 +10090,11 @@ DELIMITER ;;
BEFORE UPDATE ON `travel`
FOR EACH ROW
BEGIN
+ DECLARE vHasAnyInvoiceBooked BOOL;
+
SET NEW.editorFk = account.myUser_getId();
- IF NOT (NEW.landed <=> OLD.landed)
+ IF NOT (NEW.landed <=> OLD.landed)
OR NOT (NEW.shipped <=> OLD.shipped) THEN
CALL travel_checkDates(NEW.shipped, NEW.landed);
END IF;
@@ -9891,6 +10106,23 @@ BEGIN
IF NOT (NEW.warehouseInFk <=> OLD.warehouseInFk) THEN
CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk);
END IF;
+
+ IF NOT (NEW.awbFk <=> OLD.awbFk)THEN
+ SELECT COUNT(*) INTO vHasAnyInvoiceBooked
+ FROM travel t
+ JOIN entry e ON e.travelFk = t.id
+ JOIN invoiceIn ii ON ii.id = e.invoiceInFk
+ WHERE t.id = NEW.id
+ AND ii.isBooked;
+
+ IF vHasAnyInvoiceBooked THEN
+ CALL util.throw('The travel has entries with booked invoices');
+ END IF;
+ END IF;
+
+ IF (NOT(NEW.awbFk <=> OLD.awbFk)) AND NEW.awbFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.id) THEN
+ CALL util.throw('The AWB is incorrect, there is a different AWB in the associated entries');
+ END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -9912,7 +10144,7 @@ DELIMITER ;;
BEGIN
CALL stock.log_add('travel', NEW.id, OLD.id);
- IF !(NEW.shipped <=> OLD.shipped) THEN
+ IF NOT(NEW.shipped <=> OLD.shipped) THEN
UPDATE entry
SET commission = entry_getCommission(travelFk, currencyFk,supplierFk)
WHERE travelFk = NEW.id;
@@ -10636,6 +10868,7 @@ DELIMITER ;;
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
+
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -10656,6 +10889,7 @@ DELIMITER ;;
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
+
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -10665,11 +10899,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 = utf8mb3 */ ;
-/*!50003 SET character_set_results = utf8mb3 */ ;
-/*!50003 SET collation_connection = utf8mb3_general_ci */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneIncluded_afterDelete`
AFTER DELETE ON `zoneIncluded`
@@ -10680,6 +10914,7 @@ BEGIN
`changedModel` = 'zoneIncluded',
`changedModelId` = OLD.zoneFk,
`userFk` = account.myUser_getId();
+
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -10756,30 +10991,10 @@ DELIMITER ;
--
USE `vn2008`;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn2008`.`movement_label_afterUpdate`
- AFTER UPDATE ON `movement_label`
- FOR EACH ROW
-IF NEW.stem >= (SELECT Cantidad FROM Movimientos WHERE Id_Movimiento = NEW.Id_Movimiento) THEN
- UPDATE Movimientos SET OK = 1 WHERE Id_Movimiento = NEW.Id_Movimiento;
-END IF */;;
-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 */ ;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2024-02-23 11:43:46
+-- Dump completed on 2024-04-18 7:16:17
diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql
index bda625a96..523f41bfb 100644
--- a/db/dump/fixtures.after.sql
+++ b/db/dump/fixtures.after.sql
@@ -7,8 +7,12 @@ SET foreign_key_checks = 0;
-- XXX: vn-database
-INSERT INTO util.config (environment, mockTime, mockUtcTime, mockEnabled)
- VALUES ('local', '2001-01-01 12:00:00', '2001-01-01 11:00:00', TRUE);
+INSERT INTO util.config (id, environment, mockTime, mockUtcTime, mockEnabled)
+ VALUES (1, 'local', '2001-01-01 12:00:00', '2001-01-01 11:00:00', TRUE);
+
+INSERT INTO util.binlogQueue (code,logName, `position`)
+ VALUES ('mylogger', 'bin.000001', 4);
+
/* #5483
INSERT INTO vn.entryConfig (defaultEntry, mailToNotify, inventorySupplierFk, maxLockTime, defaultSupplierFk)
VALUES(1, NULL, 1, 300, 1);
@@ -70,7 +74,7 @@ UPDATE vn.supplier
UPDATE `vn`.`claimRatio` SET `claimAmount` = '10' WHERE (`clientFk` = '1101');
-INSERT INTO `vn`.`agency` (`name`, `warehouseFk`, `isOwn`, `isAnyVolumeAllowed`)
+INSERT INTO `vn`.`agency` (`name`, `warehouseFk`, `isOwn`, `isAnyVolumeAllowed`)
VALUES
('Agencia', '1', '1', '1'),
('Otra agencia ', '1', '0', '0');
@@ -113,9 +117,6 @@ INSERT INTO vn.ticket (clientFk, warehouseFk, shipped, nickname, refFk, addressF
(100, 4, '2022-07-12 00:00:00', 'root', NULL, 195, NULL, NULL, 0, 0, 0, 0, NULL, 0, '2022-07-12 16:18:58', 1, NULL, 4, NULL, 1, 567, 1, '2022-07-12', 0, 0, 6, NULL, NULL, NULL, NULL, NULL),
(100, 5, '2022-07-12 00:00:00', 'root', NULL, 195, NULL, NULL, 0, 0, 0, 0, NULL, 0, '2022-07-12 16:18:58', 1, NULL, 5, NULL, 1, 567, 1, '2022-07-12', 0, 0, 1, NULL, NULL, NULL, NULL, NULL);
*/
-INSERT INTO vn.sector (description,warehouseFk) VALUES
- ('Sector One',1);
-
INSERT INTO vn.saleGroup (userFk,parkingFk,sectorFk) VALUES
(100,1,1);
@@ -156,16 +157,6 @@ INSERT INTO `vn`.`occupationCode` (`code`, `name`)
('b', 'Representantes de comercio'),
('c', 'Personal de oficios en trabajos de construcción en general, y en instalac.,edificios y obras');
-INSERT INTO `vn2008`.`payroll_employee` (`CodTrabajador`,`nss`,`codpuesto`,`codempresa`,`codcontrato`,`FAntiguedad`,`grupotarifa`,`codcategoria`,`ContratoTemporal`)
- VALUES
- (36,'46/10515497-58',6,20,189,'2009-01-02',5,10,0),
- (43,'46/10235353-50',7,20,189,'2009-04-21',5,10,0),
- (76,'46/10250562-30',1,20,189,'2009-09-07',9,5,0),
- (1106,'46/10297768-94',4,20,100,'2021-03-09',7,18,0),
- (1107,'46/1627085-11',15,20,402,'2021-03-15',9,6,1),
- (1108,'46/10446901-41',25,20,502,'2021-03-22',10,29,1),
- (1109,'46/10552113-8',3,20,402,'2021-03-23',9,9,1),
- (1110,'46/10723579-75',3,20,402,'2021-03-23',9,9,1);
INSERT INTO `vn`.`trainingCourseType` (`id`, `name`)
VALUES
diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql
index aef0f13e3..8660d61c9 100644
--- a/db/dump/fixtures.before.sql
+++ b/db/dump/fixtures.before.sql
@@ -60,13 +60,13 @@ INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`)
VALUES
('1', '6');
-INSERT INTO `vn`.`bionicConfig` (`generalInflationCoeficient`, `minimumDensityVolumetricWeight`, `verdnaturaVolumeBox`, `itemCarryBox`)
+INSERT INTO `vn`.`bionicConfig` (`id`, `generalInflationCoeficient`, `minimumDensityVolumetricWeight`, `verdnaturaVolumeBox`, `itemCarryBox`)
VALUES
- (1.30, 167.00, 138000, 71);
+ (1, 1.30, 167.00, 138000, 71);
-INSERT INTO `vn`.`chatConfig` (`host`, `api`)
+INSERT INTO `vn`.`chatConfig` (`id`, `host`, `api`)
VALUES
- ('https://chat.verdnatura.es', 'https://chat.verdnatura.es/api/v1');
+ (1, 'https://chat.verdnatura.es', 'https://chat.verdnatura.es/api/v1');
INSERT IGNORE INTO `vn`.`greugeConfig`(`id`, `freightPickUpPrice`)
VALUES
@@ -81,7 +81,7 @@ INSERT INTO `account`.`roleConfig`(`id`, `mysqlPassword`, `rolePrefix`, `userPre
CALL `account`.`role_sync`;
INSERT INTO `account`.`user`(`id`,`name`, `nickname`, `role`,`active`,`email`, `lang`, `image`, `password`)
- SELECT id, name, CONCAT(name, 'Nick'), id, 1, CONCAT(name, '@mydomain.com'), 'en', '4fa3ada0-3ac4-11eb-9ab8-27f6fc3b85fd', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2'
+ SELECT id, LOWER(name), CONCAT(name, 'Nick'), id, 1, CONCAT(name, '@mydomain.com'), 'en', '4fa3ada0-3ac4-11eb-9ab8-27f6fc3b85fd', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2'
FROM `account`.`role`
ORDER BY id;
@@ -118,18 +118,18 @@ INSERT INTO `hedera`.`tpvConfig`(`id`, `currency`, `terminal`, `transactionType`
INSERT INTO `account`.`user`(`id`,`name`,`nickname`, `password`,`role`,`active`,`email`,`lang`, `image`)
VALUES
- (1101, 'BruceWayne', 'Bruce Wayne', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'BruceWayne@mydomain.com', 'es', 'e7723f0b24ff05b32ed09d95196f2f29'),
- (1102, 'PetterParker', 'Petter Parker', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'PetterParker@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'),
- (1103, 'ClarkKent', 'Clark Kent', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'ClarkKent@mydomain.com', 'fr', 'e7723f0b24ff05b32ed09d95196f2f29'),
- (1104, 'TonyStark', 'Tony Stark', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'TonyStark@mydomain.com', 'es', 'e7723f0b24ff05b32ed09d95196f2f29'),
- (1105, 'MaxEisenhardt', 'Max Eisenhardt', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'MaxEisenhardt@mydomain.com', 'pt', 'e7723f0b24ff05b32ed09d95196f2f29'),
- (1106, 'DavidCharlesHaller', 'David Charles Haller', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'DavidCharlesHaller@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'),
- (1107, 'HankPym', 'Hank Pym', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'HankPym@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'),
- (1108, 'CharlesXavier', 'Charles Xavier', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'CharlesXavier@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'),
- (1109, 'BruceBanner', 'Bruce Banner', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'BruceBanner@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'),
- (1110, 'JessicaJones', 'Jessica Jones', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'JessicaJones@mydomain.com', 'en', NULL),
- (1111, 'Missing', 'Missing', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 0, NULL, 'en', NULL),
- (1112, 'Trash', 'Trash', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 0, NULL, 'en', NULL);
+ (1101, 'brucewayne', 'Bruce Wayne', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'BruceWayne@mydomain.com', 'es','1101'),
+ (1102, 'petterparker', 'Petter Parker', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'PetterParker@mydomain.com', 'en','1102'),
+ (1103, 'clarkkent', 'Clark Kent', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'ClarkKent@mydomain.com', 'fr','1103'),
+ (1104, 'tonystark', 'Tony Stark', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'TonyStark@mydomain.com', 'es','1104'),
+ (1105, 'maxeisenhardt', 'Max Eisenhardt', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'MaxEisenhardt@mydomain.com', 'pt','1105'),
+ (1106, 'davidcharleshaller', 'David Charles Haller', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'DavidCharlesHaller@mydomain.com', 'en','1106'),
+ (1107, 'hankpym', 'Hank Pym', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'HankPym@mydomain.com', 'en','1107'),
+ (1108, 'charlesxavier', 'Charles Xavier', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'CharlesXavier@mydomain.com', 'en','1108'),
+ (1109, 'brucebanner', 'Bruce Banner', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'BruceBanner@mydomain.com', 'en','1109'),
+ (1110, 'jessicajones', 'Jessica Jones', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'JessicaJones@mydomain.com', 'en','1110'),
+ (1111, 'missing', 'Missing', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 0, NULL, 'en','e7723f0b24ff05b32ed09d95196f2f29'),
+ (1112, 'trash', 'Trash', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 0, NULL, 'en','e7723f0b24ff05b32ed09d95196f2f29');
UPDATE account.`user`
SET passExpired = DATE_SUB(util.VN_CURDATE(), INTERVAL 1 YEAR)
@@ -198,7 +198,7 @@ INSERT INTO `vn`.`printer` (`id`, `name`, `path`, `isLabeler`, `sectorFk`, `ipAd
(2, 'printer2', 'path2', 1, 1 , NULL),
(4, 'printer4', 'path4', 0, NULL, '10.1.10.4');
-UPDATE `vn`.`sector` SET mainPrinterFk = 1 WHERE id = 1;
+UPDATE `vn`.`sector` SET `backupPrinterFk` = 1 WHERE id = 1;
INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`,`bossFk`, `phone`)
@@ -592,13 +592,13 @@ INSERT INTO `vn`.`supplierAccount`(`id`, `supplierFk`, `iban`, `bankEntityFk`)
VALUES
(241, 442, 'ES111122333344111122221111', 128);
-INSERT INTO `vn`.`company`(`id`, `code`, `supplierAccountFk`, `workerManagerFk`, `companyCode`, `sage200Company`, `expired`, `companyGroupFk`, `phytosanitary` , `clientFk`)
+INSERT INTO `vn`.`company`(`id`, `code`, `supplierAccountFk`, `workerManagerFk`, `companyCode`, `expired`, `companyGroupFk`, `phytosanitary` , `clientFk`)
VALUES
- (69 , 'CCs', NULL, 30, NULL, 0, NULL, 1, NULL , NULL),
- (442 , 'VNL', 241, 30, 2 , 1, NULL, 2, 'VNL Company - Plant passport' , 1101),
- (567 , 'VNH', NULL, 30, NULL, 4, NULL, 1, 'VNH Company - Plant passport' , NULL),
- (791 , 'FTH', NULL, 30, NULL, 3, '2015-11-30', 1, NULL , NULL),
- (1381, 'ORN', NULL, 30, NULL, 7, NULL, 1, 'ORN Company - Plant passport' , NULL);
+ (69 , 'CCs', NULL, 30, 0, NULL, 1, NULL , NULL),
+ (442 , 'VNL', 241, 30, 1, NULL, 2, 'VNL Company - Plant passport' , 1101),
+ (567 , 'VNH', NULL, 30, 4, NULL, 1, 'VNH Company - Plant passport' , NULL),
+ (791 , 'FTH', NULL, 30, 3, '2015-11-30', 1, NULL , NULL),
+ (1381, 'ORN', NULL, 30, 7, NULL, 1, 'ORN Company - Plant passport' , NULL);
INSERT INTO `vn`.`taxArea` (`code`, `claveOperacionFactura`, `CodigoTransaccion`)
VALUES
@@ -608,7 +608,8 @@ INSERT INTO `vn`.`taxArea` (`code`, `claveOperacionFactura`, `CodigoTransaccion`
('WORLD', 2, 15);
INSERT INTO vn.invoiceOutConfig
- SET parallelism = 8;
+ SET id = 1,
+ parallelism = 8;
INSERT INTO `vn`.`invoiceOutSerial` (`code`, `description`, `isTaxed`, `taxAreaFk`, `isCEE`, `type`)
VALUES
@@ -714,7 +715,7 @@ INSERT INTO `vn`.`zoneClosure` (`zoneFk`, `dated`, `hour`)
(12, util.VN_CURDATE(), '23:59'),
(13, util.VN_CURDATE(), '23:59');
-INSERT INTO `vn`.`zoneConfig` (`scope`) VALUES ('1');
+INSERT INTO `vn`.`zoneConfig` (`id`, `scope`) VALUES (1, '1');
INSERT INTO `vn`.`route`(`id`, `time`, `workerFk`, `created`, `vehicleFk`, `agencyModeFk`, `description`, `m3`, `cost`, `started`, `finished`, `zoneFk`)
VALUES
@@ -759,8 +760,8 @@ INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeF
(29, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL),
(30, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL),
(31, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL),
- (32, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL);
-
+ (32, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL),
+ (33, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL);
INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`)
VALUES
(1, 11, 1, 'ready'),
@@ -983,9 +984,9 @@ INSERT INTO `vn`.`packaging`(`id`, `volume`, `width`, `height`, `depth`, `isPack
('cc', 1640038.00, 56.00, 220.00, 128.00, 1, util.VN_CURDATE(), 15, 90.00),
('pallet 100', 2745600.00, 100.00, 220.00, 120.00, 1, util.VN_CURDATE(), 16, 0.00);
-INSERT INTO `vn`.`packagingConfig`(`upperGap`, `defaultSmallPackageFk`, `defaultBigPackageFk`)
+INSERT INTO `vn`.`packagingConfig`(`id`, `upperGap`, `defaultSmallPackageFk`, `defaultBigPackageFk`)
VALUES
- ('10', 1, 'pallet 100');
+ (1, '10', 1, 'pallet 100');
INSERT INTO `vn`.`expeditionStateType`(`id`, `description`, `code`)
VALUES
@@ -1239,6 +1240,7 @@ INSERT INTO `vn`.`train`(`id`, `name`)
INSERT INTO `vn`.`operator` (`workerFk`, `numberOfWagons`, `trainFk`, `itemPackingTypeFk`, `warehouseFk`, `sectorFk`, `labelerFk`)
VALUES
('1106', '1', '1', 'H', '1', '1', '1'),
+ ('9', '2', '1', 'H', '1', '1', '1'),
('1107', '1', '1', 'V', '1', '1', '1');
INSERT INTO `vn`.`collection`(`id`, `workerFk`, `stateFk`, `created`, `trainFk`)
@@ -1490,21 +1492,21 @@ INSERT INTO `bs`.`waste`(`buyer`, `year`, `week`, `family`, `itemFk`, `itemTypeF
INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packagingFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`, `printedStickers`,`isChecked`,`isIgnored`,`weight`, `created`)
VALUES
- (1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)),
- (2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
- (3, 3, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 0, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE()),
- (4, 2, 2, 5, 450, 3, 1, 1.000, 1.000, 0.000, 10, 10, 0, NULL, 0.00, 7.30, 7.00, 0, 1, 0, 2.5, util.VN_CURDATE()),
- (5, 3, 3, 55, 500, 5, 1, 1.000, 1.000, 0.000, 1, 1, 0, NULL, 0.00, 78.3, 75.6, 0, 1, 0, 2.5, util.VN_CURDATE()),
- (6, 4, 8, 50, 1000, 4, 1, 1.000, 1.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 2.5, util.VN_CURDATE()),
- (7, 4, 9, 20, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 30.50, 29.00, 0, 1, 0, 2.5, util.VN_CURDATE()),
- (8, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 2.5, util.VN_CURDATE()),
- (9, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()),
- (10, 5, 1, 50, 10, 4, 1, 2.500, 2.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE()),
- (11, 5, 4, 1.25, 10, 3, 1, 2.500, 2.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()),
- (12, 6, 4, 1.25, 0, 3, 1, 2.500, 2.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()),
- (13, 7, 1, 50, 0, 3, 1, 2.000, 2.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE()),
- (14, 7, 2, 5, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 7.30, 7.00, 0, 1, 0, 4, util.VN_CURDATE()),
- (15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE());
+ (1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH),
+ (2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 1 MONTH),
+ (3, 3, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, NULL, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE()),
+ (4, 2, 2, 5, 450, 3, 1, 1.000, 1.000, 0.000, 10, 10, NULL, NULL, 0.00, 7.30, 7.00, 0, 1, 0, 2.5, util.VN_CURDATE()),
+ (5, 3, 3, 55, 500, 5, 1, 1.000, 1.000, 0.000, 1, 1, NULL, NULL, 0.00, 78.3, 75.6, 0, 1, 0, 2.5, util.VN_CURDATE()),
+ (6, 4, 8, 50, 1000, 4, 1, 1.000, 1.000, 0.000, 1, 1, 'grouping', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 2.5, util.VN_CURDATE()),
+ (7, 4, 9, 20, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 'packing', NULL, 0.00, 30.50, 29.00, 0, 1, 0, 2.5, util.VN_CURDATE()),
+ (8, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 2.5, util.VN_CURDATE()),
+ (9, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()),
+ (10, 5, 1, 50, 10, 4, 1, 2.500, 2.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE()),
+ (11, 5, 4, 1.25, 10, 3, 1, 2.500, 2.500, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()),
+ (12, 6, 4, 1.25, 0, 3, 1, 2.500, 2.500, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()),
+ (13, 7, 1, 50, 0, 3, 1, 2.000, 2.000, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE()),
+ (14, 7, 2, 5, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 7.30, 7.00, 0, 1, 0, 4, util.VN_CURDATE()),
+ (15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE());
INSERT INTO `hedera`.`order`(`id`, `date_send`, `customer_id`, `delivery_method_id`, `agency_id`, `address_id`, `company_id`, `note`, `source_app`, `confirmed`,`total`, `date_make`, `first_row_stamp`, `confirm_date`)
VALUES
@@ -1819,19 +1821,16 @@ INSERT INTO `vn`.`clientSample`(`id`, `clientFk`, `typeFk`, `created`, `workerFk
INSERT INTO `vn`.`claimState`(`id`, `code`, `description`, `roleFk`, `priority`, `hasToNotify`)
VALUES
( 1, 'pending', 'Pendiente', 1, 1, 0),
- ( 2, 'managed', 'Gestionado', 72, 5, 0),
( 3, 'resolved', 'Resuelto', 72, 7, 0),
( 4, 'canceled', 'Anulado', 72, 6, 1),
- ( 5, 'incomplete', 'Incompleta', 1, 3, 1),
- ( 6, 'mana', 'Mana', 72, 4, 0),
- ( 7, 'lack', 'Faltas', 72, 2, 0);
+ ( 5, 'incomplete', 'Incompleta', 1, 3, 1);
INSERT INTO `vn`.`claim`(`id`, `ticketCreated`, `claimStateFk`, `clientFk`, `workerFk`, `responsibility`, `isChargedToMana`, `created`, `packages`, `ticketFk`)
VALUES
- (1, util.VN_CURDATE(), 1, 1101, 18, 3, 0, util.VN_CURDATE(), 0, 11),
- (2, util.VN_CURDATE(), 2, 1101, 18, 3, 0, util.VN_CURDATE(), 1, 16),
- (3, util.VN_CURDATE(), 3, 1101, 18, 1, 1, util.VN_CURDATE(), 5, 7),
- (4, util.VN_CURDATE(), 3, 1104, 18, 5, 0, util.VN_CURDATE(), 10, 8);
+ (1, util.VN_CURDATE(), 1, 1101, 19, 3, 0, util.VN_CURDATE(), 0, 11),
+ (2, util.VN_CURDATE(), 4, 1101, 18, 3, 0, util.VN_CURDATE(), 1, 16),
+ (3, util.VN_CURDATE(), 3, 1101, 19, 1, 1, util.VN_CURDATE(), 5, 7),
+ (4, util.VN_CURDATE(), 3, 1104, 18, 5, 0, util.VN_CURDATE(), 10, 8);
INSERT INTO `vn`.`claimObservation` (`claimFk`, `workerFk`, `text`, `created`)
VALUES
@@ -1870,8 +1869,7 @@ INSERT INTO `vn`.`claimEnd`(`id`, `saleFk`, `claimFk`, `workerFk`, `claimDestina
INSERT INTO `vn`.`claimConfig`(`id`, `maxResponsibility`)
VALUES
- (1, 50),
- (2, 30);
+ (1, 50);
INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRate`, `priceIncreasing`, `packingRate`)
VALUES
@@ -1882,7 +1880,7 @@ INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRa
INSERT INTO `vn`.`claimLog` (`originFk`, userFk, `action`, changedModel, oldInstance, newInstance, changedModelId, `description`)
VALUES
- (1, 18, 'update', 'Claim', '{"hasToPickUp":false}', '{"hasToPickUp":true}', 1, NULL),
+ (1, 18, 'update', 'Claim', '{"pickup":null}', '{"pickup":"agency"}', 1, NULL),
(1, 18, 'update', 'ClaimObservation', '{}', '{"claimFk":1,"text":"Waiting for customer"}', 1, NULL),
(1, 18, 'insert', 'ClaimBeginning', '{}', '{"claimFk":1,"saleFk":1,"quantity":10}', 1, NULL),
(1, 18, 'insert', 'ClaimDms', '{}', '{"claimFk":1,"dmsFk":1}', 1, NULL);
@@ -1975,6 +1973,15 @@ INSERT INTO `vn`.`ticketService`(`id`, `description`, `quantity`, `price`, `taxC
(4, 'Documentos', 1, 2.00, 1, 9, 1),
(5, 'Documentos', 1, 2.00, 1, 8, 1);
+INSERT INTO `pbx`.`config` (id,defaultPrefix)
+ VALUES (1,'0034');
+
+INSERT INTO `pbx`.`prefix` (country, prefix)
+ VALUES
+ ('es', '0034'),
+ ('fr', '0033'),
+ ('pt', '00351');
+
INSERT INTO `pbx`.`sip`(`user_id`, `extension`)
VALUES
(1, 1010),
@@ -1982,10 +1989,10 @@ INSERT INTO `pbx`.`sip`(`user_id`, `extension`)
(5, 1102),
(9, 1201);
-INSERT INTO `vn`.`professionalCategory` (`id`, `name`, `level`, `dayBreak`)
+INSERT INTO `vn`.`professionalCategory` (`id`, `description`)
VALUES
- (1, 'employee', NULL, NULL),
- (2, 'florist', NULL, NULL);
+ (1, 'employee'),
+ (2, 'florist');
INSERT INTO `vn`.`calendarType` (`id`, `description`, `hoursWeek`, `isPartial`)
VALUES
@@ -2402,7 +2409,8 @@ INSERT INTO `vn`.`dmsType`(`id`, `name`, `readRoleFk`, `writeRoleFk`, `code`)
(18, 'dua', NULL, NULL, 'dua'),
(19, 'inmovilizado', NULL, NULL, 'fixedAssets'),
(20, 'Reclamación', 1, 1, 'claim'),
- (21, 'Entrada', 1, 1, 'entry');
+ (21, 'Entrada', 1, 1, 'entry'),
+ (22, 'Proveedor', 1, 1, 'supplier');
INSERT INTO `vn`.`dms`(`id`, `dmsTypeFk`, `file`, `contentType`, `workerFk`, `warehouseFk`, `companyFk`, `hardCopyNumber`, `hasFile`, `reference`, `description`, `created`)
VALUES
@@ -2414,7 +2422,8 @@ INSERT INTO `vn`.`dms`(`id`, `dmsTypeFk`, `file`, `contentType`, `workerFk`, `wa
(6, 5, '6.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'NotExists', 'DoesNotExists', util.VN_CURDATE()),
(7, 20, '7.jpg', 'image/jpeg', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', util.VN_CURDATE()),
(8, 20, '8.mp4', 'video/mp4', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', util.VN_CURDATE()),
- (9, 21, '7.jpg', 'image/jpeg', 9, 1, 442, NULL, FALSE, '1', 'ENTRADA ID 1', util.VN_CURDATE());
+ (9, 21, '7.jpg', 'image/jpeg', 9, 1, 442, NULL, FALSE, '1', 'ENTRADA ID 1', util.VN_CURDATE()),
+ (10, 21, '7.jpg', 'image/jpeg', 9, 1, 442, NULL, FALSE, '1', 'ENTRADA DE PRUEBA', util.VN_CURDATE());
INSERT INTO `vn`.`claimDms`(`claimFk`, `dmsFk`)
VALUES
@@ -2506,9 +2515,9 @@ INSERT INTO `hedera`.`imageCollectionSize`(`id`, `collectionFk`,`width`, `height
VALUES
(1, 4, 160, 160);
-INSERT INTO `vn`.`rateConfig`(`rate0`, `rate1`, `rate2`, `rate3`)
+INSERT INTO `vn`.`rateConfig`(`id`, `rate0`, `rate1`, `rate2`, `rate3`)
VALUES
- (36, 31, 25, 21);
+ (1, 36, 31, 25, 21);
INSERT INTO `vn`.`rate`(`dated`, `warehouseFk`, `rate0`, `rate1`, `rate2`, `rate3`)
VALUES
@@ -2542,15 +2551,15 @@ INSERT INTO `vn`.`duaEntry` (`duaFk`, `entryFk`, `value`, `customsValue`, `euroV
REPLACE INTO `vn`.`invoiceIn`(`id`, `serialNumber`,`serial`, `supplierFk`, `issued`, `created`, `supplierRef`, `isBooked`, `companyFk`, `docFk`)
VALUES
(1, 1001, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1234, 0, 442, 1),
- (2, 1002, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1235, 1, 442, 1),
+ (2, 1002, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1235, 0, 442, 1),
(3, 1003, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1236, 0, 442, 1),
(4, 1004, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1237, 0, 442, 1),
- (5, 1005, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1238, 1, 442, 1),
+ (5, 1005, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1238, 0, 442, 1),
(6, 1006, 'R', 2, util.VN_CURDATE(), util.VN_CURDATE(), 1239, 0, 442, 1),
- (7, 1007, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1240, 1, 442, 1),
- (8, 1008, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1241, 1, 442, 1),
- (9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 1, 442, 1),
- (10, 1010, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1243, 1, 442, 1);
+ (7, 1007, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1240, 0, 442, 1),
+ (8, 1008, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1241, 0, 442, 1),
+ (9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 0, 442, 1),
+ (10, 1010, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1243, 0, 442, 1);
INSERT INTO `vn`.`invoiceInConfig` (`id`, `retentionRate`, `retentionName`, `sageWithholdingFk`, `daysAgo`)
VALUES
@@ -2605,6 +2614,10 @@ INSERT INTO `vn`.`invoiceInIntrastat` (`invoiceInFk`, `net`, `intrastatFk`, `amo
(2, 13.20, 5080000, 15.00, 580, 5),
(2, 16.10, 6021010, 25.00, 80, 5);
+UPDATE `vn`.`invoiceIn`
+ SET isBooked = TRUE
+ WHERE id IN (2, 5, 7, 8, 9, 10);
+
INSERT INTO `vn`.`ticketRecalc`(`ticketFk`)
SELECT t.id
FROM vn.ticket t
@@ -2699,9 +2712,9 @@ INSERT INTO `bs`.`sale` (`saleFk`, `amount`, `dated`, `typeFk`, `clientFk`)
(4, 33.8, util.VN_CURDATE(), 1, 1101),
(30, 34.4, util.VN_CURDATE(), 1, 1108);
-INSERT INTO `vn`.`docuwareConfig` (`url`)
+INSERT INTO `vn`.`docuwareConfig` (`id`, `url`)
VALUES
- ('http://docuware.url/');
+ (1, 'http://docuware.url/');
INSERT INTO `vn`.`calendarHolidaysName` (`id`, `name`)
VALUES
@@ -2729,10 +2742,10 @@ INSERT INTO `vn`.`chat` (`senderFk`, `recipient`, `dated`, `checkUserStatus`, `m
(1101, '@PetterParker', util.VN_CURDATE(), 0, 'Second test message', 0, 'pending');
-INSERT INTO `vn`.`mobileAppVersionControl` (`appName`, `version`, `isVersionCritical`)
+INSERT INTO `vn`.`mobileAppVersionControl` (`appName`, `version`, `isVersionCritical`,`versionBeta`)
VALUES
- ('delivery', '9.2', 0),
- ('warehouse', '8.1', 0);
+ ('delivery', '9.2', 0,'9.7'),
+ ('warehouse', '8.1', 0,'8.3');
INSERT INTO `vn`.`machine` (`plate`, `maker`, `model`, `warehouseFk`, `departmentFk`, `type`, `use`, `productionYear`, `workerFk`, `companyFk`)
VALUES
@@ -2798,12 +2811,13 @@ INSERT INTO `vn`.`packingSite` (`id`, `code`, `hostFk`, `monitorId`)
VALUES
(1, 'h1', 1, '');
-INSERT INTO `vn`.`packingSiteConfig` (`shinobiUrl`, `shinobiToken`, `shinobiGroupKey`, `avgBoxingTime`)
+INSERT INTO `vn`.`packingSiteConfig` (`id`, `shinobiUrl`, `shinobiToken`, `shinobiGroupKey`, `avgBoxingTime`)
VALUES
- ('', 'SHINNOBI_TOKEN', 'GROUP_TOKEN', 6000);
+ (1, '', 'SHINNOBI_TOKEN', 'GROUP_TOKEN', 6000);
INSERT INTO `util`.`notificationConfig`
- SET `cleanDays` = 90;
-
+ SET `id` = 1,
+ `cleanDays` = 90;
+TRUNCATE `util`.`notification`;
INSERT INTO `util`.`notification` (`id`, `name`, `description`)
VALUES
(1, 'print-email', 'notification fixture one'),
@@ -2811,8 +2825,11 @@ INSERT INTO `util`.`notification` (`id`, `name`, `description`)
(3, 'not-main-printer-configured', 'A printer distinct than main has been configured'),
(4, 'supplier-pay-method-update', 'A supplier pay method has been updated'),
(5, 'modified-entry', 'An entry has been modified'),
- (6, 'book-entry-deleted', 'accounting entries deleted');
+ (6, 'book-entry-deleted', 'accounting entries deleted'),
+ (7, 'zone-included','An email to notify zoneCollisions'),
+ (8, 'backup-printer-selected','A backup printer has been selected');
+TRUNCATE `util`.`notificationAcl`;
INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`)
VALUES
(1, 9),
@@ -2821,13 +2838,17 @@ INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`)
(3, 9),
(4, 1),
(5, 9),
- (6, 9);
+ (6, 9),
+ (7, 9),
+ (8, 66);
+TRUNCATE `util`.`notificationQueue`;
INSERT INTO `util`.`notificationQueue` (`id`, `notificationFk`, `params`, `authorFk`, `status`, `created`)
VALUES
(1, 'print-email', '{"id": "1"}', 9, 'pending', util.VN_CURDATE()),
(2, 'print-email', '{"id": "2"}', null, 'pending', util.VN_CURDATE()),
(3, 'print-email', null, null, 'pending', util.VN_CURDATE());
+TRUNCATE `util`.`notificationSubscription`;
INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`)
VALUES
@@ -2838,16 +2859,17 @@ INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`)
(2, 1109),
(1, 9),
(1, 3),
- (6, 9);
-
+ (6, 9),
+ (7, 9),
+ (8, 66);
INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`)
VALUES
(1, 9);
-INSERT INTO `vn`.`productionConfig` (`isPreviousPreparationRequired`, `ticketPrintedMax`, `ticketTrolleyMax`, `rookieDays`, `notBuyingMonths`, `id`, `isZoneClosedByExpeditionActivated`, `maxNotReadyCollections`, `minTicketsToCloseZone`, `movingTicketDelRoute`, `defaultZone`, `defautlAgencyMode`, `hasUniqueCollectionTime`, `maxCollectionWithoutUser`, `pendingCollectionsOrder`, `pendingCollectionsAge`)
+INSERT INTO `vn`.`productionConfig` (`isPreviousPreparationRequired`, `ticketPrintedMax`, `ticketTrolleyMax`, `rookieDays`, `notBuyingMonths`, `id`, `isZoneClosedByExpeditionActivated`, `maxNotReadyCollections`, `minTicketsToCloseZone`, `movingTicketDelRoute`, `defaultZone`, `defautlAgencyMode`, `hasUniqueCollectionTime`, `maxCollectionWithoutUser`, `pendingCollectionsOrder`, `pendingCollectionsAge`, `backupPrinterNotificationDelay`)
VALUES
- (0, 8, 80, 0, 0, 1, 0, 15, 25, -1, 697, 1328, 0, 1, 8, 6);
+ (0, 8, 80, 0, 0, 1, 0, 15, 25, -1, 697, 1328, 0, 1, 8, 6, 3600);
INSERT INTO `vn`.`collection` (`id`, `created`, `workerFk`, `stateFk`, `itemPackingTypeFk`, `saleTotalCount`, `salePickedCount`, `trainFk`, `sectorFk`, `wagons`)
VALUES
@@ -2855,7 +2877,7 @@ INSERT INTO `vn`.`collection` (`id`, `created`, `workerFk`, `stateFk`, `itemPack
INSERT INTO `vn`.`itemConfig` (`id`, `isItemTagTriggerDisabled`, `monthToDeactivate`, `wasteRecipients`, `validPriorities`, `defaultPriority`, `defaultTag`, `warehouseFk`)
VALUES
- (0, 0, 24, '', '[1,2,3]', 2, 56, 60);
+ (1, 0, 24, '', '[1,2,3]', 2, 56, 60);
INSERT INTO `vn`.`ticketCollection` (`ticketFk`, `collectionFk`, `created`, `level`, `wagon`, `smartTagFk`, `usedShelves`, `itemCount`, `liters`)
VALUES
@@ -2892,7 +2914,7 @@ INSERT INTO `vn`.`ticketLog` (originFk, userFk, `action`, creationDate, changedM
(1, 18, 'insert', '1999-05-09 10:00:00', 'Ticket', 45, 'Super Man' , NULL, '{"id":45,"clientFk":8608,"warehouseFk":60,"shipped":"2023-05-16T22:00:00.000Z","nickname":"Super Man","addressFk":48637,"isSigned":true,"isLabeled":true,"isPrinted":true,"packages":0,"hour":0,"created":"2023-05-16T11:42:56.000Z","isBlocked":false,"hasPriority":false,"companyFk":442,"agencyModeFk":639,"landed":"2023-05-17T22:00:00.000Z","isBoxed":true,"isDeleted":true,"zoneFk":713,"zonePrice":13,"zoneBonus":0}', NULL);
INSERT INTO `vn`.`osTicketConfig` (`id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `day`, `comment`, `hostDb`, `userDb`, `passwordDb`, `portDb`, `responseType`, `fromEmailId`, `replyTo`)
VALUES
- (0, 'http://localhost:56596/scp', 'ostadmin', 'Admin1', '1,6', 3, 60, 'Este CAU se ha cerrado automáticamente. Si el problema persiste responda a este mensaje.', 'localhost', 'osticket', 'osticket', 40003, 'reply', 1, 'all');
+ (1, 'http://localhost:56596/scp', 'ostadmin', 'Admin1', '1,6', 3, 60, 'Este CAU se ha cerrado automáticamente. Si el problema persiste responda a este mensaje.', 'localhost', 'osticket', 'osticket', 40003, 'reply', 1, 'all');
INSERT INTO `vn`.`mdbApp` (`app`, `baselineBranchFk`, `userFk`, `locked`)
VALUES
@@ -2907,7 +2929,8 @@ INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
VALUES
('lilium', 'development', 'http://localhost:9000/#/'),
('hedera', 'development', 'http://localhost:9090/'),
- ('salix', 'development', 'http://localhost:5000/#!/');
+ ('salix', 'development', 'http://localhost:5000/#!/'),
+ ('docuware', 'development', 'http://docuware');
INSERT INTO `vn`.`report` (`id`, `name`, `paperSizeFk`, `method`)
VALUES
@@ -3069,3 +3092,681 @@ INSERT INTO `vn`.`cmr` (id,truckPlate,observations,senderInstruccions,paymentIns
UPDATE vn.department
SET workerFk = null;
+
+INSERT INTO vn.packaging
+ VALUES('--', 2745600.00, 100.00, 120.00, 220.00, 0.00, 1, '2001-01-01 00:00:00.000', NULL, NULL, NULL, 0.00, 16, 0.00, 0, NULL, 0.00, NULL, NULL, 0, NULL, 0, 0);
+
+
+INSERT IGNORE INTO vn.intrastat
+ SET id = 44219999,
+ description = 'Manufacturas de madera',
+ taxClassFk = 1,
+ taxCodeFk = 1;
+
+INSERT IGNORE INTO vn.warehouse
+ SET id = 999,
+ name = 'TestingWarehouse',
+ hasAvailable = TRUE,
+ isForTicket = TRUE,
+ isInventory = TRUE,
+ hasUbications = TRUE,
+ hasProduction = TRUE;
+
+INSERT IGNORE INTO vn.sector
+ SET id = 9991,
+ description = 'NormalSector',
+ warehouseFk = 999,
+ code = 'NS',
+ isPackagingArea = FALSE,
+ sonFk = NULL,
+ isMain = TRUE,
+ itemPackingTypeFk = NULL;
+
+INSERT IGNORE INTO vn.sector
+ SET id = 9992,
+ description = 'PreviousSector',
+ warehouseFk = 999,
+ code = 'PS',
+ isPackagingArea = FALSE,
+ sonFk = NULL,
+ isMain = TRUE,
+ itemPackingTypeFk = NULL;
+
+INSERT IGNORE INTO vn.sector
+ SET id = 9993,
+ description = 'MezaninneSector',
+ warehouseFk = 999,
+ code = 'MS',
+ isPackagingArea = FALSE,
+ sonFk = 9991,
+ isMain = TRUE,
+ itemPackingTypeFk = NULL;
+
+
+INSERT INTO vn.parking (id,sectorFk, code, pickingOrder)
+ VALUES (4,9991, 'A-01-1', 1),
+ (5,9991, 'A-02-2', 2),
+ (6,9991, 'A-03-3', 3),
+ (7,9991, 'A-04-4', 4),
+ (8,9991, 'A-05-5', 5),
+ (9,9992, 'P-01-1', 6),
+ (10,9992, 'P-02-2', 7),
+ (11,9992, 'P-03-3', 8),
+ (12,9993, 'M-01-1', 9),
+ (13,9993, 'M-02-2', 10),
+ (14,9993, 'M-03-3', 11);
+
+INSERT INTO vn.shelving (code, parkingFk, priority)
+ VALUES ('NAA', 4, 1),
+ ('NBB', 5, 1),
+ ('NCC', 6, 1),
+ ('NDD', 7, 1),
+ ('NEE', 8, 1),
+ ('PAA', 9, 1),
+ ('PBB', 10, 1),
+ ('PCC', 11, 1),
+ ('MAA', 12, 1),
+ ('MBB', 13, 1),
+ ('MCC', 14, 1);
+
+INSERT IGNORE INTO vn.itemType
+ SET id = 999,
+ code = 'WOO',
+ name = 'Wood Objects',
+ categoryFk = 3,
+ workerFk = 103,
+ isInventory = TRUE,
+ life = 10,
+ density = 250,
+ itemPackingTypeFk = NULL,
+ temperatureFk = 'warm';
+
+INSERT IGNORE INTO vn.travel
+ SET id = 99,
+ shipped = CURDATE(),
+ landed = CURDATE(),
+ warehouseInFk = 999,
+ warehouseOutFk = 1,
+ isReceived = TRUE;
+
+INSERT INTO vn.entry
+ SET id = 999,
+ supplierFk = 791,
+ isConfirmed = TRUE,
+ dated = CURDATE(),
+ travelFk = 99,
+ companyFk = 442;
+
+INSERT INTO vn.ticket
+ SET id = 999999,
+ clientFk = 2,
+ warehouseFk = 999,
+ shipped = CURDATE(),
+ nickname = 'Cliente',
+ addressFk = 1,
+ companyFk = 442,
+ agencyModeFk = 10,
+ landed = CURDATE();
+
+INSERT INTO vn.collection
+ SET id = 10101010,
+ workerFk = 9;
+
+INSERT IGNORE INTO vn.ticketCollection
+ SET id = 10101010,
+ ticketFk = 999999,
+ collectionFk = 10101010;
+
+INSERT INTO vn.item
+ SET id = 999991,
+ name = 'Palito para pinchos',
+ `size` = 25,
+ stems = NULL,
+ category = 'EXT',
+ typeFk = 999,
+ longName = 'Palito para pinchos',
+ itemPackingTypeFk = NULL,
+ originFk = 1,
+ weightByPiece = 6,
+ intrastatFk = 44219999;
+
+INSERT INTO vn.buy
+ SET id = 9999991,
+ entryFk = 999,
+ itemFk = 999991,
+ quantity = 8,
+ buyingValue = 0.61,
+ stickers = 1,
+ packing = 20,
+ `grouping` = 1,
+ groupingMode = 'packing',
+ price1 = 1,
+ price2 = 1,
+ price3 = 1,
+ minPrice = 1,
+ weight = 50;
+
+INSERT INTO vn.sale
+ SET id = 99991,
+ itemFk = 999991,
+ ticketFk = 999999,
+ concept = 'Palito para pinchos',
+ quantity = 3,
+ price = 1,
+ discount = 0;
+
+INSERT INTO vn.item
+ SET id = 999992,
+ name = 'Madera verde',
+ `size` = 10,
+ stems = NULL,
+ category = 'EXT',
+ typeFk = 999,
+ longName = 'Madera verde',
+ itemPackingTypeFk = NULL,
+ originFk = 1,
+ weightByPiece = 50,
+ intrastatFk = 44219999;
+
+INSERT INTO vn.buy
+ SET id = 9999992,
+ entryFk = 999,
+ itemFk = 999992,
+ quantity = 40,
+ buyingValue = 0.62,
+ stickers = 1,
+ packing = 40,
+ `grouping` = 5,
+ groupingMode = 'packing',
+ price1 = 1,
+ price2 = 1,
+ price3 = 1,
+ minPrice = 1,
+ weight = 25;
+
+INSERT INTO vn.sale
+ SET id = 99992,
+ itemFk = 999992,
+ ticketFk = 999999,
+ concept = 'Madera Verde',
+ quantity = 10,
+ price = 1,
+ discount = 0;
+
+INSERT INTO vn.item
+ SET id = 999993,
+ name = 'Madera Roja/Morada',
+ `size` = 12,
+ stems = 2,
+ category = 'EXT',
+ typeFk = 999,
+ longName = 'Madera Roja/Morada',
+ itemPackingTypeFk = NULL,
+ originFk = 1,
+ weightByPiece = 35,
+ intrastatFk = 44219999;
+
+INSERT INTO vn.buy
+ SET id = 9999993,
+ entryFk = 999,
+ itemFk = 999993,
+ quantity = 20,
+ buyingValue = 0.63,
+ stickers = 2,
+ packing = 10,
+ `grouping` = 5,
+ groupingMode = 'packing',
+ price1 = 1,
+ price2 = 1,
+ price3 = 1,
+ minPrice = 1,
+ weight = 25;
+
+INSERT INTO vn.itemShelving
+ SET id = 9931,
+ itemFk = 999993,
+ shelvingFk = 'NCC',
+ visible = 10,
+ `grouping` = 5,
+ packing = 10;
+
+INSERT INTO vn.sale
+ SET id = 99993,
+ itemFk = 999993,
+ ticketFk = 999999,
+ concept = 'Madera Roja/Morada',
+ quantity = 15,
+ price = 1,
+ discount = 0;
+
+INSERT INTO vn.item
+ SET id = 999994,
+ name = 'Madera Naranja',
+ `size` = 18,
+ stems = 1,
+ category = 'EXT',
+ typeFk = 999,
+ longName = 'Madera Naranja',
+ itemPackingTypeFk = NULL,
+ originFk = 1,
+ weightByPiece = 160,
+ intrastatFk = 44219999;
+
+INSERT INTO vn.buy
+ SET id = 9999994,
+ entryFk = 999,
+ itemFk = 999994,
+ quantity = 20,
+ buyingValue = 0.64,
+ stickers = 1,
+ packing = 20,
+ `grouping` = 4,
+ groupingMode = 'packing',
+ price1 = 1,
+ price2 = 1,
+ price3 = 1,
+ minPrice = 1,
+ weight = 25;
+
+INSERT INTO vn.sale
+ SET id = 99994,
+ itemFk = 999994,
+ ticketFk = 999999,
+ concept = 'Madera Naranja',
+ quantity = 4,
+ price = 1,
+ discount = 0;
+
+INSERT INTO vn.item
+ SET id = 999995,
+ name = 'Madera Amarilla',
+ `size` = 11,
+ stems = 5,
+ category = 'EXT',
+ typeFk = 999,
+ longName = 'Madera Amarilla',
+ itemPackingTypeFk = NULL,
+ originFk = 1,
+ weightByPiece = 78,
+ intrastatFk = 44219999;
+
+INSERT INTO vn.buy
+ SET id = 9999995,
+ entryFk = 999,
+ itemFk = 999995,
+ quantity = 4,
+ buyingValue = 0.65,
+ stickers = 1,
+ packing = 20,
+ `grouping` = 1,
+ groupingMode = 'packing',
+ price1 = 1,
+ price2 = 1,
+ price3 = 1,
+ minPrice = 1,
+ weight = 35;
+
+INSERT INTO vn.sale
+ SET id = 99995,
+ itemFk = 999995,
+ ticketFk = 999999,
+ concept = 'Madera Amarilla',
+ quantity = 5,
+ price = 1,
+ discount = 0;
+
+-- Palito naranja
+INSERT INTO vn.item
+ SET id = 999998,
+ name = 'Palito naranja',
+ `size` = 11,
+ stems = 1,
+ category = 'EXT',
+ typeFk = 999,
+ longName = 'Palito naranja',
+ itemPackingTypeFk = NULL,
+ originFk = 1,
+ weightByPiece = 78,
+ intrastatFk = 44219999;
+
+INSERT INTO vn.buy
+ SET id = 9999998,
+ entryFk = 999,
+ itemFk = 999998,
+ quantity = 80,
+ buyingValue = 0.65,
+ stickers = 1,
+ packing = 200,
+ `grouping` = 30,
+ groupingMode = 'packing',
+ price1 = 1,
+ price2 = 1,
+ price3 = 1,
+ minPrice = 1,
+ weight = 35;
+
+INSERT INTO vn.sale
+ SET id = 99998,
+ itemFk = 999998,
+ ticketFk = 999999,
+ concept = 'Palito naranja',
+ quantity = 60,
+ price = 1,
+ discount = 0;
+
+-- Palito amarillo
+INSERT INTO vn.item
+ SET id = 999999,
+ name = 'Palito amarillo',
+ `size` = 11,
+ stems = 1,
+ category = 'EXT',
+ typeFk = 999,
+ longName = 'Palito amarillo',
+ itemPackingTypeFk = NULL,
+ originFk = 1,
+ weightByPiece = 78,
+ intrastatFk = 44219999;
+
+INSERT INTO vn.buy
+ SET id = 9999999,
+ entryFk = 999,
+ itemFk = 999999,
+ quantity = 70,
+ buyingValue = 0.65,
+ stickers = 1,
+ packing = 500,
+ `grouping` = 10,
+ groupingMode = 'packing',
+ price1 = 1,
+ price2 = 1,
+ price3 = 1,
+ minPrice = 1,
+ weight = 35;
+
+INSERT INTO vn.sale
+ SET id = 99999,
+ itemFk = 999999,
+ ticketFk = 999999,
+ concept = 'Palito amarillo',
+ quantity = 50,
+ price = 1,
+ discount = 0;
+
+-- Palito azul
+INSERT INTO vn.item
+ SET id = 1000000,
+ name = 'Palito azul',
+ `size` = 10,
+ stems = 1,
+ category = 'EXT',
+ typeFk = 999,
+ longName = 'Palito azul',
+ itemPackingTypeFk = NULL,
+ originFk = 1,
+ weightByPiece = 78,
+ intrastatFk = 44219999;
+
+INSERT INTO vn.buy
+ SET id = 10000000,
+ entryFk = 999,
+ itemFk = 1000000,
+ quantity = 75,
+ buyingValue = 0.65,
+ stickers = 2,
+ packing = 300,
+ `grouping` = 50,
+ groupingMode = 'packing',
+ price1 = 1,
+ price2 = 1,
+ price3 = 1,
+ minPrice = 1,
+ weight = 35;
+
+INSERT INTO vn.sale
+ SET id = 100000,
+ itemFk = 1000000,
+ ticketFk = 999999,
+ concept = 'Palito azul',
+ quantity = 50,
+ price = 1,
+ discount = 0;
+
+-- Palito rojo
+INSERT INTO vn.item
+ SET id = 1000001,
+ name = 'Palito rojo',
+ `size` = 10,
+ stems = NULL,
+ category = 'EXT',
+ typeFk = 999,
+ longName = 'Palito rojo',
+ itemPackingTypeFk = NULL,
+ originFk = 1,
+ weightByPiece = 78,
+ intrastatFk = 44219999;
+
+INSERT INTO vn.buy
+ SET id = 10000001,
+ entryFk = 999,
+ itemFk = 1000001,
+ quantity = 12,
+ buyingValue = 0.65,
+ stickers = 2,
+ packing = 50,
+ `grouping` = 5,
+ groupingMode = 'packing',
+ price1 = 1,
+ price2 = 1,
+ price3 = 1,
+ minPrice = 1,
+ weight = 35;
+
+
+INSERT INTO vn.sale
+ SET id = 100001,
+ itemFk = 1000001,
+ ticketFk = 999999,
+ concept = 'Palito rojo',
+ quantity = 10,
+ price = 1,
+ discount = 0;
+
+-- Previa
+INSERT IGNORE INTO vn.item
+ SET id = 999996,
+ name = 'Bolas de madera',
+ `size` = 2,
+ stems = 4,
+ category = 'EXT',
+ typeFk = 999,
+ longName = 'Bolas de madera',
+ itemPackingTypeFk = NULL,
+ originFk = 1,
+ weightByPiece = 20,
+ intrastatFk = 44219999;
+
+INSERT vn.buy
+ SET id = 9999996,
+ entryFk = 999,
+ itemFk = 999996,
+ quantity = 5,
+ buyingValue = 3,
+ stickers = 1,
+ packing = 5,
+ `grouping` = 2,
+ groupingMode = 'packing',
+ price1 = 7,
+ price2 = 7,
+ price3 = 7,
+ minPrice = 7,
+ weight = 80;
+
+INSERT vn.sale
+ SET id = 99996,
+ itemFk = 999996,
+ ticketFk = 999999,
+ concept = 'Bolas de madera',
+ quantity = 4,
+ price = 7,
+ discount = 0,
+ isPicked = TRUE;
+
+INSERT IGNORE INTO vn.item
+ SET id = 999997,
+ name = 'Palitos de polo MIX',
+ `size` = 14,
+ stems = NULL,
+ category = 'EXT',
+ typeFk = 999,
+ longName = 'Palitos de polo MIX',
+ itemPackingTypeFk = NULL,
+ originFk = 1,
+ weightByPiece = 20,
+ intrastatFk = 44219999;
+
+INSERT vn.buy
+ SET id = 9999997,
+ entryFk = 999,
+ itemFk = 999997,
+ quantity = 100,
+ buyingValue = 3.2,
+ stickers = 1,
+ packing = 100,
+ `grouping` = 5,
+ groupingMode = 'packing',
+ price1 = 7,
+ price2 = 7,
+ price3 = 7,
+ minPrice = 7,
+ weight = 80;
+
+INSERT vn.sale
+ SET id = 99997,
+ itemFk = 999997,
+ ticketFk = 999999,
+ concept = 'Palitos de polo MIX',
+ quantity = 5,
+ price = 7,
+ discount = 0;
+
+USE vn;
+DELETE ish.* FROM vn.itemShelving ish
+ JOIN vn.shelving sh ON sh.code = ish.shelvingFk
+ JOIN vn.parking p ON p.id = sh.parkingFk
+ JOIN vn.sector s ON s.id = p.sectorFk
+ JOIN vn.warehouse w ON w.id = s.warehouseFk
+ WHERE w.name = 'TestingWarehouse';
+
+INSERT INTO vn.itemShelving
+(itemFk, shelvingFk, visible, created, `grouping`, packing, packagingFk, userFk, isChecked)
+VALUES
+ (999991, 'NAA', 8, '2023-09-20', 1, 20, NULL, 103, NULL),
+ (999998, 'NAA', 80, '2023-09-20', 10, 30, NULL, 103, NULL),
+ (1000001, 'NAA', 6, '2023-09-20', 3, 50, NULL, 103, NULL),
+ (1000000, 'NBB', 50, '2023-09-18', 25, 500, NULL, 103, NULL),
+ (999993, 'NBB', 25, '2023-09-18', NULL, 10, NULL, 103, NULL),
+ (999999, 'NBB', 30, '2023-09-18', 10, 500, NULL, 103, NULL),
+ (999993, 'NCC', 25, '2023-09-20', 5, 10, NULL, 103, NULL),
+ (999997, 'NCC', 10, '2023-09-20', NULL, 100, NULL, 103, NULL),
+ (999999, 'NCC', 40, '2023-09-20', 10, 500, NULL, 103, NULL),
+ (999995, 'NDD', 10, '2023-09-19', NULL, 20, NULL, 103, NULL),
+ (999994, 'NDD', 48, '2023-09-19', 4, 20, NULL, 103, NULL),
+ (1000001, 'NEE', 6, '2023-09-21', 3, 50, NULL, 103, NULL),
+ (999992, 'NEE', 50, '2023-09-21', NULL, 1, NULL, 103, NULL),
+ (1000000, 'NEE', 25, '2023-09-21', 25, 500, NULL, 103, NULL),
+ (999996, 'PAA', 5, '2023-09-27', 1, 5, NULL, 103, NULL),
+ (999997, 'PCC', 10, '2023-09-27', 5, 100, NULL, 103, NULL);
+
+-- Previous for Bolas de madera
+INSERT IGNORE INTO vn.sectorCollection
+ SET id = 99,
+ userFk = 1,
+ sectorFk = 9992;
+
+INSERT IGNORE INTO vn.saleGroup
+ SET id = 4,
+ userFk = 1,
+ parkingFk = 9,
+ sectorFk = 9992;
+
+INSERT IGNORE INTO vn.sectorCollectionSaleGroup
+ SET id = 9999,
+ sectorCollectionFk = 99,
+ saleGroupFk = 999;
+
+INSERT vn.saleGroupDetail
+ SET id = 99991,
+ saleFk = 99996,
+ saleGroupFk = 999;
+
+INSERT INTO vn.saleTracking
+ SET id = 7,
+ saleFk = 99996,
+ isChecked = TRUE,
+ workerFk = 103,
+ stateFk = 28;
+
+INSERT IGNORE INTO vn.itemShelvingSale
+ SET id = 991,
+ itemShelvingFk = 9962,
+ saleFk = 99996,
+ quantity = 5,
+ userFk = 1;
+
+UPDATE vn.ticket
+ SET zoneFk=1
+ WHERE id=999999;
+
+UPDATE vn.collection
+ SET workerFk=9
+ WHERE id=10101010;
+
+UPDATE vn.sale
+ SET isPicked =FALSE;
+
+INSERT INTO vn.machineWorkerConfig(id, maxHours)
+ VALUES(1, 12);
+
+INSERT INTO vn.workerAppTester(workerFk) VALUES(66);
+
+INSERT INTO `vn`.`machine` (`plate`, `maker`, `model`, `warehouseFk`, `departmentFk`, `type`, `use`, `productionYear`, `workerFk`, `companyFk`)
+ VALUES
+ ('RE-003', 'IRON', 'JPH-24', 60, 23, 'ELECTRIC TOW', 'Drag cars', 2020, 103, 442);
+
+
+INSERT INTO vn.machineWorker(workerFk,machineFk,inTimed) VALUES (104,1,'2001-01-01 10:00:00.00.000');
+
+UPDATE vn.buy SET itemOriginalFk = 1 WHERE id = 1;
+
+UPDATE vn.saleTracking SET stateFk = 26 WHERE id = 5;
+
+INSERT INTO vn.report (name) VALUES ('LabelCollection');
+
+INSERT INTO vn.parkingLog(originFk, userFk, `action`, creationDate, description, changedModel,oldInstance, newInstance, changedModelId, changedModelValue)
+ VALUES(1, 18, 'update', util.VN_CURDATE(), NULL, 'SaleGroup', '{"parkingFk":null}', '{"parkingFk":1}', 1, NULL);
+
+INSERT INTO vn.ticketLog (originFk,userFk,`action`,creationDate,changedModel,newInstance,changedModelId,changedModelValue)
+ VALUES (18,9,'insert','2001-01-01 11:01:00.000','Ticket','{"isDeleted":true}',45,'Super Man');
+
+INSERT INTO `vn`.`supplierDms`(`supplierFk`, `dmsFk`, `editorFk`)
+ VALUES (1, 10, 9);
+
+INSERT INTO `vn`.`accountReconciliation` (supplierAccountFk,operationDated,valueDated,amount,concept,debitCredit,calculatedCode,created)
+ VALUES
+ (241,'2023-12-13 00:00:00.000','2023-12-07 00:00:00.000',19.36,'BEL 1','debit','2','2023-12-14 08:39:53.000'),
+ (241,'2023-12-13 00:00:00.000','2023-12-07 00:00:00.000',30226.43,'BEL 2','debit','1','2023-12-14 08:39:53.000'),
+ (241,'2023-12-13 00:00:00.000','2023-12-13 00:00:00.000',118.81,'RCBO','debit','10','2023-12-14 08:39:53.000'),
+ (241,'2023-12-13 00:00:00.000','2023-12-13 00:00:00.000',150.03,'TJ','debit','12','2023-12-14 08:39:53.000'),
+ (241,'2023-12-13 00:00:00.000','2023-12-13 00:00:00.000',150.03,'TJ','debit','12','2023-12-14 08:39:53.000'),
+ (241,'2023-12-13 00:00:00.000','2023-12-13 00:00:00.000',2149.71,'RCBO.AMAZON','debit','122','2023-12-14 08:39:53.000'),
+ (241,'2023-12-13 00:00:00.000','2023-12-13 00:00:00.000',3210.5,'RCBO.VOLVO','debit','121','2023-12-14 08:39:53.000'),
+ (241,'2023-12-13 00:00:00.000','2023-12-13 00:00:00.000',6513.7,'RCBO.ENERPLUS','debit','120','2023-12-14 08:39:53.000');
+
+INSERT INTO `vn`.`accountReconciliationConfig`(currencyFk, warehouseFk)
+ VALUES (1, 1);
+
+
+INSERT INTO vn.workerTeam(id, team, workerFk)
+ VALUES
+ (8, 1, 19);
diff --git a/db/routines/account/procedures/user_checkName.sql b/db/routines/account/procedures/user_checkName.sql
index 4f954ad00..6fab17361 100644
--- a/db/routines/account/procedures/user_checkName.sql
+++ b/db/routines/account/procedures/user_checkName.sql
@@ -7,7 +7,7 @@ BEGIN
* The user name must only contain lowercase letters or, starting with second
* character, numbers or underscores.
*/
- IF vUserName NOT REGEXP '^[a-z0-9_-]*$' THEN
+ IF vUserName NOT REGEXP BINARY '^[a-z0-9_-]+$' THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'INVALID_USER_NAME';
END IF;
diff --git a/db/routines/bi/procedures/comparativa_add.sql b/db/routines/bi/procedures/comparativa_add.sql
deleted file mode 100644
index 4297c8aff..000000000
--- a/db/routines/bi/procedures/comparativa_add.sql
+++ /dev/null
@@ -1,32 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`comparativa_add`()
-BEGIN
- DECLARE lastCOMP INT; # Se trata de una variable para almacenar el ultimo valor del Periodo
- DECLARE vMaxPeriod INT;
- DECLARE vMaxWeek INT;
-
- SELECT t.period, t.`week` INTO vMaxPeriod, vMaxWeek
- FROM vn.`time` t
- WHERE t.dated = util.VN_CURDATE();
-
- SELECT MAX(Periodo) INTO lastCOMP FROM vn2008.Comparativa;
- -- Fijaremos las ventas con más de un mes de antiguedad en la tabla Comparativa
-
- IF lastCOMP < vMaxPeriod - 3 AND vMaxWeek > 3 THEN
-
- REPLACE vn2008.Comparativa(Periodo, Id_Article, warehouse_id, Cantidad,price)
- SELECT tm.period as Periodo, m.Id_Article, t.warehouse_id, sum(m.Cantidad), sum(v.importe)
- FROM bs.ventas v
- JOIN vn2008.time tm ON tm.date = v.fecha
- JOIN vn2008.Movimientos m ON m.Id_Movimiento = v.Id_Movimiento
- JOIN vn2008.Tipos tp ON tp.tipo_id = v.tipo_id
- JOIN vn2008.reinos r ON r.id = tp.reino_id
- JOIN vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket
- WHERE tm.period BETWEEN lastCOMP AND vMaxPeriod - 3
- AND t.Id_Cliente NOT IN(400,200)
- AND t.warehouse_id NOT IN (0,13)
- GROUP BY m.Id_Article, Periodo, t.warehouse_id;
-
- END IF;
-END$$
-DELIMITER ;
diff --git a/db/routines/bi/procedures/comparativa_add_manual.sql b/db/routines/bi/procedures/comparativa_add_manual.sql
deleted file mode 100644
index 281e15b23..000000000
--- a/db/routines/bi/procedures/comparativa_add_manual.sql
+++ /dev/null
@@ -1,40 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`comparativa_add_manual`(IN vStarted DATE, IN vEnded DATE)
-BEGIN
-/**
- * Recalcula la tabla Comparativa para dos valores dados
- *
- * @param vStarted fecha desde
- * @param vEnded fecha hasta
- */
-
- DECLARE periodStart INT;
- DECLARE periodEnd INT;
-
- -- Seleccionamos la fecha minima/maxima del periodo que vamos a consultar
-
- SELECT t.period INTO periodStart
- FROM vn.`time` t
- WHERE t.dated = vStarted;
-
- SELECT t.period INTO periodEnd
- FROM vn.`time` t
- WHERE t.dated = vEnded;
-
- DELETE FROM vn2008.Comparativa
- WHERE Periodo BETWEEN periodStart AND periodEnd;
-
- INSERT INTO vn2008.Comparativa(Periodo, Id_Article, warehouse_id, Cantidad,price)
- SELECT tm.period as Periodo, m.Id_Article, t.warehouse_id, sum(m.Cantidad), sum(v.importe)
- FROM bs.ventas v
- JOIN vn2008.time tm ON tm.date = v.fecha
- JOIN vn2008.Movimientos m ON m.Id_Movimiento = v.Id_Movimiento
- JOIN vn2008.Tipos tp ON tp.tipo_id = v.tipo_id
- JOIN vn2008.reinos r ON r.id = tp.reino_id
- JOIN vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket
- WHERE tm.period BETWEEN periodStart AND periodEnd
- AND t.Id_Cliente NOT IN(400,200)
- AND t.warehouse_id NOT IN (0,13)
- GROUP BY m.Id_Article, Periodo, t.warehouse_id;
-END$$
-DELIMITER ;
diff --git a/db/routines/bi/procedures/greuge_dif_porte_add.sql b/db/routines/bi/procedures/greuge_dif_porte_add.sql
index 02bd9eae4..330ff92b8 100644
--- a/db/routines/bi/procedures/greuge_dif_porte_add.sql
+++ b/db/routines/bi/procedures/greuge_dif_porte_add.sql
@@ -1,8 +1,19 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`greuge_dif_porte_add`()
BEGIN
- DECLARE datSTART DATETIME DEFAULT TIMESTAMPADD(DAY,-60,util.VN_CURDATE()); -- '2019-07-01'
- DECLARE datEND DATETIME DEFAULT TIMESTAMPADD(DAY,-1,util.VN_CURDATE());
+
+/**
+ * Calculates the greuge based on a specific date in the 'grievanceConfig' table
+ */
+
+ DECLARE vDateStarted DATETIME;
+ DECLARE vDateEnded DATETIME DEFAULT (util.VN_CURDATE() - INTERVAL 1 DAY);
+ DECLARE vDaysAgoOffset INT;
+
+ SELECT daysAgoOffset INTO vDaysAgoOffset
+ FROM vn.greugeConfig;
+
+ SET vDateStarted = util.VN_CURDATE() - INTERVAL vDaysAgoOffset DAY;
DROP TEMPORARY TABLE IF EXISTS tmp.dp;
@@ -10,53 +21,53 @@ BEGIN
CREATE TEMPORARY TABLE tmp.dp
(PRIMARY KEY (ticketFk))
ENGINE = MEMORY
- SELECT t.id ticketFk,
- SUM((t.zonePrice - t.zoneBonus) * ebv.ratio) AS teorico,
- 00000.00 as practico,
- 00000.00 as greuge,
- t.clientFk,
- t.shipped
- FROM
- vn.ticket t
- JOIN vn2008.Clientes cli ON cli.Id_cliente = t.clientFk
- LEFT JOIN vn.expedition e ON e.ticketFk = t.id
- JOIN vn.expeditionBoxVol ebv ON ebv.boxFk = e.freightItemFk
- JOIN vn.zone z ON t.zoneFk = z.id
- WHERE
- t.shipped between datSTART AND datEND
- AND cli.`real`
- AND t.companyFk IN (442 , 567)
- AND z.isVolumetric = FALSE
- GROUP BY t.id;
+ SELECT t.id ticketFk,
+ SUM((t.zonePrice - t.zoneBonus) * ebv.ratio) teorico,
+ 00000.00 practico,
+ 00000.00 greuge,
+ t.clientFk,
+ t.shipped
+ FROM vn.ticket t
+ JOIN vn.client c ON c.id = t.clientFk
+ LEFT JOIN vn.expedition e ON e.ticketFk = t.id
+ JOIN vn.expeditionBoxVol ebv ON ebv.boxFk = e.freightItemFk
+ JOIN vn.zone z ON t.zoneFk = z.id
+ JOIN vn.company cp ON cp.id = t.companyFk
+ WHERE t.shipped BETWEEN vDateStarted AND vDateEnded
+ AND c.isRelevant
+ AND cp.code IN ('VNL', 'VNH')
+ AND NOT z.isVolumetric
+ GROUP BY t.id;
-- Agencias que cobran por volumen
INSERT INTO tmp.dp
SELECT sv.ticketFk,
- SUM(IFNULL(sv.freight,0)) AS teorico,
- 00000.00 as practico,
- 00000.00 as greuge,
- sv.clientFk,
- sv.shipped
- FROM vn.saleVolume sv
- JOIN vn.zone z ON z.id = sv.zoneFk
- AND sv.shipped BETWEEN datSTART AND datEND
- AND z.isVolumetric != FALSE
- GROUP BY sv.ticketFk;
+ SUM(IFNULL(sv.freight,0)) teorico,
+ 00000.00 practico,
+ 00000.00 greuge,
+ sv.clientFk,
+ sv.shipped
+ FROM vn.saleVolume sv
+ JOIN vn.zone z ON z.id = sv.zoneFk
+ AND sv.shipped BETWEEN vDateStarted AND vDateEnded
+ AND z.isVolumetric != FALSE
+ GROUP BY sv.ticketFk;
DROP TEMPORARY TABLE IF EXISTS tmp.dp_aux;
CREATE TEMPORARY TABLE tmp.dp_aux
(PRIMARY KEY (ticketFk))
ENGINE = MEMORY
- SELECT dp.ticketFk, sum(Cantidad * Valor) as valor
- FROM tmp.dp
- JOIN vn2008.Movimientos m ON m.Id_Ticket = dp.ticketFk
- JOIN vn2008.Movimientos_componentes mc using(Id_Movimiento)
- WHERE mc.Id_Componente = 15
- GROUP BY dp.ticketFk;
+ SELECT dp.ticketFk, SUM(s.quantity * sc.value) valor
+ FROM tmp.dp
+ JOIN vn.sale s ON s.ticketFk = dp.ticketFk
+ JOIN vn.saleComponent sc ON sc.saleFk = s.id
+ JOIN vn.component c ON c.id = sc.componentFk
+ WHERE c.code = 'delivery'
+ GROUP BY dp.ticketFk;
UPDATE tmp.dp
- JOIN tmp.dp_aux USING(ticketFk)
+ JOIN tmp.dp_aux USING(ticketFk)
SET practico = IFNULL(valor,0);
DROP TEMPORARY TABLE tmp.dp_aux;
@@ -64,28 +75,29 @@ BEGIN
CREATE TEMPORARY TABLE tmp.dp_aux
(PRIMARY KEY (ticketFk))
ENGINE = MEMORY
- SELECT dp.ticketFk, sum(g.amount) Importe
+ SELECT dp.ticketFk, SUM(g.amount) Importe
FROM tmp.dp
- JOIN vn.greuge g ON g.ticketFk = dp.ticketFk
- WHERE g.greugeTypeFk = 1 -- dif_porte
- GROUP BY dp.ticketFk;
+ JOIN vn.greuge g ON g.ticketFk = dp.ticketFk
+ JOIN vn.greugeType gt ON gt.id = g.greugeTypeFk
+ WHERE gt.code = 'freightDifference' -- dif_porte
+ GROUP BY dp.ticketFk;
UPDATE tmp.dp
- JOIN tmp.dp_aux USING(ticketFk)
+ JOIN tmp.dp_aux USING(ticketFk)
SET greuge = IFNULL(Importe,0);
INSERT INTO vn.greuge (clientFk,description,amount,shipped,greugeTypeFk,ticketFk)
- SELECT dp.clientFk
- , concat('dif_porte ', dp.ticketFk)
- , round(IFNULL(dp.teorico,0) - IFNULL(dp.practico,0) - IFNULL(dp.greuge,0),2) as Importe
- , date(dp.shipped)
- , 1
- ,dp.ticketFk
+ SELECT dp.clientFk,
+ CONCAT('dif_porte ', dp.ticketFk),
+ ROUND(IFNULL(dp.teorico,0) - IFNULL(dp.practico,0) - IFNULL(dp.greuge,0),2) Importe,
+ date(dp.shipped),
+ 1,
+ dp.ticketFk
FROM tmp.dp
- JOIN vn.client c ON c.id = dp.clientFk
+ JOIN vn.client c ON c.id = dp.clientFk
WHERE ABS(IFNULL(dp.teorico,0) - IFNULL(dp.practico,0) - IFNULL(dp.greuge,0)) > 1
AND c.isRelevant;
-
+
DROP TEMPORARY TABLE
tmp.dp,
tmp.dp_aux;
diff --git a/db/routines/bi/procedures/rutasAnalyze.sql b/db/routines/bi/procedures/rutasAnalyze.sql
index 8b56fa74d..5f0d55c7a 100644
--- a/db/routines/bi/procedures/rutasAnalyze.sql
+++ b/db/routines/bi/procedures/rutasAnalyze.sql
@@ -1,7 +1,7 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`rutasAnalyze`(
- vYear INT,
- vMonth INT
+ vDatedFrom DATE,
+ vDatedTo DATE
)
BEGIN
/**
@@ -9,8 +9,7 @@ BEGIN
* y lo almacena en la tabla bi.rutasBoard
*/
DELETE FROM rutasBoard
- WHERE YEAR(Fecha) = vYear
- AND MONTH(Fecha) = vMonth;
+ WHERE Fecha BETWEEN vDatedFrom AND vDatedTo;
-- Rellenamos la tabla con los datos de las rutas VOLUMETRICAS, especialmente con los bultos "virtuales"
INSERT INTO rutasBoard(
@@ -27,7 +26,7 @@ BEGIN
LEFT JOIN vn.`zone` z ON z.id = t.zoneFk
JOIN vn.saleVolume sv ON sv.ticketFk = t.id
JOIN vn.expeditionBoxVol ebv ON ebv.code = 'transportBox'
- WHERE YEAR(r.created) = vYear AND MONTH(r.created) = vMonth
+ WHERE r.created BETWEEN vDatedFrom AND vDatedTo
AND z.isVolumetric
GROUP BY r.id;
@@ -44,8 +43,7 @@ BEGIN
FROM vn.route r
JOIN vn.ticket t ON t.routeFk = r.id
LEFT JOIN vn.`zone` z ON z.id = t.zoneFk
- WHERE YEAR(r.created) = vYear
- AND MONTH(r.created) = vMonth
+ WHERE r.created BETWEEN vDatedFrom AND vDatedTo
AND NOT z.isVolumetric
GROUP BY r.id
ON DUPLICATE KEY UPDATE Bultos = Bultos + VALUES(Bultos);
@@ -56,15 +54,13 @@ BEGIN
SELECT t.routeFk,
SUM(s.quantity * sc.value) totalPractice
FROM vn.route r
- JOIN vn.`time` tm ON tm.dated = r.created
JOIN vn.ticket t ON t.routeFk = r.id
JOIN vn.sale s ON s.ticketFk = t.id
JOIN vn.saleComponent sc ON sc.saleFk = s.id
JOIN vn.component c ON c.id = sc.componentFk
JOIN vn.componentType ct ON ct.id = c.typeFk
WHERE ct.code = 'FREIGHT'
- AND tm.`year` = vYear
- AND tm.`month` = vMonth
+ AND r.created BETWEEN vDatedFrom AND vDatedTo
GROUP BY r.id
) sub ON sub.routeFk = r.Id_Ruta
SET r.practico = IFNULL(sub.totalPractice / r.Bultos, 0);
@@ -76,14 +72,12 @@ BEGIN
SUM(t.zonePrice/ ebv.ratio) / COUNT(*) averageTheoreticalVolume
FROM vn.ticket t
JOIN vn.route r ON r.id = t.routeFk
- JOIN vn.`time` tm ON tm.dated = r.created
JOIN vn.expedition e ON e.ticketFk = t.id
JOIN vn.expeditionBoxVol ebv ON ebv.boxFk = e.freightItemFk
JOIN vn.address ad ON ad.id = t.addressFk
JOIN vn.client c ON c.id = ad.clientFk
LEFT JOIN vn.`zone` z ON z.id = t.zoneFk
- WHERE tm.`year` = vYear
- AND tm.`month` = vMonth
+ WHERE r.created BETWEEN vDatedFrom AND vDatedTo
AND NOT z.isVolumetric
GROUP BY t.routeFk
) sub ON r.Id_Ruta = sub.routeFk
@@ -96,12 +90,10 @@ BEGIN
SUM(freight) averageTheoreticalVolume
FROM vn.ticket t
JOIN vn.route r ON r.id = t.routeFk
- JOIN vn.`time` tm ON tm.dated = r.created
JOIN vn.saleVolume sf ON sf.ticketFk = t.id
JOIN vn.client c ON c.id = t.clientFk
JOIN vn.`zone` z ON z.id = t.zoneFk
- WHERE tm.`year` = vYear
- AND tm.`month` = vMonth
+ WHERE r.created BETWEEN vDatedFrom AND vDatedTo
AND z.isVolumetric
GROUP BY t.routeFk
) sub ON r.Id_Ruta = sub.routeFk
@@ -114,11 +106,9 @@ BEGIN
SUM(g.amount) greuge
FROM vn.ticket t
JOIN vn.route r ON r.id = t.routeFk
- JOIN vn.`time` tm ON tm.dated = r.created
JOIN vn.greuge g ON g.ticketFk = t.id
JOIN vn.greugeType gt ON gt.id = g.greugeTypeFk
- WHERE tm.`year` = vYear
- AND tm.`month` = vMonth
+ WHERE r.created BETWEEN vDatedFrom AND vDatedTo
AND gt.code = 'freightDifference'
GROUP BY t.routeFk
) sub ON r.Id_Ruta = sub.routeFk
diff --git a/db/routines/bi/procedures/rutasAnalyze_launcher.sql b/db/routines/bi/procedures/rutasAnalyze_launcher.sql
index bc50b7905..02f5e1b9c 100644
--- a/db/routines/bi/procedures/rutasAnalyze_launcher.sql
+++ b/db/routines/bi/procedures/rutasAnalyze_launcher.sql
@@ -4,6 +4,6 @@ BEGIN
/**
* Call rutasAnalyze
*/
- CALL rutasAnalyze(YEAR(util.VN_CURDATE()), MONTH(util.VN_CURDATE()));
+ CALL rutasAnalyze(util.VN_CURDATE() - INTERVAL 30 DAY , util.VN_CURDATE());
END$$
DELIMITER ;
diff --git a/db/routines/bi/views/v_clientes_jerarquia.sql b/db/routines/bi/views/v_clientes_jerarquia.sql
deleted file mode 100644
index e8e4e1e69..000000000
--- a/db/routines/bi/views/v_clientes_jerarquia.sql
+++ /dev/null
@@ -1,21 +0,0 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
- SQL SECURITY DEFINER
- VIEW `bi`.`v_clientes_jerarquia`
-AS SELECT `c`.`id_cliente` AS `Id_Cliente`,
- `c`.`cliente` AS `Cliente`,
- `t`.`CodigoTrabajador` AS `Comercial`,
- `tj`.`CodigoTrabajador` AS `Jefe`
-FROM (
- (
- (
- `vn2008`.`Clientes` `c`
- JOIN `vn2008`.`Trabajadores` `t` ON(`t`.`Id_Trabajador` = `c`.`Id_Trabajador`)
- )
- JOIN `vn2008`.`jerarquia` ON(
- `vn2008`.`jerarquia`.`worker_id` = `c`.`Id_Trabajador`
- )
- )
- JOIN `vn2008`.`Trabajadores` `tj` ON(
- `tj`.`Id_Trabajador` = `vn2008`.`jerarquia`.`boss_id`
- )
- )
diff --git a/db/routines/bs/procedures/manaCustomerUpdate.sql b/db/routines/bs/procedures/manaCustomerUpdate.sql
index 2cb25d135..2038f976a 100644
--- a/db/routines/bs/procedures/manaCustomerUpdate.sql
+++ b/db/routines/bs/procedures/manaCustomerUpdate.sql
@@ -22,7 +22,7 @@ BEGIN
FROM vn.component WHERE code = 'manaClaim';
SELECT id INTO vManaBankId
- FROM vn.bank WHERE code = 'mana';
+ FROM vn.accounting WHERE code = 'mana';
SELECT id INTO vManaGreugeTypeId
FROM vn.greugeType WHERE code = 'mana';
diff --git a/db/routines/bs/procedures/ventas_add.sql b/db/routines/bs/procedures/ventas_add.sql
index fcb00e092..0c8f636e3 100644
--- a/db/routines/bs/procedures/ventas_add.sql
+++ b/db/routines/bs/procedures/ventas_add.sql
@@ -29,30 +29,34 @@ BEGIN
WHILE vEndingDate <= vEnded DO
- REPLACE ventas(Id_Movimiento, importe, recargo, fecha, tipo_id, Id_Cliente, empresa_id)
- SELECT saleFk,
- SUM(IF(ct.isBase, s.quantity * sc.value, 0)) importe,
- SUM(IF(ct.isBase, 0, s.quantity * sc.value)) recargo,
- vStartingDate,
- i.typeFk,
- a.clientFk,
- t.companyFk
- FROM vn.saleComponent sc
- JOIN vn.component c ON c.id = sc.componentFk
- JOIN vn.componentType ct ON ct.id = c.typeFk
- JOIN vn.sale s ON s.id = sc.saleFk
- JOIN vn.item i ON i.id = s.itemFk
- JOIN vn.itemType it ON it.id = i.typeFk
- JOIN vn.itemCategory ic ON ic.id = it.categoryFk
- JOIN vn.ticket t ON t.id = s.ticketFk
- JOIN vn.address a ON a.id = t.addressFk
- JOIN vn.client cl ON cl.id = a.clientFk
- WHERE t.shipped BETWEEN vStartingDate AND vEndingDate
- AND s.quantity <> 0
- AND s.discount <> 100
- AND ic.merchandise
- GROUP BY sc.saleFk
- HAVING IFNULL(importe,0) <> 0 OR IFNULL(recargo,0) <> 0;
+ REPLACE ventas(Id_Movimiento,
+ importe,
+ recargo,
+ fecha,
+ tipo_id,
+ Id_Cliente,
+ empresa_id
+ )SELECT saleFk,
+ IFNULL(SUM(IF(ct.isBase, s.quantity * sc.value, 0)), 0) importe,
+ IFNULL(SUM(IF(ct.isBase, 0, s.quantity * sc.value)), 0) recargo,
+ vStartingDate,
+ i.typeFk,
+ a.clientFk,
+ t.companyFk
+ FROM vn.saleComponent sc
+ JOIN vn.component c ON c.id = sc.componentFk
+ JOIN vn.componentType ct ON ct.id = c.typeFk
+ JOIN vn.sale s ON s.id = sc.saleFk
+ JOIN vn.item i ON i.id = s.itemFk
+ JOIN vn.itemType it ON it.id = i.typeFk
+ JOIN vn.itemCategory ic ON ic.id = it.categoryFk
+ JOIN vn.ticket t ON t.id = s.ticketFk
+ JOIN vn.address a ON a.id = t.addressFk
+ JOIN vn.client cl ON cl.id = a.clientFk
+ WHERE t.shipped BETWEEN vStartingDate AND vEndingDate
+ AND s.quantity <> 0
+ AND ic.merchandise
+ GROUP BY sc.saleFk;
UPDATE sale s
JOIN (
diff --git a/db/routines/bs/procedures/ventas_contables_add.sql b/db/routines/bs/procedures/ventas_contables_add.sql
index 12b2738f3..66c012a19 100644
--- a/db/routines/bs/procedures/ventas_contables_add.sql
+++ b/db/routines/bs/procedures/ventas_contables_add.sql
@@ -23,7 +23,7 @@ BEGIN
ENGINE = MEMORY
SELECT Id_Ticket
FROM vn2008.Tickets t
- JOIN vn.invoiceOut io ON io.id = t.Factura
+ JOIN vn.invoiceOut io ON io.`ref` = t.Factura
WHERE year(io.issued) = vYear
AND month(io.issued) = vMonth;
diff --git a/db/routines/cache/procedures/clean.sql b/db/routines/cache/procedures/clean.sql
index 95841a713..5e6628689 100644
--- a/db/routines/cache/procedures/clean.sql
+++ b/db/routines/cache/procedures/clean.sql
@@ -1,10 +1,6 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`clean`()
BEGIN
- DECLARE vDateShort DATETIME;
-
- SET vDateShort = TIMESTAMPADD(MONTH, -1, util.VN_CURDATE());
-
- DELETE FROM cache.departure_limit WHERE Fecha < vDateShort;
+ DELETE FROM cache.departure_limit WHERE Fecha < util.VN_CURDATE() - INTERVAL 1 MONTH;
END$$
DELIMITER ;
diff --git a/db/routines/edi/procedures/ekt_load.sql b/db/routines/edi/procedures/ekt_load.sql
index ccdcd1999..9ec0c81d4 100644
--- a/db/routines/edi/procedures/ekt_load.sql
+++ b/db/routines/edi/procedures/ekt_load.sql
@@ -14,7 +14,6 @@ proc:BEGIN
DECLARE vPackage INT;
DECLARE vPutOrderFk INT;
DECLARE vIsLot BOOLEAN;
- DECLARE vForceToPacking INT DEFAULT 2;
DECLARE vEntryFk INT;
DECLARE vHasToChangePackagingFk BOOLEAN;
DECLARE vIsFloramondoDirect BOOLEAN;
@@ -147,10 +146,10 @@ proc:BEGIN
(@t := IF(i.stems, i.stems, 1)) * e.pri / IFNULL(i.stemMultiplier, 1) buyingValue,
IFNULL(vItem, vDefaultEntry) itemFk,
e.qty stickers,
- @pac := IFNULL(i.stemMultiplier, 1) * e.pac / @t packing,
+ @pac := GREATEST(1, IFNULL(i.stemMultiplier, 1) * e.pac / @t) packing,
IFNULL(b.`grouping`, e.pac),
@pac * e.qty,
- vForceToPacking,
+ 'packing',
IF(vHasToChangePackagingFk OR b.packagingFk IS NULL, vPackage, b.packagingFk),
(IFNULL(i.weightByPiece, 0) * @pac) / 1000
FROM ekt e
diff --git a/db/routines/edi/procedures/floramondo_offerRefresh.sql b/db/routines/edi/procedures/floramondo_offerRefresh.sql
index 26e09ebaf..18d3f8b7e 100644
--- a/db/routines/edi/procedures/floramondo_offerRefresh.sql
+++ b/db/routines/edi/procedures/floramondo_offerRefresh.sql
@@ -1,5 +1,5 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `edi`.`floramondo_offerRefresh`()
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `edi`.`floramondo_offerRefresh`()
proc: BEGIN
DECLARE vLanded DATETIME;
DECLARE vDone INT DEFAULT FALSE;
@@ -417,7 +417,7 @@ proc: BEGIN
o.NumberOfUnits etiquetas,
o.NumberOfItemsPerCask packing,
GREATEST(1, IFNULL(o.MinimumQuantity,0)) * o.NumberOfItemsPerCask `grouping`,
- 2, -- Obliga al Packing
+ 'packing',
o.embalageCode,
o.diId
FROM edi.offer o
@@ -518,5 +518,5 @@ proc: BEGIN
fieldValue = TIMEDIFF(util.VN_NOW(), vStartingTime);
DO RELEASE_LOCK('edi.floramondo_offerRefresh');
-END$$
-DELIMITER ;
+END$$
+DELIMITER ;
diff --git a/db/routines/floranet/events/clean.sql b/db/routines/floranet/events/clean.sql
new file mode 100644
index 000000000..4477112fd
--- /dev/null
+++ b/db/routines/floranet/events/clean.sql
@@ -0,0 +1,22 @@
+DELIMITER $$
+CREATE OR REPLACE
+ DEFINER=`root`@`localhost`
+ EVENT `floranet`.`clean`
+ ON SCHEDULE EVERY 1 DAY
+ STARTS '2024-01-01 23:00:00.000'
+ ON COMPLETION PRESERVE
+ ENABLE
+DO
+BEGIN
+ DELETE
+ FROM `order`
+ WHERE created < CURDATE()
+ AND isPaid = FALSE;
+
+ DELETE c.*
+ FROM catalogue c
+ LEFT JOIN `order` o ON o.catalogueFk = c.id
+ WHERE c.created < CURDATE()
+ AND o.id IS NULL;
+END$$
+DELIMITER ;
\ No newline at end of file
diff --git a/db/routines/floranet/procedures/catalogue_findById.sql b/db/routines/floranet/procedures/catalogue_findById.sql
new file mode 100644
index 000000000..aca6ca4d6
--- /dev/null
+++ b/db/routines/floranet/procedures/catalogue_findById.sql
@@ -0,0 +1,13 @@
+DELIMITER $$
+$$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE floranet.catalogue_findById(vSelf INT)
+READS SQL DATA
+BEGIN
+/**
+ * Returns one recordset from catalogue
+ *
+ * @param vCatalogueFk Identifier de floranet.catalogue
+ */
+ SELECT * FROM catalogue WHERE id = vSelf;
+END$$
+DELIMITER ;
diff --git a/db/routines/floranet/procedures/catalogue_get.sql b/db/routines/floranet/procedures/catalogue_get.sql
new file mode 100644
index 000000000..32624f383
--- /dev/null
+++ b/db/routines/floranet/procedures/catalogue_get.sql
@@ -0,0 +1,64 @@
+DROP PROCEDURE IF EXISTS floranet.catalogue_get;
+
+DELIMITER $$
+$$
+CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.catalogue_get(vLanded DATE, vPostalCode VARCHAR(15))
+READS SQL DATA
+proc:BEGIN
+/**
+ * Returns list, price and all the stuff regarding the floranet items.
+ *
+ * @param vLanded Delivery date
+ * @param vPostalCode Delivery address postal code
+ */
+ DECLARE vLastCatalogueFk INT;
+ DECLARE vLockName VARCHAR(20);
+ DECLARE vLockTime INT;
+
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ BEGIN
+ DO RELEASE_LOCK(vLockName);
+
+ RESIGNAL;
+ END;
+
+ SET vLockName = 'catalogue_get';
+ SET vLockTime = 15;
+
+ IF NOT GET_LOCK(vLockName, vLockTime) THEN
+ LEAVE proc;
+ END IF;
+
+ SELECT MAX(id) INTO vLastCatalogueFk
+ FROM catalogue;
+
+ INSERT INTO catalogue(
+ name,
+ price,
+ itemFk,
+ dated,
+ postalCode,
+ `type`,
+ image,
+ description
+ )
+ SELECT i.name,
+ i.`size`,
+ i.id,
+ vLanded,
+ vPostalCode,
+ it.name,
+ CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image),
+ i.description
+ FROM vn.item i
+ JOIN vn.itemType it ON it.id = i.typeFk
+ WHERE it.code IN ('FNR','FNP');
+
+ SELECT *
+ FROM catalogue
+ WHERE id > IFNULL(vLastCatalogueFk,0);
+
+ DO RELEASE_LOCK(vLockName);
+
+END$$
+DELIMITER ;
diff --git a/db/routines/floranet/procedures/contact_request.sql b/db/routines/floranet/procedures/contact_request.sql
new file mode 100644
index 000000000..2ca25b87d
--- /dev/null
+++ b/db/routines/floranet/procedures/contact_request.sql
@@ -0,0 +1,20 @@
+DROP PROCEDURE IF EXISTS floranet.contact_request;
+
+DELIMITER $$
+$$
+CREATE DEFINER=`root`@`localhost`
+PROCEDURE floranet.contact_request(
+ vName VARCHAR(100),
+ vPhone VARCHAR(15),
+ vEmail VARCHAR(100),
+ vMessage TEXT)
+READS SQL DATA
+BEGIN
+/**
+ * Set actions for contact request
+ *
+ * @param vPostalCode Delivery address postal code
+ */
+
+END$$
+DELIMITER ;
\ No newline at end of file
diff --git a/db/routines/floranet/procedures/deliveryDate_get.sql b/db/routines/floranet/procedures/deliveryDate_get.sql
new file mode 100644
index 000000000..75e9d6257
--- /dev/null
+++ b/db/routines/floranet/procedures/deliveryDate_get.sql
@@ -0,0 +1,29 @@
+DROP PROCEDURE IF EXISTS floranet.deliveryDate_get;
+
+DELIMITER $$
+$$
+CREATE DEFINER=`root`@`localhost` PROCEDURE `floranet`.`deliveryDate_get`(vPostalCode VARCHAR(15))
+ READS SQL DATA
+BEGIN
+/**
+ * Returns available dates for this postalCode, in the next seven days.
+ *
+ * @param vPostalCode Delivery address postal code
+ */
+ DECLARE vCurrentDayOfWeek INT;
+
+ SET vCurrentDayOfWeek = DAYOFWEEK(NOW());
+
+ SELECT DISTINCT nextDay
+ FROM (
+ SELECT CURDATE() + INTERVAL IF(
+ apc.dayOfWeek >= vCurrentDayOfWeek,
+ apc.dayOfWeek - vCurrentDayOfWeek,
+ 7 - apc.dayOfWeek
+ ) DAY nextDay,
+ NOW() + INTERVAL apc.hoursInAdvance - 12 HOUR minDeliveryTime
+ FROM addressPostCode apc
+ WHERE apc.postCode = vPostalCode
+ HAVING nextDay > minDeliveryTime) sub;
+END$$
+DELIMITER ;
\ No newline at end of file
diff --git a/db/routines/floranet/procedures/order_confirm.sql b/db/routines/floranet/procedures/order_confirm.sql
new file mode 100644
index 000000000..b6aec033d
--- /dev/null
+++ b/db/routines/floranet/procedures/order_confirm.sql
@@ -0,0 +1,25 @@
+DROP PROCEDURE IF EXISTS floranet.order_confirm;
+
+DELIMITER $$
+$$
+
+CREATE DEFINER=`root`@`localhost`PROCEDURE floranet.order_confirm(vCatalogueFk INT)
+READS SQL DATA
+
+BEGIN
+/** Update order.isPaid field.
+ *
+ * @param vCatalogueFk floranet.catalogue.id
+ *
+ * @returns floranet.order.isPaid
+ */
+ UPDATE `order`
+ SET isPaid = TRUE,
+ payed = NOW()
+ WHERE catalogueFk = vCatalogueFk;
+
+ SELECT isPaid
+ FROM `order`
+ WHERE catalogueFk = vCatalogueFk;
+END$$
+DELIMITER ;
\ No newline at end of file
diff --git a/db/routines/floranet/procedures/order_put.sql b/db/routines/floranet/procedures/order_put.sql
new file mode 100644
index 000000000..979588f8f
--- /dev/null
+++ b/db/routines/floranet/procedures/order_put.sql
@@ -0,0 +1,22 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE floranet.order_put(vJsonData JSON)
+READS SQL DATA
+BEGIN
+/**
+ * Get and process an order.
+ *
+ * @param vJsonData The order data in json format
+ */
+ INSERT INTO `order`
+ SET catalogueFk = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.products[0].id')),
+ customerName = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.customerName')),
+ email = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.email')),
+ customerPhone = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.customerPhone')),
+ message= JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.message')),
+ deliveryName = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.deliveryName')),
+ address = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.address')),
+ deliveryPhone = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.deliveryPhone'));
+
+ SELECT LAST_INSERT_ID() orderFk;
+END$$
+DELIMITER ;
diff --git a/db/routines/floranet/procedures/sliders_get.sql b/db/routines/floranet/procedures/sliders_get.sql
new file mode 100644
index 000000000..0e4aa297a
--- /dev/null
+++ b/db/routines/floranet/procedures/sliders_get.sql
@@ -0,0 +1,20 @@
+DROP PROCEDURE IF EXISTS floranet.sliders_get;
+
+DELIMITER $$
+$$
+CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.sliders_get()
+READS SQL DATA
+BEGIN
+/**
+ * Returns list of url for sliders.
+ */
+ SELECT
+ CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image) url,
+ i.longName
+ FROM vn.item i
+ JOIN vn.itemType it ON it.id = i.typeFk
+ WHERE it.code IN ('FNR','FNP')
+ LIMIT 3;
+
+END$$
+DELIMITER ;
\ No newline at end of file
diff --git a/db/routines/hedera/events/order_doRecalc.sql b/db/routines/hedera/events/order_doRecalc.sql
index d355e1a55..bbc61924f 100644
--- a/db/routines/hedera/events/order_doRecalc.sql
+++ b/db/routines/hedera/events/order_doRecalc.sql
@@ -3,6 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `hedera`.`order_doRecalc`
ON SCHEDULE EVERY 10 SECOND
STARTS '2019-08-29 14:18:04.000'
ON COMPLETION PRESERVE
- ENABLE
+ DISABLE
DO CALL order_doRecalc$$
DELIMITER ;
diff --git a/db/routines/hedera/procedures/catalog_calcFromMyAddress.sql b/db/routines/hedera/procedures/catalog_calcFromMyAddress.sql
index c9a9db5e0..c9fa54f36 100644
--- a/db/routines/hedera/procedures/catalog_calcFromMyAddress.sql
+++ b/db/routines/hedera/procedures/catalog_calcFromMyAddress.sql
@@ -32,7 +32,7 @@ BEGIN
WHERE c.available > 0
GROUP BY c.item_id;
- CALL vn.catalog_calculate(vDelivery, vAddress, vAgencyMode);
+ CALL vn.catalog_calculate(vDelivery, vAddress, vAgencyMode, FALSE);
DROP TEMPORARY TABLE tmp.item;
END$$
diff --git a/db/routines/hedera/procedures/item_calcCatalog.sql b/db/routines/hedera/procedures/item_calcCatalog.sql
index 81b3adf5a..e72c2fd06 100644
--- a/db/routines/hedera/procedures/item_calcCatalog.sql
+++ b/db/routines/hedera/procedures/item_calcCatalog.sql
@@ -16,7 +16,7 @@ BEGIN
ENGINE = MEMORY
SELECT vSelf itemFk;
- CALL vn.catalog_calculate(vLanded, vAddressFk, vAgencyModeFk);
+ CALL vn.catalog_calculate(vLanded, vAddressFk, vAgencyModeFk, FALSE);
SELECT l.warehouseFk, w.name warehouse,
p.`grouping`, p.price, p.rate, l.available
diff --git a/db/routines/hedera/procedures/order_calcCatalog.sql b/db/routines/hedera/procedures/order_calcCatalog.sql
index 53ede1b57..239e01788 100644
--- a/db/routines/hedera/procedures/order_calcCatalog.sql
+++ b/db/routines/hedera/procedures/order_calcCatalog.sql
@@ -27,7 +27,7 @@ BEGIN
WHERE orderFk = vSelf
GROUP BY itemFk;
- CALL vn.catalog_calculate(vDate, vAddress, vAgencyMode);
+ CALL vn.catalog_calculate(vDate, vAddress, vAgencyMode, FALSE);
DROP TEMPORARY TABLE tmp.item;
END$$
diff --git a/db/routines/hedera/procedures/order_calcCatalogFull.sql b/db/routines/hedera/procedures/order_calcCatalogFull.sql
index 52d22ba30..41408c5e8 100644
--- a/db/routines/hedera/procedures/order_calcCatalogFull.sql
+++ b/db/routines/hedera/procedures/order_calcCatalogFull.sql
@@ -22,7 +22,7 @@ BEGIN
FROM `order`
WHERE id = vSelf;
- CALL vn.catalog_calculate(vDate, vAddress, vAgencyMode);
+ CALL vn.catalog_calculate(vDate, vAddress, vAgencyMode, FALSE);
IF account.myUser_getName() = 'visitor' THEN
UPDATE tmp.ticketCalculateItem
diff --git a/db/routines/hedera/procedures/order_requestRecalc.sql b/db/routines/hedera/procedures/order_requestRecalc.sql
index 4bcb1010e..990894bb6 100644
--- a/db/routines/hedera/procedures/order_requestRecalc.sql
+++ b/db/routines/hedera/procedures/order_requestRecalc.sql
@@ -10,6 +10,7 @@ proc: BEGIN
LEAVE proc;
END IF;
- INSERT INTO orderRecalc SET orderFk = vSelf;
+ -- #4409 Disable order recalc
+ -- INSERT INTO orderRecalc SET orderFk = vSelf;
END$$
DELIMITER ;
diff --git a/db/routines/hedera/procedures/tpvTransaction_undo.sql b/db/routines/hedera/procedures/tpvTransaction_undo.sql
index ed72dd76d..f31ba6a80 100644
--- a/db/routines/hedera/procedures/tpvTransaction_undo.sql
+++ b/db/routines/hedera/procedures/tpvTransaction_undo.sql
@@ -54,7 +54,7 @@ p: BEGIN
FROM vn.`client` WHERE id = vCustomer;
SELECT account INTO vAccount
- FROM vn.bank WHERE id = vBank;
+ FROM vn.accounting WHERE id = vBank;
DELETE FROM vn.XDiario
WHERE SUBCTA = vSubaccount
diff --git a/db/routines/sage/procedures/accountingMovements_add.sql b/db/routines/sage/procedures/accountingMovements_add.sql
index bd86e132d..575c63f6c 100644
--- a/db/routines/sage/procedures/accountingMovements_add.sql
+++ b/db/routines/sage/procedures/accountingMovements_add.sql
@@ -253,9 +253,9 @@ BEGIN
LIMIT 10000000000000000000
) sub GROUP BY ASIEN
)sub2 ON sub2.ASIEN = x.ASIEN
- LEFT JOIN ( SELECT DISTINCT(account),cu.code
- FROM vn.bank b
- JOIN vn.currency cu ON cu.id = b.currencyFk
+ LEFT JOIN ( SELECT DISTINCT(a.account),cu.code
+ FROM vn.accounting a
+ JOIN vn.currency cu ON cu.id = a.currencyFk
WHERE cu.code <> 'EUR' -- no se informa cuando la divisa en EUR
)sub3 ON sub3.account = x.SUBCTA
WHERE x.enlazadoSage = FALSE
diff --git a/db/routines/sage/procedures/invoiceIn_add.sql b/db/routines/sage/procedures/invoiceIn_add.sql
index a2690deb0..0898d6810 100644
--- a/db/routines/sage/procedures/invoiceIn_add.sql
+++ b/db/routines/sage/procedures/invoiceIn_add.sql
@@ -3,10 +3,11 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `sage`.`invoiceIn_add`(vI
BEGIN
/**
* Traslada la info de contabilidad relacionada con las facturas recibidas
- *
+ *
* @vInvoiceInFk Factura recibida
* @vXDiarioFk Id tabla XDiario
- */
+ */
+ DECLARE vInvoiceInOriginalFk INT;
DECLARE vDone BOOL DEFAULT FALSE;
DECLARE vBase DOUBLE;
DECLARE vVat DOUBLE;
@@ -23,25 +24,25 @@ BEGIN
DECLARE vInvoiceTypeInformative VARCHAR(1);
DECLARE vIsInformativeExportation BOOL DEFAULT FALSE;
- DECLARE vCursor CURSOR FOR
+ DECLARE vCursor CURSOR FOR
SELECT it.taxableBase,
CAST((( it.taxableBase / 100) * t.PorcentajeIva) AS DECIMAL (10,2)),
t.PorcentajeIva,
it.transactionTypeSageFk,
it.taxTypeSageFk,
tty.isIntracommunity,
- tt.ClaveOperacionDefecto
+ tt.ClaveOperacionDefecto
FROM vn.invoiceIn i
JOIN vn.invoiceInTax it ON it.InvoiceInFk = i.id
JOIN TiposIva t ON t.CodigoIva = it.taxTypeSageFk
JOIN taxType tty ON tty.id = t.CodigoIva
JOIN TiposTransacciones tt ON tt.CodigoTransaccion = it.transactionTypeSageFk
LEFT JOIN vn.dua d ON d.id = vInvoiceInFk
- WHERE i.id = vInvoiceInFk
+ WHERE i.id = vInvoiceInFk
AND d.id IS NULL;
-
+
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
-
+
DELETE FROM movContaIVA
WHERE id = vXDiarioFk;
@@ -64,22 +65,22 @@ BEGIN
vTaxCode,
vIsIntracommunity,
vOperationCode;
-
- IF vDone THEN
+
+ IF vDone THEN
LEAVE l;
END IF;
- SET vTransactionCodeOld = vTransactionCode;
- SET vTaxCodeOld = vTaxCode;
+ SET vTransactionCodeOld = vTransactionCode;
+ SET vTaxCodeOld = vTaxCode;
- IF vOperationCode IS NOT NULL THEN
+ IF vOperationCode IS NOT NULL THEN
UPDATE movContaIVA
SET ClaveOperacionFactura = vOperationCode
WHERE id = vXDiarioFk;
END IF;
-
+
SET vCounter = vCounter + 1;
- CASE vCounter
+ CASE vCounter
WHEN 1 THEN
UPDATE movContaIVA
SET BaseIva1 = vBase,
@@ -115,31 +116,31 @@ BEGIN
WHERE id = vXDiarioFk;
ELSE
SELECT vXDiarioFk INTO vXDiarioFk;
- END CASE;
+ END CASE;
IF vIsIntracommunity THEN
UPDATE movContaIVA
SET Intracomunitaria = TRUE
WHERE id = vXDiarioFk;
END IF;
-
- SET vTransactionCodeOld = vTransactionCode;
- SET vTaxCodeOld = vTaxCode;
-
+
+ SET vTransactionCodeOld = vTransactionCode;
+ SET vTaxCodeOld = vTaxCode;
+
END LOOP;
CLOSE vCursor;
SELECT d.ASIEN AND x.ASIEN IS NULL INTO vIsInformativeExportation
FROM vn.dua d
- LEFT JOIN vn.XDiario x ON x.ASIEN = d.ASIEN
+ LEFT JOIN vn.XDiario x ON x.ASIEN = d.ASIEN
AND x.SERIE = vSerialDua COLLATE utf8mb3_unicode_ci
WHERE d.ASIEN = (
SELECT ASIEN
- FROM vn.XDiario
+ FROM vn.XDiario
WHERE id = vXDiarioFk)
LIMIT 1;
-
+
UPDATE movContaIVA mci
JOIN tmp.invoiceIn ii ON ii.id = vInvoiceInFk
JOIN vn.XDiario x ON x.id = mci.id
@@ -151,13 +152,13 @@ BEGIN
mci.Serie = ii.serial,
mci.Factura = ii.id,
mci.FechaFactura = ii.issued,
- mci.ImporteFactura = IFNULL(mci.BaseIva1, 0) + IFNULL(mci.CuotaIva1, 0) +
- IFNULL(mci.BaseIva2, 0) + IFNULL(mci.CuotaIva2, 0) +
- IFNULL(mci.BaseIva3, 0) + IFNULL(mci.CuotaIva3, 0) +
+ mci.ImporteFactura = IFNULL(mci.BaseIva1, 0) + IFNULL(mci.CuotaIva1, 0) +
+ IFNULL(mci.BaseIva2, 0) + IFNULL(mci.CuotaIva2, 0) +
+ IFNULL(mci.BaseIva3, 0) + IFNULL(mci.CuotaIva3, 0) +
IFNULL(mci.BaseIva4, 0) + IFNULL(mci.CuotaIva4, 0),
- mci.TipoFactura = IF(id.id,
- IF( ii.serial = vSerialDua COLLATE utf8mb3_unicode_ci, vInvoiceTypeReceived, vInvoiceTypeInformative),
- IF(vIsInformativeExportation,vInvoiceTypeInformative, vInvoiceTypeReceived)),
+ mci.TipoFactura = IF(id.id,
+ IF( ii.serial = vSerialDua COLLATE utf8mb3_unicode_ci, vInvoiceTypeReceived, vInvoiceTypeInformative),
+ IF(vIsInformativeExportation,vInvoiceTypeInformative, vInvoiceTypeReceived)),
mci.CodigoCuentaFactura = x.SUBCTA,
mci.CifDni = IF(LEFT(TRIM(s.nif), 2) = n.SiglaNacion, SUBSTRING(TRIM(s.nif), 3), s.nif),
mci.Nombre = s.name,
@@ -185,7 +186,7 @@ BEGIN
JOIN (SELECT SUM(x2.BASEEURO) taxableBase, SUM(x2.EURODEBE) taxBase
FROM vn.XDiario x1
JOIN vn.XDiario x2 ON x1.ASIEN = x2.ASIEN
- WHERE x2.BASEEURO <> 0
+ WHERE x2.BASEEURO <> 0
AND x1.id = vXDiarioFk
)sub
JOIN ClavesOperacion co ON co.Descripcion = 'Arrendamiento de locales de negocio'
@@ -193,10 +194,41 @@ BEGIN
mci.ClaveOperacionFactura = IF( t.Retencion = 'ARRENDAMIENTO Y SUBARRENDAMIENTO', co.ClaveOperacionFactura_, mci.ClaveOperacionFactura),
mci.BaseRetencion = IF (t.Retencion = 'ACTIVIDADES AGRICOLAS O GANADERAS', sub.taxableBase + sub.taxBase, sub.taxableBase),
mci.PorRetencion = t.PorcentajeRetencion,
- mci.ImporteRetencion = iit.taxableBase * - 1
- WHERE mci.id = vXDiarioFk
+ mci.ImporteRetencion = iit.taxableBase * - 1
+ WHERE mci.id = vXDiarioFk
AND e.name = 'Retenciones'
AND id.id IS NULL;
+ SELECT correctedFk INTO vInvoiceInOriginalFk
+ FROM vn.invoiceInCorrection
+ WHERE correctingFk = vInvoiceInFk;
+
+ IF vInvoiceInOriginalFk THEN
+
+ UPDATE movContaIVA mci
+ JOIN vn.invoiceInRefund iir ON iir.invoiceInRefundFk = vInvoiceInFk
+ JOIN (SELECT issued,
+ SUM(sub.taxableBase) taxableBase,
+ SUM(ROUND((sub.taxableBase * sub.PorcentajeIva) / 100 , 2)) vat
+ FROM(SELECT issued,
+ SUM(iit.taxableBase) taxableBase,
+ ti.PorcentajeIva
+ FROM vn.invoiceIn i
+ JOIN vn.invoiceInTax iit ON iit.invoiceInFk = i.id
+ JOIN sage.TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk
+ WHERE i.id = vInvoiceInOriginalFk
+ GROUP BY ti.CodigoIva)sub
+ )invoiceInOriginal
+ JOIN ClavesOperacion co ON co.Descripcion = 'Factura rectificativa'
+ SET mci.TipoRectificativa = iir.refundCategoryFk,
+ mci.ClaseAbonoRectificativas = iir.refundType,
+ mci.FechaFacturaOriginal = invoiceInOriginal.issued,
+ mci.FechaOperacion = invoiceInOriginal.issued,
+ mci.BaseImponibleOriginal = invoiceInOriginal.taxableBase,
+ mci.CuotaIvaOriginal = invoiceInOriginal.vat,
+ mci.ClaveOperacionFactura = co.ClaveOperacionFactura_
+ WHERE mci.id = vXDiarioFk;
+
+ END IF;
END$$
-DELIMITER ;
+DELIMITER ;
\ No newline at end of file
diff --git a/db/routines/sage/procedures/pgc_add.sql b/db/routines/sage/procedures/pgc_add.sql
index 6dd5bc72d..78d80a9fe 100644
--- a/db/routines/sage/procedures/pgc_add.sql
+++ b/db/routines/sage/procedures/pgc_add.sql
@@ -20,12 +20,12 @@ BEGIN
FROM vn.expense e
UNION
SELECT company_getCode(vCompanyFk),
- b.account,
- UCASE(b.bank),
+ a.account,
+ UCASE(a.bank),
''
- FROM vn.bank b
- WHERE b.isActive
- AND b.`account`
+ FROM vn.accounting a
+ WHERE a.isActive
+ AND a.`account`
UNION
SELECT CodigoEmpresa,
CodigoCuenta,
diff --git a/db/routines/util/functions/binlogQueue_getDelay.sql b/db/routines/util/functions/binlogQueue_getDelay.sql
new file mode 100644
index 000000000..a440fc0ab
--- /dev/null
+++ b/db/routines/util/functions/binlogQueue_getDelay.sql
@@ -0,0 +1,45 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`binlogQueue_getDelay`(vCode VARCHAR(255))
+ RETURNS BIGINT
+ NOT DETERMINISTIC
+BEGIN
+/**
+ * Returns the difference between the current position of the binary log and
+ * the passed queue.
+ *
+ * @param vCode The queue code
+ * @return The difference in MB
+ */
+ DECLARE vCurLogName VARCHAR(255);
+ DECLARE vCurPosition BIGINT;
+ DECLARE vQueueLogName VARCHAR(255);
+ DECLARE vQueuePosition BIGINT;
+ DECLARE vDelay BIGINT;
+
+ SELECT VARIABLE_VALUE INTO vCurLogName
+ FROM information_schema.GLOBAL_STATUS
+ WHERE VARIABLE_NAME = 'BINLOG_SNAPSHOT_FILE';
+
+ SELECT VARIABLE_VALUE INTO vCurPosition
+ FROM information_schema.GLOBAL_STATUS
+ WHERE VARIABLE_NAME = 'BINLOG_SNAPSHOT_POSITION';
+
+ SELECT logName, `position`
+ INTO vQueueLogName, vQueuePosition
+ FROM binlogQueue
+ WHERE code = vCode;
+
+ IF vQueuePosition IS NULL THEN
+ RETURN NULL;
+ END IF;
+
+ SET vDelay =
+ vCurPosition - CAST(vQueuePosition AS SIGNED) +
+ @@max_binlog_size * (
+ CAST(REGEXP_SUBSTR(vCurLogName, '[0-9]+') AS SIGNED) -
+ CAST(REGEXP_SUBSTR(vQueueLogName, '[0-9]+') AS SIGNED)
+ );
+
+ RETURN ROUND(vDelay / POW(1024, 2));
+END$$
+DELIMITER ;
diff --git a/db/routines/util/procedures/slowLog_prune.sql b/db/routines/util/procedures/slowLog_prune.sql
index 7294be2f6..d676ae3d9 100644
--- a/db/routines/util/procedures/slowLog_prune.sql
+++ b/db/routines/util/procedures/slowLog_prune.sql
@@ -6,16 +6,24 @@ BEGIN
*/
DECLARE vSlowQueryLog INT DEFAULT @@slow_query_log;
DECLARE vSqlLogBin INT DEFAULT @@SESSION.sql_log_bin;
+ DECLARE vLogExists BOOL;
SET sql_log_bin = OFF;
SET GLOBAL slow_query_log = OFF;
- RENAME TABLE `mysql`.`slow_log` TO `mysql`.`slow_log_temp`;
+ SELECT COUNT(*) > 0 INTO vLogExists
+ FROM information_schema.TABLES
+ WHERE TABLE_SCHEMA = 'mysql' AND TABLE_NAME = 'slow_log';
- DELETE FROM `mysql`.`slow_log_temp`
+ IF vLogExists THEN
+ DROP TEMPORARY TABLE IF EXISTS mysql.slow_log_temp;
+ RENAME TABLE mysql.slow_log TO mysql.slow_log_temp;
+ END IF;
+
+ DELETE FROM mysql.slow_log_temp
WHERE start_time < TIMESTAMPADD(WEEK, -1, util.VN_NOW());
- RENAME TABLE `mysql`.`slow_log_temp` TO `mysql`.`slow_log`;
+ RENAME TABLE mysql.slow_log_temp TO mysql.slow_log;
SET GLOBAL slow_query_log = vSlowQueryLog;
SET sql_log_bin = vSqlLogBin;
diff --git a/db/routines/vn/events/clientsDisable.sql b/db/routines/vn/events/clientsDisable.sql
index 00cd4ed8b..238e060dd 100644
--- a/db/routines/vn/events/clientsDisable.sql
+++ b/db/routines/vn/events/clientsDisable.sql
@@ -7,9 +7,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`clientsDisable`
DO BEGIN
UPDATE account.user u
JOIN client c ON c.id = u.id
- JOIN clientType ct ON ct.id = c.typeFk
SET u.active = FALSE
- WHERE ct.code = 'normal'
+ WHERE c.typeFk = 'normal'
AND u.id NOT IN (
SELECT DISTINCT c.id
FROM client c
diff --git a/db/routines/vn2008/events/raidUpdate.sql b/db/routines/vn/events/raidUpdate.sql
similarity index 65%
rename from db/routines/vn2008/events/raidUpdate.sql
rename to db/routines/vn/events/raidUpdate.sql
index aacfd6dcd..619dadb48 100644
--- a/db/routines/vn2008/events/raidUpdate.sql
+++ b/db/routines/vn/events/raidUpdate.sql
@@ -1,5 +1,5 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn2008`.`raidUpdate`
+CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`raidUpdate`
ON SCHEDULE EVERY 1 DAY
STARTS '2017-12-29 00:05:00.000'
ON COMPLETION PRESERVE
diff --git a/db/routines/vn/events/sale_checkWithoutComponents.sql b/db/routines/vn/events/sale_checkWithoutComponents.sql
deleted file mode 100644
index 2a1ced6ca..000000000
--- a/db/routines/vn/events/sale_checkWithoutComponents.sql
+++ /dev/null
@@ -1,8 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`sale_checkWithoutComponents`
- ON SCHEDULE EVERY 10 MINUTE
- STARTS '2020-05-04 11:56:23.000'
- ON COMPLETION PRESERVE
- ENABLE
-DO call sale_checkNoComponents(DATE_ADD(util.VN_NOW(), INTERVAL -10 MINUTE),DATE_ADD(util.VN_NOW(), INTERVAL -1 MINUTE))$$
-DELIMITER ;
diff --git a/db/routines/vn/functions/addressTaxArea.sql b/db/routines/vn/functions/addressTaxArea.sql
index 3586dd4ce..1d4e9e2f0 100644
--- a/db/routines/vn/functions/addressTaxArea.sql
+++ b/db/routines/vn/functions/addressTaxArea.sql
@@ -20,6 +20,7 @@ BEGIN
CALL vn.addressTaxArea();
SELECT areaFk INTO vTaxArea FROM tmp.addressTaxArea;
+
DROP TEMPORARY TABLE
tmp.addressCompany,
tmp.addressTaxArea;
diff --git a/db/routines/vn/functions/getSpecialPrice.sql b/db/routines/vn/functions/getSpecialPrice.sql
index f3b340cfe..2cc5f2b99 100644
--- a/db/routines/vn/functions/getSpecialPrice.sql
+++ b/db/routines/vn/functions/getSpecialPrice.sql
@@ -8,13 +8,16 @@ BEGIN
SELECT rate3 INTO price
FROM vn.priceFixed
- WHERE itemFk = vItemFk
+ WHERE itemFk = vItemFk
AND util.VN_CURDATE() BETWEEN started AND ended ORDER BY created DESC LIMIT 1;
- SELECT `value` INTO price
+ SELECT `value` INTO price
FROM vn.specialPrice
- WHERE itemFk = vItemFk
- AND clientFk = vClientFk ;
+ WHERE itemFk = vItemFk
+ AND (clientFk = vClientFk OR clientFk IS NULL)
+ AND started <= util.VN_CURDATE()
+ AND (ended >= util.VN_CURDATE() OR ended IS NULL)
+ ORDER BY id DESC LIMIT 1;
RETURN price;
END$$
DELIMITER ;
diff --git a/db/routines/vn/functions/till_new.sql b/db/routines/vn/functions/till_new.sql
index cfca5945d..24f4f2b79 100644
--- a/db/routines/vn/functions/till_new.sql
+++ b/db/routines/vn/functions/till_new.sql
@@ -34,7 +34,7 @@ BEGIN
-- Inserta los asientos contables
SELECT account INTO vAccount
- FROM bank WHERE id = vBank;
+ FROM accounting WHERE id = vBank;
SELECT accountingAccount INTO vSubaccount
FROM `client` WHERE id = vClient;
diff --git a/db/routines/vn/functions/travel_hasUniqueAwb.sql b/db/routines/vn/functions/travel_hasUniqueAwb.sql
new file mode 100644
index 000000000..e918f1a26
--- /dev/null
+++ b/db/routines/vn/functions/travel_hasUniqueAwb.sql
@@ -0,0 +1,28 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`travel_hasUniqueAwb`(
+ vSelf INT
+)
+ RETURNS BOOL
+ READS SQL DATA
+BEGIN
+/**
+ * Comprueba que el travel pasado tiene un AWB lógico,
+ * no se pueden tener varios AWB asociados al mismo DUA
+ *
+ * @param vSelf Id del travel
+ */
+ DECLARE vHasUniqueAwb BOOL DEFAULT TRUE;
+
+ SELECT NOT COUNT(t2.awbFk) INTO vHasUniqueAwb
+ FROM entry e
+ JOIN travel t ON t.id = e.travelFk
+ JOIN duaEntry de ON de.entryFk = e.id
+ JOIN duaEntry de2 ON de2.duaFk = de.duaFk
+ JOIN entry e2 ON e2.id = de2.entryFk
+ JOIN travel t2 ON t2.id = e2.travelFk
+ WHERE t.id = vSelf
+ AND t2.awbFk <> t.awbFk;
+
+ RETURN vHasUniqueAwb;
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/procedures/absoluteInventoryHistory.sql b/db/routines/vn/procedures/absoluteInventoryHistory.sql
new file mode 100644
index 000000000..627b7c8be
--- /dev/null
+++ b/db/routines/vn/procedures/absoluteInventoryHistory.sql
@@ -0,0 +1,102 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`absoluteInventoryHistory`(
+ vItemFk INT,
+ vWarehouseFk INT,
+ vDate DATETIME
+)
+BEGIN
+/**
+* Calcula y proporciona un historial de inventario absoluto
+* para un artículo específico en un almacén dado
+* hasta una fecha determinada.
+*
+* @param vItemFk Id de artículo
+* @param vWarehouseFk Id de almacén
+* @param vDate Fecha
+*/
+ DECLARE vCalculatedInventory INT;
+ DECLARE vToday DATETIME DEFAULT util.VN_CURDATE();
+ DECLARE vStartDate DATE DEFAULT '2001-01-01';
+
+ CREATE OR REPLACE TEMPORARY TABLE tHistoricalPast
+ ENGINE = MEMORY
+ SELECT *
+ FROM (
+ SELECT tr.landed `date`,
+ b.quantity input,
+ NULL `output`,
+ tr.isReceived ok,
+ s.name alias,
+ e.invoiceNumber reference,
+ e.id id,
+ tr.isDelivered f5
+ 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
+ WHERE tr.landed >= vStartDate
+ AND s.id <> (SELECT supplierFk FROM inventoryConfig)
+ AND vWarehouseFk IN (tr.warehouseInFk, 0)
+ AND b.itemFk = vItemFk
+ AND NOT e.isExcludedFromAvailable
+ AND NOT e.isRaid
+ UNION ALL
+ SELECT tr.shipped,
+ NULL,
+ b.quantity,
+ tr.isDelivered,
+ s.name,
+ e.invoiceNumber,
+ e.id,
+ tr.isDelivered
+ 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
+ WHERE tr.shipped >= vStartDate
+ AND vWarehouseFk = tr.warehouseOutFk
+ AND s.id <> (SELECT supplierFk FROM inventoryConfig)
+ AND b.itemFk = vItemFk
+ AND NOT e.isExcludedFromAvailable
+ AND NOT e.isRaid
+ UNION ALL
+ SELECT t.shipped,
+ NULL,
+ m.quantity,
+ (m.isPicked OR t.isLabeled OR t.refFk IS NOT NULL),
+ t.nickname,
+ t.refFk,
+ t.id,
+ t.isPrinted
+ FROM sale m
+ JOIN ticket t ON t.id = m.ticketFk
+ JOIN client c ON c.id = t.clientFk
+ WHERE t.shipped >= vStartDate
+ AND m.itemFk = vItemFk
+ AND vWarehouseFk IN (t.warehouseFk, 0)
+ ) t1
+ ORDER BY `date`, input DESC, ok DESC;
+
+ SELECT SUM(input) - SUM(`output`) INTO vCalculatedInventory
+ FROM tHistoricalPast
+ WHERE `date` < vDate;
+
+ SELECT p1.*, NULL v_virtual
+ FROM (
+ SELECT vDate `date`,
+ vCalculatedInventory input,
+ NULL `output`,
+ 1 ok,
+ 'Inventario calculado' alias,
+ '' reference,
+ 0 id,
+ 1 f5
+ UNION ALL
+ SELECT *
+ FROM tHistoricalPast
+ WHERE `date` >= vDate
+ ) p1;
+
+ DROP TEMPORARY TABLE tHistoricalPast;
+END$$
+DELIMITER ;
\ No newline at end of file
diff --git a/db/routines/vn/procedures/addAccountReconciliation.sql b/db/routines/vn/procedures/addAccountReconciliation.sql
new file mode 100644
index 000000000..8effbd76c
--- /dev/null
+++ b/db/routines/vn/procedures/addAccountReconciliation.sql
@@ -0,0 +1,66 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`addAccountReconciliation`()
+BEGIN
+/**
+ * Updates duplicate records in the accountReconciliation table,
+ * by assigning them a new identifier and then inserts a new entry in the till table.
+ */
+ UPDATE accountReconciliation ar
+ JOIN (
+ SELECT id,
+ calculatedCode,
+ CONCAT(
+ calculatedCode,
+ '(',
+ ROW_NUMBER() OVER (PARTITION BY calculatedCode ORDER BY id),
+ ')'
+ ) newId
+ FROM accountReconciliation ar
+ WHERE calculatedCode IN (
+ SELECT calculatedCode
+ FROM accountReconciliation
+ GROUP BY calculatedCode
+ HAVING COUNT(*) > 1
+ )
+ ORDER BY calculatedCode, id
+ ) sub2 ON ar.id = sub2.id
+ SET ar.calculatedCode = sub2.newId;
+
+ INSERT INTO till(
+ dated,
+ isAccountable,
+ serie,
+ concept,
+ `in`,
+ `out`,
+ bankFk,
+ companyFk,
+ warehouseFk,
+ supplierAccountFk,
+ calculatedCode,
+ InForeignValue,
+ OutForeignValue,
+ workerFk
+ )
+ SELECT ar.operationDated,
+ TRUE,
+ 'MB',
+ ar.concept,
+ IF(ar.debitCredit = 'credit' AND a.currencyFk = arc.currencyFk, ar.amount, NULL),
+ IF(ar.debitCredit = 'debit' AND a.currencyFk = arc.currencyFk, ar.amount, NULL),
+ a.id,
+ sa.supplierFk,
+ arc.warehouseFk,
+ ar.supplierAccountFk,
+ ar.calculatedCode,
+ IF(ar.debitCredit = 'credit' AND NOT a.currencyFk = arc.currencyFk, ar.amount, NULL),
+ IF(ar.debitCredit = 'debit' AND NOT a.currencyFk = arc.currencyFk, ar.amount, NULL),
+ account.myUser_getId()
+ FROM accountReconciliation ar
+ JOIN supplierAccount sa ON sa.id = ar.supplierAccountFk
+ JOIN accounting a ON a.id = sa.accountingFk
+ LEFT JOIN till t ON t.calculatedCode = ar.calculatedCode
+ JOIN accountReconciliationConfig arc
+ WHERE t.id IS NULL;
+END$$
+DELIMITER ;
\ No newline at end of file
diff --git a/db/routines/vn/procedures/agencyVolume.sql b/db/routines/vn/procedures/agencyVolume.sql
new file mode 100644
index 000000000..176b77726
--- /dev/null
+++ b/db/routines/vn/procedures/agencyVolume.sql
@@ -0,0 +1,38 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`agencyVolume`()
+BEGIN
+/**
+ * Calculates and presents information on shipment and packaging volumes
+ * for agencies that are not owned for a specific period.
+ */
+ DECLARE vStarted DATETIME DEFAULT util.VN_CURDATE();
+ DECLARE vEnded DATETIME DEFAULT util.dayEnd(util.VN_CURDATE());
+
+ SELECT ag.id agency_id,
+ CONCAT(RPAD(c.country, 16,' _') ,' ',ag.name) Agencia,
+ COUNT(*) expediciones,
+ SUM(t.packages) Bultos,
+ SUM(tpe.boxes) Faltan
+ FROM ticket t
+ JOIN warehouse w ON w.id = t.warehouseFk
+ JOIN country c ON w.countryFk = c.id
+ JOIN address a ON a.id = t.addressFk
+ JOIN agencyMode am ON am.id = t.agencyModeFk
+ JOIN agency ag ON ag.id = am.agencyFk
+ JOIN (
+ SELECT sv.ticketFk,
+ CEIL(1000 * SUM(sv.volume) / vc.standardFlowerBox) boxes
+ FROM ticket t
+ JOIN saleVolume sv ON sv.ticketFk = t.id
+ JOIN volumeConfig vc
+ WHERE t.shipped BETWEEN vStarted AND vEnded
+ AND (t.packages IS NULL OR NOT t.packages)
+ GROUP BY t.id
+ ) tpe ON tpe.ticketFk = t.id
+ WHERE t.shipped BETWEEN vStarted AND vEnded
+ AND NOT ag.isOwn
+ GROUP BY ag.id
+ ORDER BY Agencia;
+
+END$$
+DELIMITER ;
\ No newline at end of file
diff --git a/db/routines/vn/procedures/balanceNestTree_addChild.sql b/db/routines/vn/procedures/balanceNestTree_addChild.sql
new file mode 100644
index 000000000..5cd1ab470
--- /dev/null
+++ b/db/routines/vn/procedures/balanceNestTree_addChild.sql
@@ -0,0 +1,52 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`balanceNestTree_addChild`(
+ vSelf INT,
+ vName VARCHAR(45)
+)
+BEGIN
+/**
+ * Agrega un nuevo nodo hijo a un nodo existente dentro de la estructura
+ * de árbol de vn.balanceNestTree.
+ *
+ * @param vSelf Identificador del nodo
+ * @param vName Nombre del nuevo nodo hijo
+ */
+ DECLARE vTable VARCHAR(45) DEFAULT util.quoteIdentifier('balanceNestTree');
+ DECLARE vLeft INT;
+
+ CREATE OR REPLACE TEMPORARY TABLE tAux
+ SELECT 0 lft;
+
+ EXECUTE IMMEDIATE CONCAT(
+ 'UPDATE tAux
+ SET lft = (SELECT lft
+ FROM ', vTable,
+ ' WHERE id = ?)')
+ USING vSelf;
+
+ SELECT lft INTO vLeft FROM tAux;
+
+ EXECUTE IMMEDIATE CONCAT(
+ 'UPDATE ', vTable, '
+ SET rgt = rgt + 2
+ WHERE rgt > ?
+ ORDER BY rgt DESC')
+ USING vLeft;
+
+ EXECUTE IMMEDIATE CONCAT(
+ 'UPDATE ', vTable, '
+ SET lft = lft + 2
+ WHERE lft > ?
+ ORDER BY lft DESC')
+ USING vLeft;
+
+ EXECUTE IMMEDIATE CONCAT(
+ 'INSERT INTO ', vTable, ' (name, lft, rgt)
+ VALUES(?, ? + 1, ? + 2)')
+ USING vName,
+ vLeft,
+ vLeft;
+
+ DROP TEMPORARY TABLE tAux;
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/procedures/balanceNestTree_delete.sql b/db/routines/vn/procedures/balanceNestTree_delete.sql
new file mode 100644
index 000000000..1d6a9efff
--- /dev/null
+++ b/db/routines/vn/procedures/balanceNestTree_delete.sql
@@ -0,0 +1,53 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`balanceNestTree_delete`(
+ vSelf INT
+)
+BEGIN
+/**
+ * Elimina un nodo dentro de la estructura de árbol de vn.balanceNestTree.
+ *
+ * @param vSelf Identificador del nodo
+ */
+ DECLARE vTable VARCHAR(45) DEFAULT util.quoteIdentifier('balanceNestTree');
+ DECLARE vRight INT;
+ DECLARE vLeft INT;
+ DECLARE vWidth INT;
+
+ CREATE OR REPLACE TEMPORARY TABLE tAux
+ SELECT 0 rgt, 0 lft, 0 wdt;
+
+ EXECUTE IMMEDIATE CONCAT(
+ 'UPDATE tAux a
+ JOIN ', vTable, ' t
+ SET a.rgt = t.rgt,
+ a.lft = t.lft,
+ a.wdt = t.rgt - t.lft + 1
+ WHERE t.id = ?')
+ USING vSelf;
+
+ SELECT rgt, lft, wdt
+ INTO vRight, vLeft, vWidth
+ FROM tAux;
+
+ EXECUTE IMMEDIATE CONCAT(
+ 'DELETE FROM ', vTable,
+ ' WHERE lft BETWEEN ? AND ?')
+ USING vLeft, vRight;
+
+ EXECUTE IMMEDIATE CONCAT(
+ 'UPDATE ', vTable,
+ ' SET rgt = rgt - ?
+ WHERE rgt > ?
+ ORDER BY rgt')
+ USING vWidth,vRight;
+
+ EXECUTE IMMEDIATE CONCAT(
+ 'UPDATE ', vTable,
+ ' SET lft = lft - ?
+ WHERE lft > ?
+ ORDER BY lft')
+ USING vWidth, vRight;
+
+ DROP TEMPORARY TABLE tAux;
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/procedures/balanceNestTree_move.sql b/db/routines/vn/procedures/balanceNestTree_move.sql
new file mode 100644
index 000000000..ce29de1d9
--- /dev/null
+++ b/db/routines/vn/procedures/balanceNestTree_move.sql
@@ -0,0 +1,117 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`balanceNestTree_move`(
+ vSelf INT,
+ vFather INT
+)
+BEGIN
+/**
+ * Mueve un nodo dentro de la estructura de árbol de vn.balanceNestTree.
+ *
+ * @param vSelf Identificador del nodo
+ * @param vFather Identificador del nuevo padre del nodo
+ */
+ DECLARE vTable VARCHAR(45) DEFAULT util.quoteIdentifier('balanceNestTree');
+ DECLARE vRight INT;
+ DECLARE vLeft INT;
+ DECLARE vWidth INT;
+ DECLARE vFatherRight INT;
+ DECLARE vFatherLeft INT;
+ DECLARE vGap INT;
+
+ CREATE OR REPLACE TEMPORARY TABLE tAux
+ SELECT 0 rgt, 0 lft, 0 wdt, 0 frg, 0 flf;
+
+ -- Averiguamos el ancho de la rama
+ EXECUTE IMMEDIATE CONCAT(
+ 'UPDATE tAux a
+ JOIN ', vTable, ' t
+ SET a.wdt = t.rgt - t.lft + 1
+ WHERE t.id = ?')
+ USING vSelf;
+
+ -- Averiguamos la posicion del nuevo padre
+ EXECUTE IMMEDIATE CONCAT(
+ 'UPDATE tAux a
+ JOIN ', vTable, ' t
+ SET a.frg = t.rgt,
+ a.flf = t.lft
+ WHERE t.id = ?')
+ USING vFather;
+
+ SELECT wdt, frg, flf
+ INTO vWidth, vFatherRight, vFatherLeft
+ FROM tAux;
+
+ -- 1º Incrementamos los valores de todos los nodos a la derecha
+ -- del punto de inserción (vFatherRight) , para hacer sitio
+ EXECUTE IMMEDIATE CONCAT(
+ 'UPDATE ', vTable,
+ 'SET rgt = rgt + ?
+ WHERE rgt >= ?
+ ORDER BY rgt DESC')
+ USING vWidth,
+ vFatherRight;
+
+ EXECUTE IMMEDIATE CONCAT(
+ 'UPDATE ', vTable,
+ 'SET lft = lft + ?
+ WHERE lft >= ?
+ ORDER BY lft DESC')
+ USING vWidth,
+ vFatherRight;
+
+ -- Es preciso recalcular los valores del nodo en el
+ -- caso de que estuviera a la derecha del nuevo padre
+ EXECUTE IMMEDIATE CONCAT(
+ 'UPDATE tAux a
+ JOIN ', vTable, ' t
+ SET a.rgt = t.rgt,
+ a.lft = t.lft
+ WHERE t.id = ?')
+ USING vSelf;
+
+ SELECT lft, rgt, frg - lft
+ INTO vLeft, vRight, vGap
+ FROM tAux;
+
+ -- 2º Incrementamos el valor de todos los nodos a
+ -- trasladar hasta alcanzar su nueva posicion
+ EXECUTE IMMEDIATE CONCAT(
+ 'UPDATE ', vTable,
+ 'SET lft = lft + ?
+ WHERE lft BETWEEN ? AND ?
+ ORDER BY lft DESC')
+ USING vGap,
+ vLeft,
+ vRight;
+
+ EXECUTE IMMEDIATE CONCAT(
+ 'UPDATE ', vTable,
+ 'SET rgt = rgt + ?
+ WHERE rgt BETWEEN ? AND ?
+ ORDER BY rgt DESC')
+ USING vGap,
+ vLeft,
+ vRight;
+
+ -- 3º Restaremos a todos los nodos resultantes, a la derecha
+ -- de la posicion arrancada el ancho de la rama escindida
+ EXECUTE IMMEDIATE CONCAT(
+ 'UPDATE ', vTable,
+ 'SET lft = lft - ?
+ WHERE lft > ?
+ ORDER BY lft')
+ USING vWidth,
+ vLeft;
+
+ EXECUTE IMMEDIATE CONCAT(
+ 'UPDATE ', vTable,
+ 'SET rgt = rgt - ?
+ WHERE rgt > ?
+ ORDER BY rgt')
+ USING vWidth,
+ vRight;
+
+ DROP TEMPORARY TABLE tAux;
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/procedures/bankPolicy_notifyExpired.sql b/db/routines/vn/procedures/bankPolicy_notifyExpired.sql
index 52b747659..61216938d 100644
--- a/db/routines/vn/procedures/bankPolicy_notifyExpired.sql
+++ b/db/routines/vn/procedures/bankPolicy_notifyExpired.sql
@@ -10,13 +10,11 @@ BEGIN
INSERT INTO mail (receiver,replyTo,subject,body)
SELECT 'administracion@verdnatura.es' receiver,
'noreply@verdnatura.es' replyTo,
- CONCAT('El seguro de la poliza ',b.id,' ',b.bank,' ha finalizado.') subject,
- CONCAT('El seguro de la poliza ',b.id,' ',b.bank,' ha finalizado.') body
- FROM vn.bankPolicy bp
- LEFT JOIN vn.supplier s
- ON s.id = bp.supplierFk
- LEFT JOIN vn.bank b
- ON b.id = bp.accountingFk
+ CONCAT('El seguro de la poliza ',a.id,' ',a.bank,' ha finalizado.') subject,
+ CONCAT('El seguro de la poliza ',a.id,' ',a.bank,' ha finalizado.') body
+ FROM bankPolicy bp
+ LEFT JOIN supplier s ON s.id = bp.supplierFk
+ LEFT JOIN accounting a ON a.id = bp.accountingFk
WHERE bp.insuranceExpired = util.VN_CURDATE();
END$$
DELIMITER ;
diff --git a/db/routines/vn/procedures/buyUltimateFromInterval.sql b/db/routines/vn/procedures/buyUltimateFromInterval.sql
index 92434a47b..e264b500d 100644
--- a/db/routines/vn/procedures/buyUltimateFromInterval.sql
+++ b/db/routines/vn/procedures/buyUltimateFromInterval.sql
@@ -39,11 +39,11 @@ BEGIN
WHERE t.landed BETWEEN vStarted AND vEnded
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
AND b.price2 > 0
- AND b.quantity > 0
ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC
LIMIT 10000000000000000000) sub
GROUP BY itemFk, warehouseFk;
+
INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
SELECT
b.itemFk,
diff --git a/db/routines/vn/procedures/catalog_calcFromItem.sql b/db/routines/vn/procedures/catalog_calcFromItem.sql
index aeeaccb08..497fd107c 100644
--- a/db/routines/vn/procedures/catalog_calcFromItem.sql
+++ b/db/routines/vn/procedures/catalog_calcFromItem.sql
@@ -20,7 +20,7 @@ BEGIN
ENGINE = MEMORY
SELECT vItemFk itemFk;
- CALL catalog_calculate(vLanded, vAddressFk, vAgencyModeFk);
+ CALL catalog_calculate(vLanded, vAddressFk, vAgencyModeFk, TRUE);
DROP TEMPORARY TABLE tmp.item;
END$$
DELIMITER ;
diff --git a/db/routines/vn/procedures/catalog_calculate.sql b/db/routines/vn/procedures/catalog_calculate.sql
index 698328770..bb52020df 100644
--- a/db/routines/vn/procedures/catalog_calculate.sql
+++ b/db/routines/vn/procedures/catalog_calculate.sql
@@ -1,5 +1,9 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`catalog_calculate`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT)
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`catalog_calculate`(
+ vLanded DATE,
+ vAddressFk INT,
+ vAgencyModeFk INT,
+ vShowExpiredZones BOOLEAN)
BEGIN
/**
* Calcula los articulos disponibles y sus precios
@@ -25,7 +29,7 @@ BEGIN
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
- CALL vn.zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, FALSE);
+ CALL vn.zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, vShowExpiredZones);
DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
CREATE TEMPORARY TABLE tmp.ticketLot(
diff --git a/db/routines/vn/procedures/catalog_componentCalculate.sql b/db/routines/vn/procedures/catalog_componentCalculate.sql
index 64bb74430..4b860103d 100644
--- a/db/routines/vn/procedures/catalog_componentCalculate.sql
+++ b/db/routines/vn/procedures/catalog_componentCalculate.sql
@@ -10,7 +10,7 @@ BEGIN
* Calcula los componentes de los articulos de tmp.ticketLot
*
* @param vZoneFk para calcular el transporte
- * @param vAddressFk Consignatario
+ * @param vAddressFk Consignatario
* @param vShipped dia de salida del pedido
* @param vWarehouseFk warehouse de salida del pedido
* @table tmp.ticketLot (warehouseFk, available, itemFk, buyFk, zoneFk)
@@ -24,7 +24,20 @@ BEGIN
SELECT clientFk INTO vClientFK
FROM address
WHERE id = vAddressFk;
-
+
+ CREATE OR REPLACE TEMPORARY TABLE tSpecialPrice
+ (INDEX (itemFk))
+ ENGINE = MEMORY
+ SELECT * FROM (
+ SELECT *
+ FROM specialPrice
+ WHERE (clientFk = vClientFk OR clientFk IS NULL)
+ AND started <= vShipped
+ AND (ended >= vShipped OR ended IS NULL)
+ ORDER BY (clientFk = vClientFk) DESC, id DESC
+ LIMIT 10000000000000000000) t
+ GROUP BY itemFk;
+
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketComponentCalculate
(PRIMARY KEY (itemFk, warehouseFk))
ENGINE = MEMORY
@@ -35,8 +48,8 @@ BEGIN
IF(i.hasMinPrice, GREATEST(i.minPrice,IFNULL(pf.rate3, b.price3)),IFNULL(pf.rate3, b.price3)) rate3,
IFNULL(pf.packing, GREATEST(b.grouping, b.packing)) packing,
IFNULL(pf.`grouping`, b.`grouping`) `grouping`,
- ABS(IFNULL(pf.box, b.groupingMode)) groupingMode,
- tl.buyFk,
+ b.groupingMode groupingMode,
+ tl.buyFk,
i.typeFk,
IF(i.hasKgPrice, b.weight / b.packing, NULL) weightGrouping
FROM tmp.ticketLot tl
@@ -44,8 +57,7 @@ BEGIN
JOIN item i ON i.id = tl.itemFk
JOIN itemType it ON it.id = i.typeFk
JOIN itemCategory ic ON ic.id = it.categoryFk
- LEFT JOIN specialPrice sp ON sp.itemFk = i.id
- AND sp.clientFk = vClientFk
+ LEFT JOIN tSpecialPrice sp ON sp.itemFk = i.id
LEFT JOIN (
SELECT * FROM (
SELECT pf.itemFk,
@@ -63,7 +75,7 @@ BEGIN
LIMIT 10000000000000000000
) tpf
GROUP BY tpf.itemFk, tpf.warehouseFk
- ) pf ON pf.itemFk = tl.itemFk
+ ) pf ON pf.itemFk = tl.itemFk
AND pf.warehouseFk = tl.warehouseFk
WHERE b.buyingValue + b.freightValue + b.packageValue + b.comissionValue > 0.01
AND ic.merchandise
@@ -95,10 +107,10 @@ BEGIN
FROM tmp.ticketComponent tc
JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tc.itemFk AND tcc.warehouseFk = tc.warehouseFk
GROUP BY tc.itemFk, warehouseFk;
-
+
-- RECOBRO
INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost)
- SELECT tcb.warehouseFk, tcb.itemFk, c2.id,
+ SELECT tcb.warehouseFk, tcb.itemFk, c2.id,
ROUND(tcb.base *
LEAST(
MAX(GREATEST(IFNULL(cr.priceIncreasing,0),
@@ -129,29 +141,29 @@ BEGIN
ROUND(base * wm.pricesModifierRate, 3) manaAuto
FROM tmp.ticketComponentBase tcb
JOIN `client` c on c.id = vClientFk
- JOIN workerMana wm ON c.salesPersonFk = wm.workerFk
+ JOIN workerMana wm ON c.salesPersonFk = wm.workerFk
JOIN vn.component c2 ON c2.code = 'autoMana'
WHERE wm.isPricesModifierActivated
HAVING manaAuto <> 0;
-
+
-- Precios especiales
INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost)
SELECT tcb.warehouseFk,
tcb.itemFk,
c2.id,
GREATEST(
- IFNULL(ROUND(tcb.base * c2.tax, 4), 0),
+ IFNULL(ROUND(tcb.base * c2.tax, 4), 0),
IF(i.hasMinPrice, i.minPrice,0) - tcc.rate3
) cost
FROM tmp.ticketComponentBase tcb
JOIN vn.component c2 ON c2.code = 'lastUnitsDiscount'
- JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tcb.itemFk AND tcc.warehouseFk = tcb.warehouseFk
- LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk
+ JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tcb.itemFk AND tcc.warehouseFk = tcb.warehouseFk
+ LEFT JOIN tSpecialPrice sp ON sp.itemFk = tcc.itemFk
JOIN vn.item i ON i.id = tcb.itemFk
WHERE sp.value IS NULL
AND i.supplyResponseFk IS NULL;
- -- Individual
+ -- Individual
INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost)
SELECT tcb.warehouseFk,
tcb.itemFk,
@@ -162,14 +174,14 @@ BEGIN
JOIN vn.client c ON c.id = vClientFk
JOIN vn.businessType bt ON bt.code = c.businessTypeFk
WHERE bt.code = 'individual';
-
+
-- Venta por paquetes
INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost)
- SELECT tcc.warehouseFk, tcc.itemFk, c2.id, tcc.rate2 - tcc.rate3
+ SELECT tcc.warehouseFk, tcc.itemFk, c2.id, tcc.rate2 - tcc.rate3
FROM tmp.ticketComponentCalculate tcc
JOIN vn.component c2 ON c2.code = 'salePerPackage'
JOIN buy b ON b.id = tcc.buyFk
- LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk
+ LEFT JOIN tSpecialPrice sp ON sp.itemFk = tcc.itemFk
WHERE sp.value IS NULL;
CREATE OR REPLACE TEMPORARY TABLE tmp.`zone` (INDEX (id))
@@ -177,7 +189,7 @@ BEGIN
SELECT vZoneFk id;
CALL zone_getOptionsForShipment(vShipped, TRUE);
-
+
-- Reparto
INSERT INTO tmp.ticketComponent
SELECT tcc.warehouseFK,
@@ -191,7 +203,7 @@ BEGIN
JOIN agencyMode am ON am.id = z.agencyModeFk
JOIN vn.volumeConfig vc
JOIN vn.component c2 ON c2.code = 'delivery'
- LEFT JOIN itemCost ic ON ic.warehouseFk = tcc.warehouseFk
+ LEFT JOIN itemCost ic ON ic.warehouseFk = tcc.warehouseFk
AND ic.itemFk = tcc.itemFk
HAVING cost <> 0;
@@ -208,7 +220,7 @@ BEGIN
sp.value - SUM(tcc.cost) sumCost
FROM tmp.ticketComponentCopy tcc
JOIN component c ON c.id = tcc.componentFk
- JOIN specialPrice sp ON sp.clientFk = vClientFK AND sp.itemFk = tcc.itemFk
+ JOIN tSpecialPrice sp ON sp.itemFk = tcc.itemFk
JOIN vn.component c2 ON c2.code = 'specialPrices'
WHERE c.classRate IS NULL
AND tcc.warehouseFk = vWarehouseFk
@@ -240,14 +252,15 @@ BEGIN
SELECT tcc.warehouseFk,
tcc.itemFk,
1 rate,
- IF(tcc.groupingMode = 1, tcc.`grouping`, 1) `grouping`,
+ IF(tcc.groupingMode = 'grouping', 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
+ 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)
+ WHERE IFNULL(tcs.classRate, 1) = 1
+ AND NOT tcc.groupingMode = 'packing'
+ AND (tcc.packing > tcc.`grouping` OR tcc.groupingMode IS NULL)
GROUP BY tcs.warehouseFk, tcs.itemFk;
INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg)
@@ -283,12 +296,13 @@ BEGIN
SELECT * FROM tmp.ticketComponentRate ORDER BY price LIMIT 10000000000000000000
) t
GROUP BY itemFk, warehouseFk, `grouping`;
-
+
DROP TEMPORARY TABLE
tmp.ticketComponentCalculate,
tmp.ticketComponentSum,
tmp.ticketComponentBase,
tmp.ticketComponentRate,
- tmp.ticketComponentCopy;
+ tmp.ticketComponentCopy,
+ tSpecialPrice;
END$$
DELIMITER ;
diff --git a/db/routines/vn/procedures/clean.sql b/db/routines/vn/procedures/clean.sql
index 06f36afce..ed1569935 100644
--- a/db/routines/vn/procedures/clean.sql
+++ b/db/routines/vn/procedures/clean.sql
@@ -1,48 +1,43 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`clean`()
BEGIN
- DECLARE vDateShort DATETIME;
- DECLARE vOneYearAgo DATE;
- DECLARE vFourYearsAgo DATE;
- DECLARE vFiveYearsAgo DATE;
- DECLARE v18Month DATE;
- DECLARE v26Month DATE;
- DECLARE v3Month DATE;
+/**
+ * Purges outdated data to optimize performance.
+ * Exercise caution when executing.
+ */
+ DECLARE v2Months DATE DEFAULT util.VN_CURDATE() - INTERVAL 2 MONTH;
+ DECLARE v3Months DATE DEFAULT util.VN_CURDATE() - INTERVAL 3 MONTH;
+ DECLARE v18Months DATE DEFAULT util.VN_CURDATE() - INTERVAL 18 MONTH;
+ DECLARE v26Months DATE DEFAULT util.VN_CURDATE() - INTERVAL 26 MONTH;
+ DECLARE v1Years DATE DEFAULT util.VN_CURDATE() - INTERVAL 1 YEAR;
+ DECLARE v2Years DATE DEFAULT util.VN_CURDATE() - INTERVAL 2 YEAR;
+ DECLARE v4Years DATE DEFAULT util.VN_CURDATE() - INTERVAL 4 YEAR;
+ DECLARE v5Years DATE DEFAULT util.VN_CURDATE() - INTERVAL 5 YEAR;
DECLARE vTrashId VARCHAR(15);
- DECLARE v2Years DATE;
- DECLARE v5Years DATE;
-
- SET vDateShort = util.VN_CURDATE() - INTERVAL 2 MONTH;
- SET vOneYearAgo = util.VN_CURDATE() - INTERVAL 1 YEAR;
- SET vFourYearsAgo = util.VN_CURDATE() - INTERVAL 4 YEAR;
- SET vFiveYearsAgo = util.VN_CURDATE() - INTERVAL 5 YEAR;
- SET v18Month = util.VN_CURDATE() - INTERVAL 18 MONTH;
- SET v26Month = util.VN_CURDATE() - INTERVAL 26 MONTH;
- SET v3Month = util.VN_CURDATE() - INTERVAL 3 MONTH;
- SET v2Years = util.VN_CURDATE() - INTERVAL 2 YEAR;
- SET v5Years = util.VN_CURDATE() - INTERVAL 5 YEAR;
+ DECLARE vCompanyBlk INT;
DELETE FROM workerActivity WHERE created < v2Years;
- DELETE FROM ticketParking WHERE created < vDateShort;
- DELETE FROM routesMonitor WHERE dated < vDateShort;
- DELETE FROM workerTimeControlLog WHERE created < vDateShort;
- DELETE FROM `message` WHERE sendDate < vDateShort;
- DELETE FROM messageInbox WHERE sendDate < vDateShort;
- DELETE FROM messageInbox WHERE sendDate < vDateShort;
- DELETE FROM workerTimeControl WHERE timed < vFourYearsAgo;
+ DELETE FROM ticketParking WHERE created < v2Months;
+ DELETE FROM routesMonitor WHERE dated < v2Months;
+ DELETE FROM workerTimeControlLog WHERE created < v2Months;
+ DELETE FROM `message` WHERE sendDate < v2Months;
+ DELETE FROM messageInbox WHERE sendDate < v2Months;
+ DELETE FROM messageInbox WHERE sendDate < v2Months;
+ DELETE FROM workerTimeControl WHERE timed < v4Years;
DELETE FROM itemShelving WHERE created < util.VN_CURDATE() AND visible = 0;
- DELETE FROM ticketDown WHERE created < TIMESTAMPADD(DAY,-1,util.VN_CURDATE());
- DELETE FROM entryLog WHERE creationDate < vDateShort;
- DELETE IGNORE FROM expedition WHERE created < v26Month;
- DELETE FROM sms WHERE created < v18Month;
- DELETE FROM saleTracking WHERE created < vOneYearAgo;
- DELETE FROM ticketTracking WHERE created < v18Month;
- DELETE tobs FROM ticketObservation tobs
+ DELETE FROM ticketDown WHERE created < util.yesterday();
+ DELETE FROM entryLog WHERE creationDate < v2Months;
+ DELETE IGNORE FROM expedition WHERE created < v26Months;
+ DELETE FROM sms WHERE created < v18Months;
+ DELETE FROM saleTracking WHERE created < v1Years;
+ DELETE FROM productionError WHERE dated < v1Years;
+ DELETE FROM ticketTracking WHERE created < v18Months;
+ DELETE tobs FROM ticketObservation tobs
JOIN ticket t ON tobs.ticketFk = t.id
WHERE t.shipped < v5Years;
- DELETE sc.* FROM saleCloned sc JOIN sale s ON s.id = sc.saleClonedFk JOIN ticket t ON t.id = s.ticketFk WHERE t.shipped < vOneYearAgo;
- DELETE FROM sharingCart where ended < vDateShort;
- DELETE FROM sharingClient where ended < vDateShort;
+ DELETE sc.* FROM saleCloned sc JOIN sale s ON s.id = sc.saleClonedFk JOIN ticket t ON t.id = s.ticketFk WHERE t.shipped < v1Years;
+ DELETE FROM sharingCart where ended < v2Months;
+ DELETE FROM sharingClient where ended < v2Months;
DELETE tw.* FROM ticketWeekly tw
LEFT JOIN sale s ON s.ticketFk = tw.ticketFk
LEFT JOIN ticketRequest tr ON tr.ticketFk = tw.ticketFk
@@ -50,144 +45,182 @@ BEGIN
WHERE s.id IS NULL
AND tr.id IS NULL
AND ts.id IS NULL;
- DELETE FROM claim WHERE ticketCreated < vFourYearsAgo;
- DELETE FROM message WHERE sendDate < vDateShort;
- -- Robert ubicacion anterior de trevelLog comentario para debug
- DELETE FROM zoneEvent WHERE `type` = 'day' AND dated < v3Month;
+ DELETE FROM claim WHERE ticketCreated < v4Years;
+ -- Robert ubicacion anterior de travelLog comentario para debug
+ DELETE FROM zoneEvent WHERE `type` = 'day' AND dated < v3Months;
DELETE bm
FROM buyMark bm
JOIN buy b ON b.id = bm.id
JOIN entry e ON e.id = b.entryFk
JOIN travel t ON t.id = e.travelFk
- WHERE t.landed <= vDateShort;
- DELETE b FROM vn.buy b
- JOIN vn.entryConfig e ON e.defaultEntry = b.entryFk
- WHERE b.created < vDateShort;
- DELETE FROM vn.itemShelvingLog WHERE created < vDateShort;
- DELETE FROM vn.stockBuyed WHERE creationDate < vDateShort;
- DELETE FROM vn.itemCleanLog WHERE created < util.VN_NOW() - INTERVAL 1 YEAR;
- DELETE FROM printQueue WHERE statusCode = 'printed' AND created < vDateShort;
- DELETE FROM ticketLog WHERE creationDate <= vFiveYearsAgo;
+ WHERE t.landed <= v2Months;
+ DELETE b FROM buy b
+ JOIN entryConfig e ON e.defaultEntry = b.entryFk
+ WHERE b.created < v2Months;
+ DELETE FROM itemShelvingLog WHERE created < v2Months;
+ DELETE FROM stockBuyed WHERE creationDate < v2Months;
+ DELETE FROM itemCleanLog WHERE created < util.VN_NOW() - INTERVAL 1 YEAR;
+ DELETE FROM printQueue WHERE statusCode = 'printed' AND created < v2Months;
+ DELETE FROM ticketLog WHERE creationDate <= v5Years;
-- Equipos duplicados
DELETE w.*
FROM workerTeam w
- JOIN (SELECT id, team, workerFk, COUNT(*) - 1 as duplicated
+ JOIN (
+ SELECT id, team, workerFk, COUNT(*) - 1 duplicated
FROM workerTeam
GROUP BY team,workerFk
HAVING duplicated
- ) d ON d.team = w.team AND d.workerFk = w.workerFk AND d.id != w.id;
+ ) d ON d.team = w.team
+ AND d.workerFk = w.workerFk
+ AND d.id <> w.id;
DELETE sc
FROM saleComponent sc
JOIN sale s ON s.id= sc.saleFk
JOIN ticket t ON t.id= s.ticketFk
- WHERE t.shipped < v18Month;
+ WHERE t.shipped < v18Months;
DELETE c
- FROM vn.claim c
- JOIN vn.claimState cs ON cs.id = c.claimStateFk
- WHERE cs.description = "Anulado" AND
- c.created < vDateShort;
- DELETE
- FROM vn.expeditionTruck
- WHERE eta < v3Month;
+ FROM claim c
+ JOIN claimState cs ON cs.id = c.claimStateFk
+ WHERE cs.description = 'Anulado'
+ AND c.created < v2Months;
- DELETE FROM XDiario WHERE FECHA < v3Month OR FECHA IS NULL;
- -- borrar travels sin entradas
- DROP TEMPORARY TABLE IF EXISTS tmp.thermographToDelete;
- CREATE TEMPORARY TABLE tmp.thermographToDelete
+ DELETE FROM expeditionTruck WHERE eta < v3Months;
+ DELETE FROM XDiario WHERE FECHA < v3Months OR FECHA IS NULL;
+
+ -- Borrar travels sin entradas
+ CREATE OR REPLACE TEMPORARY TABLE tThermographToDelete
SELECT th.id,th.dmsFk
- FROM vn.travel t
- LEFT JOIN vn.entry e ON e.travelFk = t.id
- JOIN vn.travelThermograph th ON th.travelFk = t.id
- WHERE t.shipped < TIMESTAMPADD(MONTH, -3, util.VN_CURDATE()) AND e.travelFk IS NULL;
+ FROM travel t
+ LEFT JOIN entry e ON e.travelFk = t.id
+ JOIN travelThermograph th ON th.travelFk = t.id
+ WHERE t.shipped < v3Months
+ AND e.travelFk IS NULL;
SELECT dt.id INTO vTrashId
- FROM vn.dmsType dt
+ FROM dmsType dt
WHERE dt.code = 'trash';
- UPDATE tmp.thermographToDelete th
- JOIN vn.dms d ON d.id = th.dmsFk
+ UPDATE tThermographToDelete th
+ JOIN dms d ON d.id = th.dmsFk
SET d.dmsTypeFk = vTrashId;
DELETE th
- FROM tmp.thermographToDelete tmp
- JOIN vn.travelThermograph th ON th.id = tmp.id;
+ FROM tThermographToDelete tmp
+ JOIN travelThermograph th ON th.id = tmp.id;
DELETE t
- FROM vn.travel t
- LEFT JOIN vn.entry e ON e.travelFk = t.id
- WHERE t.shipped < TIMESTAMPADD(MONTH, -3, util.VN_CURDATE()) AND e.travelFk IS NULL;
-
+ FROM travel t
+ LEFT JOIN entry e ON e.travelFk = t.id
+ WHERE t.shipped < v3Months AND e.travelFk IS NULL;
+
UPDATE dms d
- JOIN dmsType dt ON dt.id = d.dmsTypeFk
- SET d.dmsTypeFk = vTrashId
- WHERE created < TIMESTAMPADD(MONTH, -dt.monthToDelete, util.VN_CURDATE());
-
+ JOIN dmsType dt ON dt.id = d.dmsTypeFk
+ SET d.dmsTypeFk = vTrashId
+ WHERE created < util.VN_CURDATE() - INTERVAL dt.monthToDelete MONTH;
+
-- borrar entradas sin compras
- DROP TEMPORARY TABLE IF EXISTS tmp.entryToDelete;
- CREATE TEMPORARY TABLE tmp.entryToDelete
+ CREATE OR REPLACE TEMPORARY TABLE tEntryToDelete
SELECT e.*
- FROM vn.entry e
- LEFT JOIN vn.buy b ON b.entryFk = e.id
- JOIN vn.entryConfig ec ON e.id != ec.defaultEntry
- WHERE e.dated < TIMESTAMPADD(MONTH, -3, util.VN_CURDATE()) AND b.entryFK IS NULL;
+ FROM entry e
+ LEFT JOIN buy b ON b.entryFk = e.id
+ JOIN entryConfig ec ON e.id <> ec.defaultEntry
+ WHERE e.dated < v3Months
+ AND b.entryFK IS NULL;
DELETE e
- FROM vn.entry e
- JOIN tmp.entryToDelete tmp ON tmp.id = e.id;
+ FROM entry e
+ JOIN tEntryToDelete tmp ON tmp.id = e.id;
-- borrar de route registros menores a 4 años
- DROP TEMPORARY TABLE IF EXISTS tmp.routeToDelete;
- CREATE TEMPORARY TABLE tmp.routeToDelete
+ CREATE OR REPLACE TEMPORARY TABLE tRouteToDelete
SELECT *
- FROM vn.route r
- WHERE created < TIMESTAMPADD(YEAR,-4,util.VN_CURDATE());
+ FROM route r
+ WHERE created < v4Years;
- UPDATE tmp.routeToDelete tmp
- JOIN vn.dms d ON d.id = tmp.gestdocFk
+ UPDATE tRouteToDelete tmp
+ JOIN dms d ON d.id = tmp.gestdocFk
SET d.dmsTypeFk = vTrashId;
DELETE r
- FROM tmp.routeToDelete tmp
- JOIN vn.route r ON r.id = tmp.id;
+ FROM tRouteToDelete tmp
+ JOIN route r ON r.id = tmp.id;
-- borrar registros de dua y awb menores a 2 años
- DROP TEMPORARY TABLE IF EXISTS tmp.duaToDelete;
- CREATE TEMPORARY TABLE tmp.duaToDelete
+ CREATE OR REPLACE TEMPORARY TABLE tDuaToDelete
SELECT *
- FROM vn.dua
- WHERE operated < TIMESTAMPADD(YEAR,-2,CURDATE());
+ FROM dua
+ WHERE operated < v2Years;
- UPDATE tmp.duaToDelete tm
- JOIN vn.dms d ON d.id = tm.gestdocFk
+ UPDATE tDuaToDelete tm
+ JOIN dms d ON d.id = tm.gestdocFk
SET d.dmsTypeFk = vTrashId;
DELETE d
- FROM tmp.duaToDelete tmp
- JOIN vn.dua d ON d.id = tmp.id;
+ FROM tDuaToDelete tmp
+ JOIN dua d ON d.id = tmp.id;
DELETE a
- FROM vn.awb a
- LEFT JOIN vn.travel t ON t.awbFk = a.id
+ FROM awb a
+ LEFT JOIN travel t ON t.awbFk = a.id
WHERE a.created < v2Years
AND t.id IS NULL;
-- Borra los registros de collection y ticketcollection
- DELETE FROM vn.collection WHERE created < vDateShort;
+ DELETE FROM collection WHERE created < v2Months;
+ DELETE FROM travelLog WHERE creationDate < v3Months;
- DROP TEMPORARY TABLE IF EXISTS tmp.thermographToDelete;
- DROP TEMPORARY TABLE IF EXISTS tmp.entryToDelete;
- DROP TEMPORARY TABLE IF EXISTS tmp.duaToDelete;
-
- DELETE FROM travelLog WHERE creationDate < v3Month;
-
- CALL shelving_clean;
+ CALL shelving_clean();
DELETE FROM chat WHERE dated < v5Years;
+ DELETE tt FROM ticketTracking tt
+ JOIN ticket t ON tt.ticketFk = t.id
+ WHERE t.shipped <= v2Months;
- DELETE tt FROM ticketTracking tt JOIN vn.ticket t ON tt.ticketFk = t.id
- WHERE t.shipped <= vDateShort;
+ DELETE FROM mail WHERE creationDate < v2Months;
+ DELETE FROM split WHERE dated < v18Months;
+ DELETE FROM remittance WHERE dated < v18Months;
+ CREATE OR REPLACE TEMPORARY TABLE tTicketDelete
+ SELECT DISTINCT tl.originFk ticketFk
+ FROM ticketLog tl
+ JOIN (
+ SELECT MAX(tl.id)ids
+ FROM ticket t
+ JOIN ticketLog tl ON tl.originFk = t.id
+ LEFT JOIN ticketWeekly tw ON tw.ticketFk = t.id
+ WHERE t.shipped BETWEEN '2000-01-01' AND '2000-12-31'
+ AND t.isDeleted
+ AND tw.ticketFk IS NULL
+ GROUP BY t.id
+ ) sub ON sub.ids = tl.id
+ WHERE tl.creationDate <= v2Months;
+ DELETE t
+ FROM ticket t
+ JOIN tTicketDelete tmp ON tmp.ticketFk = t.id;
+
+ DELETE sl
+ FROM saleLabel sl
+ JOIN sale s ON s.id = sl.saleFk
+ JOIN ticket t ON t.id = s.ticketFk
+ WHERE t.shipped < v2Months;
+
+ -- Tickets Nulos PAK 11/10/2016
+ SELECT id INTO vCompanyBlk FROM company WHERE code = 'BLK';
+ UPDATE ticket
+ SET companyFk = vCompanyBlk
+ WHERE clientFk = (SELECT id FROM client WHERE name = 'AUTOCONSUMO')
+ AND companyFk <> vCompanyBlk;
+
+ DROP TEMPORARY TABLE tTicketDelete,
+ tThermographToDelete,
+ tEntryToDelete,
+ tDuaToDelete,
+ tRouteToDelete;
+
+ -- Other schemas
+ DELETE FROM hedera.`order` WHERE date_send < v18Months;
+ DELETE FROM pbx.cdr WHERE call_date < v18Months;
END$$
DELIMITER ;
diff --git a/db/routines/vn/procedures/client_getDebt.sql b/db/routines/vn/procedures/client_getDebt.sql
index ad7b5b7d2..3eaace4e9 100644
--- a/db/routines/vn/procedures/client_getDebt.sql
+++ b/db/routines/vn/procedures/client_getDebt.sql
@@ -17,15 +17,15 @@ BEGIN
SET vEnded = util.dayEnd(IFNULL(vDate, util.VN_CURDATE()));
- CREATE OR REPLACE TEMPORARY TABLE tClientRisk
+ CREATE OR REPLACE TEMPORARY TABLE tClientRisk
ENGINE = MEMORY
- SELECT cr.clientFk, SUM(cr.amount) amount
+ SELECT cr.clientFk, SUM(cr.amount) amount
FROM clientRisk cr
JOIN tmp.clientGetDebt c ON c.clientFk = cr.clientFk
GROUP BY cr.clientFk;
INSERT INTO tClientRisk
- SELECT c.clientFk, SUM(r.amountPaid)
+ SELECT c.clientFk, SUM(r.amountPaid)
FROM receipt r
JOIN tmp.clientGetDebt c ON c.clientFk = r.clientFk
WHERE r.payed > vEnded
diff --git a/db/routines/vn/procedures/client_getMana.sql b/db/routines/vn/procedures/client_getMana.sql
index 99b00c6df..f5bb5747d 100644
--- a/db/routines/vn/procedures/client_getMana.sql
+++ b/db/routines/vn/procedures/client_getMana.sql
@@ -39,7 +39,8 @@ BEGIN
FROM receipt r
JOIN `client` c ON c.id = r.clientFk
JOIN tmp.client tc ON tc.id = c.id
- JOIN bank b ON r.bankFk = b.id AND b.code = 'mana'
+ JOIN accounting a ON r.bankFk = a.id
+ AND a.code = 'mana'
WHERE r.payed > vFromDated
AND r.payed <= util.VN_CURDATE()
UNION ALL
diff --git a/db/routines/vn/procedures/client_getRisk.sql b/db/routines/vn/procedures/client_getRisk.sql
new file mode 100644
index 000000000..7fbade303
--- /dev/null
+++ b/db/routines/vn/procedures/client_getRisk.sql
@@ -0,0 +1,35 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_getRisk`(
+ vDate DATE
+)
+BEGIN
+/**
+ * Retorna el riesgo de los clientes activos.
+ *
+ * @param vDate Fecha a calcular
+ */
+ CREATE OR REPLACE TEMPORARY TABLE tmp.clientGetDebt
+ (PRIMARY KEY (clientFk))
+ ENGINE = MEMORY
+ SELECT id clientFk
+ FROM client
+ WHERE isActive;
+
+ CALL client_getDebt(vDate);
+
+ SELECT c.socialName,
+ r.clientFk,
+ c.credit,
+ CAST(r.risk AS DECIMAL (10,2)) risk,
+ CAST(c.credit - r.risk AS DECIMAL (10,2)) difference,
+ co.country
+ FROM client c
+ JOIN tmp.risk r ON r.clientFk = c.id
+ JOIN country co ON co.id = c.countryFk
+ GROUP BY c.id;
+
+ DROP TEMPORARY TABLE
+ tmp.risk,
+ tmp.clientGetDebt;
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/procedures/collectionPlacement_get.sql b/db/routines/vn/procedures/collectionPlacement_get.sql
index 3641ba705..3fb3339e7 100644
--- a/db/routines/vn/procedures/collectionPlacement_get.sql
+++ b/db/routines/vn/procedures/collectionPlacement_get.sql
@@ -40,8 +40,8 @@ BEGIN
ENGINE = MEMORY
SELECT b.itemFk,
CASE b.groupingMode
- WHEN 0 THEN 1
- WHEN 2 THEN b.packing
+ WHEN NULL THEN 1
+ WHEN 'packing' THEN b.packing
ELSE b.`grouping`
END `grouping`
FROM buy b
diff --git a/db/routines/vn/procedures/collection_assign.sql b/db/routines/vn/procedures/collection_assign.sql
index 6d31fbc8f..bfc7b0f93 100644
--- a/db/routines/vn/procedures/collection_assign.sql
+++ b/db/routines/vn/procedures/collection_assign.sql
@@ -1,8 +1,8 @@
-DELIMITER $$
+DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_assign`(
vUserFk INT,
OUT vCollectionFk INT
-)
+)
proc:BEGIN
/**
* Comprueba si existen colecciones libres que se ajustan
@@ -13,15 +13,27 @@ proc:BEGIN
* @param vCollectionFk Id de colección
*/
DECLARE vHasTooMuchCollections BOOL;
+ DECLARE vItemPackingTypeFk VARCHAR(1);
+ DECLARE vWarehouseFk INT;
+ DECLARE vLockName VARCHAR(215);
DECLARE vLockTime INT DEFAULT 15;
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ BEGIN
+ IF vLockName IS NOT NULL THEN
+ DO RELEASE_LOCK(vLockName);
+ END IF;
+
+ RESIGNAL;
+ END;
+
-- Si hay colecciones sin terminar, sale del proceso
CALL collection_get(vUserFk);
SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0
INTO vHasTooMuchCollections
FROM tCollection
- JOIN productionConfig pc ;
+ JOIN productionConfig pc;
DROP TEMPORARY TABLE tCollection;
@@ -30,7 +42,18 @@ proc:BEGIN
LEAVE proc;
END IF;
- IF NOT GET_LOCK('collection_assign',vLockTime) THEN
+ SELECT warehouseFk, itemPackingTypeFk
+ INTO vWarehouseFk, vItemPackingTypeFk
+ FROM operator
+ WHERE workerFk = vUserFk;
+
+ SET vLockName = CONCAT_WS('/',
+ 'collection_assign',
+ vWarehouseFk,
+ vItemPackingTypeFk
+ );
+
+ IF NOT GET_LOCK(vLockName, vLockTime) THEN
LEAVE proc;
END IF;
@@ -83,6 +106,6 @@ proc:BEGIN
SET workerFk = vUserFk
WHERE id = vCollectionFk;
- DO RELEASE_LOCK('collection_assign');
-END$$
-DELIMITER ;
+ DO RELEASE_LOCK(vLockName);
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql
index d91c63c24..1292707af 100644
--- a/db/routines/vn/procedures/collection_new.sql
+++ b/db/routines/vn/procedures/collection_new.sql
@@ -28,6 +28,7 @@ proc:BEGIN
DECLARE vLockName VARCHAR(215);
DECLARE vLockTime INT DEFAULT 15;
DECLARE vFreeWagonFk INT;
+
DECLARE c1 CURSOR FOR
SELECT ticketFk, `lines`, m3
FROM tmp.productionBuffer
@@ -44,13 +45,21 @@ proc:BEGIN
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ BEGIN
+ IF vLockName IS NOT NULL THEN
+ DO RELEASE_LOCK(vLockName);
+ END IF;
+
+ RESIGNAL;
+ END;
+
SELECT pc.ticketTrolleyMax * o.numberOfWagons,
pc.hasUniqueCollectionTime,
w.code,
o.warehouseFk,
o.itemPackingTypeFk,
st.code,
- CONCAT('collection_new', o.warehouseFk, ':',o.itemPackingTypeFk),
o.numberOfWagons,
o.trainFk,
o.linesLimit,
@@ -61,7 +70,6 @@ proc:BEGIN
vWarehouseFk,
vItemPackingTypeFk,
vStateFk,
- vLockName,
vWagons,
vTrainFk,
vLinesLimit,
@@ -71,6 +79,12 @@ proc:BEGIN
JOIN state st ON st.`code` = 'ON_PREPARATION'
JOIN operator o ON o.workerFk = vUserFk;
+ SET vLockName = CONCAT_WS('/',
+ 'collection_new',
+ vWarehouseFk,
+ vItemPackingTypeFk
+ );
+
IF NOT GET_LOCK(vLockName, vLockTime) THEN
LEAVE proc;
END IF;
@@ -205,9 +219,11 @@ proc:BEGIN
UPDATE tmp.productionBuffer pb
JOIN (
SELECT SUM(litros) liters,
- @lines:= COUNT(*) + @lines `lines`,
+ @lines:= COUNT(*) + @lines,
+ COUNT(*) `lines`,
MAX(i.`size`) height,
- @volume := SUM(sv.volume) + @volume volume
+ @volume := SUM(sv.volume) + @volume,
+ SUM(sv.volume) volume
FROM saleVolume sv
JOIN sale s ON s.id = sv.saleFk
JOIN item i ON i.id = s.itemFk
@@ -250,13 +266,13 @@ proc:BEGIN
UPDATE tTrain
SET ticketFk = vFirstTicketFk
WHERE wagon = vFreeWagonFk;
-
+
-- Se anulan el resto de carros libres para que sólo uno lleve un pedido excesivo
DELETE tt.*
FROM tTrain tt
LEFT JOIN (
- SELECT DISTINCT wagon
- FROM tTrain
+ SELECT DISTINCT wagon
+ FROM tTrain
WHERE ticketFk IS NOT NULL
) nn ON nn.wagon = tt.wagon
WHERE nn.wagon IS NULL;
@@ -271,7 +287,7 @@ proc:BEGIN
FETCH c1 INTO vTicketFk, vTicketLines, vTicketVolume;
IF vDone THEN
LEAVE read_loop;
- END IF;
+ END IF;
END IF;
END LOOP;
CLOSE c1;
diff --git a/db/routines/vn/procedures/company_getSuppliersDebt.sql b/db/routines/vn/procedures/company_getSuppliersDebt.sql
index f6bfc229d..50c64669c 100644
--- a/db/routines/vn/procedures/company_getSuppliersDebt.sql
+++ b/db/routines/vn/procedures/company_getSuppliersDebt.sql
@@ -34,21 +34,21 @@ BEGIN
currencyFk
FROM (
SELECT p.supplierFk,
- p.companyFk,
- IF (p.currencyFk = vCurrencyEuroFk, p.amount, p.divisa) AS amount,
- p.dueDated < vStartingDate isBeforeStarting,
- p.currencyFk
- FROM payment p
+ p.companyFk,
+ IF (p.currencyFk = vCurrencyEuroFk, p.amount, p.divisa) AS amount,
+ p.dueDated < vStartingDate isBeforeStarting,
+ p.currencyFk
+ FROM payment p
WHERE p.received > vStartDate
AND p.companyFk = vSelf
UNION ALL
SELECT r.supplierFk,
- r.companyFk,
- - IF (r.currencyFk = vCurrencyEuroFk, rv.amount, rv.foreignValue) AS Total,
- rv.dueDated < vStartingDate isBeforeStarting,
- r.currencyFk
- FROM invoiceIn r
- INNER JOIN invoiceInDueDay rv ON r.id = rv.invoiceInFk
+ r.companyFk,
+ - IF (r.currencyFk = vCurrencyEuroFk, rv.amount, rv.foreignValue) AS Total,
+ rv.dueDated < vStartingDate isBeforeStarting,
+ r.currencyFk
+ FROM invoiceIn r
+ INNER JOIN invoiceInDueDay rv ON r.id = rv.invoiceInFk
WHERE r.issued > vStartDate
AND r.isBooked
AND r.companyFk = vSelf
@@ -57,7 +57,7 @@ BEGIN
DROP TEMPORARY TABLE IF EXISTS tPendingDuedates;
CREATE TEMPORARY TABLE tPendingDuedates (
id INT auto_increment,
- expirationId INT,
+ expirationId INT,
dated DATE,
supplierFk INT NOT NULL,
companyFk INT NOT NULL,
@@ -82,35 +82,35 @@ BEGIN
isPayment,
isReconciled
)SELECT p.id,
- p.dueDated,
- p.supplierFk,
- p.companyFk,
- IF (p.currencyFk = vCurrencyEuroFk, p.amount, p.divisa),
- p.currencyFk,
- TRUE isPayment,
- p.isConciliated
- FROM payment p
- WHERE p.dueDated >= vStartingDate
- AND p.companyFk = vSelf
- UNION ALL
- SELECT r.id,
- rv.dueDated,
- r.supplierFk,
- r.companyFk,
- -IF (r.currencyFk = vCurrencyEuroFk, rv.amount, rv.foreignValue),
- r.currencyFk,
- FALSE isPayment,
- TRUE
- FROM invoiceIn r
- LEFT JOIN tOpeningBalances si ON r.companyFk = si.companyFk
- AND r.supplierFk = si.supplierFk
- AND r.currencyFk = si.currencyFk
- JOIN invoiceInDueDay rv ON r.id = rv.invoiceInFk
- WHERE rv.dueDated >= vStartingDate
- AND (si.closingBalances IS NULL OR si.closingBalances <> 0)
- AND r.isBooked
- AND r.companyFk = vSelf
- ORDER BY supplierFk, companyFk, companyFk, dueDated, isPayment DESC, id;
+ p.dueDated,
+ p.supplierFk,
+ p.companyFk,
+ IF (p.currencyFk = vCurrencyEuroFk, p.amount, p.divisa),
+ p.currencyFk,
+ TRUE isPayment,
+ p.isConciliated
+ FROM payment p
+ WHERE p.dueDated >= vStartingDate
+ AND p.companyFk = vSelf
+ UNION ALL
+ SELECT r.id,
+ rv.dueDated,
+ r.supplierFk,
+ r.companyFk,
+ -IF (r.currencyFk = vCurrencyEuroFk, rv.amount, rv.foreignValue),
+ r.currencyFk,
+ FALSE isPayment,
+ TRUE
+ FROM invoiceIn r
+ LEFT JOIN tOpeningBalances si ON r.companyFk = si.companyFk
+ AND r.supplierFk = si.supplierFk
+ AND r.currencyFk = si.currencyFk
+ JOIN invoiceInDueDay rv ON r.id = rv.invoiceInFk
+ WHERE rv.dueDated >= vStartingDate
+ AND (si.closingBalances IS NULL OR si.closingBalances <> 0)
+ AND r.isBooked
+ AND r.companyFk = vSelf
+ ORDER BY supplierFk, companyFk, companyFk, dueDated, isPayment DESC, id;
-- Now, we calculate the outstanding amount for each receipt in descending order
SET @risk := 0.0;
SET @supplier := 0.0;
@@ -159,7 +159,7 @@ BEGIN
FROM tPendingDuedates
WHERE balance < vInvalidBalances
AND balance > - vInvalidBalances;
-
+
DELETE vp.*
FROM tPendingDuedates vp
JOIN tRowsToDelete rd ON (
@@ -169,27 +169,31 @@ BEGIN
AND vp.supplierFk = rd.supplierFk
AND vp.companyFk = rd.companyFk
AND vp.currencyFk = rd.currencyFk
- WHERE vp.isPayment = FALSE;
+ WHERE NOT vp.isPayment;
SELECT vp.expirationId,
vp.dated,
vp.supplierFk,
- vp.companyFk,
- vp.currencyFk,
- vp.amount,
- vp.pending,
- vp.balance,
- s.payMethodFk,
- vp.isPayment,
- vp.isReconciled,
- vp.endingBalance,
- cr.amount clientRiskAmount
+ vp.companyFk,
+ vp.currencyFk,
+ vp.amount,
+ vp.pending,
+ vp.balance,
+ s.payMethodFk,
+ vp.isPayment,
+ vp.isReconciled,
+ vp.endingBalance,
+ cr.amount clientRiskAmount,
+ co.CEE
FROM tPendingDuedates vp
- LEFT JOIN supplier s ON s.id = vp.supplierFk
+ LEFT JOIN supplier s ON s.id = vp.supplierFk
LEFT JOIN client c ON c.fi = s.nif
- LEFT JOIN clientRisk cr ON cr.clientFk = c.id
- AND cr.companyFk = vp.companyFk;
-
+ JOIN clientRisk cr ON cr.clientFk = c.id
+ AND cr.companyFk = vp.companyFk
+ LEFT JOIN supplierAccount sa ON sa.supplierFk = s.id
+ LEFT JOIN bankEntity be ON be.id = sa.bankEntityFk
+ LEFT JOIN country co ON co.id = be.countryFk;
+
DROP TEMPORARY TABLE tOpeningBalances;
DROP TEMPORARY TABLE tPendingDuedates;
DROP TEMPORARY TABLE tRowsToDelete;
diff --git a/db/routines/vn/procedures/confection_controlSource.sql b/db/routines/vn/procedures/confection_controlSource.sql
new file mode 100644
index 000000000..f011a52e9
--- /dev/null
+++ b/db/routines/vn/procedures/confection_controlSource.sql
@@ -0,0 +1,103 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`confection_controlSource`(
+ vDated DATE,
+ vScopeDays INT,
+ vMaxAlertLevel INT,
+ vWarehouseFk INT
+)
+BEGIN
+/**
+ * Obtiene la información para el control de confección,
+ * ya sean tickets y/o entradas.
+ *
+ * @param vDated Fecha a calcular
+ * @param vScopeDays Número de días desde hoy en adelante que entran en el cálculo.
+ * @param vMaxAlertLevel Id nivel de alerta
+ * @param vWarehouseFk Id de almacén
+ */
+ DECLARE vEndingDate DATETIME DEFAULT util.dayEnd(vDated) + INTERVAL vScopeDays DAY;
+
+ SELECT t.shipped,
+ t.id ticketFk,
+ s.id saleFk,
+ s.quantity,
+ s.concept,
+ ABS(s.reserved) isReserved,
+ i.category,
+ it.name itemType,
+ t.nickname,
+ wh.name warehouse,
+ t.warehouseFk warehouseFk,
+ a.provinceFk,
+ am.agencyFk,
+ ct.description,
+ stock.visible,
+ stock.available
+ FROM ticket t
+ JOIN agencyMode am ON am.id = t.agencyModeFk
+ JOIN warehouse wh ON wh.id = t.warehouseFk
+ JOIN sale s ON s.ticketFk = t.id
+ JOIN item i ON i.id = s.itemFk
+ JOIN itemType it ON it.id = i.typeFk
+ JOIN confectionType ct ON ct.id = it.making
+ JOIN `address` a on a.id = t.addressFk
+ LEFT JOIN ticketState tls on tls.ticketFk = t.id
+ LEFT JOIN
+ (
+ SELECT item_id,
+ SUM(visible) visible,
+ SUM(available) available
+ FROM (
+ SELECT a.item_id,
+ 0 visible,
+ a.available
+ FROM cache.cache_calc cc
+ LEFT JOIN cache.available a ON a.calc_id = cc.id
+ WHERE cc.cache_id IN ('visible', 'available')
+ AND cc.params = CONCAT(vWarehouseFk, "/", util.VN_CURDATE())
+ UNION ALL
+ SELECT v.item_id,
+ v.visible,
+ 0
+ FROM cache.cache_calc cc
+ LEFT JOIN cache.visible v ON v.calc_id = cc.id
+ WHERE cc.cacheName IN ('visible', 'available')
+ AND cc.params = vWarehouseFk
+ ) sub
+ GROUP BY item_id
+ ) stock ON stock.item_id = s.itemFk
+ WHERE it.making
+ AND tls.alertLevel < vMaxAlertLevel
+ AND wh.hasConfectionTeam
+ AND t.shipped BETWEEN vDated AND vEndingDate
+ AND s.quantity > 0
+ UNION ALL
+ SELECT tr.shipped,
+ e.id,
+ NULL,
+ b.quantity,
+ i.name,
+ NULL,
+ i.category,
+ NULL,
+ whi.name,
+ who.name,
+ NULL,
+ NULL,
+ NULL,
+ ct.description,
+ NULL,
+ NULL
+ FROM buy b
+ JOIN `entry` e ON e.id = b.entryFk
+ JOIN travel tr ON tr.id = e.travelFk
+ JOIN warehouse whi ON whi.id = tr.warehouseInFk
+ JOIN warehouse who ON who.id = tr.warehouseOutFk
+ JOIN item i ON i.id = b.itemFk
+ JOIN itemType it ON it.id = i.typeFk
+ JOIN confectionType ct ON ct.id = it.making
+ WHERE who.hasConfectionTeam
+ AND it.making
+ AND tr.shipped BETWEEN vDated AND vEndingDate;
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/procedures/creditRecovery.sql b/db/routines/vn/procedures/creditRecovery.sql
new file mode 100644
index 000000000..687d652dd
--- /dev/null
+++ b/db/routines/vn/procedures/creditRecovery.sql
@@ -0,0 +1,54 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`creditRecovery`()
+BEGIN
+/**
+ * Actualiza el crédito de los clientes
+ */
+
+ DECLARE EXIT HANDLER FOR SQLSTATE '45000'
+ BEGIN
+ ROLLBACK;
+ RESIGNAL;
+ END;
+
+ START TRANSACTION;
+
+ UPDATE `client` c
+ JOIN payMethod pm ON pm.id = c.payMethodFk
+ SET c.credit = 0
+ WHERE pm.`code` = 'card';
+
+ DROP TEMPORARY TABLE IF EXISTS tCreditClients;
+ CREATE TEMPORARY TABLE tCreditClients
+ SELECT clientFk, IF(credit > recovery, credit - recovery, 0) newCredit
+ FROM (
+ SELECT r.clientFk,
+ r.amount recovery,
+ (sub2.created + INTERVAL r.period DAY) deadLine,
+ sub2.amount credit
+ FROM recovery r
+ JOIN (
+ SELECT clientFk, amount, created
+ FROM (
+ SELECT clientFk, amount, created
+ FROM clientCredit
+ ORDER BY created DESC
+ LIMIT 10000000000000000000
+ ) sub
+ GROUP BY clientFk
+ ) sub2 ON sub2.clientFk = r.clientFk
+ WHERE r.finished IS NULL OR r.finished >= util.VN_CURDATE()
+ GROUP BY r.clientFk
+ HAVING deadLine <= util.VN_CURDATE()
+ ) sub3
+ WHERE credit > 0;
+
+ UPDATE client c
+ JOIN tCreditClients cc ON cc.clientFk = c.id
+ SET c.credit = newCredit;
+
+ DROP TEMPORARY TABLE tCreditClients;
+ COMMIT;
+
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/procedures/duaInvoiceInBooking.sql b/db/routines/vn/procedures/duaInvoiceInBooking.sql
index 26580907c..f95e836b1 100644
--- a/db/routines/vn/procedures/duaInvoiceInBooking.sql
+++ b/db/routines/vn/procedures/duaInvoiceInBooking.sql
@@ -33,6 +33,7 @@ BEGIN
ii.operated = IFNULL(ii.operated,d.operated),
ii.issued = IFNULL(ii.issued,d.issued),
ii.bookEntried = IFNULL(ii.bookEntried,d.bookEntried),
+ e.isBooked = TRUE,
e.isConfirmed = TRUE
WHERE d.id = vDuaFk;
diff --git a/db/routines/vn/procedures/entry_checkBooked.sql b/db/routines/vn/procedures/entry_checkBooked.sql
new file mode 100644
index 000000000..3ca8c9642
--- /dev/null
+++ b/db/routines/vn/procedures/entry_checkBooked.sql
@@ -0,0 +1,22 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_checkBooked`(
+ vSelf INT
+)
+BEGIN
+/**
+ * Comprueba si una entrada está contabilizada,
+ * y si lo está retorna un throw.
+ *
+ * @param vSelf Id de entrada
+ */
+ DECLARE vIsBooked BOOL;
+
+ SELECT isBooked INTO vIsBooked
+ FROM `entry`
+ WHERE id = vSelf;
+
+ IF vIsBooked AND NOT @isModeInventory THEN
+ CALL util.throw('Entry is already booked');
+ END IF;
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/procedures/entry_getTransfer.sql b/db/routines/vn/procedures/entry_getTransfer.sql
index 151bebd4d..b82f273ae 100644
--- a/db/routines/vn/procedures/entry_getTransfer.sql
+++ b/db/routines/vn/procedures/entry_getTransfer.sql
@@ -13,15 +13,15 @@ BEGIN
DECLARE vWarehouseIn INT;
DECLARE vWarehouseOut INT;
DECLARE vCalcVisible INT;
- DECLARE vInventoryDate DATE DEFAULT vn.getInventoryDate();
+ DECLARE vInventoryDate DATE DEFAULT getInventoryDate();
SELECT shipped, landed, warehouseInFk, warehouseOutFk
INTO vDateShipped, vDateLanded, vWarehouseIn, vWarehouseOut
- FROM vn.travel t
- JOIN vn.entry e ON e.travelFk = t.id
+ FROM travel t
+ JOIN entry e ON e.travelFk = t.id
WHERE e.id = vSelf;
- CALL vn.rate_getPrices(vDateShipped, vWarehouseIn);
+ CALL rate_getPrices(vDateShipped, vWarehouseIn);
-- Traslado en almacen origen
CREATE OR REPLACE TEMPORARY TABLE tBuy
@@ -84,7 +84,7 @@ BEGIN
WHERE a.available
ON DUPLICATE KEY UPDATE availableLanding = a.available;
ELSE
- CALL vn.item_getStock(vWarehouseOut, vDateShipped, NULL);
+ CALL item_getStock(vWarehouseOut, vDateShipped, NULL);
CREATE OR REPLACE TEMPORARY TABLE tItem
(UNIQUE INDEX i USING HASH (itemFk))
@@ -97,7 +97,7 @@ BEGIN
FROM tmp.itemList;
END IF;
- CALL vn.buyUltimateFromInterval(vWarehouseIn,vInventoryDate, vDateLanded);
+ CALL buyUltimateFromInterval(vWarehouseIn,vInventoryDate, vDateLanded);
CREATE OR REPLACE TEMPORARY TABLE tTransfer
ENGINE = MEMORY
@@ -145,26 +145,26 @@ BEGIN
b.id buyFkOrigin,
pa.returnCost,
b.weight
- FROM vn.item i
+ FROM item i
JOIN tItem ti ON ti.itemFk = i.id
- LEFT JOIN vn.producer p ON p.id = i.producerFk
- LEFT JOIN vn.itemType it ON it.id = i.typeFk
- JOIN vn.itemCategory ic ON ic.id = it.categoryFk
- LEFT JOIN vn.origin o ON o.id = i.originFk
+ LEFT JOIN producer p ON p.id = i.producerFk
+ LEFT JOIN itemType it ON it.id = i.typeFk
+ JOIN itemCategory ic ON ic.id = it.categoryFk
+ LEFT JOIN origin o ON o.id = i.originFk
LEFT JOIN tBuy lb ON lb.itemFk = i.id
- LEFT JOIN vn.buy b ON b.id = lb.buyFk
- LEFT JOIN vn.packaging pa ON pa.id = b.packagingFk
- LEFT JOIN vn.entry e2 ON e2.id = b.entryFk
- LEFT JOIN vn.supplier s ON s.id = e2.supplierFk
- LEFT JOIN vn.entry e ON e.id = vSelf
- LEFT JOIN vn.travel tr ON tr.id = e.travelFk
- LEFT JOIN vn.agencyMode am ON am.id = tr.agencyModeFk
- LEFT JOIN vn.buy b2 ON b2.itemFk = i.id
+ LEFT JOIN buy b ON b.id = lb.buyFk
+ LEFT JOIN packaging pa ON pa.id = b.packagingFk
+ LEFT JOIN entry e2 ON e2.id = b.entryFk
+ LEFT JOIN supplier s ON s.id = e2.supplierFk
+ LEFT JOIN entry e ON e.id = vSelf
+ LEFT JOIN travel tr ON tr.id = e.travelFk
+ LEFT JOIN agencyMode am ON am.id = tr.agencyModeFk
+ LEFT JOIN buy b2 ON b2.itemFk = i.id
AND b2.entryFk = vSelf
- LEFT JOIN vn.packaging pa2 ON pa2.id = b.packagingFk
+ LEFT JOIN packaging pa2 ON pa2.id = b.packagingFk
LEFT JOIN tmp.rate r ON TRUE
LEFT JOIN tmp.buyUltimateFromInterval bufi ON bufi.itemFk = i.id
- LEFT JOIN vn.buy b3 ON b3.id = bufi.buyFk
+ LEFT JOIN buy b3 ON b3.id = bufi.buyFk
WHERE ic.display
AND NOT e.isRaid
AND (ti.visible OR ti.available)
@@ -172,11 +172,6 @@ BEGIN
CREATE INDEX tIndex USING HASH ON tTransfer (itemFk);
- SET @carriage := 0;
- SET @comission := 0;
- SET @packaging := 0;
- SET @rate3 := 0;
- SET @cost := 0;
SELECT *,
quantity - MOD(quantity , `grouping`) subQuantity,
MOD(quantity, `grouping`) soll,
diff --git a/db/routines/vn/procedures/inventoryMake.sql b/db/routines/vn/procedures/inventoryMake.sql
index ed6a7fa43..b7ea377d2 100644
--- a/db/routines/vn/procedures/inventoryMake.sql
+++ b/db/routines/vn/procedures/inventoryMake.sql
@@ -114,9 +114,9 @@ BEGIN
quantity int(11) DEFAULT '0',
buyingValue decimal(10,4) DEFAULT '0.0000',
freightValue decimal(10,3) DEFAULT '0.000',
- packing int(11) DEFAULT '0',
+ packing int(11) DEFAULT '1',
`grouping` smallint(5) unsigned NOT NULL DEFAULT '1',
- groupingMode tinyint(4) NOT NULL DEFAULT 0 ,
+ groupingMode enum('grouping', 'packing') DEFAULT NULL,
comissionValue decimal(10,3) DEFAULT '0.000',
packageValue decimal(10,3) DEFAULT '0.000',
packageFk varchar(10) COLLATE utf8_unicode_ci DEFAULT '--',
@@ -232,8 +232,6 @@ BEGIN
CLOSE cWarehouses;
UPDATE config SET inventoried = vInventoryDate;
-
- SET @isModeInventory := FALSE;
CREATE OR REPLACE TEMPORARY TABLE tEntryToDelete
(INDEX(entryId)) ENGINE = MEMORY
@@ -262,6 +260,8 @@ BEGIN
FROM travel t
JOIN tEntryToDelete tmp ON tmp.travelId = t.id;
+ SET @isModeInventory := FALSE;
+
DROP TEMPORARY TABLE IF EXISTS tEntryToDelete;
COMMIT;
diff --git a/db/routines/vn/procedures/inventory_repair.sql b/db/routines/vn/procedures/inventory_repair.sql
index ea65ac37d..93527d84b 100644
--- a/db/routines/vn/procedures/inventory_repair.sql
+++ b/db/routines/vn/procedures/inventory_repair.sql
@@ -37,7 +37,7 @@ BEGIN
LEFT JOIN origin o ON o.id = i.originFk
) ON it.id = i.typeFk
LEFT JOIN edi.ekt ek ON b.ektFk = ek.id
- WHERE (b.packagingFk = "--" OR b.price2 = 0 OR b.packing = 0 OR b.buyingValue = 0) AND tr.landed > util.firstDayOfMonth(TIMESTAMPADD(MONTH,-1,util.VN_CURDATE())) AND s.name = 'INVENTARIO';
+ WHERE (b.packagingFk = "--" OR b.price2 = 0 OR b.buyingValue = 0) AND tr.landed > util.firstDayOfMonth(TIMESTAMPADD(MONTH,-1,util.VN_CURDATE())) AND s.name = 'INVENTARIO';
DROP TEMPORARY TABLE IF EXISTS tmp.lastEntryOk;
CREATE TEMPORARY TABLE tmp.lastEntryOk
@@ -94,11 +94,6 @@ BEGIN
JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk
SET b.price2 = eo.price2 WHERE b.price2 = 0 ;
- UPDATE buy b
- JOIN tmp.lastEntry lt ON lt.buyFk = b.id
- JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk
- SET b.packing = eo.packing WHERE b.packing = 0;
-
UPDATE buy b
JOIN tmp.lastEntry lt ON lt.buyFk = b.id
JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk
diff --git a/db/routines/vn/procedures/invoiceInTaxMakeByDua.sql b/db/routines/vn/procedures/invoiceInTaxMakeByDua.sql
index 2ff478d6b..3453516cc 100644
--- a/db/routines/vn/procedures/invoiceInTaxMakeByDua.sql
+++ b/db/routines/vn/procedures/invoiceInTaxMakeByDua.sql
@@ -1,8 +1,11 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInTaxMakeByDua`(vDuaFk INT)
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInTaxMakeByDua`(
+ vDuaFk INT
+)
BEGIN
/**
- * Borra los valores de duaTax y sus vctos. y los vuelve a crear en base a la tabla duaEntry
+ * Borra los valores de duaTax y sus vctos. y los vuelve a
+ * crear en base a la tabla duaEntry.
*
* @param vDuaFk Id del dua a recalcular
*/
@@ -26,7 +29,7 @@ BEGIN
LEAVE l;
END IF;
- CALL vn2008.recibidaIvaInsert(vInvoiceInFk);
+ CALL invoiceInTax_recalc(vInvoiceInFk);
CALL invoiceInDueDay_recalc(vInvoiceInFk);
END LOOP;
diff --git a/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql b/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql
index 60ec34696..43d54c28c 100644
--- a/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql
+++ b/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql
@@ -10,6 +10,8 @@ BEGIN
DECLARE vLines INT;
DECLARE vHasDistinctTransactions INT;
+ CALL invoiceIn_checkBooked(vInvoiceInFk);
+
SELECT taxRowLimit INTO vTaxRowLimit FROM invoiceInConfig;
SELECT COUNT(*) INTO vLines
diff --git a/db/routines/vn/procedures/invoiceInTax_getFromEntries.sql b/db/routines/vn/procedures/invoiceInTax_getFromEntries.sql
index 5a53b7543..631b8f31c 100644
--- a/db/routines/vn/procedures/invoiceInTax_getFromEntries.sql
+++ b/db/routines/vn/procedures/invoiceInTax_getFromEntries.sql
@@ -4,16 +4,9 @@ BEGIN
DECLARE vRate DOUBLE DEFAULT 1;
DECLARE vDated DATE;
DECLARE vExpenseFk VARCHAR(10);
- DECLARE vIsBooked BOOLEAN DEFAULT FALSE;
- SELECT isBooked INTO vIsBooked
- FROM invoiceIn ii
- WHERE id = vInvoiceInFk;
+ CALL invoiceIn_checkBooked(vInvoiceInFk);
- IF vIsBooked THEN
- CALL util.throw('A booked invoice cannot be modified');
- END IF;
-
SELECT MAX(rr.dated) INTO vDated
FROM referenceRate rr
JOIN invoiceIn ii ON ii.id = vInvoiceInFk
diff --git a/db/routines/vn/procedures/invoiceInTax_recalc.sql b/db/routines/vn/procedures/invoiceInTax_recalc.sql
new file mode 100644
index 000000000..4e20b01d3
--- /dev/null
+++ b/db/routines/vn/procedures/invoiceInTax_recalc.sql
@@ -0,0 +1,57 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInTax_recalc`(
+ vInvoiceInFk INT
+)
+BEGIN
+/**
+ * Recalcula y actualiza los impuestos de la factura
+ * usando la última tasa de cambio y detalles de compra.
+ *
+ * @param vInvoiceInFk Id de factura recibida
+ */
+ DECLARE vRate DOUBLE DEFAULT 1;
+ DECLARE vExpenseFk VARCHAR(10);
+
+ SELECT `value` INTO vRate
+ FROM referenceRate rr
+ JOIN invoiceIn ii ON ii.id = vInvoiceInFk
+ WHERE rr.dated <= ii.issued
+ AND rr.currencyFk = ii.currencyFk
+ ORDER BY dated DESC
+ LIMIT 1;
+
+ DELETE FROM invoiceInTax WHERE invoiceInFk = vInvoiceInFk;
+
+ SELECT id INTO vExpenseFk
+ FROM expense
+ WHERE code = 'extraCommGoodsAcquisition';
+
+ IF vExpenseFk IS NULL THEN
+ CALL util.throw('Expense extraCommGoodsAcquisition not exists');
+ END IF;
+
+ INSERT INTO invoiceInTax(
+ invoiceInFk,
+ taxableBase,
+ expenseFk,
+ foreignValue,
+ taxTypeSageFk,
+ transactionTypeSageFk
+ )
+ SELECT ii.id,
+ SUM(b.buyingValue * b.quantity) / vRate bi,
+ vExpenseFk,
+ IF(c.code = 'EUR', NULL, SUM(b.buyingValue * b.quantity)),
+ s.taxTypeSageFk,
+ s.transactionTypeSageFk
+ FROM invoiceIn ii
+ JOIN currency c ON c.id = ii.currencyFk
+ JOIN `entry` e ON e.invoiceInFk = ii.id
+ JOIN supplier s ON s.id = e.supplierFk
+ JOIN buy b ON b.entryFk = e.id
+ LEFT JOIN referenceRate rr ON rr.currencyFk = ii.currencyFk
+ AND rr.dated = ii.issued
+ WHERE ii.id = vInvoiceInFk
+ HAVING bi IS NOT NULL;
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/procedures/invoiceIn_add.sql b/db/routines/vn/procedures/invoiceIn_add.sql
deleted file mode 100644
index 0898d6810..000000000
--- a/db/routines/vn/procedures/invoiceIn_add.sql
+++ /dev/null
@@ -1,234 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `sage`.`invoiceIn_add`(vInvoiceInFk INT, vXDiarioFk INT)
-BEGIN
-/**
- * Traslada la info de contabilidad relacionada con las facturas recibidas
- *
- * @vInvoiceInFk Factura recibida
- * @vXDiarioFk Id tabla XDiario
- */
- DECLARE vInvoiceInOriginalFk INT;
- DECLARE vDone BOOL DEFAULT FALSE;
- DECLARE vBase DOUBLE;
- DECLARE vVat DOUBLE;
- DECLARE vRate DOUBLE;
- DECLARE vTransactionCode INT;
- DECLARE vCounter INT DEFAULT 0;
- DECLARE vTransactionCodeOld INT;
- DECLARE vTaxCode INT;
- DECLARE vTaxCodeOld INT;
- DECLARE vOperationCode VARCHAR(1);
- DECLARE vIsIntracommunity BOOL DEFAULT FALSE;
- DECLARE vSerialDua VARCHAR(1) DEFAULT 'D';
- DECLARE vInvoiceTypeReceived VARCHAR(1);
- DECLARE vInvoiceTypeInformative VARCHAR(1);
- DECLARE vIsInformativeExportation BOOL DEFAULT FALSE;
-
- DECLARE vCursor CURSOR FOR
- SELECT it.taxableBase,
- CAST((( it.taxableBase / 100) * t.PorcentajeIva) AS DECIMAL (10,2)),
- t.PorcentajeIva,
- it.transactionTypeSageFk,
- it.taxTypeSageFk,
- tty.isIntracommunity,
- tt.ClaveOperacionDefecto
- FROM vn.invoiceIn i
- JOIN vn.invoiceInTax it ON it.InvoiceInFk = i.id
- JOIN TiposIva t ON t.CodigoIva = it.taxTypeSageFk
- JOIN taxType tty ON tty.id = t.CodigoIva
- JOIN TiposTransacciones tt ON tt.CodigoTransaccion = it.transactionTypeSageFk
- LEFT JOIN vn.dua d ON d.id = vInvoiceInFk
- WHERE i.id = vInvoiceInFk
- AND d.id IS NULL;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
-
- DELETE FROM movContaIVA
- WHERE id = vXDiarioFk;
-
- SELECT codeSage INTO vInvoiceTypeReceived
- FROM invoiceType WHERE code ='received';
-
- SELECT codeSage INTO vInvoiceTypeInformative
- FROM invoiceType WHERE code ='informative';
-
- INSERT INTO movContaIVA(id, LibreA1)
- VALUES (vXDiarioFk, vInvoiceInFk);
-
- OPEN vCursor;
-
- l: LOOP
- FETCH vCursor INTO vBase,
- vVat,
- vRate,
- vTransactionCode,
- vTaxCode,
- vIsIntracommunity,
- vOperationCode;
-
- IF vDone THEN
- LEAVE l;
- END IF;
-
- SET vTransactionCodeOld = vTransactionCode;
- SET vTaxCodeOld = vTaxCode;
-
- IF vOperationCode IS NOT NULL THEN
- UPDATE movContaIVA
- SET ClaveOperacionFactura = vOperationCode
- WHERE id = vXDiarioFk;
- END IF;
-
- SET vCounter = vCounter + 1;
- CASE vCounter
- WHEN 1 THEN
- UPDATE movContaIVA
- SET BaseIva1 = vBase,
- PorIva1 = vRate,
- CuotaIva1 = vVat,
- CodigoTransaccion1 = vTransactionCode,
- CodigoIva1 = vTaxCode
- WHERE id = vXDiarioFk;
-
- WHEN 2 THEN
- UPDATE movContaIVA
- SET BaseIva2 = vBase,
- PorIva2 = vRate,
- CuotaIva2 = vVat,
- CodigoTransaccion2 = vTransactionCode,
- CodigoIva2 = vTaxCode
- WHERE id = vXDiarioFk;
- WHEN 3 THEN
- UPDATE movContaIVA
- SET BaseIva3 = vBase,
- PorIva3 = vRate,
- CuotaIva3 = vVat,
- CodigoTransaccion3 = vTransactionCode,
- CodigoIva3 = vTaxCode
- WHERE id = vXDiarioFk;
- WHEN 4 THEN
- UPDATE movContaIVA
- SET BaseIva4 = vBase,
- PorIva4 = vRate,
- CuotaIva4 = vVat,
- CodigoTransaccion4 = vTransactionCode,
- CodigoIva4 = vTaxCode
- WHERE id = vXDiarioFk;
- ELSE
- SELECT vXDiarioFk INTO vXDiarioFk;
- END CASE;
-
- IF vIsIntracommunity THEN
- UPDATE movContaIVA
- SET Intracomunitaria = TRUE
- WHERE id = vXDiarioFk;
- END IF;
-
- SET vTransactionCodeOld = vTransactionCode;
- SET vTaxCodeOld = vTaxCode;
-
- END LOOP;
-
- CLOSE vCursor;
-
- SELECT d.ASIEN AND x.ASIEN IS NULL INTO vIsInformativeExportation
- FROM vn.dua d
- LEFT JOIN vn.XDiario x ON x.ASIEN = d.ASIEN
- AND x.SERIE = vSerialDua COLLATE utf8mb3_unicode_ci
- WHERE d.ASIEN = (
- SELECT ASIEN
- FROM vn.XDiario
- WHERE id = vXDiarioFk)
- LIMIT 1;
-
- UPDATE movContaIVA mci
- JOIN tmp.invoiceIn ii ON ii.id = vInvoiceInFk
- JOIN vn.XDiario x ON x.id = mci.id
- LEFT JOIN tmp.invoiceDua id ON id.id = mci.id
- JOIN vn.supplier s ON s.id = ii.supplierFk
- JOIN Naciones n ON n.countryFk = s.countryFk
- SET mci.CodigoDivisa = ii.currencyFk,
- mci.Año = YEAR(ii.issued),
- mci.Serie = ii.serial,
- mci.Factura = ii.id,
- mci.FechaFactura = ii.issued,
- mci.ImporteFactura = IFNULL(mci.BaseIva1, 0) + IFNULL(mci.CuotaIva1, 0) +
- IFNULL(mci.BaseIva2, 0) + IFNULL(mci.CuotaIva2, 0) +
- IFNULL(mci.BaseIva3, 0) + IFNULL(mci.CuotaIva3, 0) +
- IFNULL(mci.BaseIva4, 0) + IFNULL(mci.CuotaIva4, 0),
- mci.TipoFactura = IF(id.id,
- IF( ii.serial = vSerialDua COLLATE utf8mb3_unicode_ci, vInvoiceTypeReceived, vInvoiceTypeInformative),
- IF(vIsInformativeExportation,vInvoiceTypeInformative, vInvoiceTypeReceived)),
- mci.CodigoCuentaFactura = x.SUBCTA,
- mci.CifDni = IF(LEFT(TRIM(s.nif), 2) = n.SiglaNacion, SUBSTRING(TRIM(s.nif), 3), s.nif),
- mci.Nombre = s.name,
- mci.SiglaNacion = n.SiglaNacion,
- mci.EjercicioFactura = YEAR(ii.issued),
- mci.FechaOperacion = ii.issued,
- mci.MantenerAsiento = TRUE,
- mci.SuFacturaNo = ii.supplierRef,
- mci.IvaDeducible1 = IF(id.id, FALSE, IF(IFNULL(mci.BaseIva1, FALSE) = FALSE, FALSE, ii.isVatDeductible)),
- mci.IvaDeducible2 = IF(id.id, FALSE, IF(IFNULL(mci.BaseIva2, FALSE) = FALSE, FALSE, ii.isVatDeductible)),
- mci.IvaDeducible3 = IF(id.id, FALSE, IF(IFNULL(mci.BaseIva3, FALSE) = FALSE, FALSE, ii.isVatDeductible)),
- mci.IvaDeducible4 = IF(id.id, FALSE, IF(IFNULL(mci.BaseIva4, FALSE) = FALSE, FALSE, ii.isVatDeductible)),
- mci.FechaFacturaOriginal = x.FECHA_EX
- WHERE mci.id = vXDiarioFk;
-
- -- RETENCIONES
- UPDATE movContaIVA mci
- JOIN vn.invoiceIn ii ON ii.id = vInvoiceInFk
- JOIN vn.XDiario x ON x.id = mci.id
- JOIN vn.supplier s ON s.id = supplierFk
- JOIN vn.invoiceInTax iit ON iit.invoiceInFk = ii.id
- JOIN vn.expense e ON e.id = iit.expenseFk
- JOIN TiposRetencion t ON t.CodigoRetencion = ii.withholdingSageFk
- LEFT JOIN tmp.invoiceDua id ON id.id = mci.id
- JOIN (SELECT SUM(x2.BASEEURO) taxableBase, SUM(x2.EURODEBE) taxBase
- FROM vn.XDiario x1
- JOIN vn.XDiario x2 ON x1.ASIEN = x2.ASIEN
- WHERE x2.BASEEURO <> 0
- AND x1.id = vXDiarioFk
- )sub
- JOIN ClavesOperacion co ON co.Descripcion = 'Arrendamiento de locales de negocio'
- SET mci.CodigoRetencion = t.CodigoRetencion,
- mci.ClaveOperacionFactura = IF( t.Retencion = 'ARRENDAMIENTO Y SUBARRENDAMIENTO', co.ClaveOperacionFactura_, mci.ClaveOperacionFactura),
- mci.BaseRetencion = IF (t.Retencion = 'ACTIVIDADES AGRICOLAS O GANADERAS', sub.taxableBase + sub.taxBase, sub.taxableBase),
- mci.PorRetencion = t.PorcentajeRetencion,
- mci.ImporteRetencion = iit.taxableBase * - 1
- WHERE mci.id = vXDiarioFk
- AND e.name = 'Retenciones'
- AND id.id IS NULL;
-
- SELECT correctedFk INTO vInvoiceInOriginalFk
- FROM vn.invoiceInCorrection
- WHERE correctingFk = vInvoiceInFk;
-
- IF vInvoiceInOriginalFk THEN
-
- UPDATE movContaIVA mci
- JOIN vn.invoiceInRefund iir ON iir.invoiceInRefundFk = vInvoiceInFk
- JOIN (SELECT issued,
- SUM(sub.taxableBase) taxableBase,
- SUM(ROUND((sub.taxableBase * sub.PorcentajeIva) / 100 , 2)) vat
- FROM(SELECT issued,
- SUM(iit.taxableBase) taxableBase,
- ti.PorcentajeIva
- FROM vn.invoiceIn i
- JOIN vn.invoiceInTax iit ON iit.invoiceInFk = i.id
- JOIN sage.TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk
- WHERE i.id = vInvoiceInOriginalFk
- GROUP BY ti.CodigoIva)sub
- )invoiceInOriginal
- JOIN ClavesOperacion co ON co.Descripcion = 'Factura rectificativa'
- SET mci.TipoRectificativa = iir.refundCategoryFk,
- mci.ClaseAbonoRectificativas = iir.refundType,
- mci.FechaFacturaOriginal = invoiceInOriginal.issued,
- mci.FechaOperacion = invoiceInOriginal.issued,
- mci.BaseImponibleOriginal = invoiceInOriginal.taxableBase,
- mci.CuotaIvaOriginal = invoiceInOriginal.vat,
- mci.ClaveOperacionFactura = co.ClaveOperacionFactura_
- WHERE mci.id = vXDiarioFk;
-
- END IF;
-END$$
-DELIMITER ;
\ No newline at end of file
diff --git a/db/routines/vn/procedures/invoiceIn_checkBooked.sql b/db/routines/vn/procedures/invoiceIn_checkBooked.sql
new file mode 100644
index 000000000..862870eb4
--- /dev/null
+++ b/db/routines/vn/procedures/invoiceIn_checkBooked.sql
@@ -0,0 +1,22 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceIn_checkBooked`(
+ vSelf INT
+)
+BEGIN
+/**
+ * Comprueba si una factura recibida está contabilizada,
+ * y si lo está retorna un throw.
+ *
+ * @param vSelf Id invoiceIn
+ */
+ DECLARE vIsBooked BOOL;
+
+ SELECT isBooked INTO vIsBooked
+ FROM invoiceIn
+ WHERE id = vSelf;
+
+ IF vIsBooked THEN
+ CALL util.throw('InvoiceIn is already booked');
+ END IF;
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/procedures/invoiceOut_new.sql b/db/routines/vn/procedures/invoiceOut_new.sql
index 8c35ce75f..1b486df86 100644
--- a/db/routines/vn/procedures/invoiceOut_new.sql
+++ b/db/routines/vn/procedures/invoiceOut_new.sql
@@ -68,16 +68,21 @@ BEGIN
DELETE ti.*
FROM tmp.ticketToInvoice ti
JOIN ticket t ON t.id = ti.id
+ LEFT JOIN address a ON a.id = t.addressFk
JOIN sale s ON s.ticketFk = t.id
JOIN item i ON i.id = s.itemFk
JOIN supplier su ON su.id = t.companyFk
JOIN client c ON c.id = t.clientFk
- LEFT JOIN itemTaxCountry itc ON itc.itemFk = i.id AND itc.countryFk = su.countryFk
+ LEFT JOIN itemTaxCountry itc ON itc.itemFk = i.id
+ AND itc.countryFk = su.countryFk
WHERE (YEAR(t.shipped) < 2001 AND t.isDeleted)
OR c.isTaxDataChecked = FALSE
OR t.isDeleted
OR c.hasToInvoice = FALSE
- OR itc.id IS NULL;
+ OR itc.id IS NULL
+ OR a.id IS NULL
+ OR (vTaxArea = 'WORLD'
+ AND (a.customsAgentFk IS NULL OR a.incotermsFk IS NULL));
SELECT SUM(s.quantity * s.price * (100 - s.discount)/100) <> 0
INTO vIsAnySaleToInvoice
diff --git a/db/routines/vn/procedures/itemProposal.sql b/db/routines/vn/procedures/itemProposal.sql
deleted file mode 100644
index 74d356d77..000000000
--- a/db/routines/vn/procedures/itemProposal.sql
+++ /dev/null
@@ -1,87 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemProposal`(vItemFk INT, vTicketFk INT,vShowType BOOL)
-BEGIN
-
-/**
- * Propone articulos disponible ordenado, con la cantidad de veces usado y segun sus caracteristicas
- *
- * @param vItemFk item id
- * @param vTicketFk ticket id
- * @param vShowType mostrar tipos
- */
-
- DECLARE vWarehouseFk INT;
- DECLARE vShipped DATE;
- DECLARE vCalcFk INT;
- DECLARE vTypeFk INT;
-
- DECLARE vTag1 VARCHAR(25);
- DECLARE vTag5 VARCHAR(25);
- DECLARE vTag6 VARCHAR(25);
- DECLARE vTag7 VARCHAR(25);
- DECLARE vTag8 VARCHAR(25);
-
- DECLARE vValue1 VARCHAR(50);
- DECLARE vValue5 VARCHAR(50);
- DECLARE vValue6 VARCHAR(50);
- DECLARE vValue7 VARCHAR(50);
- DECLARE vValue8 VARCHAR(50);
-
- SELECT warehouseFk, shipped INTO vWarehouseFk, vShipped
- FROM vn.ticket
- WHERE id = vTicketFk;
-
- SELECT typeFk, tag5, value5, tag6, value6, tag7, value7, tag8, value8, t1.name, it1.value
- INTO vTypeFk, vTag5, vValue5, vTag6, vValue6, vTag7, vValue7, vTag8, vValue8, vTag1, vValue1
- FROM vn.item i
- LEFT JOIN vn.itemTag it1 ON it1.itemFk = i.id AND it1.priority = 1
- LEFT JOIN vn.tag t1 ON t1.id = it1.tagFk
- WHERE i.id = vItemFk;
-
- CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vShipped);
-
- SELECT i.id itemFk,
- i.longName,
- i.subName,
- i.tag5,
- i.value5,
- (i.value5 <=> vValue5 COLLATE utf8_general_ci) match5,
- i.tag6,
- i.value6,
- (i.value6 <=> vValue6 COLLATE utf8_general_ci) match6,
- i.tag7,
- i.value7,
- (i.value7 <=> vValue7 COLLATE utf8_general_ci) match7,
- i.tag8,
- i.value8,
- (i.value8 <=> vValue8 COLLATE utf8_general_ci) match8,
- a.available,
- IFNULL(ip.counter,0) counter,
- IF(b.groupingMode = 1, b.grouping, b.packing) as minQuantity,
- iss.visible located
- FROM item i
- JOIN cache.available a ON a.item_id = i.id
- LEFT JOIN itemProposal ip ON ip.mateFk = i.id AND ip.itemFk = vItemFk
- LEFT JOIN itemTag it1 ON it1.itemFk = i.id AND it1.priority = 1
- LEFT JOIN tag t1 ON t1.id = it1.tagFk
- LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = vWarehouseFk
- LEFT JOIN buy b ON b.id = lb.buy_id
- LEFT JOIN itemShelvingStock iss ON iss.itemFk = i.id AND iss.warehouseFk = vWarehouseFk
- WHERE a.calc_id = vCalcFk
- AND available > 0
- AND IF(vShowType,i.typeFk = vTypeFk,true)
- AND i.id != vItemFk
- ORDER BY counter DESC,
- (t1.name = vTag1 COLLATE utf8_general_ci) DESC,
- (it1.value = vValue1 COLLATE utf8_general_ci) DESC,
- (i.tag5 = vTag5 COLLATE utf8_general_ci) DESC,
- (i.value5 = vValue5 COLLATE utf8_general_ci) DESC,
- (i.tag6 = vTag6 COLLATE utf8_general_ci) DESC,
- (i.value6 = vValue6 COLLATE utf8_general_ci) DESC,
- (i.tag7 = vTag7 COLLATE utf8_general_ci) DESC,
- (i.value7 = vValue7 COLLATE utf8_general_ci) DESC,
- (i.tag8 = vTag8 COLLATE utf8_general_ci) DESC,
- (i.value8 = vValue8 COLLATE utf8_general_ci) DESC;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn/procedures/itemProposal_beta.sql b/db/routines/vn/procedures/itemProposal_beta.sql
deleted file mode 100644
index 4a6f761a9..000000000
--- a/db/routines/vn/procedures/itemProposal_beta.sql
+++ /dev/null
@@ -1,76 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemProposal_beta`(vItemFk INT, vTicketFk INT)
-BEGIN
-
- DECLARE vWarehouseFk INT;
- DECLARE vShipped DATE;
- DECLARE vCalcFk INT;
- DECLARE vTypeFk INT;
- DECLARE vResultsMax INT DEFAULT 10;
-
- DECLARE vTag1 VARCHAR(25);
- DECLARE vTag5 VARCHAR(25);
- DECLARE vTag6 VARCHAR(25);
- DECLARE vTag7 VARCHAR(25);
- DECLARE vTag8 VARCHAR(25);
-
- DECLARE vValue1 VARCHAR(50);
- DECLARE vValue5 VARCHAR(50);
- DECLARE vValue6 VARCHAR(50);
- DECLARE vValue7 VARCHAR(50);
- DECLARE vValue8 VARCHAR(50);
-
- SELECT warehouseFk, shipped INTO vWarehouseFk, vShipped
- FROM vn.ticket
- WHERE id = vTicketFk;
-
- SELECT typeFk, tag5, value5, tag6, value6, tag7, value7, tag8, value8, t1.name, it1.value
- INTO vTypeFk, vTag5, vValue5, vTag6, vValue6, vTag7, vValue7, vTag8, vValue8, vTag1, vValue1
- FROM vn.item i
- LEFT JOIN vn.itemTag it1 ON it1.itemFk = i.id AND it1.priority = 1
- LEFT JOIN vn.tag t1 ON t1.id = it1.tagFk
- WHERE i.id = vItemFk;
-
- CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vShipped);
-
- SELECT i.id itemFk,
- i.longName,
- i.subName,
- i.tag5,
- i.value5,
- (i.value5 <=> vValue5 COLLATE utf8_general_ci) match5,
- i.tag6,
- i.value6,
- (i.value6 <=> vValue6 COLLATE utf8_general_ci) match6,
- i.tag7,
- i.value7,
- (i.value7 <=> vValue7 COLLATE utf8_general_ci) match7,
- i.tag8,
- i.value8,
- (i.value8 <=> vValue8 COLLATE utf8_general_ci) match8,
- a.available,
- IFNULL(ip.counter,0) counter
- FROM vn.item i
- JOIN cache.available a ON a.item_id = i.id
- LEFT JOIN vn.itemProposal ip ON ip.mateFk = i.id AND ip.itemFk = vItemFk
- LEFT JOIN vn.itemTag it1 ON it1.itemFk = i.id AND it1.priority = 1
- LEFT JOIN vn.tag t1 ON t1.id = it1.tagFk
- WHERE a.calc_id = vCalcFk
- AND available > 0
- AND i.typeFk = vTypeFk
- AND i.id != vItemFk
- ORDER BY counter DESC,
- (t1.name = vTag1 COLLATE utf8_general_ci) DESC,
- (it1.value = vValue1 COLLATE utf8_general_ci) DESC,
- (i.tag5 = vTag5 COLLATE utf8_general_ci) DESC,
- (i.value5 = vValue5 COLLATE utf8_general_ci) DESC,
- (i.tag6 = vTag6 COLLATE utf8_general_ci) DESC,
- (i.value6 = vValue6 COLLATE utf8_general_ci) DESC,
- (i.tag7 = vTag7 COLLATE utf8_general_ci) DESC,
- (i.value7 = vValue7 COLLATE utf8_general_ci) DESC,
- (i.tag8 = vTag8 COLLATE utf8_general_ci) DESC,
- (i.value8 = vValue8 COLLATE utf8_general_ci) DESC
- LIMIT vResultsMax;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn/procedures/itemShelving_add.sql b/db/routines/vn/procedures/itemShelving_add.sql
index 2a4676b50..d4c31f09e 100644
--- a/db/routines/vn/procedures/itemShelving_add.sql
+++ b/db/routines/vn/procedures/itemShelving_add.sql
@@ -21,7 +21,6 @@ BEGIN
SELECT barcodeToItem(vBarcode) INTO vItemFk;
SET vPacking = COALESCE(vPacking, GREATEST(vn.itemPacking(vBarcode,vWarehouseFk), 1));
-
SET vQuantity = vQuantity * vPacking;
IF (SELECT COUNT(*) FROM shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN
diff --git a/db/routines/vn/procedures/itemShelving_inventory.sql b/db/routines/vn/procedures/itemShelving_inventory.sql
index ce2934426..73e438fbb 100644
--- a/db/routines/vn/procedures/itemShelving_inventory.sql
+++ b/db/routines/vn/procedures/itemShelving_inventory.sql
@@ -30,10 +30,11 @@ BEGIN
ish.visible,
p.sectorFk,
it.workerFk buyer,
- CONCAT('http:',ic.url, '/catalog/1600x900/',i.image) urlImage,
+ ic.url,
+ i.image,
ish.isChecked,
CASE
- WHEN s.notPrepared > sm.parked THEN 0
+ WHEN IFNULL (s.notPrepared, 0) > sm.parked THEN 0
WHEN sm.visible > sm.parked THEN 1
ELSE 2
END priority
@@ -43,7 +44,7 @@ BEGIN
JOIN tmp.stockMisfit sm ON sm.itemFk = ish.itemFk
JOIN shelving sh ON sh.code = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
- JOIN (
+ LEFT JOIN (
SELECT s.itemFk, sum(s.quantity) notPrepared
FROM sale s
JOIN ticket t ON t.id = s.ticketFk
diff --git a/db/routines/vn/procedures/item_getSimilar.sql b/db/routines/vn/procedures/item_getSimilar.sql
index 7cc9ad63e..1da60cf70 100644
--- a/db/routines/vn/procedures/item_getSimilar.sql
+++ b/db/routines/vn/procedures/item_getSimilar.sql
@@ -1,84 +1,99 @@
DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getSimilar`(vItemFk INT, vWarehouseFk INT, vDate DATE, vIsShowedByType BOOL)
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getSimilar`(
+ vSelf INT,
+ vWarehouseFk INT,
+ vDated DATE,
+ vShowType BOOL
+)
BEGIN
-
/**
- * Propone articulos similares para posible cambio,
- * ordenado con la cantidad de veces usado y segun sus caracteristicas
- *
- * @param vItemFk item id
- * @param vWarehouseFk warehouse id
- * @param vDate fecha para revisar disponible
- * @param vIsShowedByType para mostrar solo artículos de ese tipo
- */
+* Propone articulos disponibles ordenados, con la cantidad
+* de veces usado y segun sus caracteristicas.
+*
+* @param vSelf Id de artículo
+* @param vWarehouseFk Id de almacen
+* @param vDated Fecha
+* @param vShowType Mostrar tipos
+*/
+ DECLARE vCalcFk INT;
+ DECLARE vTypeFk INT;
+ DECLARE vPriority INT DEFAULT 1;
- DECLARE vCalcFk INT;
- DECLARE vTypeFk INT;
-
- DECLARE vTag1 VARCHAR(25) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
- DECLARE vTag5 VARCHAR(25) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
- DECLARE vTag6 VARCHAR(25) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
- DECLARE vTag7 VARCHAR(25) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
- DECLARE vTag8 VARCHAR(25) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
-
- DECLARE vValue1 VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
- DECLARE vValue5 VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
- DECLARE vValue6 VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
- DECLARE vValue7 VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
- DECLARE vValue8 VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
+ CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vDated);
-
- SELECT typeFk, tag5, value5, tag6, value6, tag7, value7, tag8, value8, t1.name, it1.value
- INTO vTypeFk, vTag5, vValue5, vTag6, vValue6, vTag7, vValue7, vTag8, vValue8, vTag1, vValue1
- FROM vn.item i
- LEFT JOIN vn.itemTag it1 ON it1.itemFk = i.id AND it1.priority = 1
- LEFT JOIN vn.tag t1 ON t1.id = it1.tagFk
- WHERE i.id = vItemFk;
-
- CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vDate);
-
- SELECT i.id itemFk,
- i.longName,
- i.subName,
- i.tag5,
- i.value5,
- (i.value5 <=> vValue5) match5,
- i.tag6,
- i.value6,
- (i.value6 <=> vValue6) match6,
- i.tag7,
- i.value7,
- (i.value7 <=> vValue7) match7,
- i.tag8,
- i.value8,
- (i.value8 <=> vValue8) match8,
- a.available,
- IFNULL(ip.counter,0) counter,
- IF(b.groupingMode = 1, b.grouping, b.packing) as minQuantity
- FROM vn.item i
- JOIN cache.available a ON a.item_id = i.id
- LEFT JOIN vn.itemProposal ip ON ip.mateFk = i.id AND ip.itemFk = vItemFk
- LEFT JOIN vn.itemTag it1 ON it1.itemFk = i.id AND it1.priority = 1
- LEFT JOIN vn.tag t1 ON t1.id = it1.tagFk
- LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = vWarehouseFk
+ -- Añadido temporalmente para ver si ya no sucede el cuelgue de db
+ SET vShowType = TRUE;
+
+ WITH itemTags AS (
+ SELECT i.id,
+ typeFk,
+ tag5,
+ value5,
+ tag6,
+ value6,
+ tag7,
+ value7,
+ tag8,
+ value8,
+ t.name,
+ it.value
+ FROM vn.item i
+ LEFT JOIN vn.itemTag it ON it.itemFk = i.id
+ AND it.priority = vPriority
+ LEFT JOIN vn.tag t ON t.id = it.tagFk
+ WHERE i.id = vSelf
+ )
+ SELECT i.id itemFk,
+ i.longName,
+ i.subName,
+ i.tag5,
+ i.value5,
+ (i.value5 <=> its.value5) match5,
+ i.tag6,
+ i.value6,
+ (i.value6 <=> its.value6) match6,
+ i.tag7,
+ i.value7,
+ (i.value7 <=> its.value7) match7,
+ i.tag8,
+ i.value8,
+ (i.value8 <=> its.value8) match8,
+ a.available,
+ IFNULL(ip.counter, 0) `counter`,
+ CASE
+ WHEN b.groupingMode = 'grouping' THEN b.grouping
+ WHEN b.groupingMode = 'packing' THEN b.packing
+ ELSE 1
+ END AS minQuantity,
+ iss.visible located
+ FROM vn.item i
+ JOIN cache.available a ON a.item_id = i.id
+ AND a.calc_id = vCalcFk
+ LEFT JOIN vn.itemProposal ip ON ip.mateFk = i.id
+ AND ip.itemFk = vSelf
+ LEFT JOIN vn.itemTag it ON it.itemFk = i.id
+ AND it.priority = vPriority
+ LEFT JOIN vn.tag t ON t.id = it.tagFk
+ LEFT JOIN cache.last_buy lb ON lb.item_id = i.id
+ AND lb.warehouse_id = vWarehouseFk
LEFT JOIN vn.buy b ON b.id = lb.buy_id
- WHERE a.calc_id = vCalcFk
- AND available > 0
- AND IF(vIsShowedByType, i.typeFk = vTypeFk, TRUE)
- AND i.id != vItemFk
- ORDER BY counter DESC,
- (t1.name = vTag1) DESC,
- (it1.value = vValue1) DESC,
- (i.tag6 = vTag6) DESC,
- (i.value6 = vValue6) DESC,
- (i.tag5 = vTag5) DESC,
- (i.value5 = vValue5) DESC,
- (i.tag7 = vTag7) DESC,
- (i.value7 = vValue7) DESC,
- (i.tag8 = vTag8) DESC,
- (i.value8 = vValue8) DESC
- LIMIT 30;
-
-
+ LEFT JOIN vn.itemShelvingStock iss ON iss.itemFk = i.id
+ AND iss.warehouseFk = vWarehouseFk
+ JOIN itemTags its
+ WHERE a.available > 0
+ AND IF(vShowType, i.typeFk = its.typeFk, TRUE)
+ AND i.id <> vSelf
+ ORDER BY `counter` DESC,
+ (t.name = its.name) DESC,
+ (it.value = its.value) DESC,
+ (i.tag5 = its.tag5) DESC,
+ match5 DESC,
+ (i.tag6 = its.tag6) DESC,
+ match6 DESC,
+ (i.tag7 = its.tag7) DESC,
+ match7 DESC,
+ (i.tag8 = its.tag8) DESC,
+ match8 DESC
+ LIMIT 100;
END$$
DELIMITER ;
diff --git a/db/routines/vn/procedures/item_setVisibleDiscard.sql b/db/routines/vn/procedures/item_setVisibleDiscard.sql
index 1cc2a8871..0a6c54971 100644
--- a/db/routines/vn/procedures/item_setVisibleDiscard.sql
+++ b/db/routines/vn/procedures/item_setVisibleDiscard.sql
@@ -13,6 +13,7 @@ BEGIN
* @param vQuantity a dar de alta/baja
* @param vAddressFk id address
*/
+
DECLARE vTicketFk INT;
DECLARE vClientFk INT;
DECLARE vDefaultCompanyFk INT;
@@ -23,17 +24,17 @@ BEGIN
SELECT DEFAULT(companyFk) INTO vDefaultCompanyFk
FROM vn.ticket LIMIT 1;
-
- IF vAddressFk IS NULL THEN
+
+ IF vAddressFk IS NULL THEN
SELECT pc.shortageAddressFk INTO vAddressShortage
FROM productionConfig pc ;
- ELSE
+ ELSE
SET vAddressShortage = vAddressFk;
END IF;
SELECT a.clientFk INTO vClientFk
FROM address a
- WHERE a.id = vAddressFk;
+ WHERE a.id = vAddressShortage;
SELECT t.id INTO vTicketFk
FROM ticket t
@@ -65,7 +66,7 @@ BEGIN
INSERT INTO sale(ticketFk, itemFk, concept, quantity)
SELECT vTicketFk,
vItemFk,
- CONCAT(longName,' ', worker_getCode(), ' ', LEFT(CAST(util.VN_NOW() AS TIME),5)),
+ name,
vQuantity
FROM item
WHERE id = vItemFk;
diff --git a/db/routines/vn/procedures/payment_add.sql b/db/routines/vn/procedures/payment_add.sql
new file mode 100644
index 000000000..061a75848
--- /dev/null
+++ b/db/routines/vn/procedures/payment_add.sql
@@ -0,0 +1,84 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`payment_add`(
+ vDated DATE,
+ vSupplierFk INT,
+ vAmount DOUBLE,
+ vCurrencyFk INT,
+ vForeignValue DOUBLE,
+ vBankFk INT,
+ vPayMethodFk INT,
+ vExpenseFk DOUBLE,
+ vConcept VARCHAR(40),
+ vCompanyFk INT)
+BEGIN
+/**
+ * Registra un pago realizado a un proveedor y
+ * su correspondiente registro en caja.
+ *
+ * @param vDated Fecha del pago
+ * @param vSupplierFk Id del proveedor
+ * @param vAmount Cantidad a pagar
+ * @param vCurrencyFk Id de la moneda
+ * @param vForeignValue Tipo de cambio utilizado
+ * @param vBankFk Id del banco
+ * @param vPayMethodFk Id del método de pago
+ * @param vExpenseFk Id de gasto
+ * @param vConcept Concepto del pago
+ * @param vCompanyFk Id de la empresa
+ * @return paymentFk Id de pago insertado
+ */
+ INSERT INTO till(
+ concept,
+ serie,
+ `number`,
+ `out`,
+ dated,
+ isAccountable,
+ bankFk,
+ workerFk,
+ companyFk,
+ isConciliate
+ )
+ SELECT CONCAT('n/pago a ', `name`),
+ 'R',
+ vSupplierFk,
+ vAmount,
+ vDated,
+ 1,
+ vBankFk,
+ account.myUser_getId(),
+ vCompanyFk,
+ 1
+ FROM supplier
+ WHERE id = vSupplierFk;
+
+ INSERT INTO payment(
+ received,
+ dueDated,
+ supplierFk,
+ amount,
+ currencyFk,
+ divisa,
+ bankFk,
+ payMethodFk,
+ bankingFees,
+ concept,
+ companyFk
+ )
+ VALUES(
+ vDated,
+ vDated,
+ vSupplierFk,
+ vAmount,
+ vCurrencyFk,
+ IF(NOT vForeignValue, NULL, vForeignValue),
+ vBankFk,
+ vPayMethodFk,
+ vExpenseFk,
+ vConcept,
+ vCompanyFk
+ );
+
+ SELECT LAST_INSERT_ID() paymentFk;
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/procedures/productionError_add.sql b/db/routines/vn/procedures/productionError_add.sql
index 5e0ce93f0..e29accac9 100644
--- a/db/routines/vn/procedures/productionError_add.sql
+++ b/db/routines/vn/procedures/productionError_add.sql
@@ -34,16 +34,22 @@ BEGIN
-- Rellena la tabla tmp.errorsByChecker con fallos de revisores
CREATE OR REPLACE TEMPORARY TABLE tmp.errorsByChecker
ENGINE = MEMORY
- SELECT st.workerFk,
- COUNT(t.id) errors
- FROM saleMistake sm
- JOIN saleTracking st ON sm.saleFk = st.saleFk
- JOIN `state` s2 ON s2.id = st.stateFk
- JOIN sale s ON s.id = sm.saleFk
- JOIN ticket t on t.id = s.ticketFk
- WHERE (t.shipped BETWEEN vDatedFrom AND vDatedTo)
- AND s2.code IN ('OK','PREVIOUS_PREPARATION','PREPARED','CHECKED')
- GROUP BY st.workerFk;
+ WITH rankedWorkers AS (
+ SELECT sm.id,
+ st.workerFk,
+ ROW_NUMBER() OVER(PARTITION BY sm.id ORDER BY s2.`order`) rnk
+ FROM vn.saleMistake sm
+ JOIN vn.saleTracking st ON sm.saleFk = st.saleFk
+ JOIN vn.`state` s2 ON s2.id = st.stateFk
+ JOIN vn.sale s ON s.id = sm.saleFk
+ JOIN vn.ticket t ON t.id = s.ticketFk
+ WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo
+ AND s2.code IN ('OK', 'PREVIOUS_PREPARATION', 'PREPARED', 'CHECKED')
+ )
+ SELECT workerFk, COUNT(*) errors
+ FROM rankedWorkers
+ WHERE rnk = 1
+ GROUP BY workerFk;
-- Rellena la tabla tmp.expeditionErrors con fallos de expediciones
CREATE OR REPLACE TEMPORARY TABLE tmp.expeditionErrors
diff --git a/db/routines/vn/procedures/raidUpdate.sql b/db/routines/vn/procedures/raidUpdate.sql
new file mode 100644
index 000000000..703c14e5c
--- /dev/null
+++ b/db/routines/vn/procedures/raidUpdate.sql
@@ -0,0 +1,31 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`raidUpdate`()
+BEGIN
+/**
+ * Actualiza el travel de las entradas de redadas
+ */
+ UPDATE entry e
+ JOIN entryVirtual ev ON ev.entryFk = e.id
+ JOIN travel t ON t.id = e.travelFk
+ JOIN (
+ SELECT *
+ FROM (
+ SELECT t.id, t.landed, tt.warehouseInFk, tt.warehouseOutFk
+ FROM travel t
+ JOIN (
+ SELECT t.warehouseInFk, t.warehouseOutFk
+ FROM entryVirtual ev
+ JOIN entry e ON e.id = ev.entryFk
+ JOIN travel t ON t.id = e.travelFk
+ GROUP BY t.warehouseInFk, t.warehouseOutFk
+ ) tt ON t.warehouseInFk = tt.warehouseInFk AND t.warehouseOutFk = tt.warehouseOutFk
+ WHERE shipped > util.VN_CURDATE() AND NOT isDelivered
+ ORDER BY t.landed
+ LIMIT 10000000000000000000
+ ) t
+ GROUP BY t.warehouseInFk, t.warehouseOutFk
+ ) tt ON t.warehouseInFk = tt.warehouseInFk AND t.warehouseOutFk = tt.warehouseOutFk
+ SET e.travelFk = t.id;
+
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/procedures/rateView.sql b/db/routines/vn/procedures/rateView.sql
new file mode 100644
index 000000000..d840aa9d5
--- /dev/null
+++ b/db/routines/vn/procedures/rateView.sql
@@ -0,0 +1,38 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`rateView`()
+BEGIN
+/**
+ * Muestra información sobre tasas de cambio de Dolares
+ */
+ SELECT
+ t.year año,
+ t.month mes,
+ pay.dollars dolares,
+ pay.changePractical cambioPractico,
+ CAST(SUM(iit.foreignValue ) / SUM(iit.taxableBase) AS DECIMAL(5,4))cambioTeorico,
+ pay.changeOfficial cambioOficial
+ FROM invoiceIn ii
+ JOIN time t ON t.dated = ii.issued
+ JOIN invoiceInTax iit ON ii.id = iit.invoiceInFk
+ JOIN
+ ( SELECT
+ t.year,
+ t.month,
+ CAST(SUM(p.divisa) AS DECIMAL(10,2)) dollars,
+ CAST(SUM(p.divisa) / SUM(p.amount) AS DECIMAL(5,4)) changePractical,
+ CAST(rr.value * 0.998 AS DECIMAL(5,4)) changeOfficial
+ FROM payment p
+ JOIN time t ON t.dated = p.received
+ JOIN referenceRate rr ON rr.dated = p.received
+ JOIN currency c ON c.id = rr.currencyFk
+ WHERE p.divisa
+ AND c.code = 'USD'
+ GROUP BY t.year, t.month
+ ) pay ON t.year = pay.year AND t.month = pay.month
+ JOIN currency c ON c.id = ii.currencyFk
+ WHERE c.code = 'USD'
+ AND iit.foreignValue
+ AND iit.taxableBase
+ GROUP BY t.year, t.month;
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/procedures/remittance_calc.sql b/db/routines/vn/procedures/remittance_calc.sql
new file mode 100644
index 000000000..ed0a18662
--- /dev/null
+++ b/db/routines/vn/procedures/remittance_calc.sql
@@ -0,0 +1,70 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`remittance_calc`(
+ vDated DATE
+)
+BEGIN
+/**
+* Calcula los datos de remesa, incluyendo el importe,
+* el vencimiento, y otros datos relevantes.
+*
+* @param vDated Fecha a calcular
+* @return tmp.remittance
+*/
+ CREATE OR REPLACE TEMPORARY TABLE tmp.remittance
+ SELECT CONCAT(s.nif, REPEAT('0', 12 - LENGTH(s.nif))) cif,
+ c.id clientFk,
+ c.name client,
+ c.fi,
+ sub.paymentDate,
+ 0 invoiceAmount,
+ CAST(sub.receipt AS DECIMAL(10,2)) receiptAmount,
+ 0 currentAmount,
+ sub.companyFk,
+ c.socialName,
+ CAST(sub.receipt AS DECIMAL(10,2)) totalAmount,
+ CAST(sub.receipt AS DECIMAL(10,2)) balance,
+ s.name company,
+ co.code companyCode,
+ c.accountingAccount,
+ c.iban,
+ c.hasSepaVnl,
+ c.hasCoreVnl,
+ c.hasLcr,
+ be.bic,
+ be.`name` entityName
+ FROM client c
+ JOIN (
+ SELECT risk.companyFk,
+ c.id,
+ SUM(risk.amount) receipt,
+ IF((c.dueDay + graceDays) MOD 30.001 <= DAY(vDated),
+ LAST_DAY(vDated - INTERVAL 1 MONTH) + INTERVAL (c.dueDay + graceDays) MOD 30.001 DAY,
+ LAST_DAY(vDated - INTERVAL 2 MONTH) + INTERVAL (c.dueDay + graceDays) MOD 30.001 DAY
+ ) paymentDate
+ FROM client c
+ JOIN payMethod pm ON pm.id = c.payMethodFk
+ JOIN (
+ SELECT cr.companyFk, cr.clientFk, cr.amount
+ FROM client c
+ JOIN clientRisk cr ON cr.clientFk = c.id
+ JOIN payMethod pm ON pm.id = c.payMethodFk
+ WHERE pm.code = 'bankDraft'
+ UNION ALL
+ SELECT io.companyFk, io.clientFk, - io.amount
+ FROM invoiceOut io
+ JOIN client c ON c.id = io.clientFk
+ JOIN payMethod pm ON pm.id = c.payMethodFk
+ WHERE io.dued > vDated
+ AND pm.code = 'bankDraft'
+ AND pm.outstandingDebt
+ AND io.amount > 0
+
+ ) risk ON risk.clientFk = c.id
+ GROUP BY risk.companyFk, c.id
+ HAVING receipt > 10
+ ) sub ON sub.id = c.id
+ JOIN supplier s ON s.id = sub.companyFk
+ JOIN company co ON co.id = sub.companyFk
+ LEFT JOIN bankEntity be ON be.id = c.bankEntityFk;
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/procedures/riskAllClients.sql b/db/routines/vn/procedures/riskAllClients.sql
deleted file mode 100644
index 66c0a0dd5..000000000
--- a/db/routines/vn/procedures/riskAllClients.sql
+++ /dev/null
@@ -1,29 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`riskAllClients`(maxRiskDate DATE)
-BEGIN
-
- DROP TEMPORARY TABLE IF EXISTS tmp.client_list;
- CREATE TEMPORARY TABLE tmp.client_list
- (PRIMARY KEY (Id_Cliente))
- ENGINE = MEMORY
- SELECT id Id_Cliente, null grade FROM vn.client;
-
- CALL vn2008.risk_vs_client_list(maxRiskDate);
-
- SELECT
- c.RazonSocial,
- c.Id_Cliente,
- c.Credito,
- CAST(r.risk as DECIMAL (10,2)) risk,
- CAST(c.Credito - r.risk as DECIMAL (10,2)) Diferencia,
- c.Id_Pais
- FROM
- vn2008.Clientes c
- JOIN tmp.risk r ON r.Id_Cliente = c.Id_Cliente
- JOIN tmp.client_list ci ON c.Id_Cliente = ci.Id_Cliente
- GROUP BY c.Id_cliente;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.risk;
- DROP TEMPORARY TABLE IF EXISTS tmp.client_list;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn/procedures/sale_boxPickingPrint.sql b/db/routines/vn/procedures/sale_boxPickingPrint.sql
new file mode 100644
index 000000000..dbb3b6c14
--- /dev/null
+++ b/db/routines/vn/procedures/sale_boxPickingPrint.sql
@@ -0,0 +1,286 @@
+DELIMITER $$
+$$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE vn.sale_boxPickingPrint(
+ IN vPrinterFk INT,
+ IN vSaleFk INT,
+ IN vPacking INT,
+ IN vSectorFk INT,
+ IN vUserFk INT,
+ IN vPackagingFk VARCHAR(10),
+ IN vPackingSiteFk INT)
+BEGIN
+/** Splits a line of sale to a different ticket and prints the transport sticker
+ */
+ DECLARE vAgencyModeFk INT;
+ DECLARE vConcept VARCHAR(30);
+ DECLARE vExpeditionFk INT;
+ DECLARE vItemFk INT;
+ DECLARE vItemShelvingFk INT;
+ DECLARE vItemShelvingSaleFk INT;
+ DECLARE vItemShelvingSaleFk_old INT;
+ DECLARE vLastExpeditionTimeStamp DATETIME;
+ DECLARE vMaxPhoneLength INT DEFAULT 11;
+ DECLARE vMaxStreetLength INT DEFAULT 36;
+ DECLARE vNewSaleFk INT;
+ DECLARE vNewTicketFk INT;
+ DECLARE vParkingCode VARCHAR(10);
+ DECLARE vQuantity INT;
+ DECLARE vRemainder INT DEFAULT 0;
+ DECLARE vRemainderSaleFk INT;
+ DECLARE vShelving VARCHAR(10);
+ DECLARE vTicketFk INT;
+
+ SELECT s.quantity,
+ s.quantity MOD vPacking,
+ s.ticketFk,
+ s.itemFk,
+ s.concept
+ INTO vQuantity,
+ vRemainder,
+ vTicketFk,
+ vItemFk,
+ vConcept
+ FROM sale s
+ WHERE s.id = vSaleFk;
+
+ IF vRemainder THEN
+ UPDATE sale SET quantity = quantity - vRemainder WHERE id = vSaleFk;
+
+ INSERT INTO sale(ticketFk, itemFk, quantity, price, discount, concept)
+ SELECT ticketFk, itemFk, vRemainder, price, discount, concept
+ FROM sale
+ WHERE id = vSaleFk;
+
+ SET vRemainderSaleFk = LAST_INSERT_ID();
+
+ INSERT INTO saleComponent(saleFk, componentFk, value)
+ SELECT vRemainderSaleFk, componentFk, value
+ FROM saleComponent
+ WHERE saleFk = vSaleFk;
+ END IF;
+
+w1: WHILE vQuantity >= vPacking DO
+
+ SET vQuantity = vQuantity - vPacking;
+
+ SET vItemShelvingFk = NULL;
+
+ SELECT sub.id
+ INTO vItemShelvingFk
+ FROM productionConfig pc
+ JOIN (
+ SELECT ish.id,
+ ish.visible - IFNULL(SUM(iss.quantity),0) available,
+ p.pickingOrder,
+ ish.created
+ FROM itemShelving ish
+ JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN parking p ON p.id = sh.parkingFk
+ LEFT JOIN itemShelvingSale iss
+ ON iss.itemShelvingFk = ish.id
+ AND iss.created >= CURDATE()
+ AND iss.isPicked = FALSE
+ WHERE ish.itemFk = vItemFk
+ AND p.sectorFk = vSectorFk
+ GROUP BY ish.id
+ HAVING available >= vPacking) sub
+ ORDER BY IF(pc.orderMode = 'Location',sub.pickingOrder, sub.created)
+ LIMIT 1;
+
+ IF vItemShelvingFk THEN
+ INSERT INTO itemShelvingSale
+ SET itemShelvingFk = vItemShelvingFk,
+ saleFk = vSaleFk,
+ quantity = vPacking,
+ userFk = vUserFk,
+ isPicked = TRUE;
+
+ SET vItemShelvingSaleFk = LAST_INSERT_ID();
+
+ UPDATE sale SET isPicked = FALSE WHERE id = vSaleFk;
+ ELSE
+ LEAVE w1;
+ END IF;
+
+ SET vNewTicketFk = NULL;
+
+ SELECT MAX(t.id) INTO vNewTicketFk
+ FROM ticket t
+ JOIN ticketLastState tls ON tls.ticketFk = t.id
+ JOIN (SELECT addressFk, clientFk, date(shipped) shipped, warehouseFk
+ FROM ticket
+ WHERE id = vTicketFk) tt
+ ON tt.addressFk = t.addressFk
+ AND tt.clientFk = t.clientFk
+ AND t.shipped BETWEEN tt.shipped AND util.dayend(tt.shipped)
+ AND t.warehouseFk = tt.warehouseFk
+ WHERE tls.name = 'Encajado' ;
+
+ IF ISNULL(vNewTicketFk) THEN
+ INSERT INTO ticket( clientFk,
+ shipped,
+ addressFk,
+ agencyModeFk,
+ nickname,
+ warehouseFk,
+ companyFk,
+ landed,
+ zoneFk,
+ zonePrice,
+ zoneBonus,
+ routeFk,
+ priority,
+ hasPriority,
+ clonedFrom)
+ SELECT clientFk,
+ shipped,
+ addressFk,
+ agencyModeFk,
+ nickname,
+ warehouseFk,
+ companyFk,
+ landed,
+ zoneFk,
+ zonePrice,
+ zoneBonus,
+ routeFk,
+ priority,
+ hasPriority,
+ id
+ FROM ticket
+ WHERE id = vTicketFk;
+
+ SET vNewTicketFk = LAST_INSERT_ID();
+
+ INSERT INTO ticketTracking(ticketFk, stateFk, userFk)
+ SELECT vNewTicketFk, id, vUserFk
+ FROM state
+ WHERE code = 'PACKED';
+ END IF;
+
+ UPDATE sale SET quantity = quantity - vPacking WHERE id = vSaleFk;
+
+ UPDATE itemShelving SET visible = visible - vPacking WHERE id = vItemShelvingFk;
+
+ SET vNewSaleFk = NULL;
+
+ SELECT MAX(id) INTO vNewSaleFk
+ FROM sale
+ WHERE ticketFk = vNewTicketFk
+ AND itemFk = vItemFk;
+
+ IF vNewSaleFk THEN
+ UPDATE sale
+ SET quantity = quantity + vPacking
+ WHERE id = vNewSaleFk;
+
+ SET vItemShelvingSaleFk_old = NULL;
+
+ SELECT MAX(id) INTO vItemShelvingSaleFk_old
+ FROM itemShelvingSale
+ WHERE itemShelvingFk = vItemShelvingFk
+ AND saleFk = vNewSaleFk;
+
+ IF vItemShelvingSaleFk_old THEN
+ UPDATE itemShelvingSale
+ SET quantity = quantity + vPacking
+ WHERE id = vItemShelvingSaleFk_old;
+
+ DELETE FROM itemShelvingSale
+ WHERE id = vItemShelvingSaleFk;
+
+ SET vItemShelvingSaleFk = vItemShelvingSaleFk_old;
+ ELSE
+ UPDATE itemShelvingSale
+ SET saleFk = vNewSaleFk
+ WHERE id = vItemShelvingSaleFk;
+ END IF;
+ ELSE
+ INSERT INTO sale(ticketFk, itemFk, concept, quantity, discount, price)
+ SELECT vNewTicketFk, itemFk, concept, vPacking, discount, price
+ FROM sale
+ WHERE id = vSaleFk;
+
+ SET vNewSaleFk = LAST_INSERT_ID();
+
+ INSERT INTO saleComponent(saleFk, componentFk, value, isGreuge)
+ SELECT vNewSaleFk, componentFk, value, isGreuge
+ FROM saleComponent
+ WHERE saleFk = vSaleFk;
+
+ UPDATE itemShelvingSale
+ SET saleFk = vNewSaleFk
+ WHERE id = vItemShelvingSaleFk;
+
+ END IF;
+
+ INSERT IGNORE INTO saleTracking(saleFk, isChecked, workerFk, stateFk)
+ SELECT vNewSaleFk, TRUE, vUserFk, id
+ FROM state
+ WHERE code = 'PREPARED';
+
+ SELECT agencyModeFk INTO vAgencyModeFk
+ FROM ticket
+ WHERE id = vNewTicketFk;
+
+ INSERT INTO expedition(
+ agencyModeFk,
+ ticketFk,
+ freightItemFk,
+ workerFk,
+ packagingFk,
+ itemPackingTypeFk,
+ hostFk,
+ packingSiteFk,
+ monitorId,
+ started,
+ ended
+ )
+ SELECT vAgencyModeFk,
+ vNewTicketFk,
+ pc.defaultFreightItemFk,
+ vUserFk,
+ vPackagingFk,
+ ps.code,
+ h.code,
+ vPackingSiteFk,
+ ps.monitorId,
+ IFNULL(vLastExpeditionTimeStamp, NOW()),
+ NOW()
+ FROM packingSite ps
+ JOIN host h ON h.id = ps.hostFk
+ JOIN productionConfig pc
+ WHERE ps.id = vPackingSiteFk;
+
+ SET vExpeditionFk = LAST_INSERT_ID();
+
+ SET vLastExpeditionTimeStamp = NOW();
+
+ CALL dipole.expedition_Add(vExpeditionFk,vPrinterFk, TRUE);
+
+ SELECT shelvingFk, p.code
+ INTO vShelving, vParkingCode
+ FROM itemShelving ish
+ JOIN shelving sh ON sh.code = ish.shelvingFk
+ JOIN parking p ON p.id = sh.parkingFk
+ WHERE ish.id = vItemShelvingFk;
+
+ UPDATE dipole.expedition_PrintOut
+ SET isPrinted = FALSE,
+ itemFk = vItemFk,
+ quantity = vPacking,
+ longName = vConcept,
+ shelvingFk = vShelving,
+ parkingCode = vParkingCode,
+ phone = RIGHT(phone,vMaxPhoneLength),
+ street = RIGHT(street, vMAxStreetLength)
+ WHERE expeditionFk = vExpeditionFk;
+
+ DELETE FROM sale
+ WHERE quantity = 0
+ AND id = vSaleFk;
+
+ END WHILE;
+
+END$$
+DELIMITER ;
\ No newline at end of file
diff --git a/db/routines/vn/procedures/sale_checkNoComponents.sql b/db/routines/vn/procedures/sale_checkNoComponents.sql
deleted file mode 100644
index 79abbbf92..000000000
--- a/db/routines/vn/procedures/sale_checkNoComponents.sql
+++ /dev/null
@@ -1,70 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_checkNoComponents`(vCreatedFrom DATETIME, vCreatedTo DATETIME)
-BEGIN
-/**
- * Comprueba que las ventas creadas entre un rango de fechas tienen componentes
- *
- * @param vCreatedFrom inicio del rango
- * @param vCreatedTo fin del rango
- */
- DECLARE v_done BOOL DEFAULT FALSE;
- DECLARE vSaleFk INTEGER;
- DECLARE vTicketFk INTEGER;
- DECLARE vConcept VARCHAR(50);
- DECLARE vCur CURSOR FOR
- SELECT s.id
- FROM sale s
- JOIN ticket t ON t.id = s.ticketFk
- JOIN item i ON i.id = s.itemFk
- JOIN itemType tp ON tp.id = i.typeFk
- JOIN itemCategory ic ON ic.id = tp.categoryFk
- LEFT JOIN tmp.coste c ON c.id = s.id
- WHERE s.created >= vCreatedFrom AND s.created <= vCreatedTo
- AND c.id IS NULL
- AND t.agencyModeFk IS NOT NULL
- AND t.isDeleted IS FALSE
- AND t.warehouseFk = 60
- AND ic.merchandise != FALSE
- GROUP BY s.id;
-
- 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 sale s
- 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 = 6
- WHERE s.created >= vCreatedFrom
- AND ic.merchandise != FALSE;
-
- OPEN vCur;
-
- l: LOOP
- SET v_done = FALSE;
- FETCH vCur INTO vSaleFk;
-
- IF v_done THEN
- LEAVE l;
- END IF;
-
- SELECT ticketFk, concept
- INTO vTicketFk, vConcept
- FROM sale
- WHERE id = vSaleFk;
-
- CALL sale_calculateComponent(vSaleFk, 'renewPrices');
- END LOOP;
-
- CLOSE vCur;
- DROP TEMPORARY TABLE tmp.coste;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn/procedures/sale_getBoxPickingList.sql b/db/routines/vn/procedures/sale_getBoxPickingList.sql
index 0af23e945..7466eb9be 100644
--- a/db/routines/vn/procedures/sale_getBoxPickingList.sql
+++ b/db/routines/vn/procedures/sale_getBoxPickingList.sql
@@ -27,7 +27,7 @@ BEGIN
s.quantity,
MAKETIME(pb.HH,pb.mm,0) etd,
pb.routeFk,
- FLOOR(s.quantity / ish.packing) stickers,
+ FLOOR(s.quantity / IF(i.isBoxPickingMode, ish.packing, i.packingOut)) stickers,
IF(i.isBoxPickingMode, ish.packing, i.packingOut) packing,
b.packagingFk
FROM sale s
@@ -46,6 +46,7 @@ BEGIN
JOIN parking p ON p.id = sh.parkingFk
JOIN tmp.productionBuffer pb ON pb.ticketFk = s.ticketFk
JOIN agencyMode am ON am.id = pb.agencyModeFk
+ JOIN agency a ON a .id = am.agencyFk
LEFT JOIN routesMonitor rm ON rm.routeFk = pb.routeFk
LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = s.id
LEFT JOIN ticketState ts ON ts.ticketFk = s.ticketFk
@@ -60,6 +61,7 @@ BEGIN
AND ((rm.bufferFk AND rm.isPickingAllowed)
OR am.code = 'REC_ALG')
AND pb.shipped = vDated
+ AND a.isOwn
GROUP BY s.id
ORDER BY etd;
@@ -71,5 +73,3 @@ BEGIN
DROP TEMPORARY TABLE tmp.sale;
END$$
DELIMITER ;
-
-CALL `vn`.`sale_getBoxPickingList`(1, curdate());
\ No newline at end of file
diff --git a/db/routines/vn/procedures/sale_getFromTicketOrCollection.sql b/db/routines/vn/procedures/sale_getFromTicketOrCollection.sql
index e0cff202f..5308bdd28 100644
--- a/db/routines/vn/procedures/sale_getFromTicketOrCollection.sql
+++ b/db/routines/vn/procedures/sale_getFromTicketOrCollection.sql
@@ -79,7 +79,10 @@ DECLARE vIsCollection BOOL;
IF(SUM(iss.quantity) IS NULL, 0, SUM(iss.quantity)) pickedQuantity,
MIN(iss.created) picked,
IF(sm.id, TRUE, FALSE) hasMistake,
- sg.sectorFk
+ sg.sectorFk,
+ b.packing,
+ b.grouping,
+ o.code
FROM tmp.ticket t
JOIN sale s ON s.ticketFk = t.id
JOIN ticket tt ON tt.id = t.id
diff --git a/db/routines/vn/procedures/sale_replaceItem.sql b/db/routines/vn/procedures/sale_replaceItem.sql
index aff34d5e9..056397274 100644
--- a/db/routines/vn/procedures/sale_replaceItem.sql
+++ b/db/routines/vn/procedures/sale_replaceItem.sql
@@ -13,7 +13,7 @@ BEGIN
DECLARE vWarehouseFk SMALLINT;
DECLARE vDate DATE;
DECLARE vGrouping INT;
- DECLARE vGroupingModeFk INT;
+ DECLARE vGroupingMode VARCHAR(255);
DECLARE vPacking INT;
DECLARE vRoundQuantity INT DEFAULT 1;
DECLARE vLanded DATE;
@@ -23,8 +23,6 @@ BEGIN
DECLARE vOldPrice DECIMAL(10,2);
DECLARE vOption VARCHAR(255);
DECLARE vNewSaleFk INT;
- DECLARE vForceToGrouping INT DEFAULT 1;
- DECLARE vForceToPacking INT DEFAULT 2;
DECLARE vFinalPrice DECIMAL(10,2);
DECLARE EXIT HANDLER FOR SQLEXCEPTION
@@ -58,15 +56,15 @@ BEGIN
CALL buyUltimate(vWarehouseFk, vDate);
SELECT `grouping`, groupingMode, packing
- INTO vGrouping,vGroupingModeFk,vPacking
+ INTO vGrouping,vGroupingMode,vPacking
FROM buy b
JOIN tmp.buyUltimate tmp ON b.id = tmp.buyFk
WHERE tmp.itemFk = vNewItemFk AND tmp.WarehouseFk = vWarehouseFk;
- IF vGroupingModeFk = vForceToPacking AND vPacking > 0 THEN
+ IF vGroupingMode = 'packing' AND vPacking > 0 THEN
SET vRoundQuantity = vPacking;
END IF;
- IF vGroupingModeFk = vForceToGrouping AND vGrouping > 0 THEN
+ IF vGroupingMode = 'grouping' AND vGrouping > 0 THEN
SET vRoundQuantity = vGrouping;
END IF;
@@ -77,11 +75,9 @@ BEGIN
vNewItemFk);
SELECT price INTO vNewPrice
- FROM tmp.ticketCalculateItem;
-
- IF vNewPrice IS NULL THEN
- CALL util.throw('price retrieval failed');
- END IF;
+ FROM tmp.ticketComponentPrice
+ ORDER BY (vQuantity % `grouping`) ASC
+ LIMIT 1;
IF vNewPrice > vOldPrice THEN
SET vFinalPrice = vOldPrice;
@@ -104,7 +100,7 @@ BEGIN
price)
SELECT vTicketFk,
vNewItemFk,
- CEIL(vQuantity / vRoundQuantity) * vRoundQuantity, CONCAT('+ ',i.longName),
+ CEIL(vQuantity / vRoundQuantity) * vRoundQuantity, CONCAT('+ ', i.name),
vFinalPrice
FROM vn.item i
WHERE id = vNewItemFk;
diff --git a/db/routines/vn/procedures/solunionRiskRequest.sql b/db/routines/vn/procedures/solunionRiskRequest.sql
deleted file mode 100644
index b735bea33..000000000
--- a/db/routines/vn/procedures/solunionRiskRequest.sql
+++ /dev/null
@@ -1,31 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`solunionRiskRequest`()
-BEGIN
-
- DROP TEMPORARY TABLE IF EXISTS tmp.client_list;
- CREATE TEMPORARY TABLE tmp.client_list
- (PRIMARY KEY (Id_Cliente))
- ENGINE = MEMORY
- SELECT * FROM (SELECT cc.client Id_Cliente, ci.grade FROM vn.creditClassification cc
- JOIN vn.creditInsurance ci ON cc.id = ci.creditClassification
- WHERE dateEnd IS NULL
- ORDER BY ci.creationDate DESC
- LIMIT 10000000000000000000) t1 GROUP BY Id_Cliente;
-
- CALL vn2008.risk_vs_client_list(util.VN_CURDATE());
-
- SELECT
- c.Id_Cliente, c.Cliente, c.Credito credito_vn, c.creditInsurance solunion, cast(r.risk as DECIMAL(10,0)) riesgo_vivo,
- cast(c.creditInsurance - r.risk as decimal(10,0)) margen_vivo,
- f.Consumo consumo_anual, c.Vencimiento, ci.grade
- FROM
- vn2008.Clientes c
- JOIN tmp.risk r ON r.Id_Cliente = c.Id_Cliente
- JOIN tmp.client_list ci ON c.Id_Cliente = ci.Id_Cliente
- JOIN bi.facturacion_media_anual f ON c.Id_Cliente = f.Id_Cliente
- GROUP BY Id_cliente;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.risk;
- DROP TEMPORARY TABLE IF EXISTS tmp.client_list;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn/procedures/supplier_statement.sql b/db/routines/vn/procedures/supplier_statement.sql
index 406286e9d..a03a7770c 100644
--- a/db/routines/vn/procedures/supplier_statement.sql
+++ b/db/routines/vn/procedures/supplier_statement.sql
@@ -94,7 +94,7 @@ BEGIN
'payment'
FROM payment p
LEFT JOIN currency c ON c.id = p.currencyFk
- LEFT JOIN bank b ON b.id = p.bankFk
+ LEFT JOIN accounting a ON a.id = p.bankFk
LEFT JOIN payMethod pm ON pm.id = p.payMethodFk
LEFT JOIN promissoryNote pn ON pn.paymentFk = p.id
WHERE p.received > '2014-12-31'
diff --git a/db/routines/vn/procedures/ticketCalculateFromType.sql b/db/routines/vn/procedures/ticketCalculateFromType.sql
index 106e0aecc..63f4b8941 100644
--- a/db/routines/vn/procedures/ticketCalculateFromType.sql
+++ b/db/routines/vn/procedures/ticketCalculateFromType.sql
@@ -11,7 +11,7 @@ BEGIN
SELECT id itemFk FROM vn.item
WHERE typeFk = vTypeFk;
- CALL catalog_calculate(vLanded, vAddressFk, vAgencyModeFk);
+ CALL catalog_calculate(vLanded, vAddressFk, vAgencyModeFk, FALSE);
DROP TEMPORARY TABLE tmp.item;
DROP TEMPORARY TABLE tmp.ticketLot;
END$$
diff --git a/db/routines/vn/procedures/ticketClon.sql b/db/routines/vn/procedures/ticketClon.sql
index 81328bc11..9144ac709 100644
--- a/db/routines/vn/procedures/ticketClon.sql
+++ b/db/routines/vn/procedures/ticketClon.sql
@@ -1,55 +1,10 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketClon`(vTicketFk INT, vNewShipped DATE)
BEGIN
-
- DECLARE done INT DEFAULT FALSE;
- DECLARE vNewTicketFk INT;
- DECLARE vOldSaleFk INT;
- DECLARE vNewSaleFk INT;
-
- DECLARE cur1 CURSOR FOR
- SELECT id
- FROM vn.sale
- WHERE ticketFk = vTicketFk;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
-
- SET vNewShipped = IFNULL(vNewShipped, util.VN_CURDATE());
-
- CALL vn.ticket_Clone(vTicketFk, vNewTicketFk);
-
- UPDATE vn.ticket
- SET landed = TIMESTAMPADD(DAY, DATEDIFF(vNewShipped, shipped), landed),
- shipped = vNewShipped
- WHERE id = vNewTicketFk;
-
- OPEN cur1;
-
- read_loop: LOOP
-
- FETCH cur1 INTO vOldSaleFk;
-
- IF done THEN
- LEAVE read_loop;
- END IF;
-
- INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed)
- SELECT vNewTicketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed
- FROM vn.sale
- WHERE id = vOldSaleFk;
-
- SELECT max(id) INTO vNewSaleFk
- FROM vn.sale
- WHERE ticketFk = vNewTicketFk;
-
- INSERT INTO vn.saleComponent(saleFk, componentFk, value, isGreuge)
- SELECT vNewSaleFk, componentFk, value, isGreuge
- FROM vn.saleComponent
- WHERE saleFk = vOldSaleFk;
-
- END LOOP;
- CLOSE cur1;
-
+ DECLARE vNewTicketFk INT;
+
+ CALL ticket_cloneAll(vTicketFk, vNewShipped, TRUE, vNewTicketFk);
+
END$$
DELIMITER ;
diff --git a/db/routines/vn/procedures/ticket_cloneAll.sql b/db/routines/vn/procedures/ticket_cloneAll.sql
new file mode 100644
index 000000000..4b3401ed7
--- /dev/null
+++ b/db/routines/vn/procedures/ticket_cloneAll.sql
@@ -0,0 +1,55 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_cloneAll`(vTicketFk INT, vNewShipped DATE, vWithWarehouse BOOLEAN, OUT vNewTicketFk INT)
+BEGIN
+
+ DECLARE vDone BOOLEAN DEFAULT FALSE;
+ DECLARE vOldSaleFk INT;
+ DECLARE vNewSaleFk INT;
+
+ DECLARE cur1 CURSOR FOR
+ SELECT id
+ FROM sale
+ WHERE ticketFk = vTicketFk;
+
+ DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
+
+ SET vNewShipped = IFNULL(vNewShipped, util.VN_CURDATE());
+
+ CALL ticket_Clone(vTicketFk, vNewTicketFk);
+
+ UPDATE ticket
+ SET landed = TIMESTAMPADD(DAY, DATEDIFF(vNewShipped, shipped), landed),
+ shipped = vNewShipped,
+ warehouseFk = IF(vWithWarehouse, warehouseFk, NULL)
+ WHERE id = vNewTicketFk;
+
+ OPEN cur1;
+
+ read_loop: LOOP
+
+ FETCH cur1 INTO vOldSaleFk;
+
+ IF vDone THEN
+ LEAVE read_loop;
+ END IF;
+
+ INSERT INTO sale(ticketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed)
+ SELECT vNewTicketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed
+ FROM sale
+ WHERE id = vOldSaleFk;
+
+ SELECT max(id) INTO vNewSaleFk
+ FROM sale
+ WHERE ticketFk = vNewTicketFk;
+
+ INSERT INTO saleComponent(saleFk, componentFk, value, isGreuge)
+ SELECT vNewSaleFk, componentFk, value, isGreuge
+ FROM saleComponent
+ WHERE saleFk = vOldSaleFk;
+
+ END LOOP;
+
+ CLOSE cur1;
+
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/procedures/ticket_closeByTicket.sql b/db/routines/vn/procedures/ticket_closeByTicket.sql
index 93772225b..837b809a2 100644
--- a/db/routines/vn/procedures/ticket_closeByTicket.sql
+++ b/db/routines/vn/procedures/ticket_closeByTicket.sql
@@ -15,10 +15,11 @@ BEGIN
JOIN agencyMode am ON am.id = t.agencyModeFk
LEFT JOIN ticketState ts ON ts.ticketFk = t.id
JOIN alertLevel al ON al.id = ts.alertLevel
- WHERE al.code = 'PACKED' OR (am.code = 'refund' AND al.code != 'delivered')
+ WHERE (al.code = 'PACKED' OR (am.code = 'refund' AND al.code != 'delivered'))
AND t.id = vTicketFk
AND t.refFk IS NULL
- GROUP BY t.id);
+ GROUP BY t.id
+ );
CALL ticket_close();
diff --git a/db/routines/vn/procedures/ticket_doCmr.sql b/db/routines/vn/procedures/ticket_doCmr.sql
index 5789d09de..61d8da5f9 100644
--- a/db/routines/vn/procedures/ticket_doCmr.sql
+++ b/db/routines/vn/procedures/ticket_doCmr.sql
@@ -1,5 +1,5 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_doCmr`(vSelf INT)
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_doCmr`(vSelf INT)
BEGIN
/**
* Crea u actualiza la información del CMR asociado con
@@ -29,7 +29,6 @@ BEGIN
JOIN province p ON p.id = a.provinceFk
JOIN country co ON co.id = p.countryFk
JOIN agencyMode am ON am.id = t.agencyModeFk
- JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
JOIN warehouse w ON w.id = t.warehouseFk
JOIN company com ON com.id = t.companyFk
JOIN client c2 ON c2.id = com.clientFk
@@ -38,12 +37,10 @@ BEGIN
LEFT JOIN route r ON r.id = t.routeFk
LEFT JOIN worker wo ON wo.id = r.workerFk
LEFT JOIN vehicle v ON v.id = r.vehicleFk
- WHERE t.shipped BETWEEN util.yesterday() AND util.dayEnd(util.VN_CURDATE())
- AND al.code IN ('PACKED', 'DELIVERED')
+ WHERE al.code IN ('PACKED', 'DELIVERED')
AND co.code <> 'ES'
AND am.name <> 'ABONO'
AND w.code = 'ALG'
- AND dm.code = 'DELIVERY'
AND t.id = vSelf
GROUP BY t.id;
@@ -85,5 +82,5 @@ BEGIN
COMMIT;
DROP TEMPORARY TABLE tTicket;
-END$$
-DELIMITER ;
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/procedures/zone_getAddresses.sql b/db/routines/vn/procedures/zone_getAddresses.sql
index 1412c7ab3..ce7b0204e 100644
--- a/db/routines/vn/procedures/zone_getAddresses.sql
+++ b/db/routines/vn/procedures/zone_getAddresses.sql
@@ -28,7 +28,7 @@ BEGIN
SELECT c.id clientFk,
c.name,
c.phone,
- c.mobile,
+ bt.description,
c.salesPersonFk,
u.name username,
aai.invoiced,
@@ -44,10 +44,11 @@ BEGIN
LEFT JOIN bs.clientNewBorn cnb ON cnb.clientFk = c.id
LEFT JOIN vn.annualAverageInvoiced aai ON aai.clientFk = c.id
JOIN vn.clientType ct ON ct.code = c.typeFk
+ JOIN vn.businessType bt ON bt.code = c.businessTypeFk
WHERE a.isActive
AND c.isActive
AND ct.code = 'normal'
- AND c.businessTypeFk <> 'worker'
+ AND bt.code <> 'worker'
GROUP BY c.id;
DROP TEMPORARY TABLE tmp.zoneNodes;
diff --git a/db/routines/vn/procedures/zone_getCollisions.sql b/db/routines/vn/procedures/zone_getCollisions.sql
index f6779e1b7..023b9aac2 100644
--- a/db/routines/vn/procedures/zone_getCollisions.sql
+++ b/db/routines/vn/procedures/zone_getCollisions.sql
@@ -1,8 +1,9 @@
DELIMITER $$
+
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getCollisions`()
BEGIN
/**
- * Calcula si para un mismo codigo postal y dia
+ * Calcula si para un mismo codigo postal y dia
* hay mas de una zona configurada y manda correo
*
*/
@@ -10,17 +11,18 @@ BEGIN
DECLARE vZoneFk INT;
DECLARE vIsDone INT DEFAULT FALSE;
DECLARE vTableCollisions TEXT;
+ DECLARE json_data JSON;
DECLARE cur1 CURSOR FOR SELECT zoneFk from tmp.zoneOption;
-
+
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE;
DROP TEMPORARY TABLE IF EXISTS tmp.zone;
CREATE TEMPORARY TABLE tmp.zone
- SELECT z.id
+ SELECT z.id
FROM zone z
JOIN agencyMode am ON am.id = z.agencyModeFk
JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
- WHERE dm.code IN ('AGENCY','DELIVERY');
+ WHERE dm.code IN ('AGENCY','DELIVERY');
CALL zone_getOptionsForShipment(util.VN_CURDATE(),FALSE);
@@ -35,7 +37,7 @@ BEGIN
PRIMARY KEY zoneFkk (zoneFk, geoFk),
INDEX(geoFk))
ENGINE = MyISAM;
-
+
OPEN cur1;
cur1Loop: LOOP
SET vIsDone = FALSE;
@@ -43,82 +45,63 @@ BEGIN
IF vIsDone THEN
LEAVE cur1Loop;
END IF;
-
+
CALL zone_getLeaves(vZoneFk, NULL, NULL, TRUE);
- myLoop: LOOP
+ myLoop: LOOP
SET vGeoFk = NULL;
- SELECT geoFk INTO vGeoFk
+ SELECT geoFk INTO vGeoFk
FROM tmp.zoneNodes zn
WHERE NOT isChecked
LIMIT 1;
-
+
IF vGeoFk IS NULL THEN
LEAVE myLoop;
END IF;
-
+
CALL zone_getLeaves(vZoneFk, vGeoFk, NULL, TRUE);
UPDATE tmp.zoneNodes
- SET isChecked = TRUE
+ SET isChecked = TRUE
WHERE geoFk = vGeoFk;
END LOOP;
END LOOP;
CLOSE cur1;
- DELETE FROM tmp.zoneNodes
+ DELETE FROM tmp.zoneNodes
WHERE sons > 0;
-
+
DROP TEMPORARY TABLE IF EXISTS geoCollision;
CREATE TEMPORARY TABLE geoCollision
SELECT z.agencyModeFk, zn.geoFk, zw.warehouseFk
FROM tmp.zoneNodes zn
JOIN zone z ON z.id = zn.zoneFk
- JOIN zoneWarehouse zw ON z.id = zw.zoneFk
+ JOIN zoneWarehouse zw ON z.id = zw.zoneFk
GROUP BY z.agencyModeFk, zn.geoFk, zw.warehouseFk
HAVING count(*) > 1;
-
- SELECT '
-
- C.Postal |
- Número de zona |
- Precio |
- Zona |
- Almacén |
- Salix |
-
' INTO vTableCollisions;
-
- INSERT INTO mail (receiver,replyTo,subject,body)
- SELECT 'pepe@verdnatura.es' receiver,
- 'noreply@verdnatura.es' replyTo,
- CONCAT('Colisiones en zonas ', util.VN_CURDATE()) subject,
- CONCAT(vTableCollisions,
- GROUP_CONCAT(sub.td SEPARATOR ''),
- '
') body
- FROM(SELECT
- CONCAT('
- ', zn.name, ' |
- ', zoneFk,' |
- ', z.price,' |
- ', z.name,' |
- ', w.name, ' |
- ', CONCAT(''
- 'https://salix.verdnatura.es/#!/zone/',
- zoneFk,
- '/location?q=%7B%22search%22:%22',
- zn.name,
- '%22%7D'),' |
-
') td
- FROM tmp.zoneNodes zn
- JOIN zone z ON z.id = zn.zoneFk
- JOIN geoCollision gc ON gc.agencyModeFk = z.agencyModeFk AND zn.geoFk = gc.geoFk
- JOIN warehouse w ON w.id = gc.warehouseFk) sub;
-
- DROP TEMPORARY TABLE
- geoCollision,
+
+ -- Recojo los datos de la zona que ha dado conflicto
+ SELECT JSON_ARRAYAGG(
+ JSON_OBJECT(
+ 'zoneFk', zoneFk,
+ 'zn', JSON_OBJECT('name', zn.name),
+ 'z', JSON_OBJECT('name', z.name,'price', z.price),
+ 'w', JSON_OBJECT('name', w.name)
+ )
+ ) FROM tmp.zoneNodes zn
+ JOIN zone z ON z.id = zn.zoneFk
+ JOIN geoCollision gc ON gc.agencyModeFk = z.agencyModeFk AND zn.geoFk = gc.geoFk
+ JOIN warehouse w ON w.id = gc.warehouseFk
+ INTO json_data;
+
+ -- Creo un registro de la notificacion 'zone-included' para reportar via email
+ SELECT util.notification_send(
+ 'zone-included',
+ JSON_OBJECT('zoneCollisions',json_data),
+ account.myUser_getId()
+ );
+
+ DROP TEMPORARY TABLE
+ geoCollision,
tmp.zone,
tmp.zoneNodes;
END$$
diff --git a/db/routines/vn/triggers/accountReconciliation_beforeInsert.sql b/db/routines/vn/triggers/accountReconciliation_beforeInsert.sql
index c586dc57e..4fedd62b8 100644
--- a/db/routines/vn/triggers/accountReconciliation_beforeInsert.sql
+++ b/db/routines/vn/triggers/accountReconciliation_beforeInsert.sql
@@ -3,13 +3,13 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`accountReconciliation
BEFORE INSERT ON `accountReconciliation`
FOR EACH ROW
- SET NEW.calculatedCode = REPLACE(
- REPLACE(
- REPLACE(
- REPLACE(
- CONCAT(NEW.supplierAccountFk,NEW.operationDated,NEW.amount,NEW.concept,NEW.debitCredit)
- ,' ','')
- ,":",'')
- ,'-','')
- ,'.','')$$
-DELIMITER ;
+ SET NEW.calculatedCode = REGEXP_REPLACE(
+ CONCAT(NEW.supplierAccountFk,
+ NEW.operationDated,
+ NEW.amount,
+ NEW.concept,
+ CAST(NEW.debitCredit AS UNSIGNED)
+ ),
+ '[ :\\-.]', ''
+ )$$
+DELIMITER ;
\ No newline at end of file
diff --git a/db/routines/vn/triggers/buy_beforeDelete.sql b/db/routines/vn/triggers/buy_beforeDelete.sql
index eb7c0ef70..85f1cf298 100644
--- a/db/routines/vn/triggers/buy_beforeDelete.sql
+++ b/db/routines/vn/triggers/buy_beforeDelete.sql
@@ -3,6 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`buy_beforeDelete`
BEFORE DELETE ON `buy`
FOR EACH ROW
BEGIN
+ CALL entry_checkBooked(OLD.entryFk);
IF OLD.printedStickers <> 0 THEN
CALL util.throw("it is not possible to delete buys with printed labels ");
END IF;
diff --git a/db/routines/vn/triggers/buy_beforeInsert.sql b/db/routines/vn/triggers/buy_beforeInsert.sql
index c88bef05a..6ad72916b 100644
--- a/db/routines/vn/triggers/buy_beforeInsert.sql
+++ b/db/routines/vn/triggers/buy_beforeInsert.sql
@@ -6,20 +6,29 @@ trig: BEGIN
DECLARE vWarehouse INT;
DECLARE vLanding DATE;
DECLARE vGrouping INT;
- DECLARE vGroupingMode TINYINT;
+ DECLARE vGroupingMode VARCHAR(255);
DECLARE vGenericFk INT;
DECLARE vGenericInDate BOOL;
+ DECLARE vBuyerFk INT;
IF @isModeInventory THEN
LEAVE trig;
END IF;
+ CALL entry_checkBooked(NEW.entryFk);
IF NEW.printedStickers <> 0 THEN
CALL util.throw('it is not possible to create buy lines with printedstickers other than 0');
END IF;
SET NEW.editorFk = account.myUser_getId();
+ SELECT it.workerFk INTO vBuyerFk
+ FROM item i
+ JOIN itemType it ON it.id = i.typeFk
+ WHERE i.id = NEW.itemFk;
+
+ SET NEW.buyerFk = vBuyerFk;
+
CALL buy_checkGrouping(NEW.`grouping`);
SELECT t.warehouseInFk, t.landed
diff --git a/db/routines/vn/triggers/buy_beforeUpdate.sql b/db/routines/vn/triggers/buy_beforeUpdate.sql
index fc03c456f..2403091c6 100644
--- a/db/routines/vn/triggers/buy_beforeUpdate.sql
+++ b/db/routines/vn/triggers/buy_beforeUpdate.sql
@@ -7,11 +7,13 @@ trig:BEGIN
DECLARE vGenericInDate BOOL;
DECLARE vIsInventory BOOL;
DECLARE vDefaultEntry INT;
+ DECLARE vBuyerFk INT;
IF @isTriggerDisabled THEN
LEAVE trig;
END IF;
+ CALL entry_checkBooked(OLD.entryFk);
SET NEW.editorFk = account.myUser_getId();
SELECT defaultEntry INTO vDefaultEntry
@@ -65,6 +67,15 @@ trig:BEGIN
SET NEW.isIgnored = TRUE;
END IF;
+ IF NOT (NEW.itemFk <=> OLD.itemFk) THEN
+ SELECT it.workerFk INTO vBuyerFk
+ FROM item i
+ JOIN itemType it ON it.id = i.typeFk
+ WHERE i.id = NEW.itemFk;
+
+ SET NEW.buyerFk = vBuyerFk;
+ END IF;
+
IF NOT (NEW.itemFk <=> OLD.itemFk) OR
NOT (OLD.entryFk <=> NEW.entryFk) THEN
CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck
diff --git a/db/routines/vn/triggers/entry_beforeDelete.sql b/db/routines/vn/triggers/entry_beforeDelete.sql
index 82a3dabd5..1d2c84b9e 100644
--- a/db/routines/vn/triggers/entry_beforeDelete.sql
+++ b/db/routines/vn/triggers/entry_beforeDelete.sql
@@ -3,6 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entry_beforeDelete`
BEFORE DELETE ON `entry`
FOR EACH ROW
BEGIN
+ CALL entry_checkBooked(OLD.id);
DELETE FROM buy WHERE entryFk = OLD.id;
END$$
DELIMITER ;
diff --git a/db/routines/vn/triggers/entry_beforeInsert.sql b/db/routines/vn/triggers/entry_beforeInsert.sql
index f475630db..c0c0aa28c 100644
--- a/db/routines/vn/triggers/entry_beforeInsert.sql
+++ b/db/routines/vn/triggers/entry_beforeInsert.sql
@@ -7,6 +7,8 @@ BEGIN
CALL supplier_checkIsActive(NEW.supplierFk);
SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk);
SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk,NEW.supplierFk);
-
+ IF NEW.travelFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.travelFk) THEN
+ CALL util.throw('The travel is incorrect, there is a different AWB in the associated entries');
+ END IF;
END$$
DELIMITER ;
diff --git a/db/routines/vn/triggers/entry_beforeUpdate.sql b/db/routines/vn/triggers/entry_beforeUpdate.sql
index 60b83002c..98ebe1364 100644
--- a/db/routines/vn/triggers/entry_beforeUpdate.sql
+++ b/db/routines/vn/triggers/entry_beforeUpdate.sql
@@ -6,15 +6,24 @@ BEGIN
DECLARE vIsVirtual BOOL;
DECLARE vPrintedCount INT;
DECLARE vHasDistinctWarehouses BOOL;
+
+ IF NEW.isBooked = OLD.isBooked THEN
+ CALL entry_checkBooked(OLD.id);
+ END IF;
SET NEW.editorFk = account.myUser_getId();
- IF !(NEW.travelFk <=> OLD.travelFk) THEN
+ IF NOT (NEW.travelFk <=> OLD.travelFk) THEN
+
+ IF NEW.travelFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.travelFk) THEN
+ CALL util.throw('The travel is incorrect, there is a different AWB in the associated entries');
+ END IF;
+
SELECT COUNT(*) > 0 INTO vIsVirtual
FROM entryVirtual WHERE entryFk = NEW.id;
- SELECT !(o.warehouseInFk <=> n.warehouseInFk)
- OR !(o.warehouseOutFk <=> n.warehouseOutFk)
+ SELECT NOT (o.warehouseInFk <=> n.warehouseInFk)
+ OR NOT (o.warehouseOutFk <=> n.warehouseOutFk)
INTO vHasDistinctWarehouses
FROM travel o, travel n
WHERE o.id = OLD.travelFk
@@ -43,9 +52,8 @@ BEGIN
SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk);
END IF;
- IF NOT (NEW.travelFk <=> OLD.travelFk)
- OR NOT (NEW.currencyFk <=> OLD.currencyFk) THEN
- SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk,NEW.supplierFk);
+ IF NOT (NEW.travelFk <=> OLD.travelFk) OR NOT (NEW.currencyFk <=> OLD.currencyFk) THEN
+ SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk, NEW.supplierFk);
END IF;
END$$
DELIMITER ;
diff --git a/db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql b/db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql
new file mode 100644
index 000000000..f4df48dcd
--- /dev/null
+++ b/db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql
@@ -0,0 +1,8 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInCorrection_beforeDelete`
+ BEFORE DELETE ON `invoiceInCorrection`
+ FOR EACH ROW
+BEGIN
+ CALL invoiceIn_checkBooked(OLD.correctingFk);
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/triggers/invoiceInCorrection_beforeInsert.sql b/db/routines/vn/triggers/invoiceInCorrection_beforeInsert.sql
new file mode 100644
index 000000000..aec58a265
--- /dev/null
+++ b/db/routines/vn/triggers/invoiceInCorrection_beforeInsert.sql
@@ -0,0 +1,8 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInCorrection_beforeInsert`
+ BEFORE INSERT ON `invoiceInCorrection`
+ FOR EACH ROW
+BEGIN
+ CALL invoiceIn_checkBooked(NEW.correctingFk);
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/triggers/invoiceInCorrection_beforeUpdate.sql b/db/routines/vn/triggers/invoiceInCorrection_beforeUpdate.sql
new file mode 100644
index 000000000..bd324863b
--- /dev/null
+++ b/db/routines/vn/triggers/invoiceInCorrection_beforeUpdate.sql
@@ -0,0 +1,8 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInCorrection_beforeUpdate`
+ BEFORE UPDATE ON `invoiceInCorrection`
+ FOR EACH ROW
+BEGIN
+ CALL invoiceIn_checkBooked(OLD.correctingFk);
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/triggers/invoiceInDueDay_beforeDelete.sql b/db/routines/vn/triggers/invoiceInDueDay_beforeDelete.sql
new file mode 100644
index 000000000..10c9d0b52
--- /dev/null
+++ b/db/routines/vn/triggers/invoiceInDueDay_beforeDelete.sql
@@ -0,0 +1,8 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_beforeDelete`
+ BEFORE DELETE ON `invoiceInDueDay`
+ FOR EACH ROW
+BEGIN
+ CALL invoiceIn_checkBooked(OLD.invoiceInFk);
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql b/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql
index f7e4265a7..95b227616 100644
--- a/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql
+++ b/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql
@@ -5,6 +5,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_befor
BEGIN
DECLARE vIsNotified BOOLEAN;
+ CALL invoiceIn_checkBooked(NEW.invoiceInFk);
+
SET NEW.editorFk = account.myUser_getId();
SELECT isNotified INTO vIsNotified
diff --git a/db/routines/vn/triggers/invoiceInDueDay_beforeUpdate.sql b/db/routines/vn/triggers/invoiceInDueDay_beforeUpdate.sql
index 2452ff0d1..5d58ef28b 100644
--- a/db/routines/vn/triggers/invoiceInDueDay_beforeUpdate.sql
+++ b/db/routines/vn/triggers/invoiceInDueDay_beforeUpdate.sql
@@ -5,6 +5,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_befor
BEGIN
DECLARE vIsNotified BOOLEAN;
+ CALL invoiceIn_checkBooked(OLD.invoiceInFk);
SET NEW.editorFk = account.myUser_getId();
SELECT isNotified INTO vIsNotified
diff --git a/db/routines/vn/triggers/invoiceInIntrastat_beforeDelete.sql b/db/routines/vn/triggers/invoiceInIntrastat_beforeDelete.sql
new file mode 100644
index 000000000..412b091f4
--- /dev/null
+++ b/db/routines/vn/triggers/invoiceInIntrastat_beforeDelete.sql
@@ -0,0 +1,8 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInIntrastat_beforeDelete`
+ BEFORE DELETE ON `invoiceInIntrastat`
+ FOR EACH ROW
+BEGIN
+ CALL invoiceIn_checkBooked(OLD.invoiceInFk);
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/triggers/invoiceInIntrastat_beforeInsert.sql b/db/routines/vn/triggers/invoiceInIntrastat_beforeInsert.sql
new file mode 100644
index 000000000..d6c25c505
--- /dev/null
+++ b/db/routines/vn/triggers/invoiceInIntrastat_beforeInsert.sql
@@ -0,0 +1,8 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInIntrastat_beforeInsert`
+ BEFORE INSERT ON `invoiceInIntrastat`
+ FOR EACH ROW
+BEGIN
+ CALL invoiceIn_checkBooked(NEW.invoiceInFk);
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/triggers/invoiceInIntrastat_beforeUpdate.sql b/db/routines/vn/triggers/invoiceInIntrastat_beforeUpdate.sql
new file mode 100644
index 000000000..649c9ef30
--- /dev/null
+++ b/db/routines/vn/triggers/invoiceInIntrastat_beforeUpdate.sql
@@ -0,0 +1,8 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInIntrastat_beforeUpdate`
+ BEFORE UPDATE ON `invoiceInIntrastat`
+ FOR EACH ROW
+BEGIN
+ CALL invoiceIn_checkBooked(OLD.invoiceInFk);
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/triggers/invoiceInTax_beforeDelete.sql b/db/routines/vn/triggers/invoiceInTax_beforeDelete.sql
new file mode 100644
index 000000000..a43f602b4
--- /dev/null
+++ b/db/routines/vn/triggers/invoiceInTax_beforeDelete.sql
@@ -0,0 +1,8 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInTax_beforeDelete`
+ BEFORE DELETE ON `invoiceInTax`
+ FOR EACH ROW
+BEGIN
+ CALL invoiceIn_checkBooked(OLD.invoiceInFk);
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql b/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql
index 30918b7c5..3e5ecf030 100644
--- a/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql
+++ b/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql
@@ -3,6 +3,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInTax_beforeUp
BEFORE UPDATE ON `invoiceInTax`
FOR EACH ROW
BEGIN
+ CALL invoiceIn_checkBooked(OLD.invoiceInFk);
+
IF NOT (NEW.invoiceInFk <=> OLD.invoiceInFk) THEN
CALL invoiceInTax_afterUpsert(NEW.invoiceInFk);
END IF;
diff --git a/db/routines/vn/triggers/invoiceIn_afterUpdate.sql b/db/routines/vn/triggers/invoiceIn_afterUpdate.sql
index b1308393c..1a9105c9e 100644
--- a/db/routines/vn/triggers/invoiceIn_afterUpdate.sql
+++ b/db/routines/vn/triggers/invoiceIn_afterUpdate.sql
@@ -3,7 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_afterUpdate
AFTER UPDATE ON `invoiceIn`
FOR EACH ROW
BEGIN
-
IF NEW.issued != OLD.issued
OR NEW.currencyFk != OLD.currencyFk THEN
diff --git a/db/routines/vn/triggers/invoiceIn_beforeDelete.sql b/db/routines/vn/triggers/invoiceIn_beforeDelete.sql
new file mode 100644
index 000000000..2ffff923a
--- /dev/null
+++ b/db/routines/vn/triggers/invoiceIn_beforeDelete.sql
@@ -0,0 +1,8 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_beforeDelete`
+ BEFORE DELETE ON `invoiceIn`
+ FOR EACH ROW
+BEGIN
+ CALL invoiceIn_checkBooked(OLD.id);
+END$$
+DELIMITER ;
diff --git a/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql b/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql
index 4503c7dbd..d0762de96 100644
--- a/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql
+++ b/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql
@@ -5,6 +5,10 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_beforeUpdat
BEGIN
DECLARE vWithholdingSageFk INT;
+ IF NEW.isBooked = OLD.isBooked THEN
+ CALL invoiceIn_checkBooked(OLD.id);
+ END IF;
+
IF NOT (NEW.supplierRef <=> OLD.supplierRef) AND NOT util.checkPrintableChars(NEW.supplierRef) THEN
CALL util.throw('The invoiceIn reference contains invalid characters');
END IF;
diff --git a/db/routines/vn/triggers/parking_afterDelete.sql b/db/routines/vn/triggers/parking_afterDelete.sql
new file mode 100644
index 000000000..1ec96c24d
--- /dev/null
+++ b/db/routines/vn/triggers/parking_afterDelete.sql
@@ -0,0 +1,12 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`parking_afterDelete`
+ AFTER DELETE ON `parking`
+ FOR EACH ROW
+BEGIN
+ INSERT INTO parkingLog
+ SET `action` = 'delete',
+ `changedModel` = 'Parking',
+ `changedModelId` = OLD.id,
+ `userFk` = account.myUser_getId();
+END$$
+DELIMITER ;
\ No newline at end of file
diff --git a/db/routines/vn/triggers/parking_beforeInsert.sql b/db/routines/vn/triggers/parking_beforeInsert.sql
index 9cf0bd42a..cdec4c759 100644
--- a/db/routines/vn/triggers/parking_beforeInsert.sql
+++ b/db/routines/vn/triggers/parking_beforeInsert.sql
@@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`parking_beforeInsert`
BEFORE INSERT ON `parking`
FOR EACH ROW
BEGIN
-
+ SET NEW.editorFk = account.myUser_getId();
-- SET new.`code` = CONCAT(new.`column`,' - ',new.`row`) ;
END$$
diff --git a/db/routines/vn/triggers/parking_beforeUpdate.sql b/db/routines/vn/triggers/parking_beforeUpdate.sql
index 38238daa1..3e808f505 100644
--- a/db/routines/vn/triggers/parking_beforeUpdate.sql
+++ b/db/routines/vn/triggers/parking_beforeUpdate.sql
@@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`parking_beforeUpdate`
BEFORE UPDATE ON `parking`
FOR EACH ROW
BEGIN
-
+ SET NEW.editorFk = account.myUser_getId();
-- SET new.`code` = CONCAT(new.`column`,' - ',new.`row`) ;
END$$
diff --git a/db/routines/vn/triggers/payment_beforeInsert.sql b/db/routines/vn/triggers/payment_beforeInsert.sql
index 6a28a1382..1b343712f 100644
--- a/db/routines/vn/triggers/payment_beforeInsert.sql
+++ b/db/routines/vn/triggers/payment_beforeInsert.sql
@@ -10,21 +10,21 @@ BEGIN
-- PAK 10/02/15 No se asientan los pagos directamente, salvo en el caso de las cajas de CASH
SELECT (at2.code = 'cash') INTO bolCASH
- FROM vn.bank b
- JOIN vn.accountingType at2 ON at2.id = b.cash
- WHERE b.id = NEW.bankFk;
+ FROM accounting a
+ JOIN accountingType at2 ON at2.id = a.accountingTypeFk
+ WHERE a.id = NEW.bankFk;
IF bolCASH THEN
SELECT account INTO cuenta_banco
- FROM bank
+ FROM accounting
WHERE id = NEW.bankFk;
SELECT account INTO cuenta_proveedor
FROM supplier
WHERE id = NEW.supplierFk;
- CALL vn.ledger_next(vNewBookEntry);
+ CALL ledger_next(vNewBookEntry);
INSERT INTO XDiario ( ASIEN,
FECHA,
diff --git a/db/routines/vn/triggers/travel_afterUpdate.sql b/db/routines/vn/triggers/travel_afterUpdate.sql
index b4e40ae41..38cd3ba13 100644
--- a/db/routines/vn/triggers/travel_afterUpdate.sql
+++ b/db/routines/vn/triggers/travel_afterUpdate.sql
@@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`travel_afterUpdate`
BEGIN
CALL stock.log_add('travel', NEW.id, OLD.id);
- IF !(NEW.shipped <=> OLD.shipped) THEN
+ IF NOT(NEW.shipped <=> OLD.shipped) THEN
UPDATE entry
SET commission = entry_getCommission(travelFk, currencyFk,supplierFk)
WHERE travelFk = NEW.id;
diff --git a/db/routines/vn/triggers/travel_beforeInsert.sql b/db/routines/vn/triggers/travel_beforeInsert.sql
index 4e1dae3ef..817bd69bb 100644
--- a/db/routines/vn/triggers/travel_beforeInsert.sql
+++ b/db/routines/vn/triggers/travel_beforeInsert.sql
@@ -8,5 +8,9 @@ BEGIN
CALL travel_checkDates(NEW.shipped, NEW.landed);
CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk);
+
+ IF NEW.awbFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.id) THEN
+ CALL util.throw('The AWB is incorrect, there is a different AWB in the associated entries');
+ END IF;
END$$
DELIMITER ;
diff --git a/db/routines/vn/triggers/travel_beforeUpdate.sql b/db/routines/vn/triggers/travel_beforeUpdate.sql
index 7cc198e3c..5e43c8761 100644
--- a/db/routines/vn/triggers/travel_beforeUpdate.sql
+++ b/db/routines/vn/triggers/travel_beforeUpdate.sql
@@ -32,5 +32,9 @@ BEGIN
CALL util.throw('The travel has entries with booked invoices');
END IF;
END IF;
+
+ IF (NOT(NEW.awbFk <=> OLD.awbFk)) AND NEW.awbFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.id) THEN
+ CALL util.throw('The AWB is incorrect, there is a different AWB in the associated entries');
+ END IF;
END$$
DELIMITER ;
diff --git a/db/routines/vn/triggers/zoneIncluded_afterDelete.sql b/db/routines/vn/triggers/zoneIncluded_afterDelete.sql
index 6d184bb12..18332bb55 100644
--- a/db/routines/vn/triggers/zoneIncluded_afterDelete.sql
+++ b/db/routines/vn/triggers/zoneIncluded_afterDelete.sql
@@ -8,5 +8,6 @@ BEGIN
`changedModel` = 'zoneIncluded',
`changedModelId` = OLD.zoneFk,
`userFk` = account.myUser_getId();
+
END$$
DELIMITER ;
diff --git a/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql b/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql
index 5eff33efa..18895c9a5 100644
--- a/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql
+++ b/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql
@@ -4,5 +4,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_beforeIn
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
+
END$$
DELIMITER ;
diff --git a/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql b/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql
index 445f37699..e3f0a27e2 100644
--- a/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql
+++ b/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql
@@ -4,5 +4,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_beforeUp
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
+
END$$
DELIMITER ;
diff --git a/db/routines/vn/views/bank.sql b/db/routines/vn/views/bank.sql
deleted file mode 100644
index fa0d9a4f0..000000000
--- a/db/routines/vn/views/bank.sql
+++ /dev/null
@@ -1,12 +0,0 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
- SQL SECURITY DEFINER
- VIEW `vn`.`bank`
-AS SELECT `a`.`id` AS `id`,
- `a`.`bank` AS `bank`,
- `a`.`account` AS `account`,
- `a`.`accountingTypeFk` AS `cash`,
- `a`.`entityFk` AS `entityFk`,
- `a`.`isActive` AS `isActive`,
- `a`.`currencyFk` AS `currencyFk`,
- `a`.`code` AS `code`
-FROM `vn`.`accounting` `a`
diff --git a/db/routines/vn/views/exchangeInsuranceInPrevious.sql b/db/routines/vn/views/exchangeInsuranceInPrevious.sql
new file mode 100644
index 000000000..3f997e8bf
--- /dev/null
+++ b/db/routines/vn/views/exchangeInsuranceInPrevious.sql
@@ -0,0 +1,9 @@
+CREATE OR REPLACE DEFINER=`root`@`localhost`
+ SQL SECURITY DEFINER
+ VIEW `vn`.`exchangeInsuranceInPrevious`
+AS SELECT `ei`.`dueDated` AS `dated`,
+ `ei`.`amount` AS `amount`,
+ `ei`.`rate` AS `rate`
+FROM `vn`.`exchangeInsurance` `ei`
+WHERE `ei`.`amount` <> 0
+ AND `ei`.`financialProductTypefk` = 'SC'
diff --git a/db/routines/vn/views/exchangeInsuranceOut.sql b/db/routines/vn/views/exchangeInsuranceOut.sql
index f93b65331..5c41dbb24 100644
--- a/db/routines/vn/views/exchangeInsuranceOut.sql
+++ b/db/routines/vn/views/exchangeInsuranceOut.sql
@@ -7,9 +7,9 @@ AS SELECT `p`.`received` AS `received`,
FROM (
(
`vn`.`payment` `p`
- JOIN `vn`.`bank` `b` ON(`b`.`id` = `p`.`bankFk`)
+ JOIN `vn`.`accounting` `a` ON(`a`.`id` = `p`.`bankFk`)
)
- JOIN `vn`.`accountingType` `at2` ON(`at2`.`id` = `b`.`cash`)
+ JOIN `vn`.`accountingType` `at2` ON(`at2`.`id` = `a`.`accountingTypeFk`)
)
WHERE `p`.`currencyFk` = 2
AND `at2`.`code` = 'wireTransfer'
diff --git a/db/routines/vn/views/payrollCenter.sql b/db/routines/vn/views/payrollCenter.sql
index fc6635483..dfe7e4728 100644
--- a/db/routines/vn/views/payrollCenter.sql
+++ b/db/routines/vn/views/payrollCenter.sql
@@ -1,12 +1,7 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`payrollCenter`
-AS SELECT `b`.`cod_centro` AS `codCenter`,
- `b`.`Centro` AS `name`,
- `b`.`nss_cotizacion` AS `nss`,
- `b`.`domicilio` AS `street`,
- `b`.`poblacion` AS `city`,
- `b`.`cp` AS `postcode`,
- `b`.`empresa_id` AS `companyFk`,
- `b`.`codempresa` AS `companyCode`
-FROM `vn2008`.`payroll_centros` `b`
+AS SELECT `b`.`workCenterFkA3` AS `codCenter`,
+ `b`.`companyFkA3` AS `companyCode`
+FROM `vn`.`payrollWorkCenter` `b`
+
diff --git a/db/routines/vn/views/preparationException.sql b/db/routines/vn/views/preparationException.sql
deleted file mode 100644
index ba624ad27..000000000
--- a/db/routines/vn/views/preparationException.sql
+++ /dev/null
@@ -1,7 +0,0 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
- SQL SECURITY DEFINER
- VIEW `vn`.`preparationException`
-AS SELECT `p`.`exception_day` AS `exceptionDay`,
- `p`.`warehouse_id` AS `warehouseFk`,
- `p`.`percentage` AS `percentage`
-FROM `vn2008`.`preparation_exception` `p`
diff --git a/db/routines/vn/views/salesPersonSince.sql b/db/routines/vn/views/salesPersonSince.sql
index 43c45adc0..4234ecac4 100644
--- a/db/routines/vn/views/salesPersonSince.sql
+++ b/db/routines/vn/views/salesPersonSince.sql
@@ -12,5 +12,5 @@ FROM (
`pc`.`id` = `b`.`workerBusinessProfessionalCategoryFk`
)
)
-WHERE `pc`.`name` = 'Aux ventas'
+WHERE `pc`.`description` = 'Aux ventas'
GROUP BY `b`.`workerFk`
diff --git a/db/routines/vn/views/unary.sql b/db/routines/vn/views/unary.sql
deleted file mode 100644
index 7f4c0d8c5..000000000
--- a/db/routines/vn/views/unary.sql
+++ /dev/null
@@ -1,6 +0,0 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
- SQL SECURITY DEFINER
- VIEW `vn`.`unary`
-AS SELECT `a`.`id` AS `id`,
- `a`.`parent` AS `parent`
-FROM `vn2008`.`unary` `a`
diff --git a/db/routines/vn/views/unaryScan.sql b/db/routines/vn/views/unaryScan.sql
deleted file mode 100644
index 18428dd62..000000000
--- a/db/routines/vn/views/unaryScan.sql
+++ /dev/null
@@ -1,8 +0,0 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
- SQL SECURITY DEFINER
- VIEW `vn`.`unaryScan`
-AS SELECT `u`.`unary_id` AS `unaryFk`,
- `u`.`name` AS `name`,
- `u`.`odbc_date` AS `created`,
- `u`.`type` AS `type`
-FROM `vn2008`.`unary_scan` `u`
diff --git a/db/routines/vn/views/unaryScanLine.sql b/db/routines/vn/views/unaryScanLine.sql
deleted file mode 100644
index 75aec7fed..000000000
--- a/db/routines/vn/views/unaryScanLine.sql
+++ /dev/null
@@ -1,8 +0,0 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
- SQL SECURITY DEFINER
- VIEW `vn`.`unaryScanLine`
-AS SELECT `u`.`id` AS `id`,
- `u`.`code` AS `code`,
- `u`.`odbc_date` AS `created`,
- `u`.`unary_id` AS `unaryScanFk`
-FROM `vn2008`.`unary_scan_line` `u`
diff --git a/db/routines/vn2008/procedures/CalculoRemesas.sql b/db/routines/vn2008/procedures/CalculoRemesas.sql
deleted file mode 100644
index a4c191a80..000000000
--- a/db/routines/vn2008/procedures/CalculoRemesas.sql
+++ /dev/null
@@ -1,66 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`CalculoRemesas`(IN vFechaRemesa DATE)
-BEGIN
-
- DROP TEMPORARY TABLE IF EXISTS TMP_REMESAS;
- CREATE TEMPORARY TABLE TMP_REMESAS
- SELECT
- CONCAT(p.NIF,REPEAT('0', 12-LENGTH(p.NIF))) as CIF1,
- cli.Id_Cliente,
- cli.Cliente,
- cli.`IF` as NIF,
- c.PaymentDate as Vencimiento,
- 0 ImporteFac,
- cast(c.Recibo as decimal(10,2)) as ImporteRec,
- 0 as ImporteActual,
- c.companyFk empresa_id,
- cli.RazonSocial,
- cast(c.Recibo as decimal(10,2)) as ImporteTotal,
- cast(c.Recibo as decimal(10,2)) as Saldo,
- p.Proveedor as Empresa,
- e.abbreviation as EMP,
- cli.cuenta,
- iban AS Iban,
- CONVERT(SUBSTRING(iban,5,4),UNSIGNED INT) AS nrbe,
- sepavnl as SEPA,
- corevnl as RecibidoCORE,
- hasLcr,
- be.bic,
- be.`name` entityName
- FROM Clientes cli
- JOIN
- (SELECT risk.companyFk,
- c.Id_Cliente,
- sum(risk.amount) as Recibo,
- IF((c.Vencimiento + graceDays) mod 30.001 <= day(vFechaRemesa)
- ,TIMESTAMPADD(DAY, (c.Vencimiento + graceDays) MOD 30.001, LAST_DAY(TIMESTAMPADD(MONTH,-1,vFechaRemesa)))
- ,TIMESTAMPADD(DAY, (c.Vencimiento + graceDays) MOD 30.001, LAST_DAY(TIMESTAMPADD(MONTH,-2,vFechaRemesa)))
- ) as PaymentDate
- FROM Clientes c
- JOIN pay_met pm on pm.id = pay_met_id
- JOIN
- (
- SELECT companyFk, clientFk, amount
- FROM Clientes c
- JOIN vn.clientRisk cr ON cr.clientFk = c.Id_Cliente
- WHERE pay_met_id = 4
-
- UNION ALL
-
- SELECT io.companyFk, io.clientFk Id_Cliente, - io.amount
- FROM vn.invoiceOut io
- JOIN Clientes c ON c.Id_Cliente = io.clientFk
- JOIN pay_met pm on pm.id = pay_met_id
- WHERE io.dued > vFechaRemesa
- AND pay_met_id = 4 AND pm.deudaviva
- AND io.amount > 0
-
- ) risk ON c.Id_Cliente = risk.clientFk
- GROUP BY risk.companyFk, Id_Cliente
- HAVING Recibo > 10
- ) c on c.Id_Cliente = cli.Id_Cliente
- JOIN Proveedores p on p.Id_Proveedor = c.companyFk
- JOIN empresa e on e.id = c.companyFk
- LEFT JOIN vn.bankEntity be ON be.id = cli.bankEntityFk;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/ListaTicketsEncajados.sql b/db/routines/vn2008/procedures/ListaTicketsEncajados.sql
deleted file mode 100644
index ce99916ee..000000000
--- a/db/routines/vn2008/procedures/ListaTicketsEncajados.sql
+++ /dev/null
@@ -1,25 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`ListaTicketsEncajados`(IN intId_Trabajador int)
-BEGIN
-
-SELECT Agencia,
- Consignatario,
- ti.Id_Ticket,
- ts.userFk Id_Trabajador,
- IFNULL(ncajas,0) AS ncajas,
- IFNULL(nbultos,0) AS nbultos,
- IFNULL(notros,0) AS notros,
- ts.code AS Estado
- FROM Tickets ti
- INNER JOIN Consignatarios ON ti.Id_Consigna = Consignatarios.Id_consigna
- INNER JOIN Agencias ON ti.Id_Agencia = Agencias.Id_Agencia
- LEFT JOIN (SELECT ticketFk,count(*) AS ncajas FROM vn.expedition WHERE packagingFk=94 GROUP BY ticketFk) sub1 ON ti.Id_Ticket=sub1.ticketFk
- LEFT JOIN (SELECT ticketFk,count(*) AS nbultos FROM vn.expedition WHERE packagingFk IS NULL GROUP BY ticketFk) sub2 ON ti.Id_Ticket=sub2.ticketFk
- LEFT JOIN (SELECT ticketFk,count(*) AS notros FROM vn.expedition WHERE packagingFk >0 GROUP BY ticketFk) sub3 ON ti.Id_Ticket=sub3.ticketFk
- INNER JOIN vn.ticketState ts ON ti.Id_ticket = ts.ticketFk
- WHERE ti.Fecha=util.VN_CURDATE() AND
- ts.userFk=intId_Trabajador
- GROUP BY ti.Id_Ticket;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/account_conciliacion_add.sql b/db/routines/vn2008/procedures/account_conciliacion_add.sql
deleted file mode 100644
index 94ef0b14b..000000000
--- a/db/routines/vn2008/procedures/account_conciliacion_add.sql
+++ /dev/null
@@ -1,33 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`account_conciliacion_add`()
-BEGIN
- UPDATE account_conciliacion ac
- JOIN
- (
- SELECT idaccount_conciliacion, @c:= if(@id = id_calculated, @c + 1, 1) contador,
- @id:= id_calculated as id_calculated, concat(id_calculated,'(',@c,')') as new_id
- FROM account_conciliacion
- JOIN
- (
- select id_calculated, count(*) rep, @c:= 0, @id:= concat('-',id_calculated)
- from account_conciliacion
- group by id_calculated
- having rep > 1
- ) sub using(id_calculated)
- ) sub2 using(idaccount_conciliacion)
- SET ac.id_calculated = sub2.new_id;
-
- INSERT INTO Cajas(Cajafecha, Partida, Serie, Concepto, Entrada,
- Salida, Id_Banco,empresa_id, warehouse_id,
- Proveedores_account_id, id_calculated, InForeignValue, OutForeignValue, Id_Trabajador)
- SELECT Fechaoperacion, TRUE, 'MB', ac.Concepto, IF(DebeHaber = 2 AND currencyFk = 1, importe,null),
- IF(DebeHaber = 1 AND currencyFk = 1, importe, null), a.id, sa.supplierFk, 1,
- ac.Id_Proveedores_account, ac.id_calculated, IF(DebeHaber = 2 AND NOT currencyFk = 1, importe, null),
- IF(DebeHaber = 1 AND NOT currencyFk = 1, importe, null), account.myUser_getId()
- FROM account_conciliacion ac
- JOIN vn.supplierAccount sa on sa.id = ac.Id_Proveedores_account
- JOIN vn.accounting a ON a.id = sa.accountingFk
- LEFT JOIN Cajas c on c.id_calculated = ac.id_calculated
- WHERE c.Id_Caja IS NULL;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/add_awb_component.sql b/db/routines/vn2008/procedures/add_awb_component.sql
deleted file mode 100644
index e75290b4b..000000000
--- a/db/routines/vn2008/procedures/add_awb_component.sql
+++ /dev/null
@@ -1,61 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`add_awb_component`(IN vAwbFk SMALLINT)
-BEGIN
-
- DECLARE vShipped DATE;
- DECLARE vHasStems BOOLEAN;
-
- SELECT t.shipped, IF(a.stems, TRUE, FALSE)
- INTO vShipped, vHasStems
- FROM vn.travel t
- JOIN vn.awb a ON a.id = t.awbFk
- WHERE awbFk = vAwbFk
- LIMIT 1;
-
- INSERT IGNORE INTO awb_component (awb_id,Id_Proveedor,awb_component_type_id,awb_role_id,awb_unit_id,value,Id_Moneda)
- SELECT id, Id_Proveedor, awb_component_type_id, awb_role_id,awb_unit_id, LEAST(GREATEST(value1, IFNULL(min_value, value1)), IFNULL(max_value, value1)), Id_Moneda
- FROM (
- SELECT a.id,
- IFNULL(act.carguera_id,
- CASE awb_role_id
- WHEN 1 THEN a.carguera_id
- WHEN 2 THEN a.transitario_id
- WHEN 3 THEN f.airline_id
- END
- ) Id_Proveedor,
- act.awb_component_type_id,
- act.awb_role_id,
- act.awb_unit_id,
- value *
- CASE awb_unit_id
- WHEN '1000Tj-20' THEN ((CAST(stems AS SIGNED) - 20000)/1000) + (min_value / value)
- WHEN '1000Tj-10' THEN ((CAST(stems AS SIGNED) - 10000)/1000) + (min_value / value)
- WHEN '100GW' THEN peso/100
- WHEN 'AWB' THEN 1 -- No action
- WHEN 'FB' THEN hb/2
- WHEN 'GW' THEN peso
- WHEN 'TW' THEN GREATEST(peso,volume_weight)
- WHEN 'PN' THEN LEAST(90, value + a.propertyNumber * 10)
- END value1,
- value,
- act.Id_Moneda,
- act.min_value,
- act.max_value
- FROM awb a
- JOIN flight f ON f.flight_id = a.flight_id
- LEFT JOIN awb_component_template act ON
- ((IFNULL(act.carguera_id, a.carguera_id) = a.carguera_id AND awb_role_id = 1)
- OR (IFNULL(act.carguera_id, a.transitario_id) = a.transitario_id AND awb_role_id = 2)
- OR (IFNULL(act.airline_id, f.airline_id) = f.airline_id AND awb_role_id = 3)
- OR (awb_role_id = 4))
- AND IFNULL(act.airport_out, f.airport_out) = f.airport_out
- AND IFNULL(act.airport_in, f.airport_in) = f.airport_in
- AND IFNULL(act.airline_id, f.airline_id) = f.airline_id
- AND INSTR(IFNULL(act.days, WEEKDAY(vShipped) + 1),WEEKDAY(vShipped) + 1)
- JOIN awb_component_type acty ON acty.awb_component_type_id = act.awb_component_type_id
- WHERE a.id = vAwbFk AND Fecha <= vShipped
- AND (vHasStems = TRUE OR acty.hasStems)
- ORDER BY Fecha DESC, act.days DESC LIMIT 10000000000000000000
- ) t;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/agencia_volume.sql b/db/routines/vn2008/procedures/agencia_volume.sql
deleted file mode 100644
index ea631793d..000000000
--- a/db/routines/vn2008/procedures/agencia_volume.sql
+++ /dev/null
@@ -1,44 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`agencia_volume`()
-BEGIN
- DECLARE vStarted DATETIME DEFAULT TIMESTAMP(util.VN_CURDATE());
- DECLARE vEnded DATETIME DEFAULT TIMESTAMP(util.VN_CURDATE(), '23:59:59');
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticket_PackagingEstimated;
- CREATE TEMPORARY TABLE tmp.ticket_PackagingEstimated
- (
- ticketFk INT PRIMARY KEY
- ,boxes INT DEFAULT 0
- );
-
- INSERT INTO tmp.ticket_PackagingEstimated(ticketFk, boxes)
- SELECT sv.ticketFk, CEIL(1000 * sum(sv.volume) / vc.standardFlowerBox)
- FROM vn.ticket t
- JOIN vn.saleVolume sv ON sv.ticketFk = t.id
- JOIN vn.volumeConfig vc
- WHERE t.shipped BETWEEN vStarted AND vEnded
- AND IFNULL(t.packages,0) = 0
- GROUP BY t.id;
- SELECT * FROM
- (
- SELECT ag.id agency_id,
- CONCAT(RPAD(c.country, 16,' _') ,' ',ag.name) Agencia,
- count(*) expediciones,
- sum(t.packages) Bultos,
- sum(tpe.boxes) Faltan
- FROM vn.ticket t
- JOIN vn.warehouse w ON w.id = t.warehouseFk
- JOIN vn.country c ON w.countryFk = c.id
- JOIN vn.address a ON a.id = t.addressFk
- JOIN vn.agencyMode am ON am.id = t.agencyModeFk
- JOIN vn.agency ag ON ag.id = am.agencyFk
- JOIN tmp.ticket_PackagingEstimated tpe ON tpe.ticketFk = t.id
- WHERE t.shipped BETWEEN vStarted AND vEnded
- AND ag.isOwn = FALSE
- GROUP BY ag.id
- ) sub
- ORDER BY Agencia;
-
- DROP TEMPORARY TABLE tmp.ticket_PackagingEstimated;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/agencyModeImbalance.sql b/db/routines/vn2008/procedures/agencyModeImbalance.sql
deleted file mode 100644
index 89706f0d2..000000000
--- a/db/routines/vn2008/procedures/agencyModeImbalance.sql
+++ /dev/null
@@ -1,50 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`agencyModeImbalance`(vStarted DATE, vEnded DATE)
-BEGIN
-/**
- * Devuelve el valor de los precios teorico, practico de las agencias
- * y si ademas es de mrw lo compara con su fichero previamente procesado
- *
- * @param vEktFk Identificador de edi.ekt
- */
- DECLARE vEndedDayEnd DATETIME;
-
- SET vEndedDayEnd = util.dayEnd(vEnded);
-
- SELECT t.id ticketFk,t.addressFk,
- CAST(v.amount AS DECIMAL (10,2)) AS VN,
- CAST(v.amount - e.shipping_charge AS DECIMAL (10,2)) AS Difer,
- CAST(mrwPrice AS DECIMAL (10,2)) mrwPrice,
- CAST(e.shipping_charge - mrwPrice AS DECIMAL (10,2)) mrwDifference,
- CAST(e.shipping_charge AS DECIMAL (10,2)) AS teorico,
- CAST(e.extraCharge AS DECIMAL (10,2)) AS extraCharge,
- t.packages, t.clientFk,
- t.zoneFk, a.provinceFk, mrwCount
- FROM vn.ticket t
- LEFT JOIN
- (SELECT ticketFk, SUM(amount) amount, fc.shipped
- FROM vn.sale_freightComponent fc
- JOIN vn.ticket t ON t.id = fc.ticketFk
- JOIN tmp.agencyMode am ON am.agencyModeFk = t.agencyModeFk
- WHERE fc.shipped BETWEEN vStarted AND vEndedDayEnd
- GROUP BY ticketFk) v ON t.id = v.ticketFk
- LEFT JOIN (SELECT t.id,
- SUM(t.zonePrice) shipping_charge,
- SUM(IFNULL(aex.price,0)) extraCharge
- FROM vn.ticket t
- LEFT JOIN vn.expedition e ON e.ticketFk = t.id
- LEFT JOIN vn.packaging p ON p.id = e.packagingFk
- JOIN tmp.agencyMode amc ON amc.agencyModeFk = t.agencyModeFk
- JOIN vn.agencyMode am ON am.id = amc.agencyModeFk
- LEFT JOIN vn.agencyExtraCharge aex ON p.width+p.depth+p.height BETWEEN aex.sizeMin AND aex.sizeMax AND aex.agencyFk = am.agencyFk
- WHERE t.shipped BETWEEN vStarted AND vEndedDayEnd
- GROUP BY t.id
- ) e ON t.id = e.id
- LEFT JOIN (SELECT ticketFk, SUM(price) mrwPrice, COUNT(*) mrwCount
- FROM vn.mrw
- GROUP BY ticketFk) mrw ON mrw.ticketFk = t.id
- JOIN vn.address a ON a.id = t.addressFk
- JOIN tmp.agencyMode am ON am.agencyModeFk = t.agencyModeFk
- WHERE t.shipped BETWEEN vStarted AND vEndedDayEnd;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/article.sql b/db/routines/vn2008/procedures/article.sql
deleted file mode 100644
index 3c2664c0f..000000000
--- a/db/routines/vn2008/procedures/article.sql
+++ /dev/null
@@ -1,15 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`article`()
-BEGIN
-/**
- * Crea la tabla temporal: article_inventory
- */
- DROP TEMPORARY TABLE IF EXISTS article_inventory;
- CREATE TEMPORARY TABLE article_inventory
- (
- `article_id` INT(11) NOT NULL PRIMARY KEY,
- `future` DATETIME
- )
- ENGINE = MEMORY;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/cacheReset.sql b/db/routines/vn2008/procedures/cacheReset.sql
deleted file mode 100644
index f36169fda..000000000
--- a/db/routines/vn2008/procedures/cacheReset.sql
+++ /dev/null
@@ -1,11 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`cacheReset`(vCacheName VARCHAR(10), vParams VARCHAR(15))
-BEGIN
-
- UPDATE cache.cache_calc
- SET expires = util.VN_NOW()
- WHERE cacheName = vCacheName collate utf8_unicode_ci
- AND params = vParams collate utf8_unicode_ci;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/camiones.sql b/db/routines/vn2008/procedures/camiones.sql
deleted file mode 100644
index 4c37cf9da..000000000
--- a/db/routines/vn2008/procedures/camiones.sql
+++ /dev/null
@@ -1,23 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`camiones`(vWarehouse INT, vDate DATE)
-BEGIN
- SELECT Temperatura
- ,ROUND(SUM(Etiquetas * volume)) AS cm3
- ,ROUND(SUM(IF(scanned, Etiquetas, 0) * volume)) AS cm3s
- ,ROUND(SUM(Vida * volume)) AS cm3e
- FROM (
- SELECT t.Temperatura, c.Etiquetas, b.scanned, c.Vida,
- IF(cu.Volumen > 0, cu.Volumen, cu.x * cu.y * IF(cu.z > 0, cu.z, a.Medida + 10)) volume
- FROM Compres c
- LEFT JOIN buy_edi b ON b.id = c.buy_edi_id
- JOIN Articles a ON a.Id_Article = c.Id_Article
- JOIN Tipos t ON t.tipo_id = a.tipo_id
- JOIN Entradas e ON e.Id_Entrada = c.Id_Entrada
- JOIN travel tr ON tr.id = e.travel_id
- JOIN Cubos cu ON cu.Id_Cubo = c.Id_Cubo
- WHERE tr.warehouse_id = vWarehouse
- AND tr.landing = vDate
- ) sub
- GROUP BY Temperatura;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/clean.sql b/db/routines/vn2008/procedures/clean.sql
deleted file mode 100644
index 946157fa0..000000000
--- a/db/routines/vn2008/procedures/clean.sql
+++ /dev/null
@@ -1,79 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`clean`(IN `v_full` TINYINT(1))
-proc: BEGIN
- DECLARE vDate DATETIME;
- DECLARE vDate18 DATETIME;
- DECLARE vDate26 DATETIME;
- DECLARE vDate8 DATE;
- DECLARE vDate6 DATE;
- DECLARE vDate3 DATE;
- DECLARE vDate2000 DATE;
- DECLARE vRangeDeleteTicket INT;
- DECLARE vStrtable VARCHAR(15) DEFAULT NULL;
-
- SET vDate = util.VN_CURDATE() - INTERVAL 2 MONTH;
- SET vDate18 = util.VN_CURDATE() - INTERVAL 18 MONTH;
- SET vDate26 = util.VN_CURDATE() - INTERVAL 26 MONTH;
- SET vDate3 = util.VN_CURDATE() - INTERVAL 3 MONTH;
- SET vDate8 = util.VN_CURDATE() - INTERVAL 8 DAY;
- SET vDate6 = util.VN_CURDATE() - INTERVAL 6 DAY;
- SET vDate2000 = util.VN_CURDATE() + INTERVAL (2000 - YEAR(util.VN_CURDATE())) YEAR;
- SET vRangeDeleteTicket = 60;
-
- DELETE FROM cdr WHERE calldate < vDate18;
- DELETE FROM mail WHERE DATE_ODBC < vDate;
- DELETE FROM Movimientos_mark WHERE odbc_date < vDate;
- DELETE FROM Splits WHERE Fecha < vDate18;
-
- DELETE tobs
- FROM movement_label tobs
- JOIN Movimientos m ON tobs.Id_Movimiento = m.Id_Movimiento
- JOIN Tickets t ON m.Id_Ticket = t.Id_Ticket WHERE t.Fecha < vDate;
-
- DELETE FROM Remesas WHERE `Fecha Remesa` < vDate18;
-
- DELETE tt.*
- FROM Tickets_turno tt
- LEFT JOIN Movimientos m USING(Id_Ticket)
- WHERE m.Id_Article IS NULL;
-
- DELETE FROM cl_main WHERE Fecha < vDate18;
- DELETE FROM hedera.`order` WHERE date_send < vDate18;
- DELETE FROM vn.message WHERE sendDate < vDate;
-
- DELETE FROM cache.departure_limit WHERE Fecha < util.VN_CURDATE() - INTERVAL 1 MONTH;
-
- DELETE cm
- FROM Compres_mark cm
- JOIN Compres c ON c.Id_Compra = cm.Id_Compra
- JOIN Entradas e ON e.Id_Entrada = c.Id_Entrada
- JOIN travel t ON t.id = e.travel_id
- WHERE t.landing <= vDate;
-
- IF v_full THEN
- CREATE OR REPLACE TEMPORARY TABLE tTicketDelete
- SELECT DISTINCT tl.originFk ticketFk
- FROM vn.ticketLog tl
- JOIN (SELECT MAX(tl.id)ids
- FROM vn.ticket t
- JOIN vn.ticketLog tl ON tl.originFk = t.id
- WHERE t.shipped BETWEEN '2000-01-01' AND '2000-12-31'
- AND t.isDeleted
- GROUP BY t.id
- )sub ON sub.ids = tl.id
- WHERE tl.creationDate <= util.VN_CURDATE() - INTERVAL 60 DAY;
-
- DELETE t
- FROM vn.ticket t
- JOIN tTicketDelete tmp ON tmp.ticketFk = t.id;
-
- DROP TEMPORARY TABLE tTicketDelete;
- END IF;
-
- -- Tickets Nulos PAK 11/10/2016
- UPDATE Tickets
- SET empresa_id = 965
- WHERE Id_Cliente = 31
- AND empresa_id != 965;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/clean_launcher.sql b/db/routines/vn2008/procedures/clean_launcher.sql
deleted file mode 100644
index 63c23e8cf..000000000
--- a/db/routines/vn2008/procedures/clean_launcher.sql
+++ /dev/null
@@ -1,6 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`clean_launcher`()
-BEGIN
- CALL clean(TRUE);
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/cobro.sql b/db/routines/vn2008/procedures/cobro.sql
deleted file mode 100644
index 26d906813..000000000
--- a/db/routines/vn2008/procedures/cobro.sql
+++ /dev/null
@@ -1,79 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`cobro`(IN datFEC DATE
- , IN idCLI INT
- , IN dblIMPORTE DOUBLE
- , IN idCAJA INT
- , IN idPAYMET INT
- , IN strCONCEPTO VARCHAR(40)
- , IN idEMP INT
- , IN idWH INT
- , IN idTRABAJADOR INT)
-BEGIN
-
- DECLARE bolCASH BOOLEAN;
- DECLARE cuenta_banco BIGINT;
- DECLARE cuenta_cliente BIGINT;
- DECLARE max_asien INT;
- -- XDIARIO
- -- No se asientan los cobros directamente, salvo en el caso de las cajas de CASH
- SELECT (at2.code = 'cash') INTO bolCASH FROM Bancos b JOIN vn.accountingType at2 ON at2.id = b.cash WHERE b.Id_Banco = idCAJA;
- IF bolCASH THEN
- SELECT Cuenta INTO cuenta_banco
- FROM Bancos
- WHERE Id_Banco = idCAJA;
- SELECT Cuenta INTO cuenta_cliente
- FROM Clientes
- WHERE Id_Cliente = idCLI;
- CALL vn.ledger_next(max_asien);
- INSERT INTO vn.XDiario (ASIEN,FECHA,SUBCTA,CONTRA,CONCEPTO,EURODEBE,EUROHABER,empresa_id)
- SELECT max_asien,datFEC,SUBCTA,CONTRA,strCONCEPTO,EURODEBE,EUROHABER,idEMP
- FROM(SELECT cuenta_banco SUBCTA, cuenta_cliente CONTRA, 0 EURODEBE, dblIMPORTE EUROHABER
- UNION ALL
- SELECT cuenta_cliente SUBCTA, cuenta_banco CONTRA, dblIMPORTE EURODEBE, 0 EUROHABER
- ) gf;
- END IF;
-
- -- CAJERA
- INSERT INTO Cajas(Id_Trabajador,
- Id_Banco,
- Entrada,
- Concepto,
- Cajafecha,
- Serie,
- Partida,
- Numero,
- empresa_id,
- warehouse_id
- )
- VALUES (idTRABAJADOR,
- idCAJA,
- dblIMPORTE,
- strCONCEPTO,
- datFEC,
- 'A',
- TRUE,
- idCLI,
- idEMP,
- idWH
- );
-
- -- RECIBO
- INSERT INTO Recibos(Entregado,
- Fechacobro,
- Id_Trabajador,
- Id_Banco,
- Id_Cliente,
- Id_Factura,
- empresa_id
- )
- VALUES ( dblIMPORTE,
- datFEC,
- idTRABAJADOR,
- idCAJA,
- idCLI,
- strCONCEPTO,
- idEMP
- );
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/confection_control_source.sql b/db/routines/vn2008/procedures/confection_control_source.sql
deleted file mode 100644
index 77b4df5f3..000000000
--- a/db/routines/vn2008/procedures/confection_control_source.sql
+++ /dev/null
@@ -1,105 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`confection_control_source`(vDated DATE, vScopeDays TINYINT)
-BEGIN
-
- DECLARE vMidnight DATETIME DEFAULT TIMESTAMP(vDated,'23:59:59');
- DECLARE vEndingDate DATETIME DEFAULT TIMESTAMPADD(DAY,vScopeDays,vMidnight);
- DECLARE maxAlertLevel INT DEFAULT 2;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.production_buffer;
-
- CREATE TEMPORARY TABLE tmp.production_buffer
- ENGINE = MEMORY
- SELECT
- date(t.Fecha) as Fecha,
- hour(t.Fecha) as Hora,
- hour(t.Fecha) as Departure,
- t.Id_Ticket,
- m.Id_Movimiento,
- m.Cantidad,
- m.Concepte,
- ABS(m.Reservado) Reservado,
- i.Categoria,
- tp.Tipo,
- t.Alias as Cliente,
- wh.name as Almacen,
- t.warehouse_id,
- cs.province_id,
- a.agency_id,
- ct.description as Taller,
- stock.visible,
- stock.available
- FROM vn2008.Tickets t
- JOIN vn2008.Agencias a ON a.Id_Agencia = t.Id_Agencia
- JOIN vn.warehouse wh ON wh.id = t.warehouse_id
- JOIN vn2008.Movimientos m ON m.Id_Ticket = t.Id_Ticket
- JOIN vn2008.Articles i ON i.Id_Article = m.Id_Article
- JOIN vn2008.Tipos tp ON tp.tipo_id = i.tipo_id
- JOIN vn.confectionType ct ON ct.id = tp.confeccion
- JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.Id_Consigna
- LEFT JOIN vn.ticketState tls on tls.ticketFk = t.Id_Ticket
- LEFT JOIN
- (
- SELECT item_id, sum(visible) visible, sum(available) available
- FROM
- (
- SELECT a.item_id, 0 as visible, a.available
- FROM cache.cache_calc cc
- LEFT JOIN cache.available a ON a.calc_id = cc.id
- WHERE cc.cache_id IN (2,8)
- AND cc.params IN (concat("1/", util.VN_CURDATE()),concat("44/", util.VN_CURDATE()))
-
- UNION ALL
-
- SELECT v.item_id, v.visible, 0 as available
- FROM cache.cache_calc cc
- LEFT JOIN cache.visible v ON v.calc_id = cc.id
- where cc.cache_id IN (2,8) and cc.params IN ("1","44")
- ) sub
- GROUP BY item_id
- ) stock ON stock.item_id = m.Id_Article
- WHERE tp.confeccion
- AND tls.alertLevel < maxAlertLevel
- AND wh.hasConfectionTeam
- AND t.Fecha BETWEEN vDated AND vEndingDate
- AND m.Cantidad > 0;
-
- -- Entradas
-
- INSERT INTO tmp.production_buffer(
- Fecha,
- Id_Ticket,
- Cantidad,
- Concepte,
- Categoria,
- Cliente,
- Almacen,
- Taller
- )
- SELECT
- tr.shipment AS Fecha,
- e.Id_Entrada AS Id_Ticket,
- c.Cantidad,
- a.Article,
- a.Categoria,
- whi.name as Cliente,
- who.name as Almacen,
- ct.description as Taller
- FROM vn2008.Compres c
- JOIN vn2008.Entradas e ON e.Id_Entrada = c.Id_Entrada
- JOIN vn2008.travel tr ON tr.id = e.travel_id
- JOIN vn.warehouse whi ON whi.id = tr.warehouse_id
- JOIN vn.warehouse who ON who.id = tr.warehouse_id_out
- JOIN vn2008.Articles a ON a.Id_Article = c.Id_Article
- JOIN vn2008.Tipos tp ON tp.tipo_id = a.tipo_id
- JOIN vn.confectionType ct ON ct.id = tp.confeccion
- WHERE who.hasConfectionTeam
- AND tp.confeccion
- AND tr.shipment BETWEEN vDated AND vEndingDate;
-
-
- SELECT * FROM tmp.production_buffer;
-
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/customerDebtEvolution.sql b/db/routines/vn2008/procedures/customerDebtEvolution.sql
deleted file mode 100644
index b9763b985..000000000
--- a/db/routines/vn2008/procedures/customerDebtEvolution.sql
+++ /dev/null
@@ -1,49 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`customerDebtEvolution`(IN vCustomer INT)
-BEGIN
-
-SELECT * FROM
-(
- SELECT day, date, @s:= round(IFNULL(Euros,0) + @s,2) as Saldo, Euros, Credito, 0 as Cero
- FROM
- (
- SELECT day, date, IFNULL(Euros,0) as Euros, Credito
- FROM time
- JOIN (SELECT @s:= 0, - Credito as Credito FROM Clientes WHERE Id_Cliente = vCustomer) c
- LEFT JOIN
- (SELECT Euros, date(Fecha) as Fecha FROM
- (
- SELECT Fechacobro as Fecha, Entregado as Euros
- FROM Recibos
- WHERE Id_Cliente = vCustomer
- AND Fechacobro >= '2017-01-01'
- UNION ALL
- SELECT vn.getDueDate(io.issued,c.Vencimiento), - io.amount
- FROM vn.invoiceOut io
- JOIN Clientes c ON io.clientFk = c.Id_Cliente
- WHERE io.clientFk = vCustomer
- AND io.issued >= '2017-01-01'
- UNION ALL
- SELECT '2016-12-31', Debt
- FROM bi.customerDebtInventory
- WHERE Id_Cliente = vCustomer
- UNION ALL
- SELECT Fecha, - SUM(Cantidad * Preu * (100 - Descuento ) * 1.10 / 100)
- FROM Tickets t
- JOIN Movimientos m on m.Id_Ticket = t.Id_Ticket
- WHERE Id_Cliente = vCustomer
- AND Factura IS NULL
- AND Fecha >= '2017-01-01'
- GROUP BY Fecha
- ) sub2
- ORDER BY Fecha
- )sub ON time.date = sub.Fecha
- WHERE time.date BETWEEN '2016-12-31' AND util.VN_CURDATE()
- ORDER BY date
- ) sub3
-)sub4
-;
-
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql b/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql
deleted file mode 100644
index 439eba5ad..000000000
--- a/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql
+++ /dev/null
@@ -1,100 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`emailYesterdayPurchasesByConsigna`(IN v_Date DATE, IN v_Client_Id INT)
-BEGIN
-
- DECLARE MyIdTicket BIGINT;
- DECLARE MyAlias VARCHAR(50);
- DECLARE MyDomicilio VARCHAR(255);
- DECLARE MyPoblacion VARCHAR(25);
- DECLARE MyImporte DOUBLE;
- DECLARE MyMailTo VARCHAR(250);
- DECLARE MyMailReplyTo VARCHAR(250);
- DECLARE done INT DEFAULT FALSE;
- DECLARE emptyList INT DEFAULT 0;
- DECLARE txt TEXT;
-
- DECLARE rs CURSOR FOR
- SELECT t.Id_Ticket, Alias, cast(amount as decimal(10,2)) Importe, Domicilio, POBLACION
- FROM Tickets t
- JOIN Consignatarios cs ON t.Id_Consigna = cs.Id_Consigna
- JOIN (
- SELECT `Movimientos`.`Id_Ticket` AS `Id_Ticket`,
- sum(
- `Movimientos`.`Cantidad` * `Movimientos`.`Preu` * (100 - `Movimientos`.`Descuento`) / 100
- ) AS `amount`
- FROM (
- `vn2008`.`Movimientos`
- JOIN `vn2008`.`Tickets` ON(
- `Movimientos`.`Id_Ticket` = `Tickets`.`Id_Ticket`
- )
- )
- WHERE `Tickets`.`Fecha` >= `util`.`VN_CURDATE`() + INTERVAL -6 MONTH
- GROUP BY `Movimientos`.`Id_Ticket`
- ) v ON v.Id_Ticket = t.Id_Ticket
- WHERE t.Fecha BETWEEN v_Date AND util.dayEnd(v_Date)
- AND t.Id_Cliente = v_Client_Id;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
-
- SET v_Date = IFNULL(v_Date, util.yesterday());
-
- OPEN rs;
-
- FETCH rs INTO MyIdTicket, MyAlias, MyImporte, MyDomicilio, MyPoblacion;
-
- SET emptyList = done;
-
- SET txt = CONCAT('',
- ' Relación de envíos.
',
- 'Dia: ', v_Date, '
');
-
- WHILE NOT done DO
-
- SET txt = CONCAT(txt, '
',
- ''
- , ' ', MyAlias, '
'
- , ' ', MyDomicilio, '(', MyPoblacion, ')');
-
- FETCH rs INTO MyIdTicket, MyAlias, MyImporte, MyDomicilio, MyPoblacion;
-
- END WHILE;
-
- SET txt = CONCAT(
- txt,
- '',
- '
Puede acceder al detalle de los albaranes haciendo click sobre el número de Ticket',
- '
Muchas gracias por su confianza
',
- '
');
-
- -- Envío del email
- IF emptyList = 0 THEN
-
- SELECT CONCAT(`e-mail`,',pako@verdnatura.es') INTO MyMailTo
- FROM Clientes
- WHERE Id_Cliente = v_Client_Id AND `e-mail`>'';
-
- IF v_Client_Id = 7818 THEN -- LOEWE
- SET MyMailTo = 'isabel@elisabethblumen.com,emunozca@loewe.es,pako@verdnatura.es';
- END IF;
-
- CALL vn.mail_insert(
- IFNULL(MyMailTo,'pako.natek@gmail.com'),
- 'pako@verdnatura.es',
- 'Resumen de pedidos preparados',
- txt
- );
-
- END IF;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/emailYesterdayPurchasesLauncher.sql b/db/routines/vn2008/procedures/emailYesterdayPurchasesLauncher.sql
deleted file mode 100644
index c414cf1c4..000000000
--- a/db/routines/vn2008/procedures/emailYesterdayPurchasesLauncher.sql
+++ /dev/null
@@ -1,27 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`emailYesterdayPurchasesLauncher`()
-BEGIN
-
-DECLARE done INT DEFAULT 0;
-DECLARE vMyClientId INT;
-
-DECLARE rs CURSOR FOR
-SELECT Id_Cliente
-FROM Clientes
-WHERE EYPBC != 0;
-
-DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
-
-OPEN rs;
-
-FETCH rs INTO vMyClientId;
-
-WHILE NOT done DO
-
- CALL emailYesterdayPurchasesByConsigna(util.yesterday(), vMyClientId);
-
- FETCH rs INTO vMyClientId;
-
-END WHILE;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/embalajes_stocks.sql b/db/routines/vn2008/procedures/embalajes_stocks.sql
deleted file mode 100644
index b20e44c79..000000000
--- a/db/routines/vn2008/procedures/embalajes_stocks.sql
+++ /dev/null
@@ -1,51 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`embalajes_stocks`(IN idPEOPLE INT, IN bolCLIENT BOOLEAN)
-BEGIN
-
-if bolCLIENT then
-
- select m.Id_Article, Article, - cast(sum(m.Cantidad) as decimal) as Saldo
- from Movimientos m
- join Articles a on m.Id_Article = a.Id_Article
- join Tipos tp on tp.tipo_id = a.tipo_id
- join Tickets t using(Id_Ticket)
- join Consignatarios cs using(Id_Consigna)
- where cs.Id_Cliente = idPEOPLE
- and Tipo = 'Contenedores'
- and t.Fecha > '2010-01-01'
- group by m.Id_Article;
-
-else
-
-select Id_Article, Article, sum(Cantidad) as Saldo
-from
-(select Id_Article, Cantidad
-from Compres c
-join Articles a using(Id_Article)
-join Tipos tp using(tipo_id)
-join Entradas e using(Id_Entrada)
-join travel tr on tr.id = travel_id
-where Id_Proveedor = idPEOPLE
-and landing >= '2010-01-01'
-and reino_id = 6
-
-union all
-
-select Id_Article, - Cantidad
-from Movimientos m
-join Articles a using(Id_Article)
-join Tipos tp using(tipo_id)
-join Tickets t using(Id_Ticket)
-join Consignatarios cs using(Id_Consigna)
-join proveedores_clientes pc on pc.Id_Cliente = cs.Id_Cliente
-where Id_Proveedor = idPEOPLE
-and reino_id = 6
-and t.Fecha > '2010-01-01') mov
-
-join Articles a using(Id_Article)
-group by Id_Article;
-
-end if;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/embalajes_stocks_detalle.sql b/db/routines/vn2008/procedures/embalajes_stocks_detalle.sql
deleted file mode 100644
index c49d1b88a..000000000
--- a/db/routines/vn2008/procedures/embalajes_stocks_detalle.sql
+++ /dev/null
@@ -1,78 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`embalajes_stocks_detalle`(IN idPEOPLE INT, IN idARTICLE INT, IN bolCLIENT BOOLEAN)
-BEGIN
-
-
-if bolCLIENT then
-
- select m.Id_Article
- , Article
- , IF(Cantidad < 0, - Cantidad, NULL) as Entrada
- , IF(Cantidad < 0, NULL, Cantidad) as Salida
- , 'T' as Tabla
- , t.Id_Ticket as Registro
- , t.Fecha
- , w.name as Almacen
- , cast(Preu as Decimal(5,2)) Precio
- , c.Cliente as Proveedor
- , abbreviation as Empresa
- from Movimientos m
- join Articles a using(Id_Article)
- join Tickets t using(Id_Ticket)
- join empresa e on e.id = t.empresa_id
- join warehouse w on w.id = t.warehouse_id
- join Consignatarios cs using(Id_Consigna)
- join Clientes c on c.Id_Cliente = cs.Id_Cliente
- where cs.Id_Cliente = idPEOPLE
- and m.Id_Article = idARTICLE
- and t.Fecha > '2010-01-01';
-
-else
-
-select Id_Article, Tabla, Registro, Fecha, Article
-, w.name as Almacen, Entrada, Salida, Proveedor, cast(Precio as Decimal(5,2)) Precio
-
-from
-
-(select Id_Article
- , IF(Cantidad > 0, Cantidad, NULL) as Entrada
- , IF(Cantidad > 0, NULL,- Cantidad) as Salida
- , 'E' as Tabla
- , Id_Entrada as Registro
- , landing as Fecha
- , tr.warehouse_id
- , Costefijo as Precio
-from Compres c
-join Entradas e using(Id_Entrada)
-join travel tr on tr.id = travel_id
-where Id_Proveedor = idPEOPLE
-and Id_Article = idARTICLE
-and landing >= '2010-01-01'
-
-union all
-
-select Id_Article
- , IF(Cantidad < 0, - Cantidad, NULL) as Entrada
- , IF(Cantidad < 0, NULL, Cantidad) as Salida
- , 'T'
- , Id_Ticket
- , Fecha
- , t.warehouse_id
- , Preu
-from Movimientos m
-join Tickets t using(Id_Ticket)
-join Consignatarios cs using(Id_Consigna)
-join proveedores_clientes pc on pc.Id_Cliente = cs.Id_Cliente
-where Id_Proveedor = idPEOPLE
-and Id_Article = idARTICLE
-and t.Fecha > '2010-01-01') mov
-
-join Articles a using(Id_Article)
-join Proveedores p on Id_Proveedor = idPEOPLE
-join warehouse w on w.id = mov.warehouse_id
-;
-
-end if;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/historico_absoluto.sql b/db/routines/vn2008/procedures/historico_absoluto.sql
deleted file mode 100644
index 1a7e1dbfa..000000000
--- a/db/routines/vn2008/procedures/historico_absoluto.sql
+++ /dev/null
@@ -1,91 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`historico_absoluto`(IN idART INT, IN wh INT, IN datfecha DATETIME)
-BEGIN
-
- DECLARE inv_calculado INT;
- DECLARE inv INT;
- DECLARE today DATETIME;
- DECLARE fecha_inv DATETIME;
-
- SET today = util.VN_CURDATE();
-
- CREATE OR REPLACE TEMPORARY TABLE historico_pasado
- SELECT *
- FROM (
- SELECT TR.landing Fecha,
- C.Cantidad Entrada,
- NULL Salida,
- (TR.received != FALSE) OK,
- P.Proveedor Alias,
- E.Referencia Referencia,
- E.Id_Entrada id,
- TR.delivered F5
- FROM Compres C -- mirar perque no entra en received
- INNER JOIN Entradas E USING (Id_Entrada)
- INNER JOIN travel TR ON TR.id = E.travel_id
- INNER JOIN Proveedores P USING (Id_Proveedor)
- WHERE TR.landing >= '2001-01-01'
- AND Id_proveedor <> 4
- AND wh IN (TR.warehouse_id , 0)
- AND C.Id_Article = idART
- AND E.Inventario = 0
- AND E.Redada = 0
- UNION ALL
- SELECT TR.shipment Fecha,
- NULL Entrada,
- C.Cantidad Salida,
- TR.delivered OK,
- P.Proveedor Alias,
- E.Referencia Referencia,
- E.Id_Entrada id,
- TR.delivered F5
- FROM Compres C
- INNER JOIN Entradas E USING (Id_Entrada)
- INNER JOIN travel TR ON TR.id = E.travel_id
- INNER JOIN Proveedores P USING (Id_Proveedor)
- WHERE TR.shipment >= '2001-01-01'
- AND wh = TR.warehouse_id_out
- AND Id_Proveedor <> 4
- AND C.Id_Article = idART
- AND E.Inventario = 0
- AND E.Redada = 0
- UNION ALL
- SELECT T.Fecha Fecha,
- NULL Entrada,
- M.Cantidad Salida,
- (M.OK <> 0 OR T.Etiquetasemitidas <> 0 OR T.Factura IS NOT NULL) OK,
- T.Alias Alias,
- T.Factura Referencia,
- T.Id_Ticket,
- T.PedidoImpreso
- FROM Movimientos M
- INNER JOIN Tickets T USING (Id_Ticket)
- JOIN Clientes C ON C.Id_Cliente = T.Id_Cliente
- WHERE T.Fecha >= '2001-01-01'
- AND M.Id_Article = idART
- AND wh IN (T.warehouse_id , 0)
- ) t1
- ORDER BY Fecha, Entrada DESC, OK DESC;
-
- SELECT sum(Entrada) - sum(Salida) INTO inv_calculado
- FROM historico_pasado
- WHERE Fecha < datfecha;
-
- SELECT p1.*, NULL v_virtual
- FROM(
- SELECT datfecha Fecha,
- inv_calculado Entrada,
- NULL Salida,
- 1 OK,
- 'Inventario calculado' Alias,
- '' Referencia, 0 id,
- 1 F5
- UNION ALL
- SELECT *
- FROM historico_pasado
- WHERE Fecha >= datfecha
- ) p1;
-
- DROP TEMPORARY TABLE historico_pasado;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/historico_multiple.sql b/db/routines/vn2008/procedures/historico_multiple.sql
deleted file mode 100644
index ae4045a34..000000000
--- a/db/routines/vn2008/procedures/historico_multiple.sql
+++ /dev/null
@@ -1,206 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`historico_multiple`(IN vItemFk INT)
-BEGIN
-
- DECLARE vDateInventory DATETIME;
-
- SELECT Fechainventario INTO vDateInventory FROM tblContadores;
-
- SET @a = 0;
-
- DROP TEMPORARY TABLE IF EXISTS hm1;
-
- CREATE TEMPORARY TABLE hm1
- SELECT DATE(Fecha) as Fecha,
- Entrada,
- Salida,
- OK,
- Referencia,
- Historia.id,
-
- wh,
-
- `name` as wh_name
-
- FROM
-
- ( SELECT TR.landing as Fecha,
- C.Cantidad as Entrada,
- NULL as Salida,
-
- IF(warehouse_id = 44, 1, warehouse_id) as wh,
- (TR.received != FALSE) as OK,
- E.Referencia as Referencia,
- E.Id_Entrada as id
-
-
-
- FROM Compres C
- INNER JOIN Entradas E USING (Id_Entrada)
- INNER JOIN travel TR ON TR.id = E.travel_id
- WHERE TR.landing >= vDateInventory
- AND C.Id_Article = vItemFk
- AND E.Redada = 0
-
- AND C.Cantidad <> 0
-
- UNION ALL
-
- SELECT TR.shipment as Fecha,
- NULL as Entrada,
- C.Cantidad as Salida,
- warehouse_id_out as wh,
- TR.delivered as OK,
- E.Referencia as Referencia,
- E.Id_Entrada as id
-
- FROM Compres C
- INNER JOIN Entradas E USING (Id_Entrada)
- INNER JOIN travel TR ON TR.id = E.travel_id
- WHERE TR.shipment >= vDateInventory
- AND C.Id_Article = vItemFk
-
- AND E.Redada = 0
-
- AND C.Cantidad <> 0
-
- UNION ALL
-
- SELECT T.Fecha as Fecha,
- NULL as Entrada,
- M.Cantidad as Salida,
- warehouse_id as wh,
- (M.OK <> 0 OR T.Etiquetasemitidas <> 0 OR T.Factura IS NOT NULL) as OK,
- T.Factura as Referencia,
- T.Id_Ticket as id
-
- FROM Movimientos M
- INNER JOIN Tickets T USING (Id_Ticket)
- WHERE T.Fecha >= vDateInventory
- AND M.Id_Article = vItemFk
-
- ) AS Historia
-
- INNER JOIN warehouse ON warehouse.id = Historia.wh
- ORDER BY Fecha, Entrada DESC, OK DESC;
-
-
- DROP TEMPORARY TABLE IF EXISTS hm2;
- DROP TEMPORARY TABLE IF EXISTS hm3;
- DROP TEMPORARY TABLE IF EXISTS hm4;
- DROP TEMPORARY TABLE IF EXISTS hm5;
- DROP TEMPORARY TABLE IF EXISTS hm6;
- DROP TEMPORARY TABLE IF EXISTS hm7;
- DROP TEMPORARY TABLE IF EXISTS hm8;
- CREATE TEMPORARY TABLE hm2 SELECT * FROM hm1 WHERE wh = 19;
- CREATE TEMPORARY TABLE hm3 SELECT * FROM hm1 WHERE wh = 7;
- CREATE TEMPORARY TABLE hm4 SELECT * FROM hm1 WHERE wh = 60;
- CREATE TEMPORARY TABLE hm5 SELECT * FROM hm1 WHERE wh = 5;
- CREATE TEMPORARY TABLE hm6 SELECT * FROM hm1 WHERE wh = 17;
- CREATE TEMPORARY TABLE hm7 SELECT * FROM hm1 WHERE wh = 37;
- CREATE TEMPORARY TABLE hm8 SELECT * FROM hm1 WHERE wh = 55;
-
- SELECT * FROM
-
- (
-
- SELECT Fecha, Entrada as BOGEntrada, Salida as BOGSalida, OK as BOGOK, Referencia as BOGReferencia, id as BOGid,
-
- NULL AS VNHEntrada, NULL AS VNHSalida, NULL AS VNHOK, NULL AS VNHReferencia, NULL AS VNHid,
-
- NULL AS ALGEntrada, NULL AS ALGSalida, NULL AS ALGOK, NULL AS ALGReferencia, NULL AS ALGid,
-
- NULL AS MADEntrada, NULL AS MADSalida, NULL AS MADOK, NULL AS MADReferencia, NULL AS MADid,
-
- NULL AS MCFEntrada, NULL AS MCFSalida, NULL AS MCFOK, NULL AS MCFReferencia, NULL AS MCFid,
-
- NULL AS VILEntrada, NULL AS VILSalida, NULL AS VILOK, NULL AS VILReferencia, NULL AS VILid,
-
- NULL AS BAREntrada, NULL AS BARSalida, NULL AS BAROK, NULL AS BARReferencia, NULL AS BARid
-
- FROM hm2
-
-
- UNION ALL
-
- SELECT Fecha
- , NULL, NULL, NULL, NULL, NULL
- ,Entrada, Salida, OK, Referencia, id
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- FROM hm3
-
-
-
- UNION ALL
-
- SELECT Fecha
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , Entrada, Salida, OK, Referencia, id
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- FROM hm4
-
- UNION ALL
-
- SELECT Fecha
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , Entrada, Salida, OK, Referencia, id
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- FROM hm5
-
- UNION ALL
-
- SELECT Fecha
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , Entrada, Salida, OK, Referencia, id
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- FROM hm6
-
- UNION ALL
-
- SELECT Fecha
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , Entrada, Salida, OK, Referencia, id
- , NULL, NULL, NULL, NULL, NULL
-
-
- FROM hm7
-
- UNION ALL
-
- SELECT Fecha
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , NULL, NULL, NULL, NULL, NULL
- , Entrada, Salida, OK, Referencia, id
-
- FROM hm8
-
- ) sub
-
- ORDER BY Fecha, BOGEntrada IS NULL, VNHEntrada IS NULL, ALGEntrada IS NULL, MADEntrada IS NULL, MCFEntrada IS NULL, VILEntrada IS NULL, BAREntrada IS NULL;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/nest_child_add.sql b/db/routines/vn2008/procedures/nest_child_add.sql
deleted file mode 100644
index 5b45a9d07..000000000
--- a/db/routines/vn2008/procedures/nest_child_add.sql
+++ /dev/null
@@ -1,48 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`nest_child_add`(
- vTable VARCHAR(45)
- ,vChild VARCHAR(45)
- ,vFatherId INT
-)
-BEGIN
- DECLARE vMyLeft INT;
-
- SET vTable = util.quoteIdentifier(vTable);
-
- DROP TEMPORARY TABLE IF EXISTS aux;
- CREATE TEMPORARY TABLE aux
- SELECT 0 as lft;
-
- EXECUTE IMMEDIATE CONCAT(
- 'UPDATE aux
- SET lft = (SELECT lft
- FROM ', vTable,
- ' WHERE id = ?)')
- USING vFatherId;
-
- SELECT lft INTO vMyLeft FROM aux;
- DROP TEMPORARY TABLE aux;
-
- EXECUTE IMMEDIATE CONCAT(
- 'UPDATE ', vTable, '
- SET rgt = rgt + 2
- WHERE rgt > ?
- ORDER BY rgt DESC')
- USING vMyLeft;
-
- EXECUTE IMMEDIATE CONCAT(
- 'UPDATE ', vTable, '
- SET lft = lft + 2
- WHERE lft > ?
- ORDER BY lft DESC')
- USING vMyLeft;
-
- EXECUTE IMMEDIATE CONCAT(
- 'INSERT INTO ', vTable, ' (name, lft, rgt)
- VALUES(?, ? + 1, ? + 2)')
- USING vChild,
- vMyLeft,
- vMyLeft;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/nest_delete.sql b/db/routines/vn2008/procedures/nest_delete.sql
deleted file mode 100644
index 84f75294b..000000000
--- a/db/routines/vn2008/procedures/nest_delete.sql
+++ /dev/null
@@ -1,51 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`nest_delete`(
- vTable VARCHAR(45)
- ,vNodeId INT
-)
-BEGIN
- DECLARE vMyRight INT;
- DECLARE vMyLeft INT;
- DECLARE vMyWidth INT;
-
- DROP TEMPORARY TABLE IF EXISTS aux;
- CREATE TEMPORARY TABLE aux
- SELECT 0 rgt, 0 lft, 0 wdt;
-
- SET vTable = util.quoteIdentifier(vTable);
-
- EXECUTE IMMEDIATE CONCAT(
- 'UPDATE aux a
- JOIN ', vTable, ' t
- SET a.rgt = t.rgt,
- a.lft = t.lft,
- a.wdt = t.rgt - t.lft + 1
- WHERE t.id = ?')
- USING vNodeId;
-
- SELECT rgt, lft, wdt
- INTO vMyRight, vMyLeft, vMyWidth
- FROM aux;
-
- DROP TEMPORARY TABLE aux;
-
- EXECUTE IMMEDIATE CONCAT(
- 'DELETE FROM ', vTable,
- ' WHERE lft BETWEEN ? AND ?')
- USING vMyLeft, vMyRight;
-
- EXECUTE IMMEDIATE CONCAT(
- 'UPDATE ', vTable,
- ' SET rgt = rgt - ?
- WHERE rgt > ?
- ORDER BY rgt')
- USING vMyWidth,vMyRight;
-
- EXECUTE IMMEDIATE CONCAT(
- 'UPDATE ', vTable,
- ' SET lft = lft - ?
- WHERE lft > ?
- ORDER BY lft')
- USING vMyWidth, vMyRight;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/nest_move.sql b/db/routines/vn2008/procedures/nest_move.sql
deleted file mode 100644
index 950d46e68..000000000
--- a/db/routines/vn2008/procedures/nest_move.sql
+++ /dev/null
@@ -1,108 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`nest_move`(
- vTable VARCHAR(45)
- ,idNODE INT
- ,idFATHER INT
-)
-BEGIN
- DECLARE myRight INT;
- DECLARE myLeft INT;
- DECLARE myWidth INT;
- DECLARE fatherRight INT;
- DECLARE fatherLeft INT;
- DECLARE gap INT;
-
- SET vTable = util.quoteIdentifier(vTable);
-
- DROP TEMPORARY TABLE IF EXISTS aux;
- CREATE TEMPORARY TABLE aux
- SELECT 0 as rgt, 0 as lft, 0 as wdt, 0 as frg, 0 as flf;
-
- -- Averiguamos el ancho de la rama
- EXECUTE IMMEDIATE CONCAT(
- 'UPDATE aux a
- JOIN ', vTable, ' t
- SET a.wdt = t.rgt - t.lft + 1
- WHERE t.id = ?')
- USING idNODE;
-
- -- Averiguamos la posicion del nuevo padre
- EXECUTE IMMEDIATE CONCAT(
- 'UPDATE aux a
- JOIN ', vTable, ' t
- SET a.frg = t.rgt,
- a.flf = t.lft
- WHERE t.id = ?')
- USING idFATHER;
-
- SELECT wdt, frg, flf INTO myWidth, fatherRight, fatherLeft
- FROM aux;
-
- -- 1º Incrementamos los valores de todos los nodos a la derecha del punto de inserción (fatherRight) , para hacer sitio
- EXECUTE IMMEDIATE CONCAT(
- 'UPDATE ', vTable,
- 'SET rgt = rgt + ?
- WHERE rgt >= ?
- ORDER BY rgt DESC')
- USING myWidth,
- fatherRight;
-
- EXECUTE IMMEDIATE CONCAT(
- 'UPDATE ', vTable,
- 'SET lft = lft + ?
- WHERE lft >= ?
- ORDER BY lft DESC')
- USING myWidth,
- fatherRight;
-
- -- Es preciso recalcular los valores del nodo en el caso de que estuviera a la derecha del nuevo padre
- EXECUTE IMMEDIATE CONCAT(
- 'UPDATE aux a
- JOIN ', vTable, ' t
- SET a.rgt = t.rgt,
- a.lft = t.lft
- WHERE t.id = ?')
- USING idNODE;
-
- SELECT lft, rgt, frg - lft INTO myLeft, myRight, gap
- FROM aux;
-
- -- 2º Incrementamos el valor de todos los nodos a trasladar hasta alcanzar su nueva posicion
- EXECUTE IMMEDIATE CONCAT(
- 'UPDATE ', vTable,
- 'SET lft = lft + ?
- WHERE lft BETWEEN ? AND ?
- ORDER BY lft DESC')
- USING gap,
- myLeft,
- myRight;
-
- EXECUTE IMMEDIATE CONCAT(
- 'UPDATE ', vTable,
- 'SET rgt = rgt + ?
- WHERE rgt BETWEEN ? AND ?
- ORDER BY rgt DESC')
- USING gap,
- myLeft,
- myRight;
-
- -- 3º Restaremos a todos los nodos resultantes, a la derecha de la posicion arrancada el ancho de la rama escindida
- EXECUTE IMMEDIATE CONCAT(
- 'UPDATE ', vTable,
- 'SET lft = lft - ?
- WHERE lft > ?
- ORDER BY lft')
- USING myWidth,
- myLeft;
-
- EXECUTE IMMEDIATE CONCAT(
- 'UPDATE ', vTable,
- 'SET rgt = rgt - ?
- WHERE rgt > ?
- ORDER BY rgt')
- USING myWidth,
- myRight;
-
- DROP TEMPORARY TABLE aux;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/pay.sql b/db/routines/vn2008/procedures/pay.sql
deleted file mode 100644
index ec73ee696..000000000
--- a/db/routines/vn2008/procedures/pay.sql
+++ /dev/null
@@ -1,67 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`pay`(IN datFEC DATE
- , IN idPROV INT
- , IN dblIMPORTE DOUBLE
- , IN idMONEDA INT
- , IN dblDIVISA DOUBLE
- , IN idCAJA INT
- , IN idPAYMET INT
- , IN dblGASTOS DOUBLE
- , IN strCONCEPTO VARCHAR(40)
- , IN idEMP INT)
-BEGIN
-
- -- Registro en la tabla Cajas
- INSERT INTO Cajas ( Concepto
- , Serie
- , Numero
- , Salida
- , Cajafecha
- , Partida
- , Id_Banco
- , Id_Trabajador
- ,empresa_id
- ,conciliado)
-
- SELECT CONCAT('n/pago a ', Proveedor)
- , 'R'
- , idPROV
- , dblIMPORTE
- , datFEC
- , 1
- , idCAJA
- , account.myUser_getId()
- , idEMP
- , 1
- FROM Proveedores
- WHERE Id_Proveedor = idPROV;
-
- -- Registro en la tabla pago
- INSERT INTO pago(fecha
- , dueDated
- , id_proveedor
- , importe
- , id_moneda
- , divisa
- , id_banco
- , pay_met_id
- , g_bancarios
- , concepte
- , empresa_id)
-
- VALUES(datFEC
- , datFEC
- , idPROV
- , dblIMPORTE
- , idMONEDA
- , IF(dblDIVISA = 0, NULL, dblDIVISA)
- , idCAJA
- , idPAYMET
- , dblGASTOS
- , strCONCEPTO
- , idEMP);
-
- SELECT LAST_INSERT_ID() as pago_id;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/preOrdenarRuta.sql b/db/routines/vn2008/procedures/preOrdenarRuta.sql
deleted file mode 100644
index b5fd2b24b..000000000
--- a/db/routines/vn2008/procedures/preOrdenarRuta.sql
+++ /dev/null
@@ -1,22 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`preOrdenarRuta`(IN vRutaId INT)
-BEGIN
-/* Usa los valores del ultimo año para adivinar el orden de los tickets en la ruta
- * vRutaId id ruta
- * DEPRECATED use vn.routeGressPriority
-*/
-
-UPDATE Tickets mt
-JOIN (
- SELECT tt.Id_Consigna, round(ifnull(avg(t.Prioridad),0),0) as Prioridad
- from Tickets t
- JOIN Tickets tt on tt.Id_Consigna = t.Id_Consigna
- where t.Fecha > TIMESTAMPADD(YEAR,-1,util.VN_CURDATE())
- AND tt.Id_Ruta = vRutaId
- GROUP BY Id_Consigna
- ) sub ON sub.Id_Consigna = mt.Id_Consigna
- SET mt.Prioridad = sub.Prioridad
- WHERE mt.Id_Ruta = vRutaId;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/prepare_ticket_list.sql b/db/routines/vn2008/procedures/prepare_ticket_list.sql
deleted file mode 100644
index e407a91b7..000000000
--- a/db/routines/vn2008/procedures/prepare_ticket_list.sql
+++ /dev/null
@@ -1,22 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`prepare_ticket_list`(vStartingDate DATETIME, vEndingDate DATETIME)
-BEGIN
- DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list;
- CREATE TEMPORARY TABLE tmp.ticket_list
- (PRIMARY KEY (Id_Ticket))
- ENGINE = MEMORY
- SELECT t.Id_Ticket, c.Id_Cliente
- FROM Tickets t
- LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.Id_Ticket
- JOIN Clientes c ON c.Id_Cliente = t.Id_Cliente
- WHERE c.typeFk IN ('normal','handMaking','internalUse')
- AND (
- Fecha BETWEEN util.today() AND vEndingDate
- OR (
- ts.alertLevel < 3
- AND t.Fecha >= vStartingDate
- AND t.Fecha < util.today()
- )
- );
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/raidUpdate.sql b/db/routines/vn2008/procedures/raidUpdate.sql
deleted file mode 100644
index 9746f3cf9..000000000
--- a/db/routines/vn2008/procedures/raidUpdate.sql
+++ /dev/null
@@ -1,28 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`raidUpdate`()
-BEGIN
-
- UPDATE Entradas e
- JOIN Entradas_Auto ea USING (Id_Entrada)
- JOIN travel t ON t.id = e.travel_id
- JOIN (
- SELECT *
- FROM (
- SELECT id, landing, warehouse_id, warehouse_id_out
- FROM travel
- JOIN (
- SELECT warehouse_id, warehouse_id_out
- FROM Entradas_Auto ea
- JOIN Entradas e USING(Id_Entrada)
- JOIN travel t ON t.id = e.travel_id
- GROUP BY warehouse_id, warehouse_id_out
- ) t USING (warehouse_id, warehouse_id_out)
- WHERE shipment > util.VN_CURDATE() AND delivered = FALSE
- ORDER BY landing
- LIMIT 10000000000000000000
- ) t
- GROUP BY warehouse_id, warehouse_id_out
- ) t USING (warehouse_id, warehouse_id_out)
- SET e.travel_id = t.id;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/rateView.sql b/db/routines/vn2008/procedures/rateView.sql
deleted file mode 100644
index 91e317be6..000000000
--- a/db/routines/vn2008/procedures/rateView.sql
+++ /dev/null
@@ -1,37 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`rateView`()
-BEGIN
-
- SELECT
- t.year as año,
- t.month as mes,
- pagos.dolares,
- pagos.cambioPractico,
- CAST(sum(divisa) / sum(bi) as DECIMAL(5,4)) as cambioTeorico,
- pagos.cambioOficial
- FROM recibida r
- JOIN time t ON t.date = r.fecha
- JOIN recibida_iva ri ON r.id = ri.recibida_id
- JOIN
- (
- SELECT
- t.year as Año,
- t.month as Mes,
- cast(sum(divisa) as DECIMAL(10,2)) as dolares,
- cast(sum(divisa) / sum(importe) as DECIMAL(5,4)) as cambioPractico,
- cast(rr.rate * 0.998 as DECIMAL(5,4)) as cambioOficial
- FROM pago p
- JOIN time t ON t.date = p.fecha
- JOIN reference_rate rr ON rr.date = p.fecha AND moneda_id = 2
- WHERE divisa
- AND fecha >= '2015-01-11'
- GROUP BY t.year, t.month
- ) pagos ON t.year = pagos.Año AND t.month = pagos.Mes
- WHERE moneda_id = 2
- AND fecha >= '2015-01-01'
- AND divisa
- AND bi
- GROUP BY t.year, t.month;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/recibidaIvaInsert.sql b/db/routines/vn2008/procedures/recibidaIvaInsert.sql
deleted file mode 100644
index e2aba0a35..000000000
--- a/db/routines/vn2008/procedures/recibidaIvaInsert.sql
+++ /dev/null
@@ -1,39 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`recibidaIvaInsert`(IN vId INT)
-BEGIN
-
- DECLARE vRate DOUBLE DEFAULT 1;
- DECLARE vDated DATE;
-
- SELECT MAX(rr.date) INTO vDated
- FROM reference_rate rr
- JOIN recibida r ON r.id = vId
- WHERE rr.date <= r.fecha
- AND rr.moneda_id = r.moneda_id ;
-
- IF vDated THEN
-
- SELECT rate INTO vRate
- FROM reference_rate
- WHERE `date` = vDated;
- END IF;
-
- DELETE FROM recibida_iva WHERE recibida_id = vId;
-
- INSERT INTO recibida_iva(recibida_id, bi, gastos_id, divisa, taxTypeSageFk, transactionTypeSageFk)
- SELECT r.id,
- SUM(Costefijo * Cantidad) / IFNULL(vRate,1) bi,
- 6003000000,
- IF(r.moneda_id = 1,NULL,SUM(Costefijo * Cantidad )) divisa,
- taxTypeSageFk,
- transactionTypeSageFk
- FROM recibida r
- JOIN Entradas e ON e.recibida_id = r.id
- JOIN Proveedores p ON p.Id_Proveedor = e.Id_Proveedor
- JOIN Compres c ON c.Id_Entrada = e.Id_Entrada
- LEFT JOIN reference_rate rr ON rr.moneda_id = r.moneda_id AND rr.date = r.fecha
- WHERE r.id = vId
- HAVING bi IS NOT NULL;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/recobro_credito.sql b/db/routines/vn2008/procedures/recobro_credito.sql
deleted file mode 100644
index 3657f2b9b..000000000
--- a/db/routines/vn2008/procedures/recobro_credito.sql
+++ /dev/null
@@ -1,45 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`recobro_credito`()
-BEGIN
- DECLARE EXIT HANDLER FOR SQLSTATE '45000'
- BEGIN
- ROLLBACK;
- RESIGNAL;
- END;
-
- START TRANSACTION;
- UPDATE vn.`client` c
- JOIN vn.payMethod pm ON pm.id = c.payMethodFk
- SET credit = 0
- WHERE pm.`code` = 'card';
-
- DROP TEMPORARY TABLE IF EXISTS clientes_credit;
- CREATE TEMPORARY TABLE clientes_credit
- SELECT Id_Cliente, if (Credito > Recobro ,Credito - Recobro,0) AS newCredit
- FROM (
- SELECT r.Id_Cliente, r.amount AS Recobro,
- timestampadd(DAY, period, UltimaFecha) AS Deadline, sub2.amount AS Credito
- FROM vn2008.recovery r
- JOIN (
- SELECT Id_Cliente, amount , odbc_date AS UltimaFecha
- FROM (
- SELECT * FROM credit
- ORDER BY odbc_date DESC
- LIMIT 10000000000000000000
- ) sub
- GROUP BY Id_Cliente
- ) sub2 USING(Id_Cliente)
- WHERE dend IS NULL or dend >= util.VN_CURDATE()
- GROUP BY Id_Cliente
- HAVING Deadline <= util.VN_CURDATE()
- ) sub3
- WHERE Credito > 0;
-
- UPDATE Clientes
- JOIN clientes_credit USING(Id_Cliente)
- SET Clientes.Credito = newCredit;
-
- DROP TEMPORARY TABLE clientes_credit;
- COMMIT;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/risk_vs_client_list.sql b/db/routines/vn2008/procedures/risk_vs_client_list.sql
deleted file mode 100644
index 92f94eb9f..000000000
--- a/db/routines/vn2008/procedures/risk_vs_client_list.sql
+++ /dev/null
@@ -1,84 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`risk_vs_client_list`(maxRiskDate DATE)
-BEGIN
-/**
- * Calcula el riesgo para los clientes activos de la tabla temporal tmp.client_list
- *
- * @deprecated usar vn.client_getDebt
- * @param maxRiskDate Fecha maxima de los registros
- * @return table tmp.risk
- */
- DECLARE startingDate DATETIME DEFAULT TIMESTAMPADD(DAY, - DAYOFMONTH(util.VN_CURDATE()) - 60, util.VN_CURDATE());
- DECLARE endingDate DATETIME;
- DECLARE MAX_RISK_ALLOWED INT DEFAULT 200;
-
- SET maxRiskDate = IFNULL(maxRiskDate, util.VN_CURDATE());
- SET endingDate = TIMESTAMP(maxRiskDate, '23:59:59');
-
- DROP TEMPORARY TABLE IF EXISTS tmp.client_list_2;
- CREATE TEMPORARY TABLE tmp.client_list_2
- (PRIMARY KEY (Id_Cliente))
- ENGINE = MEMORY
- SELECT *
- FROM tmp.client_list;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.client_list_3;
- CREATE TEMPORARY TABLE tmp.client_list_3
- (PRIMARY KEY (Id_Cliente))
- ENGINE = MEMORY
- SELECT *
- FROM tmp.client_list;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.tickets_sin_facturar;
- CREATE TEMPORARY TABLE tmp.tickets_sin_facturar
- (PRIMARY KEY (Id_Cliente))
- ENGINE = MEMORY
- SELECT t.Id_Cliente, floor(IF(cl.isVies, 1, 1.1) * sum(Cantidad * Preu * (100 - Descuento) / 100)) as total
- FROM Movimientos m
- JOIN Tickets t on m.Id_Ticket = t.Id_Ticket
- JOIN tmp.client_list c on c.Id_Cliente = t.Id_Cliente
- JOIN vn.client cl ON cl.id = t.Id_Cliente
- WHERE Factura IS NULL
- AND Fecha BETWEEN startingDate AND endingDate
- GROUP BY t.Id_Cliente;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.risk;
- CREATE TEMPORARY TABLE tmp.risk
- (PRIMARY KEY (Id_Cliente))
- ENGINE = MEMORY
- SELECT Id_Cliente, SUM(amount) risk, sum(saldo) saldo
- FROM Clientes c
- JOIN (
- SELECT clientFk, SUM(amount) amount,SUM(amount) saldo
- FROM vn.clientRisk
- JOIN tmp.client_list on Id_Cliente = clientFk
- GROUP BY clientFk
- UNION ALL
- SELECT Id_Cliente, SUM(Entregado),SUM(Entregado)
- FROM Recibos
- JOIN tmp.client_list_2 using(Id_Cliente)
- WHERE Fechacobro > endingDate
- GROUP BY Id_Cliente
- UNION ALL
- SELECT Id_Cliente, total,0
- FROM tmp.tickets_sin_facturar
- UNION ALL
- SELECT t.clientFk, CAST(-SUM(t.amount) / 100 AS DECIMAL(10,2)), CAST(-SUM(t.amount) / 100 AS DECIMAL(10,2))
- FROM hedera.tpvTransaction t
- JOIN tmp.client_list_3 on Id_Cliente = t.clientFk
- WHERE t.receiptFk IS NULL
- AND t.status = 'ok'
- GROUP BY t.clientFk
- ) t ON c.Id_Cliente = t.clientFk
- WHERE c.activo != FALSE
- GROUP BY c.Id_Cliente;
-
- DELETE r.*
- FROM tmp.risk r
- JOIN vn2008.Clientes c on c.Id_Cliente = r.Id_Cliente
- JOIN vn2008.pay_met pm on pm.id = c.pay_met_id
- WHERE IFNULL(r.saldo,0) < 10
- AND r.risk <= MAX_RISK_ALLOWED
- AND pm.`name` = 'TARJETA';
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/unary_leaves.sql b/db/routines/vn2008/procedures/unary_leaves.sql
deleted file mode 100644
index 28b5baa76..000000000
--- a/db/routines/vn2008/procedures/unary_leaves.sql
+++ /dev/null
@@ -1,58 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`unary_leaves`(v_top INT)
-BEGIN
-/**
- * A partir de un nodo devuelve todos sus descendientes.
- *
- * @table tmp.tree Tabla con los ids de los nodos descendientes;
- **/
- DECLARE v_count INT;
- DECLARE v_parent INT;
- DECLARE v_depth INT DEFAULT 0;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.tree;
- CREATE TEMPORARY TABLE tmp.tree
- (INDEX (id))
- ENGINE = MEMORY
- SELECT v_top id, v_parent parent, v_depth depth;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.parent;
- CREATE TEMPORARY TABLE tmp.parent
- ENGINE = MEMORY
- SELECT v_top id;
-
- l: LOOP
-
- SET v_depth = v_depth + 1;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.child;
- CREATE TEMPORARY TABLE tmp.child
- ENGINE = MEMORY
- SELECT c.`id`, c.parent
- FROM `unary` c
- JOIN tmp.parent p ON c.`parent` = p.id;
-
- DROP TEMPORARY TABLE tmp.parent;
- CREATE TEMPORARY TABLE tmp.parent
- ENGINE = MEMORY
- SELECT c.id, c.parent
- FROM tmp.child c
- LEFT JOIN tmp.tree t ON t.id = c.id
- WHERE t.id IS NULL;
-
- INSERT INTO tmp.tree
- SELECT id, parent, v_depth FROM tmp.parent;
-
- SELECT COUNT(*) INTO v_count
- FROM tmp.parent;
-
- IF v_count = 0 THEN
- LEAVE l;
- END IF;
- END LOOP;
-
- DROP TEMPORARY TABLE
- tmp.parent,
- tmp.child;
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/procedures/unary_tops.sql b/db/routines/vn2008/procedures/unary_tops.sql
deleted file mode 100644
index b3a7cf11d..000000000
--- a/db/routines/vn2008/procedures/unary_tops.sql
+++ /dev/null
@@ -1,19 +0,0 @@
-DELIMITER $$
-CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`unary_tops`()
-BEGIN
-/**
- * Devuelve todos los nodos que no tienen padre.
- *
- * @table tmp.tree Tabla con los ids de los nodos que no tienen padre;
- **/
-
- DROP TEMPORARY TABLE IF EXISTS tmp.tree;
- CREATE TEMPORARY TABLE tmp.tree
- ENGINE = MEMORY
- SELECT s.`unary_id` AS id, s.name, s.odbc_date, s.type
- FROM `unary_scan` s
- INNER JOIN `unary` u ON s.unary_id = u.id
- WHERE u.parent IS NULL;
-
-END$$
-DELIMITER ;
diff --git a/db/routines/vn2008/views/Bancos.sql b/db/routines/vn2008/views/Bancos.sql
index 0c6f8d1bd..6e850f365 100644
--- a/db/routines/vn2008/views/Bancos.sql
+++ b/db/routines/vn2008/views/Bancos.sql
@@ -1,11 +1,11 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Bancos`
-AS SELECT `b`.`id` AS `Id_Banco`,
- `b`.`bank` AS `Banco`,
- `b`.`account` AS `Cuenta`,
- `b`.`cash` AS `cash`,
- `b`.`entityFk` AS `entity_id`,
- `b`.`isActive` AS `activo`,
- `b`.`currencyFk` AS `currencyFk`
-FROM `vn`.`bank` `b`
+AS SELECT `a`.`id` AS `Id_Banco`,
+ `a`.`bank` AS `Banco`,
+ `a`.`account` AS `Cuenta`,
+ `a`.`accountingTypeFk` AS `cash`,
+ `a`.`entityFk` AS `entity_id`,
+ `a`.`isActive` AS `activo`,
+ `a`.`currencyFk` AS `currencyFk`
+FROM `vn`.`accounting` `a`
diff --git a/db/routines/vn2008/views/Proveedores.sql b/db/routines/vn2008/views/Proveedores.sql
index 0b7ee89f8..b5d3d3684 100644
--- a/db/routines/vn2008/views/Proveedores.sql
+++ b/db/routines/vn2008/views/Proveedores.sql
@@ -23,7 +23,7 @@ AS SELECT `s`.`id` AS `Id_Proveedor`,
`s`.`isOfficial` AS `oficial`,
`s`.`workerFk` AS `workerFk`,
`s`.`payDay` AS `pay_day`,
- `s`.`isSerious` AS `serious`,
+ `s`.`isReal` AS `serious`,
`s`.`note` AS `notas`,
`s`.`taxTypeSageFk` AS `taxTypeSageFk`,
`s`.`withholdingSageFk` AS `withholdingSageFk`,
diff --git a/db/routines/vn2008/views/Proveedores_cargueras.sql b/db/routines/vn2008/views/Proveedores_cargueras.sql
new file mode 100644
index 000000000..c1dc6ad23
--- /dev/null
+++ b/db/routines/vn2008/views/Proveedores_cargueras.sql
@@ -0,0 +1,5 @@
+CREATE OR REPLACE DEFINER=`root`@`localhost`
+ SQL SECURITY DEFINER
+ VIEW `vn2008`.`Proveedores_cargueras`
+AS SELECT `fs`.`supplierFk` AS `Id_Proveedor`
+FROM `vn`.`supplierFreight` `fs`
diff --git a/db/routines/vn2008/views/Tramos.sql b/db/routines/vn2008/views/Tramos.sql
new file mode 100644
index 000000000..6919a610b
--- /dev/null
+++ b/db/routines/vn2008/views/Tramos.sql
@@ -0,0 +1,6 @@
+CREATE OR REPLACE DEFINER=`root`@`localhost`
+ SQL SECURITY DEFINER
+ VIEW `vn2008`.`Tramos`
+AS SELECT `s`.`id` AS `id`,
+ `s`.`section` AS `Tramo`
+FROM `vn`.`timeSlots` `s`
\ No newline at end of file
diff --git a/db/routines/vn2008/views/empresa.sql b/db/routines/vn2008/views/empresa.sql
index 3b43ee574..8c80a06e8 100644
--- a/db/routines/vn2008/views/empresa.sql
+++ b/db/routines/vn2008/views/empresa.sql
@@ -5,7 +5,6 @@ AS SELECT `c`.`id` AS `id`,
`c`.`code` AS `abbreviation`,
`c`.`supplierAccountFk` AS `Id_Proveedores_account`,
`c`.`workerManagerFk` AS `gerente_id`,
- `c`.`sage200Company` AS `digito_factura`,
`c`.`phytosanitary` AS `phytosanitary`,
`c`.`companyCode` AS `CodigoEmpresa`,
`c`.`companyGroupFk` AS `empresa_grupo`,
diff --git a/db/routines/vn2008/views/gastos_resumen.sql b/db/routines/vn2008/views/gastos_resumen.sql
index 02231bcbf..d40d6d229 100644
--- a/db/routines/vn2008/views/gastos_resumen.sql
+++ b/db/routines/vn2008/views/gastos_resumen.sql
@@ -2,6 +2,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`gastos_resumen`
AS SELECT
+ `es`.`id` AS `id`,
`es`.`expenseFk` AS `Id_Gasto`,
`es`.`year` AS `year`,
`es`.`month` AS `month`,
diff --git a/db/routines/vn2008/views/payrollWorker.sql b/db/routines/vn2008/views/payrollWorker.sql
new file mode 100644
index 000000000..d4ada9aa0
--- /dev/null
+++ b/db/routines/vn2008/views/payrollWorker.sql
@@ -0,0 +1,6 @@
+CREATE OR REPLACE DEFINER=`root`@`localhost`
+ SQL SECURITY DEFINER
+ VIEW `vn2008`.`payroll_employee`
+AS SELECT `pw`.`workerFkA3` AS `CodTrabajador`,
+ `pw`.`companyFkA3` AS `codempresa`
+FROM `vn`.`payrollWorker` `pw`
diff --git a/db/routines/vn2008/views/payroll_centros.sql b/db/routines/vn2008/views/payroll_centros.sql
new file mode 100644
index 000000000..b7e162f90
--- /dev/null
+++ b/db/routines/vn2008/views/payroll_centros.sql
@@ -0,0 +1,6 @@
+CREATE OR REPLACE DEFINER=`root`@`localhost`
+ SQL SECURITY DEFINER
+ VIEW `vn2008`.`payroll_centros`
+AS SELECT `pwc`.`workCenterFkA3` AS `cod_centro`,
+ `pwc`.`companyFkA3` AS `codempresa`
+FROM `vn`.`payrollWorkCenter` `pwc`
diff --git a/db/routines/vn2008/views/payroll_conceptos.sql b/db/routines/vn2008/views/payroll_conceptos.sql
new file mode 100644
index 000000000..a7c6ece5b
--- /dev/null
+++ b/db/routines/vn2008/views/payroll_conceptos.sql
@@ -0,0 +1,9 @@
+CREATE OR REPLACE DEFINER=`root`@`localhost`
+ SQL SECURITY DEFINER
+ VIEW `vn2008`.`payroll_conceptos`
+AS SELECT `pc`.`id` AS `conceptoid`,
+ `pc`.`name` AS `concepto`,
+ `pc`.`isSalaryAgreed` AS `isSalaryAgreed`,
+ `pc`.`isVariable` AS `isVariable`,
+ `pc`.`isException` AS `isException`
+FROM `vn`.`payrollComponent` `pc`
diff --git a/db/routines/vn2008/views/v_jerarquia.sql b/db/routines/vn2008/views/v_jerarquia.sql
deleted file mode 100644
index 6938a1fdf..000000000
--- a/db/routines/vn2008/views/v_jerarquia.sql
+++ /dev/null
@@ -1,10 +0,0 @@
-CREATE OR REPLACE DEFINER=`root`@`localhost`
- SQL SECURITY DEFINER
- VIEW `vn2008`.`v_jerarquia`
-AS SELECT `vn2008`.`jerarquia`.`worker_id` AS `Id_Trabajador`,
- `vn2008`.`jerarquia`.`boss_id` AS `boss_id`
-FROM `vn2008`.`jerarquia`
-UNION ALL
-SELECT DISTINCT `vn2008`.`jerarquia`.`boss_id` AS `Id_Trabajador`,
- `vn2008`.`jerarquia`.`boss_id` AS `boss_id`
-FROM `vn2008`.`jerarquia`
diff --git a/db/versions/10832-purpleAralia/00-newWareHouse.sql b/db/versions/10832-purpleAralia/00-newWareHouse.sql
new file mode 100644
index 000000000..dd2c16bdb
--- /dev/null
+++ b/db/versions/10832-purpleAralia/00-newWareHouse.sql
@@ -0,0 +1,12 @@
+INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
+ VALUES
+ ('Collection', 'assign', 'WRITE', 'ALLOW', 'ROLE', 'production'),
+ ('ExpeditionPallet', 'getPallet', 'READ', 'ALLOW', 'ROLE', 'production'),
+ ('MachineWorker','updateInTime','WRITE','ALLOW','ROLE','production'),
+ ('MobileAppVersionControl','getVersion','READ','ALLOW','ROLE','production'),
+ ('SaleTracking','delete','WRITE','ALLOW','ROLE','production'),
+ ('SaleTracking','updateTracking','WRITE','ALLOW','ROLE','production'),
+ ('SaleTracking','setPicked','WRITE','ALLOW','ROLE','production'),
+ ('ExpeditionPallet', '*', 'READ', 'ALLOW', 'ROLE', 'production'),
+ ('Sale', 'getFromSectorCollection', 'READ', 'ALLOW', 'ROLE', 'production'),
+ ('ItemBarcode', 'delete', 'WRITE', 'ALLOW', 'ROLE', 'production');
\ No newline at end of file
diff --git a/db/versions/10880-salmonHydrangea/00-firstScript.sql b/db/versions/10880-salmonHydrangea/00-firstScript.sql
new file mode 100644
index 000000000..934fc2020
--- /dev/null
+++ b/db/versions/10880-salmonHydrangea/00-firstScript.sql
@@ -0,0 +1 @@
+ALTER TABLE vn.buy ADD buyerFk int(10) unsigned DEFAULT NULL NULL;
diff --git a/db/versions/10881-greenHydrangea/00-alterTableNotification.sql b/db/versions/10881-greenHydrangea/00-alterTableNotification.sql
new file mode 100644
index 000000000..068d77839
--- /dev/null
+++ b/db/versions/10881-greenHydrangea/00-alterTableNotification.sql
@@ -0,0 +1 @@
+ALTER TABLE util.notification MODIFY COLUMN id int(11) auto_increment NOT NULL;
diff --git a/db/versions/10881-greenHydrangea/01-notification.sql b/db/versions/10881-greenHydrangea/01-notification.sql
new file mode 100644
index 000000000..ab5480548
--- /dev/null
+++ b/db/versions/10881-greenHydrangea/01-notification.sql
@@ -0,0 +1,15 @@
+INSERT IGNORE INTO util.notification ( `name`,`description`)
+ VALUES
+ ( 'zone-included','An email to notify zoneCollisions');
+
+-- Change value if destionation user should be different
+SET @DESTINATION_USER = "pepe";
+
+SET @MaxId = LAST_INSERT_ID();
+
+INSERT IGNORE INTO util.notificationSubscription (notificationFk,userFk)
+ VALUES(
+ @MaxId, (SELECT id from `account`.`user` where name = @DESTINATION_USER));
+
+INSERT IGNORE INTO util.notificationAcl (notificationFk,roleFk)
+ SELECT @MaxId, (SELECT role from `account`.`user` where name = @DESTINATION_USER) FROM util.notification WHERE name= "zone-included";
diff --git a/db/versions/10887-floranet/00-schemaAndUser.sql b/db/versions/10887-floranet/00-schemaAndUser.sql
new file mode 100644
index 000000000..34da92550
--- /dev/null
+++ b/db/versions/10887-floranet/00-schemaAndUser.sql
@@ -0,0 +1,14 @@
+
+CREATE SCHEMA IF NOT EXISTS `floranet`;
+
+CREATE ROLE IF NOT EXISTS 'floranet' ;
+
+GRANT Create temporary tables ON floranet.* TO 'floranet';
+
+GRANT Execute ON floranet.* TO 'floranet';
+
+GRANT Lock tables ON floranet.* TO 'floranet';
+
+CREATE USER IF NOT EXISTS 'floranet'@'%';
+
+GRANT floranet TO floranet@'%';
\ No newline at end of file
diff --git a/db/versions/10887-floranet/01-tables.sql b/db/versions/10887-floranet/01-tables.sql
new file mode 100644
index 000000000..b63c81c21
--- /dev/null
+++ b/db/versions/10887-floranet/01-tables.sql
@@ -0,0 +1,61 @@
+CREATE OR REPLACE TABLE floranet.`builder` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `itemFk` int(11) NOT NULL,
+ `elementFk` int(11) NOT NULL,
+ `quantity` int(10) unsigned NOT NULL DEFAULT 1,
+ PRIMARY KEY (`id`),
+ KEY `builder_FK` (`itemFk`),
+ KEY `builder_FK_1` (`elementFk`),
+ CONSTRAINT `builder_FK` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Links handmade products with their elements';
+
+CREATE OR REPLACE TABLE floranet.`element` (
+ `itemFk` int(11) NOT NULL,
+ `typeFk` smallint(5) unsigned DEFAULT NULL,
+ `size` int(11) DEFAULT NULL,
+ `inkFk` char(3) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL,
+ `originFk` tinyint(2) unsigned DEFAULT NULL,
+ `name` varchar(30) DEFAULT NULL,
+ `quantity` int(11) NOT NULL DEFAULT 1,
+ PRIMARY KEY (`itemFk`),
+ KEY `element_FK` (`itemFk`),
+ KEY `element_FK_1` (`typeFk`),
+ KEY `element_FK_2` (`inkFk`),
+ KEY `element_FK_3` (`originFk`),
+ CONSTRAINT `element_FK` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `element_FK_1` FOREIGN KEY (`typeFk`) REFERENCES `vn`.`itemType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `element_FK_2` FOREIGN KEY (`inkFk`) REFERENCES `vn`.`ink` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `element_FK_3` FOREIGN KEY (`originFk`) REFERENCES `vn`.`origin` (`id`) ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Filtro para localizar posibles items que coincidan con la descripción';
+
+ALTER TABLE floranet.builder ADD CONSTRAINT `builder_FK_1` FOREIGN KEY (`elementFk`) REFERENCES `element` (`itemFk`) ON UPDATE CASCADE;
+
+CREATE OR REPLACE TABLE floranet.catalogue
+(id INT AUTO_INCREMENT PRIMARY KEY,
+ name VARCHAR(50),
+ price DECIMAL(10,2) NOT NULL,
+ itemFk INT NOT NULL,
+ dated DATE,
+ postalCode VARCHAR(12),
+ `type` VARCHAR(50),
+ image VARCHAR(255),
+ description TEXT,
+ created TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ payed DATETIME,
+ FOREIGN KEY (itemFk) REFERENCES vn.item(id) ON DELETE RESTRICT ON UPDATE CASCADE);
+
+
+CREATE OR REPLACE TABLE floranet.`order`
+(id INT AUTO_INCREMENT PRIMARY KEY,
+ catalogueFk INT UNIQUE,
+ customerName VARCHAR(100),
+ email VARCHAR(100),
+ customerPhone VARCHAR(15),
+ message VARCHAR(255),
+ deliveryName VARCHAR(100),
+ address VARCHAR(200),
+ deliveryPhone VARCHAR(100),
+ isPaid BOOL NOT NULL DEFAULT FALSE,
+ payed DATETIME,
+ created TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ FOREIGN KEY (catalogueFk) REFERENCES catalogue(id) ON DELETE RESTRICT ON UPDATE CASCADE);
\ No newline at end of file
diff --git a/db/versions/10892-yellowGerbera/00-firstScript.sql b/db/versions/10892-yellowGerbera/00-firstScript.sql
new file mode 100644
index 000000000..52dbdbee1
--- /dev/null
+++ b/db/versions/10892-yellowGerbera/00-firstScript.sql
@@ -0,0 +1,19 @@
+SET @isTriggerDisabled := TRUE;
+
+UPDATE vn.buy
+ SET packing = 1
+ WHERE packing IS NULL
+ OR packing <= 0;
+
+UPDATE vn.itemShelving
+ SET packing = 1
+ WHERE packing IS NULL
+ OR NOT packing;
+
+SET @isTriggerDisabled := FALSE;
+
+ALTER TABLE vn.buy MODIFY COLUMN packing int(11) NOT NULL DEFAULT 1 CHECK(packing > 0);
+ALTER TABLE vn.itemShelving MODIFY COLUMN packing int(11) NOT NULL DEFAULT 1 CHECK(packing > 0);
+
+-- Antes tenia '0=sin obligar 1=groping 2=packing' (groping → grouping)
+ALTER TABLE vn.buy MODIFY COLUMN groupingMode tinyint(4) DEFAULT 0 NOT NULL COMMENT '0=sin obligar 1=grouping 2=packing';
diff --git a/db/versions/10893-limeFern/00-sage.sql b/db/versions/10893-limeFern/00-sage.sql
new file mode 100644
index 000000000..d4c7e6221
--- /dev/null
+++ b/db/versions/10893-limeFern/00-sage.sql
@@ -0,0 +1,73 @@
+-- Auto-generated SQL script #202403061303
+UPDATE vn.company
+ SET companyCode=0
+ WHERE id=69;
+UPDATE vn.company
+ SET companyCode=1
+ WHERE id=442;
+UPDATE vn.company
+ SET companyCode=4
+ WHERE id=567;
+UPDATE vn.company
+ SET companyCode=2
+ WHERE id=791;
+UPDATE vn.company
+ SET companyCode=3
+ WHERE id=792;
+UPDATE vn.company
+ SET companyCode=5
+ WHERE id=965;
+UPDATE vn.company
+ SET companyCode=7
+ WHERE id=1381;
+UPDATE vn.company
+ SET companyCode=3
+ WHERE id=1463;
+UPDATE vn.company
+ SET companyCode=8
+ WHERE id=2142;
+UPDATE vn.company
+ SET companyCode=6
+ WHERE id=2393;
+UPDATE vn.company
+ SET companyCode=9
+ WHERE id=3869;
+
+-- Auto-generated SQL script #202403061311
+UPDATE vn.company
+ SET sage200Company=NULL
+ WHERE id=69;
+UPDATE vn.company
+ SET sage200Company=NULL
+ WHERE id=442;
+UPDATE vn.company
+ SET sage200Company=NULL
+ WHERE id=567;
+UPDATE vn.company
+ SET sage200Company=NULL
+ WHERE id=791;
+UPDATE vn.company
+ SET sage200Company=NULL
+ WHERE id=792;
+UPDATE vn.company
+ SET sage200Company=NULL
+ WHERE id=965;
+UPDATE vn.company
+ SET sage200Company=NULL
+ WHERE id=1381;
+UPDATE vn.company
+ SET sage200Company=NULL
+ WHERE id=1463;
+UPDATE vn.company
+ SET sage200Company=NULL
+ WHERE id=2142;
+UPDATE vn.company
+ SET sage200Company=NULL
+ WHERE id=2393;
+UPDATE vn.company
+ SET sage200Company=NULL
+ WHERE id=3869;
+
+
+ALTER TABLE vn.company CHANGE sage200Company sage200Company__ int(2) DEFAULT NULL NULL COMMENT '@deprecated 06/03/2024';
+ALTER TABLE vn.company MODIFY COLUMN sage200Company__ int(2) DEFAULT NULL NULL COMMENT '@deprecated 06/03/2024';
diff --git a/db/versions/10895-pinkArborvitae/00-firstScript.sql b/db/versions/10895-pinkArborvitae/00-firstScript.sql
new file mode 100644
index 000000000..2387fda08
--- /dev/null
+++ b/db/versions/10895-pinkArborvitae/00-firstScript.sql
@@ -0,0 +1,11 @@
+ALTER TABLE `vn`.`packingSite` DROP FOREIGN KEY IF EXISTS `packingSite_FK_4`;
+ALTER TABLE `vn`.`arcRead` DROP FOREIGN KEY IF EXISTS `worker_printer_FK`;
+ALTER TABLE `vn`.`host` DROP FOREIGN KEY IF EXISTS `configHost_FK`;
+ALTER TABLE `vn`.`operator` DROP FOREIGN KEY IF EXISTS `operator_FK_5`;
+ALTER TABLE `vn`.`packingSite` DROP FOREIGN KEY IF EXISTS `packingSite_FK_1`;
+ALTER TABLE `vn`.`printQueue` DROP FOREIGN KEY IF EXISTS `printQueue_printerFk`;
+ALTER TABLE `vn`.`sector` DROP FOREIGN KEY IF EXISTS `sector_FK_1`;
+ALTER TABLE `vn`.`worker` DROP FOREIGN KEY IF EXISTS `worker_FK`;
+ALTER TABLE dipole.printer DROP FOREIGN KEY IF EXISTS printer_FK;
+ALTER TABLE dipole.expedition_PrintOut DROP FOREIGN KEY IF EXISTS expedition_PrintOut_FK;
+
diff --git a/db/versions/10895-pinkArborvitae/01-secondScript.sql b/db/versions/10895-pinkArborvitae/01-secondScript.sql
new file mode 100644
index 000000000..03f1aeccb
--- /dev/null
+++ b/db/versions/10895-pinkArborvitae/01-secondScript.sql
@@ -0,0 +1,28 @@
+ALTER TABLE `vn`.`printer` MODIFY COLUMN IF EXISTS `id` int unsigned auto_increment NOT NULL;
+
+ALTER TABLE `vn`.`arcRead` MODIFY COLUMN IF EXISTS `printerFk` int unsigned DEFAULT NULL NULL;
+ALTER TABLE `vn`.`arcRead` ADD CONSTRAINT `arcRead_FK` FOREIGN KEY IF NOT EXISTS (printerFk) REFERENCES vn.printer(id) ON DELETE CASCADE ON UPDATE CASCADE;
+
+ALTER TABLE `vn`.`host` MODIFY COLUMN IF EXISTS `printerFk` int unsigned DEFAULT NULL NULL;
+ALTER TABLE `vn`.`host` ADD CONSTRAINT `host_FK` FOREIGN KEY IF NOT EXISTS (printerFk) REFERENCES vn.printer(id) ON DELETE RESTRICT ON UPDATE CASCADE;
+
+ALTER TABLE `vn`.`operator` MODIFY COLUMN IF EXISTS `labelerFk` int unsigned DEFAULT NULL NULL;
+ALTER TABLE `vn`.`operator` ADD CONSTRAINT `operator_FK_4` FOREIGN KEY IF NOT EXISTS (labelerFk) REFERENCES vn.printer(id) ON DELETE CASCADE ON UPDATE CASCADE;
+
+ALTER TABLE `vn`.`packingSite` MODIFY COLUMN IF EXISTS `printerFk` int unsigned DEFAULT NULL NULL;
+ALTER TABLE `vn`.`packingSite` ADD CONSTRAINT `packingSite_FK_1` FOREIGN KEY IF NOT EXISTS (printerFk) REFERENCES vn.printer(id) ON DELETE RESTRICT ON UPDATE RESTRICT;
+
+ALTER TABLE `vn`.`packingSite` MODIFY COLUMN IF EXISTS `printerRfidFk` int unsigned DEFAULT NULL NULL;
+ALTER TABLE `vn`.`packingSite` ADD CONSTRAINT `packingSite_FK_4` FOREIGN KEY IF NOT EXISTS(printerRfidFk) REFERENCES vn.printer(id) ON DELETE RESTRICT ON UPDATE CASCADE;
+
+ALTER TABLE `vn`.`printQueue` MODIFY COLUMN IF EXISTS `printerFk` int unsigned DEFAULT NULL NULL;
+ALTER TABLE `vn`.`printQueue` ADD CONSTRAINT `printQueue_FK` FOREIGN KEY IF NOT EXISTS (printerFk) REFERENCES vn.printer(id) ON DELETE RESTRICT ON UPDATE CASCADE;
+
+ALTER TABLE `vn`.`sector` MODIFY COLUMN IF EXISTS `mainPrinterFk` int unsigned DEFAULT NULL NULL;
+ALTER TABLE `vn`.`sector` ADD CONSTRAINT `sector_FK` FOREIGN KEY IF NOT EXISTS (mainPrinterFk) REFERENCES vn.printer(id) ON DELETE CASCADE ON UPDATE CASCADE;
+
+ALTER TABLE `dipole`.`printer` MODIFY COLUMN IF EXISTS `id` int unsigned DEFAULT NULL NULL;
+ALTER TABLE `dipole`.`printer` ADD CONSTRAINT `vnPrinter_FK` FOREIGN KEY IF NOT EXISTS (id) REFERENCES vn.printer(id) ON DELETE CASCADE ON UPDATE CASCADE;
+
+ALTER TABLE `dipole`.`expedition_PrintOut` MODIFY COLUMN IF EXISTS `printerFk` int unsigned DEFAULT 0 NOT NULL;
+ALTER TABLE `dipole`.`expedition_PrintOut` ADD CONSTRAINT `expedition_PrintOut_FK` FOREIGN KEY IF NOT EXISTS (printerFk) REFERENCES printer(id) ON DELETE CASCADE ON UPDATE CASCADE;
diff --git a/db/versions/10895-pinkArborvitae/02-thirdScript.sql b/db/versions/10895-pinkArborvitae/02-thirdScript.sql
new file mode 100644
index 000000000..142ec06b1
--- /dev/null
+++ b/db/versions/10895-pinkArborvitae/02-thirdScript.sql
@@ -0,0 +1,17 @@
+
+ALTER TABLE `vn`.`productionConfig` ADD IF NOT EXISTS backupPrinterNotificationDelay int unsigned NULL
+ COMMENT 'Minimum seconds Interval to Prevent Spam from Same-Type Notifications';
+
+ALTER TABLE vn.sector DROP FOREIGN KEY IF EXISTS sector_FK;
+
+ALTER TABLE `vn`.`sector` CHANGE IF EXISTS `mainPrinterFk` `backupPrinterFk` int unsigned DEFAULT NULL NULL;
+
+ALTER TABLE `util`.`notificationSubscription` DROP FOREIGN KEY IF EXISTS `notificationSubscription_ibfk_1`;
+ALTER TABLE `util`.`notificationQueue` DROP FOREIGN KEY IF EXISTS `nnotificationQueue_ibfk_1`;
+ALTER TABLE `util`.`notificationAcl` DROP FOREIGN KEY IF EXISTS `notificationAcl_ibfk_1`;
+
+ALTER TABLE `util`.`notification` MODIFY COLUMN IF EXISTS `id` int(11) auto_increment NOT NULL;
+
+ALTER TABLE `util`.`notificationSubscription` ADD CONSTRAINT `notificationSubscription_Fk` FOREIGN KEY IF NOT EXISTS (`notificationFk`) REFERENCES `util`.`notification`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
+ALTER TABLE `util`.`notificationQueue` ADD CONSTRAINT `notificationQueue_Fk` FOREIGN KEY IF NOT EXISTS (`notificationFk`) REFERENCES `util`.`notification`(`name`) ON DELETE CASCADE ON UPDATE CASCADE;
+ALTER TABLE `util`.`notificationAcl` ADD CONSTRAINT `notificationAcl_Fk` FOREIGN KEY IF NOT EXISTS (`notificationFk`) REFERENCES `util`.`notification`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
diff --git a/db/versions/10895-pinkArborvitae/03-insertBackUpNotification.vn.sql b/db/versions/10895-pinkArborvitae/03-insertBackUpNotification.vn.sql
new file mode 100644
index 000000000..9dc3c0f60
--- /dev/null
+++ b/db/versions/10895-pinkArborvitae/03-insertBackUpNotification.vn.sql
@@ -0,0 +1,12 @@
+INSERT IGNORE INTO util.notification (name, description)
+ VALUES ('backup-printer-selected','A backup printer has been selected');
+
+INSERT IGNORE INTO util.notificationSubscription (notificationFk, userFk)
+ SELECT id, 10435
+ FROM util.notification
+ WHERE name = 'backup-printer-selected';
+
+INSERT IGNORE INTO util.notificationAcl (notificationFk, roleFk)
+ SELECT id, 66
+ FROM util.notification
+ WHERE name = 'backup-printer-selected';
\ No newline at end of file
diff --git a/db/versions/10900-redOak/00-firstScript.sql b/db/versions/10900-redOak/00-firstScript.sql
new file mode 100644
index 000000000..8609ddc7e
--- /dev/null
+++ b/db/versions/10900-redOak/00-firstScript.sql
@@ -0,0 +1 @@
+ALTER TABLE vn.supplier CHANGE COLUMN isSerious isReal tinyint(1) unsigned NOT NULL DEFAULT 0;
diff --git a/db/versions/10905-grayIvy/00-firstScript.sql b/db/versions/10905-grayIvy/00-firstScript.sql
new file mode 100644
index 000000000..cca41cd48
--- /dev/null
+++ b/db/versions/10905-grayIvy/00-firstScript.sql
@@ -0,0 +1,36 @@
+USE vn;
+
+CREATE OR REPLACE TABLE vn.workerActivityType (
+ `code` varchar(20) NOT NULL,
+ `description` varchar(45) NOT NULL,
+ PRIMARY KEY (`code`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+
+ALTER TABLE vn.department ADD workerActivityTypeFk varchar(20) NULL COMMENT 'Indica la actitividad que desempeña por defecto ese departamento';
+ALTER TABLE vn.department ADD CONSTRAINT department_workerActivityType_FK FOREIGN KEY (workerActivityTypeFk) REFERENCES vn.workerActivityType(code) ON DELETE CASCADE ON UPDATE CASCADE;
+
+
+
+INSERT INTO vn.workerActivityType (code, description) VALUES('ON_CHECKING', 'REVISION');
+INSERT INTO vn.workerActivityType (code, description) VALUES('PREVIOUS_CAM', 'CAMARA');
+INSERT INTO vn.workerActivityType (code, description) VALUES('PREVIOUS_ART', 'ARTIFICIAL');
+INSERT INTO vn.workerActivityType (code, description) VALUES('ON_PREPARATION', 'SACADO');
+INSERT INTO vn.workerActivityType (code, description) VALUES('PACKING', 'ENCAJADO');
+INSERT INTO vn.workerActivityType (code, description) VALUES('FIELD', 'CAMPOS');
+INSERT INTO vn.workerActivityType (code, description) VALUES('DELIVERY', 'REPARTO');
+INSERT INTO vn.workerActivityType (code, description) VALUES('STORAGE', 'ALMACENAJE');
+INSERT INTO vn.workerActivityType (code, description) VALUES('PALLETIZING', 'PALETIZADO');
+INSERT INTO vn.workerActivityType (code, description) VALUES('STOP', 'PARADA');
+
+
+INSERT INTO salix.ACL ( model, property, accessType, permission, principalType, principalId) VALUES('WorkerActivityType', '*', 'READ', 'ALLOW', 'ROLE', 'production');
+INSERT INTO salix.ACL ( model, property, accessType, permission, principalType, principalId) VALUES('WorkerActivity', '*', '*', 'ALLOW', 'ROLE', 'production');
+
+
+ALTER TABLE vn.workerActivity MODIFY COLUMN event enum('open','close','insert','delete','update','refresh') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NULL;
+ALTER TABLE vn.workerActivity MODIFY COLUMN model enum('COM','ENT','TPV','ENC','LAB','ETI','APP') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL;
+
+
+ALTER TABLE vn.workerActivity ADD workerActivityTypeFk varchar(20) NULL;
+ALTER TABLE vn.workerActivity ADD CONSTRAINT workerActivity_workerActivityType_FK FOREIGN KEY (workerActivityTypeFk) REFERENCES vn.workerActivityType(code) ON DELETE CASCADE ON UPDATE CASCADE;
+
diff --git a/db/versions/10914-aquaBirch/00-firstScript.sql b/db/versions/10914-aquaBirch/00-firstScript.sql
new file mode 100644
index 000000000..a182d5407
--- /dev/null
+++ b/db/versions/10914-aquaBirch/00-firstScript.sql
@@ -0,0 +1,6 @@
+-- Place your SQL code here
+ALTER TABLE IF EXISTS vn2008.dock__ RENAME vn2008.dock;
+ALTER TABLE IF EXISTS vn2008.dock COMMENT='';
+
+ALTER TABLE IF EXISTS vn2008.Tramos__ RENAME vn2008.Tramos;
+ALTER TABLE IF EXISTS vn2008.Tramos COMMENT='';
\ No newline at end of file
diff --git a/db/versions/10915-limeMastic/00-firstScript.sql b/db/versions/10915-limeMastic/00-firstScript.sql
new file mode 100644
index 000000000..be83a4984
--- /dev/null
+++ b/db/versions/10915-limeMastic/00-firstScript.sql
@@ -0,0 +1,2 @@
+DELETE IGNORE FROM bs.nightTask
+ WHERE `procedure` = 'clean_launcher';
diff --git a/db/versions/10917-aquaPhormium/00-firstScript.sql b/db/versions/10917-aquaPhormium/00-firstScript.sql
new file mode 100644
index 000000000..436243ba5
--- /dev/null
+++ b/db/versions/10917-aquaPhormium/00-firstScript.sql
@@ -0,0 +1,9 @@
+UPDATE account.user
+SET name = LOWER(name),
+ name = REPLACE(name, ' ', ''),
+ name = REPLACE(name, '.', ''),
+ name = REPLACE(name, 'ñ', 'n'),
+ name = REPLACE(name, '*', ''),
+ name = REPLACE(name, 'ç', 'z'),
+ name = REPLACE(name, 'ã', 'a')
+WHERE NOT active;
diff --git a/db/versions/10918-wheatRose/00-firstScript.sql b/db/versions/10918-wheatRose/00-firstScript.sql
new file mode 100644
index 000000000..5d0fb1c32
--- /dev/null
+++ b/db/versions/10918-wheatRose/00-firstScript.sql
@@ -0,0 +1,2 @@
+DELETE FROM bs.nightTask
+ WHERE `procedure` = 'emailYesterdayPurchasesLauncher';
diff --git a/db/versions/10919-brownMoss/00-firstScript.sql b/db/versions/10919-brownMoss/00-firstScript.sql
new file mode 100644
index 000000000..640d2180a
--- /dev/null
+++ b/db/versions/10919-brownMoss/00-firstScript.sql
@@ -0,0 +1,3 @@
+-- Place your SQL code here
+
+
diff --git a/db/versions/10922-salmonCordyline/00-firstScript.sql b/db/versions/10922-salmonCordyline/00-firstScript.sql
new file mode 100644
index 000000000..37557d326
--- /dev/null
+++ b/db/versions/10922-salmonCordyline/00-firstScript.sql
@@ -0,0 +1 @@
+ALTER TABLE vn.warehouse AUTO_INCREMENT=92;
diff --git a/db/versions/10923-pinkOak/00-createParkingLog.sql b/db/versions/10923-pinkOak/00-createParkingLog.sql
new file mode 100644
index 000000000..f31f58196
--- /dev/null
+++ b/db/versions/10923-pinkOak/00-createParkingLog.sql
@@ -0,0 +1,60 @@
+CREATE OR REPLACE TABLE vn.parkingLog (
+
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+
+ `originFk` int(11) DEFAULT NULL,
+
+ `userFk` int(10) unsigned DEFAULT NULL,
+
+ `action` set('insert','update','delete','select') NOT NULL,
+
+ `creationDate` timestamp NULL DEFAULT current_timestamp(),
+
+ `description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
+
+ `changedModel` enum('Parking','SaleGroup','SaleGroupDetail') NOT NULL DEFAULT 'Parking',
+
+ `oldInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`oldInstance`)),
+
+ `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)),
+
+ `changedModelId` int(11) NOT NULL,
+
+ `changedModelValue` varchar(45) DEFAULT NULL,
+
+ PRIMARY KEY (`id`),
+
+ KEY `logParkinguserFk` (`userFk`),
+
+ KEY `parkingLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`),
+
+ KEY `parkingLog_originFk` (`originFk`,`creationDate`),
+
+ CONSTRAINT `parkingOriginFk` FOREIGN KEY (`originFk`) REFERENCES `parking` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+
+ CONSTRAINT `parkingUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+
+) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+
+ALTER TABLE vn.parking DROP COLUMN IF EXISTS editorFk;
+ALTER TABLE IF EXISTS vn.parking ADD COLUMN editorFk INT;
+
+ALTER TABLE vn.saleGroupDetail DROP COLUMN IF EXISTS editorFk;
+ALTER TABLE IF EXISTS vn.saleGroupDetail ADD COLUMN editorFk INT;
+
+
+ALTER TABLE vn.ticketLog
+ MODIFY COLUMN changedModel ENUM(
+ 'Ticket',
+ 'Sale',
+ 'TicketWeekly',
+ 'TicketTracking',
+ 'TicketService',
+ 'TicketRequest',
+ 'TicketRefund',
+ 'TicketPackaging',
+ 'TicketObservation',
+ 'TicketDms',
+ 'Expedition',
+ 'Sms'
+ ) NOT NULL DEFAULT 'Ticket';
diff --git a/db/versions/10923-pinkOak/01-aclParkingLog.sql b/db/versions/10923-pinkOak/01-aclParkingLog.sql
new file mode 100644
index 000000000..8f7e55d63
--- /dev/null
+++ b/db/versions/10923-pinkOak/01-aclParkingLog.sql
@@ -0,0 +1,2 @@
+INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
+ VALUES ('ParkingLog', '*', 'READ', 'ALLOW', 'ROLE', 'employee');
\ No newline at end of file
diff --git a/db/versions/10924-pinkCordyline/00-firstScript.sql b/db/versions/10924-pinkCordyline/00-firstScript.sql
new file mode 100644
index 000000000..1c6c1c0f8
--- /dev/null
+++ b/db/versions/10924-pinkCordyline/00-firstScript.sql
@@ -0,0 +1,31 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`balanceNestTree_addChild`()
+BEGIN
+ SELECT 1;
+END$$
+DELIMITER ;
+GRANT EXECUTE ON PROCEDURE vn.balanceNestTree_addChild TO adminBoss;
+
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`balanceNestTree_delete`()
+BEGIN
+ SELECT 1;
+END$$
+DELIMITER ;
+GRANT EXECUTE ON PROCEDURE vn.balanceNestTree_delete TO adminBoss;
+
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`balanceNestTree_move`()
+BEGIN
+ SELECT 1;
+END$$
+DELIMITER ;
+GRANT EXECUTE ON PROCEDURE vn.balanceNestTree_move TO adminBoss;
+
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`payment_add`()
+BEGIN
+ SELECT 1;
+END$$
+DELIMITER ;
+GRANT EXECUTE ON PROCEDURE vn.payment_add TO financial;
diff --git a/db/versions/10925-orangeLaurel/00-firstScript.sql b/db/versions/10925-orangeLaurel/00-firstScript.sql
new file mode 100644
index 000000000..049627082
--- /dev/null
+++ b/db/versions/10925-orangeLaurel/00-firstScript.sql
@@ -0,0 +1,15 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`confection_controlSource`()
+BEGIN
+ SELECT 1;
+END$$
+DELIMITER ;
+GRANT EXECUTE ON PROCEDURE vn.confection_controlSource TO handmadeBoss, productionAssi, artificialBoss;
+
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`remittance_calc`()
+BEGIN
+ SELECT 1;
+END$$
+DELIMITER ;
+GRANT EXECUTE ON PROCEDURE vn.remittance_calc TO financial;
\ No newline at end of file
diff --git a/db/versions/10926-limeFern/00-refactorClaimState.sql b/db/versions/10926-limeFern/00-refactorClaimState.sql
new file mode 100644
index 000000000..bb2dc349a
--- /dev/null
+++ b/db/versions/10926-limeFern/00-refactorClaimState.sql
@@ -0,0 +1,8 @@
+UPDATE vn.claim c
+ JOIN vn.claimState cs ON cs.id = c.claimStateFk
+ JOIN vn.claimState ns ON ns.code = 'resolved'
+ SET c.claimStateFk = ns.id
+ WHERE cs.code IN ('managed', 'mana', 'lack', 'relocation');
+
+DELETE FROM vn.claimState
+ WHERE code IN ('managed', 'mana', 'lack', 'relocation');
diff --git a/db/versions/10927-blackSalal/00-firstScript.sql b/db/versions/10927-blackSalal/00-firstScript.sql
new file mode 100644
index 000000000..9f3617406
--- /dev/null
+++ b/db/versions/10927-blackSalal/00-firstScript.sql
@@ -0,0 +1,57 @@
+-- Place your SQL code here
+UPDATE vn.componentType
+ SET isBase = 1
+ WHERE code = 'MANA';
+
+CREATE OR REPLACE TEMPORARY TABLE tmp.discountSale
+ (PRIMARY KEY (saleFk))
+ SELECT bs.saleFk,
+ bs.amount,
+ s.discount,
+ SUM(IF(ct.isBase, s.quantity * sc.value, 0)) importe,
+ SUM(IF(ct.isBase, 0, s.quantity * sc.value)) recargo
+ FROM bs.sale bs
+ JOIN vn.sale s ON s.id = bs.saleFk
+ JOIN vn.saleComponent sc ON sc.saleFk = s.id
+ JOIN vn.component c ON c.id = sc.componentFk
+ JOIN vn.componentType ct ON ct.id = c.typeFk
+ WHERE s.discount
+ GROUP BY bs.saleFk;
+UPDATE bs.sale bs
+ JOIN tmp.discountSale ts ON ts.saleFk = bs.saleFk
+ SET bs.amount = ts.importe
+ bs.surcharge = ts.recargo;
+
+DROP TEMPORARY TABLE tmp.discountSale;
+
+
+DELETE FROM comparative WHERE timePeriod BETWEEN '202101' AND '202409';
+
+INSERT INTO comparative(
+ timePeriod,
+ itemFk,
+ warehouseFk,
+ quantity,
+ price,
+ countryFk
+)
+SELECT tm.period,
+ s.itemFk,
+ t.warehouseFk,
+ sum(s.quantity),
+ sum(v.importe),
+ p.countryFk
+ FROM bs.ventas v
+ JOIN time tm ON tm.dated = v.fecha
+ JOIN sale s ON s.id = v.Id_Movimiento
+ JOIN itemType tp ON tp.id = v.tipo_id
+ JOIN itemCategory ic ON ic.id = tp.categoryFk
+ JOIN ticket t ON t.id = s.ticketFk
+ JOIN client c ON c.id = t.clientFk
+ JOIN warehouse w ON w.id = t.warehouseFk
+ JOIN address ad ON ad.id = t.addressFk
+ LEFT JOIN province p ON p.id = ad.provinceFk
+ WHERE tm.period BETWEEN '202101' AND '202409'
+ AND c.typeFk <> 'loses'
+ AND NOT w.code = 'inv'
+ GROUP BY p.countryFk, s.itemFk, tm.period, t.warehouseFk;
\ No newline at end of file
diff --git a/db/versions/10928-orangeEucalyptus/00-firstScript.sql b/db/versions/10928-orangeEucalyptus/00-firstScript.sql
new file mode 100644
index 000000000..58d3605de
--- /dev/null
+++ b/db/versions/10928-orangeEucalyptus/00-firstScript.sql
@@ -0,0 +1,5 @@
+REVOKE SELECT ON TABLE vn.bank FROM administrative, hr;
+GRANT SELECT ON TABLE vn.accounting TO administrative, hr;
+UPDATE salix.ACL
+ SET model = 'Accounting'
+ WHERE model = 'Bank';
diff --git a/db/versions/10929-orangeAnthurium/00-firstScript.sql b/db/versions/10929-orangeAnthurium/00-firstScript.sql
new file mode 100644
index 000000000..299ac63c7
--- /dev/null
+++ b/db/versions/10929-orangeAnthurium/00-firstScript.sql
@@ -0,0 +1,2 @@
+-- Place your SQL code here
+ALTER TABLE dipole.expedition_PrintOut MODIFY COLUMN street varchar(42) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT ' ' NOT NULL;
\ No newline at end of file
diff --git a/db/versions/10930-wheatDendro/00-firstScript.sql b/db/versions/10930-wheatDendro/00-firstScript.sql
new file mode 100644
index 000000000..167c38f70
--- /dev/null
+++ b/db/versions/10930-wheatDendro/00-firstScript.sql
@@ -0,0 +1,3 @@
+-- Place your SQL code here
+ALTER TABLE IF EXISTS vn.flight ADD CONSTRAINT flight_airline_FK FOREIGN KEY (airlineFk)
+ REFERENCES vn.airline(id) ON DELETE CASCADE ON UPDATE CASCADE;
\ No newline at end of file
diff --git a/db/versions/10930-wheatDendro/01-Tramos.sql b/db/versions/10930-wheatDendro/01-Tramos.sql
new file mode 100644
index 000000000..595aa5dcb
--- /dev/null
+++ b/db/versions/10930-wheatDendro/01-Tramos.sql
@@ -0,0 +1,5 @@
+-- Place your SQL code here
+ALTER TABLE IF EXISTS `vn2008`.`Tramos` RENAME `vn`.`timeSlots`;
+
+ALTER TABLE IF EXISTS `vn`.`timeSlots`
+CHANGE COLUMN IF EXISTS `Tramo` `section` time NOT NULL;
\ No newline at end of file
diff --git a/db/versions/10930-wheatDendro/02-dock.sql b/db/versions/10930-wheatDendro/02-dock.sql
new file mode 100644
index 000000000..acce9f37c
--- /dev/null
+++ b/db/versions/10930-wheatDendro/02-dock.sql
@@ -0,0 +1,3 @@
+-- Place your SQL code here
+ALTER TABLE IF EXISTS `vn2008`.`dock` RENAME `vn2008`.`dock__`;
+ALTER TABLE IF EXISTS vn2008.dock__ COMMENT='refs #6371 deprecated 2024-03-05';
\ No newline at end of file
diff --git a/db/versions/10930-wheatDendro/03-Proveedores_cargueras.sql b/db/versions/10930-wheatDendro/03-Proveedores_cargueras.sql
new file mode 100644
index 000000000..148174215
--- /dev/null
+++ b/db/versions/10930-wheatDendro/03-Proveedores_cargueras.sql
@@ -0,0 +1,5 @@
+-- Place your SQL code here
+ALTER TABLE IF EXISTS `vn2008`.`Proveedores_cargueras` RENAME `vn`.`supplierFreight`;
+
+ALTER TABLE IF EXISTS `vn`.`supplierFreight`
+CHANGE COLUMN IF EXISTS `Id_Proveedor` `supplierFk` int(10) unsigned NOT NULL;
\ No newline at end of file
diff --git a/db/versions/10930-wheatDendro/04-payroll_employee.sql b/db/versions/10930-wheatDendro/04-payroll_employee.sql
new file mode 100644
index 000000000..c346fbf8d
--- /dev/null
+++ b/db/versions/10930-wheatDendro/04-payroll_employee.sql
@@ -0,0 +1,13 @@
+-- Place your SQL code here
+ALTER TABLE IF EXISTS `vn2008`.`payroll_employee` RENAME `vn`.`payrollWorker`;
+
+ALTER TABLE IF EXISTS `vn`.`payrollWorker`
+CHANGE COLUMN IF EXISTS `CodTrabajador` `workerFkA3` int(11) NOT NULL COMMENT 'Columna que hace referencia a A3.',
+CHANGE COLUMN IF EXISTS `nss` `nss__` varchar(23) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024',
+CHANGE COLUMN IF EXISTS `codpuesto` `codpuesto__` int(10) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024',
+CHANGE COLUMN IF EXISTS `codempresa` `companyFkA3` int(10) NOT NULL COMMENT 'Columna que hace referencia a A3.',
+CHANGE COLUMN IF EXISTS `codcontrato` `codcontrato__` int(10) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024',
+CHANGE COLUMN IF EXISTS `FAntiguedad` `FAntiguedad__` date NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024',
+CHANGE COLUMN IF EXISTS `grupotarifa` `grupotarifa__` int(10) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024',
+CHANGE COLUMN IF EXISTS `codcategoria` `codcategoria__` int(10) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024',
+CHANGE COLUMN IF EXISTS `ContratoTemporal` `ContratoTemporal__` tinyint(1) NOT NULL DEFAULT 0 COMMENT '@Deprecated refs #6738 15/03/2024';
\ No newline at end of file
diff --git a/db/versions/10930-wheatDendro/05-payroll_centros.sql b/db/versions/10930-wheatDendro/05-payroll_centros.sql
new file mode 100644
index 000000000..4911c8707
--- /dev/null
+++ b/db/versions/10930-wheatDendro/05-payroll_centros.sql
@@ -0,0 +1,13 @@
+-- Place your SQL code here
+ALTER TABLE IF EXISTS `vn2008`.`payroll_centros` RENAME `vn`.`payrollWorkCenter`;
+
+ALTER TABLE IF EXISTS `vn`.`payrollWorkCenter`
+CHANGE COLUMN IF EXISTS `cod_centro` `workCenterFkA3` int(11) NOT NULL COMMENT 'Columna que hace referencia a A3.',
+CHANGE COLUMN IF EXISTS `Centro` `Centro__` varchar(255) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024',
+CHANGE COLUMN IF EXISTS `nss_cotizacion` `nss_cotizacion__` varchar(15) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024',
+CHANGE COLUMN IF EXISTS `domicilio` `domicilio__` varchar(255) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024',
+CHANGE COLUMN IF EXISTS `poblacion` `poblacion__` varchar(45) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024',
+CHANGE COLUMN IF EXISTS `cp` `cp__` varchar(5) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024',
+CHANGE COLUMN IF EXISTS `empresa_id` `empresa_id__` int(10) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024',
+CHANGE COLUMN IF EXISTS `codempresa` `companyFkA3` int(11) DEFAULT NULL COMMENT 'Columna que hace referencia a A3.';
+;
\ No newline at end of file
diff --git a/db/versions/10930-wheatDendro/06-payroll_conceptos.sql b/db/versions/10930-wheatDendro/06-payroll_conceptos.sql
new file mode 100644
index 000000000..1803dc2a3
--- /dev/null
+++ b/db/versions/10930-wheatDendro/06-payroll_conceptos.sql
@@ -0,0 +1,6 @@
+-- Place your SQL code here
+ALTER TABLE IF EXISTS `vn2008`.`payroll_conceptos` RENAME `vn`.`payrollComponent`;
+
+ALTER TABLE IF EXISTS `vn`.`payrollComponent`
+CHANGE COLUMN IF EXISTS `conceptoid` `id` int(11) NOT NULL,
+CHANGE COLUMN IF EXISTS `concepto` `name` varchar(255) DEFAULT NULL;
\ No newline at end of file
diff --git a/db/versions/10930-wheatDendro/07-Permisos.sql b/db/versions/10930-wheatDendro/07-Permisos.sql
new file mode 100644
index 000000000..5a3dc1413
--- /dev/null
+++ b/db/versions/10930-wheatDendro/07-Permisos.sql
@@ -0,0 +1,40 @@
+CREATE OR REPLACE DEFINER=`root`@`localhost`
+ SQL SECURITY DEFINER
+ VIEW `vn2008`.`Tramos` AS
+SELECT 1;
+
+GRANT SELECT ON TABLE vn2008.Tramos TO `employee`;
+GRANT SELECT ON TABLE vn.timeSlots TO `employee`;
+
+CREATE OR REPLACE DEFINER=`root`@`localhost`
+ SQL SECURITY DEFINER
+ VIEW `vn2008`.`Proveedores_cargueras` AS
+SELECT 1;
+
+GRANT SELECT ON TABLE vn2008.Proveedores_cargueras TO `buyer`;
+GRANT SELECT ON TABLE vn.supplierFreight TO `buyer`;
+
+CREATE OR REPLACE DEFINER=`root`@`localhost`
+ SQL SECURITY DEFINER
+ VIEW `vn2008`.`payroll_employee` AS
+SELECT 1;
+
+GRANT SELECT,INSERT ON TABLE vn2008.payroll_employee TO `hr`;
+GRANT SELECT,INSERT ON TABLE vn.payrollWorker TO `hr`;
+
+
+CREATE OR REPLACE DEFINER=`root`@`localhost`
+ SQL SECURITY DEFINER
+ VIEW `vn2008`.`payroll_centros` AS
+SELECT 1;
+
+GRANT SELECT ON TABLE vn2008.payroll_centros TO `hr`;
+GRANT SELECT ON TABLE vn.payrollWorkCenter TO `hr`;
+
+CREATE OR REPLACE DEFINER=`root`@`localhost`
+ SQL SECURITY DEFINER
+ VIEW `vn2008`.`payroll_conceptos` AS
+SELECT 1;
+
+GRANT SELECT,UPDATE ON TABLE vn2008.payroll_conceptos TO `hr`;
+GRANT SELECT,UPDATE ON TABLE vn.payrollComponent TO `hr`;
\ No newline at end of file
diff --git a/db/versions/10932-azureEucalyptus/00-firstScript.sql b/db/versions/10932-azureEucalyptus/00-firstScript.sql
new file mode 100644
index 000000000..399819cc4
--- /dev/null
+++ b/db/versions/10932-azureEucalyptus/00-firstScript.sql
@@ -0,0 +1,22 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`multipleInventoryHistory`(
+ vItemFk INT)
+BEGIN
+ DECLARE vDateInventory DATETIME;
+ SELECT inventoried INTO vDateInventory FROM config;
+
+END$$
+DELIMITER ;
+
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`absoluteInventoryHistory`(
+ vItemFk INT, vWarehouse INT, vDate DATETIME)
+BEGIN
+ DECLARE vCalculatedInventory INT;
+ SET vCalculatedInventory = 0;
+
+END$$
+DELIMITER ;
+
+GRANT EXECUTE ON PROCEDURE vn.absoluteInventoryHistory TO buyer;
+GRANT EXECUTE ON PROCEDURE vn.multipleInventoryHistory TO buyer;
diff --git a/db/versions/10940-aquaLilium/00-firstScript.sql b/db/versions/10940-aquaLilium/00-firstScript.sql
new file mode 100644
index 000000000..fb4fa33ff
--- /dev/null
+++ b/db/versions/10940-aquaLilium/00-firstScript.sql
@@ -0,0 +1,8 @@
+
+ ALTER TABLE vn.department
+ ADD COLUMN pbxQueue varchar(128) CHARACTER
+ SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL NULL;
+
+ ALTER TABLE vn.department
+ ADD CONSTRAINT department_queue_FK
+ FOREIGN KEY (pbxQueue) REFERENCES pbx.queue(name) ON DELETE RESTRICT ON UPDATE CASCADE;
diff --git a/db/versions/10941-limePaniculata/00-restoreVn2008Jerarquia.sql b/db/versions/10941-limePaniculata/00-restoreVn2008Jerarquia.sql
new file mode 100644
index 000000000..3f6a52bef
--- /dev/null
+++ b/db/versions/10941-limePaniculata/00-restoreVn2008Jerarquia.sql
@@ -0,0 +1 @@
+ALTER TABLE IF EXISTS vn2008.jerarquia__ RENAME vn2008.jerarquia;
diff --git a/db/versions/10944-tealLaurel/00-firstScript.sql b/db/versions/10944-tealLaurel/00-firstScript.sql
new file mode 100644
index 000000000..2d61cde90
--- /dev/null
+++ b/db/versions/10944-tealLaurel/00-firstScript.sql
@@ -0,0 +1,8 @@
+REVOKE UPDATE ON vn.entry FROM entryEditor;
+GRANT UPDATE ON vn.entry TO administrative;
+GRANT UPDATE (id, supplierFk, dated, invoiceNumber, isExcludedFromAvailable,
+ isConfirmed, isOrdered, isRaid,commission, created, evaNotes, travelFk,
+ currencyFk,companyFk, gestDocFk, invoiceInFk, loadPriority,
+ kop, sub, pro, auction, invoiceAmount, buyerFk, typeFk, reference,
+ observationEditorFk, clonedFrom, editorFk, lockerUserFk, locked
+) ON vn.entry TO entryEditor;
diff --git a/db/versions/10946-blueChrysanthemum/00-firstScript.sql b/db/versions/10946-blueChrysanthemum/00-firstScript.sql
new file mode 100644
index 000000000..c73903f65
--- /dev/null
+++ b/db/versions/10946-blueChrysanthemum/00-firstScript.sql
@@ -0,0 +1,4 @@
+ALTER TABLE IF EXISTS vn2008.unary_scan RENAME vn2008.unary_scan__;
+ALTER TABLE IF EXISTS vn2008.unary_scan_line RENAME vn2008.unary_scan_line__;
+ALTER TABLE IF EXISTS vn2008.unary_scan_line_buy RENAME vn2008.unary_scan_line_buy__;
+ALTER TABLE IF EXISTS vn2008.unary_scan_line_expedition RENAME vn2008.unary_scan_line_expedition__;
diff --git a/db/versions/10948-azureSalal/00-addReconciliationConfig.sql b/db/versions/10948-azureSalal/00-addReconciliationConfig.sql
new file mode 100644
index 000000000..1da6473b4
--- /dev/null
+++ b/db/versions/10948-azureSalal/00-addReconciliationConfig.sql
@@ -0,0 +1,8 @@
+ CREATE OR REPLACE TABLE `vn`.`accountReconciliationConfig` (
+ `id` INT AUTO_INCREMENT,
+ `currencyFk` TINYINT(3) unsigned,
+ `warehouseFk` SMALLINT(6) unsigned,
+ PRIMARY KEY (`id`),
+ CONSTRAINT `account_fk_currency` FOREIGN KEY (`currencyFk`) REFERENCES `currency` (`id`),
+ CONSTRAINT `account_fk_warehouse` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
\ No newline at end of file
diff --git a/db/versions/10948-azureSalal/01-addReconciliationConfig.vn.sql b/db/versions/10948-azureSalal/01-addReconciliationConfig.vn.sql
new file mode 100644
index 000000000..21743a007
--- /dev/null
+++ b/db/versions/10948-azureSalal/01-addReconciliationConfig.vn.sql
@@ -0,0 +1,2 @@
+INSERT INTO `vn`.`accountReconciliationConfig`(currencyFk, warehouseFk)
+ VALUES (1, 1);
\ No newline at end of file
diff --git a/db/versions/10948-azureSalal/02-grantPrivileges.sql b/db/versions/10948-azureSalal/02-grantPrivileges.sql
new file mode 100644
index 000000000..d6853f759
--- /dev/null
+++ b/db/versions/10948-azureSalal/02-grantPrivileges.sql
@@ -0,0 +1,13 @@
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`agencyVolume`()
+BEGIN
+END;
+
+REVOKE EXECUTE ON PROCEDURE `vn2008`.`agencia_volume` FROM `agency`;
+GRANT EXECUTE ON PROCEDURE `vn`.`agencyVolume` TO `agency`;
+
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`addAccountReconciliation`()
+BEGIN
+END;
+
+REVOKE EXECUTE ON PROCEDURE `vn2008`.`account_conciliacion_add` FROM `financial`;
+GRANT EXECUTE ON PROCEDURE `vn`.`addAccountReconciliation` TO `financial`;
diff --git a/db/versions/10948-azureSalal/03-modifyColumn.sql b/db/versions/10948-azureSalal/03-modifyColumn.sql
new file mode 100644
index 000000000..95b7d9c74
--- /dev/null
+++ b/db/versions/10948-azureSalal/03-modifyColumn.sql
@@ -0,0 +1 @@
+ALTER TABLE `vn`.`accountReconciliation` MODIFY debitCredit ENUM('debit', 'credit');
\ No newline at end of file
diff --git a/db/versions/10949-limeLaurel/00-firstScript.sql b/db/versions/10949-limeLaurel/00-firstScript.sql
new file mode 100644
index 000000000..cc0bcc96b
--- /dev/null
+++ b/db/versions/10949-limeLaurel/00-firstScript.sql
@@ -0,0 +1,15 @@
+ INSERT INTO util.notification ( name, description)
+ SELECT 'invoice-ticket-closure',
+ 'Tickets not invoiced during the nightly closure ticket process';
+
+ SET @notificationFk =LAST_INSERT_ID();
+
+ INSERT IGNORE INTO util.notificationAcl (notificationFk, roleFk)
+ SELECT @notificationFk,id
+ FROM account.role
+ WHERE name ='administrative';
+
+ INSERT IGNORE INTO util.notificationSubscription (notificationFk, userFk)
+ SELECT @notificationFk, id
+ FROM account.`user`
+ WHERE `name` = 'admon';
diff --git a/db/versions/10953-redChico/00-account.sql b/db/versions/10953-redChico/00-account.sql
new file mode 100644
index 000000000..e6944a686
--- /dev/null
+++ b/db/versions/10953-redChico/00-account.sql
@@ -0,0 +1,23 @@
+-- account.accountConfig
+ALTER TABLE account.accountConfig MODIFY COLUMN id tinyint(3) unsigned NOT NULL;
+ALTER TABLE account.accountConfig ADD CONSTRAINT accountConfig_check CHECK (id = 1);
+
+-- account.ldapConfig
+ALTER TABLE account.ldapConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE account.ldapConfig ADD CONSTRAINT ldapConfig_check CHECK (id = 1);
+
+-- account.mailConfig
+ALTER TABLE account.mailConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE account.mailConfig ADD CONSTRAINT mailConfig_check CHECK (id = 1);
+
+-- account.roleConfig
+ALTER TABLE account.roleConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE account.roleConfig ADD CONSTRAINT roleConfig_check CHECK (id = 1);
+
+-- account.sambaConfig
+ALTER TABLE account.sambaConfig MODIFY COLUMN id tinyint(3) unsigned NOT NULL;
+ALTER TABLE account.sambaConfig ADD CONSTRAINT sambaConfig_check CHECK (id = 1);
+
+-- account.userConfig
+ALTER TABLE account.userConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE account.userConfig ADD CONSTRAINT userConfig_check CHECK (id = 1);
diff --git a/db/versions/10953-redChico/01-bs.sql b/db/versions/10953-redChico/01-bs.sql
new file mode 100644
index 000000000..e451c8205
--- /dev/null
+++ b/db/versions/10953-redChico/01-bs.sql
@@ -0,0 +1,7 @@
+-- bs.nightTaskConfig
+ALTER TABLE bs.nightTaskConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE bs.nightTaskConfig ADD CONSTRAINT nightTaskConfig_check CHECK (id = 1);
+
+-- bs.workerProductivityConfig
+ALTER TABLE bs.workerProductivityConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE bs.workerProductivityConfig ADD CONSTRAINT workerProductivityConfig_check CHECK (id = 1);
diff --git a/db/versions/10953-redChico/02-edi.sql b/db/versions/10953-redChico/02-edi.sql
new file mode 100644
index 000000000..e97cfcec8
--- /dev/null
+++ b/db/versions/10953-redChico/02-edi.sql
@@ -0,0 +1,15 @@
+-- edi.exchangeConfig
+ALTER TABLE edi.exchangeConfig MODIFY COLUMN id tinyint(3) unsigned NOT NULL;
+ALTER TABLE edi.exchangeConfig ADD CONSTRAINT exchangeConfig_check CHECK (id = 1);
+
+-- edi.ftpConfig
+ALTER TABLE edi.ftpConfig MODIFY COLUMN id tinyint(3) unsigned NOT NULL;
+ALTER TABLE edi.ftpConfig ADD CONSTRAINT ftpConfig_check CHECK (id = 1);
+
+-- edi.imapConfig (Tiene más de 1 registro en producción)
+-- ALTER TABLE edi.imapConfig MODIFY COLUMN id tinyint(3) unsigned NOT NULL;
+-- ALTER TABLE edi.imapConfig ADD CONSTRAINT imapConfig_check CHECK (id = 1);
+
+-- edi.offerRefreshConfig
+ALTER TABLE edi.offerRefreshConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE edi.offerRefreshConfig ADD CONSTRAINT offerRefreshConfig_check CHECK (id = 1);
\ No newline at end of file
diff --git a/db/versions/10953-redChico/03-hedera.sql b/db/versions/10953-redChico/03-hedera.sql
new file mode 100644
index 000000000..3c86fb593
--- /dev/null
+++ b/db/versions/10953-redChico/03-hedera.sql
@@ -0,0 +1,27 @@
+-- hedera.config
+ALTER TABLE hedera.config MODIFY COLUMN id tinyint(3) unsigned NOT NULL;
+ALTER TABLE hedera.config ADD CONSTRAINT config_check CHECK (id = 1);
+
+-- hedera.imageConfig
+ALTER TABLE hedera.imageConfig MODIFY COLUMN id tinyint(3) unsigned NOT NULL;
+ALTER TABLE hedera.imageConfig ADD CONSTRAINT imageConfig_check CHECK (id = 1);
+
+-- hedera.mailConfig
+ALTER TABLE hedera.mailConfig MODIFY COLUMN id tinyint(3) unsigned NOT NULL;
+ALTER TABLE hedera.mailConfig ADD CONSTRAINT mailConfig_check CHECK (id = 1);
+
+-- hedera.orderConfig
+ALTER TABLE hedera.orderConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE hedera.orderConfig ADD CONSTRAINT orderConfig_check CHECK (id = 1);
+
+-- hedera.shelfConfig (Tiene más de 1 registro en producción)
+-- ALTER TABLE hedera.shelfConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+-- ALTER TABLE hedera.shelfConfig ADD CONSTRAINT shelfConfig_check CHECK (id = 1);
+
+-- hedera.tpvConfig
+ALTER TABLE hedera.tpvConfig MODIFY COLUMN id tinyint(3) unsigned NOT NULL;
+ALTER TABLE hedera.tpvConfig ADD CONSTRAINT tpvConfig_check CHECK (id = 1);
+
+-- hedera.tpvImapConfig
+ALTER TABLE hedera.tpvImapConfig MODIFY COLUMN id tinyint(3) unsigned NOT NULL;
+ALTER TABLE hedera.tpvImapConfig ADD CONSTRAINT tpvImapConfig_check CHECK (id = 1);
diff --git a/db/versions/10953-redChico/04-pbx.sql b/db/versions/10953-redChico/04-pbx.sql
new file mode 100644
index 000000000..49f4172c4
--- /dev/null
+++ b/db/versions/10953-redChico/04-pbx.sql
@@ -0,0 +1,15 @@
+-- pbx.config
+ALTER TABLE pbx.config MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE pbx.config ADD CONSTRAINT config_check CHECK (id = 1);
+
+-- pbx.followmeConfig
+ALTER TABLE pbx.followmeConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE pbx.followmeConfig ADD CONSTRAINT followmeConfig_check CHECK (id = 1);
+
+-- pbx.queueConfig (Tiene más de 1 registro en producción)
+-- ALTER TABLE pbx.queueConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+-- ALTER TABLE pbx.queueConfig ADD CONSTRAINT queueConfig_check CHECK (id = 1);
+
+-- pbx.sipConfig
+ALTER TABLE pbx.sipConfig MODIFY COLUMN id mediumint(8) unsigned NOT NULL;
+ALTER TABLE pbx.sipConfig ADD CONSTRAINT sipConfig_check CHECK (id = 1);
diff --git a/db/versions/10953-redChico/05-sage.sql b/db/versions/10953-redChico/05-sage.sql
new file mode 100644
index 000000000..ee60f5f7d
--- /dev/null
+++ b/db/versions/10953-redChico/05-sage.sql
@@ -0,0 +1,3 @@
+-- sage.config
+ALTER TABLE sage.config MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE sage.config ADD CONSTRAINT config_check CHECK (id = 1);
diff --git a/db/versions/10953-redChico/06-salix.sql b/db/versions/10953-redChico/06-salix.sql
new file mode 100644
index 000000000..d6a248f0d
--- /dev/null
+++ b/db/versions/10953-redChico/06-salix.sql
@@ -0,0 +1,7 @@
+-- salix.accessTokenConfig
+ALTER TABLE salix.accessTokenConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE salix.accessTokenConfig ADD CONSTRAINT accessTokenConfig_check CHECK (id = 1);
+
+-- salix.printConfig
+ALTER TABLE salix.printConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE salix.printConfig ADD CONSTRAINT printConfig_check CHECK (id = 1);
diff --git a/db/versions/10953-redChico/06-srt.sql b/db/versions/10953-redChico/06-srt.sql
new file mode 100644
index 000000000..53000eee6
--- /dev/null
+++ b/db/versions/10953-redChico/06-srt.sql
@@ -0,0 +1,3 @@
+-- srt.config
+ALTER TABLE srt.config MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE srt.config ADD CONSTRAINT config_check CHECK (id = 1);
diff --git a/db/versions/10953-redChico/07-util.sql b/db/versions/10953-redChico/07-util.sql
new file mode 100644
index 000000000..152dce3d1
--- /dev/null
+++ b/db/versions/10953-redChico/07-util.sql
@@ -0,0 +1,11 @@
+-- util.config
+ALTER TABLE util.config MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE util.config ADD CONSTRAINT config_check CHECK (id = 1);
+
+-- util.notificationConfig
+ALTER TABLE util.notificationConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE util.notificationConfig ADD CONSTRAINT notificationConfig_check CHECK (id = 1);
+
+-- util.versionConfig
+ALTER TABLE util.versionConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE util.versionConfig ADD CONSTRAINT versionConfig_check CHECK (id = 1);
diff --git a/db/versions/10953-redChico/08-vn.sql b/db/versions/10953-redChico/08-vn.sql
new file mode 100644
index 000000000..14bd3b13f
--- /dev/null
+++ b/db/versions/10953-redChico/08-vn.sql
@@ -0,0 +1,87 @@
+-- vn.accountingConfig
+ALTER TABLE vn.accountingConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.accountingConfig ADD CONSTRAINT accountingConfig_check CHECK (id = 1);
+
+-- vn.auctionConfig
+ALTER TABLE vn.auctionConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.auctionConfig ADD CONSTRAINT auctionConfig_check CHECK (id = 1);
+
+-- vn.autoRadioConfig
+ALTER TABLE vn.autoRadioConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.autoRadioConfig ADD CONSTRAINT autoRadioConfig_check CHECK (id = 1);
+
+-- vn.bankEntityConfig
+ALTER TABLE vn.bankEntityConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.bankEntityConfig ADD CONSTRAINT bankEntityConfig_check CHECK (id = 1);
+
+-- vn.bionicConfig
+ALTER TABLE vn.bionicConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.bionicConfig ADD CONSTRAINT bionicConfig_check CHECK (id = 1);
+
+-- vn.buyConfig
+ALTER TABLE vn.buyConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.buyConfig ADD CONSTRAINT buyConfig_check CHECK (id = 1);
+
+-- vn.chatConfig
+ALTER TABLE vn.chatConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.chatConfig ADD CONSTRAINT chatConfig_check CHECK (id = 1);
+
+-- vn.claimConfig
+ALTER TABLE vn.claimConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.claimConfig ADD CONSTRAINT claimConfig_check CHECK (id = 1);
+
+-- vn.clientConfig
+ALTER TABLE vn.clientConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.clientConfig ADD CONSTRAINT clientConfig_check CHECK (id = 1);
+
+-- vn.comparativeAddConfig
+ALTER TABLE vn.comparativeAddConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.comparativeAddConfig ADD CONSTRAINT comparativeAddConfig_check CHECK (id = 1);
+
+-- vn.comparativeConfig
+ALTER TABLE vn.comparativeConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.comparativeConfig ADD CONSTRAINT comparativeConfig_check CHECK (id = 1);
+
+-- vn.config
+ALTER TABLE vn.config MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.config ADD CONSTRAINT config_check CHECK (id = 1);
+
+-- vn.conveyorConfig (Tiene más de 1 registro en producción)
+-- ALTER TABLE vn.conveyorConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+-- ALTER TABLE vn.conveyorConfig ADD CONSTRAINT conveyorConfig_check CHECK (id = 1);
+
+-- vn.deviceProductionConfig
+ALTER TABLE vn.deviceProductionConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.deviceProductionConfig ADD CONSTRAINT deviceProductionConfig_check CHECK (id = 1);
+
+-- vn.docuwareConfig
+ALTER TABLE vn.docuwareConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.docuwareConfig ADD CONSTRAINT docuwareConfig_check CHECK (id = 1);
+
+-- vn.floramondoConfig
+ALTER TABLE vn.floramondoConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.floramondoConfig ADD CONSTRAINT floramondoConfig_check CHECK (id = 1);
+
+-- vn.franceExpressConfig
+ALTER TABLE vn.franceExpressConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.franceExpressConfig ADD CONSTRAINT franceExpressConfig_check CHECK (id = 1);
+
+-- vn.glsConfig
+ALTER TABLE vn.glsConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.glsConfig ADD CONSTRAINT glsConfig_check CHECK (id = 1);
+
+-- vn.greugeConfig
+ALTER TABLE vn.greugeConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.greugeConfig ADD CONSTRAINT greugeConfig_check CHECK (id = 1);
+
+-- vn.inventoryConfig
+ALTER TABLE vn.inventoryConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.inventoryConfig ADD CONSTRAINT inventoryConfig_check CHECK (id = 1);
+
+-- vn.invoiceInConfig
+ALTER TABLE vn.invoiceInConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.invoiceInConfig ADD CONSTRAINT invoiceInConfig_check CHECK (id = 1);
+
+-- vn.invoiceOutConfig
+ALTER TABLE vn.invoiceOutConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.invoiceOutConfig ADD CONSTRAINT invoiceOutConfig_check CHECK (id = 1);
diff --git a/db/versions/10953-redChico/08-vn2.sql b/db/versions/10953-redChico/08-vn2.sql
new file mode 100644
index 000000000..42985365e
--- /dev/null
+++ b/db/versions/10953-redChico/08-vn2.sql
@@ -0,0 +1,91 @@
+-- vn.invoiceOutTaxConfig (Tiene más de 1 registro en producción)
+-- ALTER TABLE vn.invoiceOutTaxConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+-- ALTER TABLE vn.invoiceOutTaxConfig ADD CONSTRAINT invoiceOutTaxConfig_check CHECK (id = 1);
+
+-- vn.itemConfig
+ALTER TABLE vn.itemConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.itemConfig ADD CONSTRAINT itemConfig_check CHECK (id = 1);
+
+-- vn.machineWorkerConfig
+ALTER TABLE vn.machineWorkerConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.machineWorkerConfig ADD CONSTRAINT machineWorkerConfig_check CHECK (id = 1);
+
+-- vn.mdbConfig
+ALTER TABLE vn.mdbConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.mdbConfig ADD CONSTRAINT mdbConfig_check CHECK (id = 1);
+
+-- vn.mrwConfig
+ALTER TABLE vn.mrwConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.mrwConfig ADD CONSTRAINT mrwConfig_check CHECK (id = 1);
+
+-- vn.osTicketConfig
+ALTER TABLE vn.osTicketConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.osTicketConfig ADD CONSTRAINT osTicketConfig_check CHECK (id = 1);
+
+-- vn.packagingConfig
+ALTER TABLE vn.packagingConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.packagingConfig ADD CONSTRAINT packagingConfig_check CHECK (id = 1);
+
+-- vn.packingSiteConfig
+ALTER TABLE vn.packingSiteConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.packingSiteConfig ADD CONSTRAINT packingSiteConfig_check CHECK (id = 1);
+
+-- vn.productionConfig
+ALTER TABLE vn.productionConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.productionConfig ADD CONSTRAINT productionConfig_check CHECK (id = 1);
+
+-- vn.rateConfig
+ALTER TABLE vn.rateConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.rateConfig ADD CONSTRAINT rateConfig_check CHECK (id = 1);
+
+-- vn.routeConfig
+ALTER TABLE vn.routeConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.routeConfig ADD CONSTRAINT routeConfig_check CHECK (id = 1);
+
+-- vn.salespersonConfig
+ALTER TABLE vn.salespersonConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.salespersonConfig ADD CONSTRAINT salespersonConfig_check CHECK (id = 1);
+
+-- vn.sendingConfig
+ALTER TABLE vn.sendingConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.sendingConfig ADD CONSTRAINT sendingConfig_check CHECK (id = 1);
+
+-- vn.smsConfig
+ALTER TABLE vn.smsConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.smsConfig ADD CONSTRAINT smsConfig_check CHECK (id = 1);
+
+-- vn.ticketConfig
+ALTER TABLE vn.ticketConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.ticketConfig ADD CONSTRAINT ticketConfig_check CHECK (id = 1);
+
+-- vn.tillConfig
+ALTER TABLE vn.tillConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.tillConfig ADD CONSTRAINT tillConfig_check CHECK (id = 1);
+
+-- vn.travelConfig
+ALTER TABLE vn.travelConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.travelConfig ADD CONSTRAINT travelConfig_check CHECK (id = 1);
+
+-- vn.viaexpressConfig
+ALTER TABLE vn.viaexpressConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.viaexpressConfig ADD CONSTRAINT viaexpressConfig_check CHECK (id = 1);
+
+-- vn.wagonConfig
+ALTER TABLE vn.wagonConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.wagonConfig ADD CONSTRAINT wagonConfig_check CHECK (id = 1);
+
+-- vn.workerConfig
+ALTER TABLE vn.workerConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.workerConfig ADD CONSTRAINT workerConfig_check CHECK (id = 1);
+
+-- vn.workerTimeControlConfig
+ALTER TABLE vn.workerTimeControlConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.workerTimeControlConfig ADD CONSTRAINT workerTimeControlConfig_check CHECK (id = 1);
+
+-- vn.zipConfig
+ALTER TABLE vn.zipConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.zipConfig ADD CONSTRAINT zipConfig_check CHECK (id = 1);
+
+-- vn.zoneConfig
+ALTER TABLE vn.zoneConfig MODIFY COLUMN id int(10) unsigned NOT NULL;
+ALTER TABLE vn.zoneConfig ADD CONSTRAINT zoneConfig_check CHECK (id = 1);
diff --git a/db/versions/10956-brownBirch/00-firstScript.sql b/db/versions/10956-brownBirch/00-firstScript.sql
new file mode 100644
index 000000000..bcd15432c
--- /dev/null
+++ b/db/versions/10956-brownBirch/00-firstScript.sql
@@ -0,0 +1,12 @@
+CREATE TABLE floranet.`addressPostCode` (
+ `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `addressFk` int(11) NOT NULL,
+ `postCode` varchar(30) NOT NULL,
+ `hoursInAdvance` int(10) unsigned NOT NULL DEFAULT 24,
+ `dayOfWeek` int(10) unsigned NOT NULL,
+ `deliveryCost` decimal(10,2) NOT NULL DEFAULT 0.00,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `addressPostCode_unique` (`postCode`,`addressFk`,`dayOfWeek`),
+ KEY `addressPostCode_address_FK` (`addressFk`),
+ CONSTRAINT `addressPostCode_address_FK` FOREIGN KEY (`addressFk`) REFERENCES `vn`.`address` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Client''s address registered for floranet network';
\ No newline at end of file
diff --git a/db/versions/10957-goldenAnthurium/00-aclTicketClone.sql b/db/versions/10957-goldenAnthurium/00-aclTicketClone.sql
new file mode 100644
index 000000000..6387b77b0
--- /dev/null
+++ b/db/versions/10957-goldenAnthurium/00-aclTicketClone.sql
@@ -0,0 +1,2 @@
+INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
+ VALUES('Ticket', 'clone', 'WRITE', 'ALLOW', 'ROLE', 'administrative');
\ No newline at end of file
diff --git a/db/versions/10959-bronzePalmetto/00-firstScript.sql b/db/versions/10959-bronzePalmetto/00-firstScript.sql
new file mode 100644
index 000000000..323238d2e
--- /dev/null
+++ b/db/versions/10959-bronzePalmetto/00-firstScript.sql
@@ -0,0 +1 @@
+ALTER TABLE util.debug MODIFY COLUMN value text CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL;
diff --git a/db/versions/10962-greenOrchid/00-firstScript.sql b/db/versions/10962-greenOrchid/00-firstScript.sql
new file mode 100644
index 000000000..c34f5d00b
--- /dev/null
+++ b/db/versions/10962-greenOrchid/00-firstScript.sql
@@ -0,0 +1,7 @@
+-- Place your SQL code here
+USE vn;
+
+INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
+ VALUES
+ ('ExpeditionPallet', '*', 'READ', 'ALLOW', 'ROLE', 'production'),
+ ('Ticket', 'addSaleByCode', 'WRITE', 'ALLOW', 'ROLE', 'production');
\ No newline at end of file
diff --git a/db/versions/10964-silverDracena/00-firstScript.sql b/db/versions/10964-silverDracena/00-firstScript.sql
new file mode 100644
index 000000000..dbc4ba8a0
--- /dev/null
+++ b/db/versions/10964-silverDracena/00-firstScript.sql
@@ -0,0 +1,2 @@
+-- Place your SQL code here
+ALTER TABLE vn.entry CHANGE isBlocked isBlocked__ tinyint(4) DEFAULT 0 NOT NULL COMMENT '@deprecated 27/03/2024';
diff --git a/db/versions/10967-wheatLilium/00-firstScript.sql b/db/versions/10967-wheatLilium/00-firstScript.sql
new file mode 100644
index 000000000..40cfe45bd
--- /dev/null
+++ b/db/versions/10967-wheatLilium/00-firstScript.sql
@@ -0,0 +1,4 @@
+-- Place your SQL code here
+
+INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
+ VALUES('ItemShelving', 'hasItemOlder', 'READ', 'ALLOW', 'ROLE', 'production');
diff --git a/db/versions/10968-salmonBamboo/00-firstScript.sql b/db/versions/10968-salmonBamboo/00-firstScript.sql
new file mode 100644
index 000000000..b79201071
--- /dev/null
+++ b/db/versions/10968-salmonBamboo/00-firstScript.sql
@@ -0,0 +1,3 @@
+ALTER TABLE vn.professionalCategory DROP COLUMN dayBreak, DROP COLUMN `level`;
+ALTER TABLE vn.professionalCategory
+ CHANGE name description varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL;
diff --git a/db/versions/10969-silverCataractarum/00-aclSupplierDms.sql b/db/versions/10969-silverCataractarum/00-aclSupplierDms.sql
new file mode 100644
index 000000000..48c7438f1
--- /dev/null
+++ b/db/versions/10969-silverCataractarum/00-aclSupplierDms.sql
@@ -0,0 +1,3 @@
+-- Place your SQL code here
+INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
+ VALUES('SupplierDms', '*', '*', 'ALLOW', 'ROLE', 'employee');
\ No newline at end of file
diff --git a/db/versions/10970-bronzeGerbera/00-specialPrice.sql b/db/versions/10970-bronzeGerbera/00-specialPrice.sql
new file mode 100644
index 000000000..e2e46fb1f
--- /dev/null
+++ b/db/versions/10970-bronzeGerbera/00-specialPrice.sql
@@ -0,0 +1,10 @@
+ALTER TABLE vn.specialPrice MODIFY COLUMN clientFk int(11) NULL;
+ALTER TABLE vn.specialPrice ADD started date NOT NULL DEFAULT '2024-01-01';
+ALTER TABLE vn.specialPrice ADD ended date NULL;
+ALTER TABLE vn.specialPrice MODIFY COLUMN itemFk int(11) NOT NULL;
+ALTER TABLE vn.specialPrice MODIFY COLUMN value DECIMAL(10,2) NOT NULL;
+
+
+ALTER TABLE vn.`specialPrice`
+ ADD CONSTRAINT `check_date_range`
+ CHECK (`ended` IS NULL OR `ended` >= `started`);
diff --git a/db/versions/10971-turquoiseRuscus/00-firstScript.sql b/db/versions/10971-turquoiseRuscus/00-firstScript.sql
new file mode 100644
index 000000000..82a0117c3
--- /dev/null
+++ b/db/versions/10971-turquoiseRuscus/00-firstScript.sql
@@ -0,0 +1,4 @@
+ALTER TABLE IF EXISTS `vn`.`greugeConfig`
+ ADD COLUMN IF NOT EXISTS `daysAgoOffset` int(11) NOT NULL;
+
+UPDATE vn.greugeConfig SET daysAgoOffset=15;
\ No newline at end of file
diff --git a/db/versions/10973-purpleAsparagus/00-firstScript.sql b/db/versions/10973-purpleAsparagus/00-firstScript.sql
new file mode 100644
index 000000000..f5b838529
--- /dev/null
+++ b/db/versions/10973-purpleAsparagus/00-firstScript.sql
@@ -0,0 +1,2 @@
+-- Place your SQL code here
+ALTER TABLE vn.productionConfig ADD defaultFreightItemFk INT UNSIGNED DEFAULT 71 NOT NULL COMMENT 'Default value for expedition table';
diff --git a/db/versions/10975-whiteIvy/00-action.sql b/db/versions/10975-whiteIvy/00-action.sql
new file mode 100644
index 000000000..3f9cf9d8b
--- /dev/null
+++ b/db/versions/10975-whiteIvy/00-action.sql
@@ -0,0 +1 @@
+CREATE INDEX expeditionLog_action_IDX USING BTREE ON srt.expeditionLog (`action`);
diff --git a/db/versions/10975-whiteIvy/01-expeditionFk.sql b/db/versions/10975-whiteIvy/01-expeditionFk.sql
new file mode 100644
index 000000000..ac1e01e6f
--- /dev/null
+++ b/db/versions/10975-whiteIvy/01-expeditionFk.sql
@@ -0,0 +1 @@
+CREATE INDEX expeditionLog_expeditionFk_IDX USING BTREE ON srt.expeditionLog (expeditionFk);
diff --git a/db/versions/10976-greenCamellia/00-firstScript.sql b/db/versions/10976-greenCamellia/00-firstScript.sql
new file mode 100644
index 000000000..0fd944021
--- /dev/null
+++ b/db/versions/10976-greenCamellia/00-firstScript.sql
@@ -0,0 +1,20 @@
+CREATE OR REPLACE TEMPORARY TABLE tmp.claimsWithHasToPickUp
+ SELECT id
+ FROM vn.claim
+ WHERE hasToPickUp;
+
+ALTER TABLE vn.claim CHANGE hasToPickUp pickup ENUM('agency', 'delivery') DEFAULT NULL;
+
+UPDATE vn.claim c
+ JOIN tmp.claimsWithHasToPickUp tmp ON tmp.id = c.id
+ SET c.pickup = 'delivery';
+
+-- Solved bug empty value
+UPDATE vn.claim
+ SET pickup = NULL
+ WHERE pickup = '';
+
+DROP TEMPORARY TABLE tmp.claimsWithHasToPickUp;
+
+INSERT INTO salix.ACL (model,property,accessType,principalId)
+ VALUES ('Application','getEnumValues','*','employee');
\ No newline at end of file
diff --git a/db/versions/10977-wheatFern/00-firstScript.sql b/db/versions/10977-wheatFern/00-firstScript.sql
new file mode 100644
index 000000000..53c1a4fa6
--- /dev/null
+++ b/db/versions/10977-wheatFern/00-firstScript.sql
@@ -0,0 +1,2 @@
+-- Place your SQL code here
+ALTER TABLE vn.buy DROP COLUMN packageFk;
diff --git a/db/versions/10984-navyDendro/00-firstScript.sql b/db/versions/10984-navyDendro/00-firstScript.sql
new file mode 100644
index 000000000..c08462d75
--- /dev/null
+++ b/db/versions/10984-navyDendro/00-firstScript.sql
@@ -0,0 +1,4 @@
+-- Place your SQL code here
+UPDATE bs.nightTask SET `schema`='vn' WHERE `procedure`='raidUpdate';
+
+UPDATE bs.nightTask SET `schema`='vn',`procedure`='creditRecovery' WHERE `procedure` ='recobro_credito';
\ No newline at end of file
diff --git a/db/versions/10988-blackIvy/00-pbx_prefix.sql b/db/versions/10988-blackIvy/00-pbx_prefix.sql
new file mode 100644
index 000000000..3ce9f5808
--- /dev/null
+++ b/db/versions/10988-blackIvy/00-pbx_prefix.sql
@@ -0,0 +1,35 @@
+CREATE TABLE IF NOT EXISTS pbx.prefix (
+ country CHAR(2) NOT NULL COMMENT 'Country code',
+ prefix varchar(100) NOT NULL COMMENT 'Country prefix',
+ CONSTRAINT prefix_pk PRIMARY KEY (country)
+)
+ENGINE=InnoDB
+DEFAULT CHARSET=utf8mb3
+COLLATE=utf8mb3_unicode_ci;
+
+ALTER TABLE pbx.config
+ CHANGE countryPrefix defaultPrefix varchar(20)
+ CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL NULL;
+
+ALTER TABLE pbx.config DROP COLUMN IF EXISTS sundayFestive;
+
+CREATE TABLE IF NOT EXISTS pbx.holiday (
+ id INT UNSIGNED auto_increment NOT NULL,
+ country CHAR(2) NOT NULL,
+ `day` DATE NOT NULL,
+ CONSTRAINT holiday_pk PRIMARY KEY (id)
+)
+ENGINE=InnoDB
+DEFAULT CHARSET=utf8mb3
+COLLATE=utf8mb3_unicode_ci;
+CREATE UNIQUE INDEX holiday_country_IDX USING BTREE ON pbx.holiday (country,`day`);
+
+ALTER TABLE pbx.schedule
+ CHANGE timeStart startTime time NOT NULL,
+ CHANGE timeEnd endTime time NOT NULL,
+ DROP FOREIGN KEY schedule_ibfk_1,
+ DROP COLUMN queue,
+ ADD country CHAR(2) NOT NULL,
+ CHANGE weekDay weekDays set('mon','tue','wed','thu','fri','sat','sun') NOT NULL
+ COMMENT '0 = Monday, 6 = Sunday';
+
diff --git a/db/versions/10988-blackIvy/01-pbx_prefix.vn.sql b/db/versions/10988-blackIvy/01-pbx_prefix.vn.sql
new file mode 100644
index 000000000..37a17309c
--- /dev/null
+++ b/db/versions/10988-blackIvy/01-pbx_prefix.vn.sql
@@ -0,0 +1,13 @@
+INSERT INTO pbx.prefix (country,prefix)
+ VALUES ('es','0034');
+INSERT INTO pbx.prefix (country,prefix)
+ VALUES ('fr','0033');
+INSERT INTO pbx.prefix (country,prefix)
+ VALUES ('pt','00351');
+
+INSERT INTO pbx.schedule (weekDays,startTime,endTime,country)
+ VALUES ('mon,tue,wed,thu,fri,sat,sun','00:00','24:00','es');
+INSERT INTO pbx.schedule (weekDays,startTime,endTime,country)
+ VALUES ('mon,tue,wed,thu,fri,sat,sun','00:00','24:00','fr');
+INSERT INTO pbx.schedule (weekDays,startTime,endTime,country)
+ VALUES ('mon,tue,wed,thu,fri,sat,sun','00:00','24:00','pt');
diff --git a/db/versions/10990-yellowPalmetto/00-firstScript.sql b/db/versions/10990-yellowPalmetto/00-firstScript.sql
new file mode 100644
index 000000000..be866af8c
--- /dev/null
+++ b/db/versions/10990-yellowPalmetto/00-firstScript.sql
@@ -0,0 +1,5 @@
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_getRisk`()
+BEGIN
+END;
+
+GRANT EXECUTE ON PROCEDURE vn.client_getRisk TO financialBoss;
diff --git a/db/versions/10994-wheatLaurel/00-modifyAcls.sql b/db/versions/10994-wheatLaurel/00-modifyAcls.sql
new file mode 100644
index 000000000..905f67aba
--- /dev/null
+++ b/db/versions/10994-wheatLaurel/00-modifyAcls.sql
@@ -0,0 +1,4 @@
+UPDATE salix.ACL SET principalId = "hr" WHERE property IN ('find','findById','findOne') AND model = "Worker";
+
+INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
+ VALUES ('Worker', '__get__summary', 'READ', 'ALLOW', 'ROLE', 'employee');
\ No newline at end of file
diff --git a/db/versions/10997-crimsonCyca/00-groupingMode.sql b/db/versions/10997-crimsonCyca/00-groupingMode.sql
new file mode 100644
index 000000000..dd4896cc1
--- /dev/null
+++ b/db/versions/10997-crimsonCyca/00-groupingMode.sql
@@ -0,0 +1,16 @@
+START TRANSACTION;
+
+SET @isTriggerDisabled = TRUE;
+
+ALTER TABLE vn.buy ADD groupingMode2 enum('grouping', 'packing') DEFAULT NULL NULL;
+ALTER TABLE vn.buy CHANGE groupingMode2 groupingMode2 enum('grouping', 'packing') DEFAULT NULL NULL AFTER groupingMode;
+
+UPDATE vn.buy SET groupingMode2 = 'packing' WHERE groupingMode = 2;
+UPDATE vn.buy SET groupingMode2 = 'grouping' WHERE groupingMode = 1;
+
+ALTER TABLE vn.buy DROP COLUMN groupingMode;
+ALTER TABLE vn.buy CHANGE groupingMode2 groupingMode enum('grouping','packing') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL;
+
+SET @isTriggerDisabled = FALSE;
+
+COMMIT;
\ No newline at end of file
diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js
index dba430e66..685345273 100644
--- a/e2e/helpers/selectors.js
+++ b/e2e/helpers/selectors.js
@@ -762,7 +762,6 @@ export default {
claimBasicData: {
claimState: 'vn-claim-basic-data vn-autocomplete[ng-model="$ctrl.claim.claimStateFk"]',
packages: 'vn-input-number[ng-model="$ctrl.claim.packages"]',
- hasToPickUpCheckbox: 'vn-claim-basic-data vn-check[ng-model="$ctrl.claim.hasToPickUp"]',
saveButton: `button[type=submit]`
},
claimDetail: {
@@ -1259,7 +1258,7 @@ export default {
},
supplierBasicData: {
alias: 'vn-supplier-basic-data vn-textfield[ng-model="$ctrl.supplier.nickname"]',
- isSerious: 'vn-supplier-basic-data vn-check[ng-model="$ctrl.supplier.isSerious"]',
+ isReal: 'vn-supplier-basic-data vn-check[ng-model="$ctrl.supplier.isReal"]',
isActive: 'vn-supplier-basic-data vn-check[ng-model="$ctrl.supplier.isActive"]',
isPayMethodChecked: 'vn-supplier-basic-data vn-check[ng-model="$ctrl.supplier.isPayMethodChecked"]',
notes: 'vn-supplier-basic-data vn-textarea[ng-model="$ctrl.supplier.note"]',
diff --git a/e2e/paths/02-client/01_create_client.spec.js b/e2e/paths/02-client/01_create_client.spec.js
index 744b11a72..e951ec784 100644
--- a/e2e/paths/02-client/01_create_client.spec.js
+++ b/e2e/paths/02-client/01_create_client.spec.js
@@ -32,7 +32,7 @@ describe('Client create path', () => {
await page.autocompleteSearch(selectors.createClientView.salesPerson, 'salesPerson');
await page.autocompleteSearch(selectors.createClientView.businessType, 'florist');
await page.write(selectors.createClientView.taxNumber, '74451390E');
- await page.write(selectors.createClientView.userName, 'CaptainMarvel');
+ await page.write(selectors.createClientView.userName, 'captainmarvel');
await page.write(selectors.createClientView.email, 'CarolDanvers@verdnatura.es');
await page.waitToClick(selectors.createClientView.createButton);
const message = await page.waitForSnackbar();
diff --git a/e2e/paths/02-client/07_edit_web_access.spec.js b/e2e/paths/02-client/07_edit_web_access.spec.js
index c5e132ab7..8758c3b05 100644
--- a/e2e/paths/02-client/07_edit_web_access.spec.js
+++ b/e2e/paths/02-client/07_edit_web_access.spec.js
@@ -29,7 +29,7 @@ describe('Client web access path', () => {
await page.click($.enableWebAccess);
await page.click($.saveButton);
const enableMessage = await page.waitForSnackbar();
- await page.overwrite($.userName, 'Legion');
+ await page.overwrite($.userName, 'legion');
await page.overwrite($.email, 'legion@marvel.com');
await page.click($.saveButton);
const modifyMessage = await page.waitForSnackbar();
@@ -47,7 +47,7 @@ describe('Client web access path', () => {
expect(modifyMessage.type).toBe('success');
expect(hasAccess).toBe('unchecked');
- expect(userName).toEqual('Legion');
+ expect(userName).toEqual('legion');
expect(email).toEqual('legion@marvel.com');
// expect(logName).toEqual('Legion');
diff --git a/e2e/paths/02-client/09_add_credit.spec.js b/e2e/paths/02-client/09_add_credit.spec.js
index 2365f0635..179265b0f 100644
--- a/e2e/paths/02-client/09_add_credit.spec.js
+++ b/e2e/paths/02-client/09_add_credit.spec.js
@@ -34,6 +34,6 @@ describe('Client Add credit path', () => {
const result = await page.waitToGetProperty(selectors.clientCredit.firstCreditText, 'innerText');
expect(result).toContain(999);
- expect(result).toContain('salesAssistant');
+ expect(result).toContain('salesassistant');
});
});
diff --git a/e2e/paths/02-client/19_summary.spec.js b/e2e/paths/02-client/19_summary.spec.js
index b3bf43c5c..dec8d505c 100644
--- a/e2e/paths/02-client/19_summary.spec.js
+++ b/e2e/paths/02-client/19_summary.spec.js
@@ -61,7 +61,7 @@ describe('Client summary path', () => {
it('should display web access details', async() => {
const result = await page.waitToGetProperty(selectors.clientSummary.userName, 'innerText');
- expect(result).toContain('PetterParker');
+ expect(result).toContain('petterparker');
});
it('should display business data', async() => {
diff --git a/e2e/paths/03-worker/01_summary.spec.js b/e2e/paths/03-worker/01_summary.spec.js
index 51992b41d..3c6149726 100644
--- a/e2e/paths/03-worker/01_summary.spec.js
+++ b/e2e/paths/03-worker/01_summary.spec.js
@@ -2,7 +2,6 @@ import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
describe('Worker summary path', () => {
- const workerId = 3;
let browser;
let page;
beforeAll(async() => {
@@ -10,7 +9,7 @@ describe('Worker summary path', () => {
page = browser.page;
await page.loginAndModule('employee', 'worker');
const httpDataResponse = page.waitForResponse(response => {
- return response.status() === 200 && response.url().includes(`Workers/${workerId}`);
+ return response.status() === 200 && response.url().includes(`Workers/summary`);
});
await page.accessToSearchResult('agencyNick');
await httpDataResponse;
diff --git a/e2e/paths/05-ticket/05_tracking_state.spec.js b/e2e/paths/05-ticket/05_tracking_state.spec.js
index 9ac373287..5cfc1c9d4 100644
--- a/e2e/paths/05-ticket/05_tracking_state.spec.js
+++ b/e2e/paths/05-ticket/05_tracking_state.spec.js
@@ -59,7 +59,7 @@ describe('Ticket Create new tracking state path', () => {
const result = await page
.waitToGetProperty(selectors.createStateView.worker, 'value');
- expect(result).toEqual('salesPerson');
+ expect(result).toEqual('salesperson');
});
it(`should succesfully create a valid state`, async() => {
diff --git a/e2e/paths/05-ticket/09_weekly.spec.js b/e2e/paths/05-ticket/09_weekly.spec.js
index 74febfd01..20cfa0d13 100644
--- a/e2e/paths/05-ticket/09_weekly.spec.js
+++ b/e2e/paths/05-ticket/09_weekly.spec.js
@@ -24,7 +24,7 @@ describe('Ticket descriptor path', () => {
it('should go back to the ticket index then search and access a ticket summary', async() => {
await page.accessToSection('ticket.index');
- await page.accessToSearchResult('11');
+ await page.accessToSearchResult('33');
});
it('should add the ticket to thursday turn using the descriptor more menu', async() => {
@@ -33,7 +33,7 @@ describe('Ticket descriptor path', () => {
await page.waitToClick(selectors.ticketDescriptor.thursdayButton);
const message = await page.waitForSnackbar();
- expect(message.text).toContain('Data saved!');
+ expect(message.text).toContain('Current ticket deleted and added to shift');
});
it('should again click on the Tickets button of the top bar menu', async() => {
@@ -43,7 +43,7 @@ describe('Ticket descriptor path', () => {
await page.waitForState('ticket.index');
});
- it('should confirm the ticket 11 was added to thursday', async() => {
+ it('should confirm the ticket 33 was added to thursday', async() => {
await page.accessToSection('ticket.weekly.index');
const result = await page.waitToGetProperty(selectors.ticketsIndex.thirdWeeklyTicket, 'value');
@@ -57,8 +57,8 @@ describe('Ticket descriptor path', () => {
await page.waitForState('ticket.index');
});
- it('should now search for the ticket 11', async() => {
- await page.accessToSearchResult('11');
+ it('should now search for the ticket 33', async() => {
+ await page.accessToSearchResult('33');
await page.waitForState('ticket.card.summary');
});
@@ -68,7 +68,7 @@ describe('Ticket descriptor path', () => {
await page.waitToClick(selectors.ticketDescriptor.saturdayButton);
const message = await page.waitForSnackbar();
- expect(message.text).toContain('Data saved!');
+ expect(message.text).toContain('Current ticket deleted and added to shift');
});
it('should click on the Tickets button of the top bar menu once again', async() => {
@@ -78,7 +78,7 @@ describe('Ticket descriptor path', () => {
await page.waitForState('ticket.index');
});
- it('should confirm the ticket 11 was added on saturday', async() => {
+ it('should confirm the ticket 33 was added on saturday', async() => {
await page.accessToSection('ticket.weekly.index');
await page.waitForTimeout(5000);
@@ -87,14 +87,14 @@ describe('Ticket descriptor path', () => {
expect(result).toEqual('Saturday');
});
- it('should now search for the weekly ticket 11', async() => {
- await page.doSearch('11');
+ it('should now search for the weekly ticket 33', async() => {
+ await page.doSearch('33');
const nResults = await page.countElement(selectors.ticketsIndex.searchWeeklyResult);
expect(nResults).toEqual(2);
});
- it('should delete the weekly ticket 11', async() => {
+ it('should delete the weekly ticket 33', async() => {
await page.waitToClick(selectors.ticketsIndex.firstWeeklyTicketDeleteIcon);
await page.waitToClick(selectors.ticketsIndex.acceptDeleteTurn);
const message = await page.waitForSnackbar();
diff --git a/e2e/paths/06-claim/01_basic_data.spec.js b/e2e/paths/06-claim/01_basic_data.spec.js
index 0a08cad9f..33c68183f 100644
--- a/e2e/paths/06-claim/01_basic_data.spec.js
+++ b/e2e/paths/06-claim/01_basic_data.spec.js
@@ -21,7 +21,7 @@ describe('Claim edit basic data path', () => {
});
it(`should edit claim state and observation fields`, async() => {
- await page.autocompleteSearch(selectors.claimBasicData.claimState, 'Gestionado');
+ await page.autocompleteSearch(selectors.claimBasicData.claimState, 'Resuelto');
await page.clearInput(selectors.claimBasicData.packages);
await page.write(selectors.claimBasicData.packages, '2');
await page.waitToClick(selectors.claimBasicData.saveButton);
@@ -34,27 +34,12 @@ describe('Claim edit basic data path', () => {
await page.waitForState('claim.card.detail');
});
- it('should check the "Pick up" checkbox', async() => {
- await page.reloadSection('claim.card.basicData');
- await page.waitToClick(selectors.claimBasicData.hasToPickUpCheckbox);
- await page.waitToClick(selectors.claimBasicData.saveButton);
- const message = await page.waitForSnackbar();
-
- expect(message.text).toContain('Data saved!');
- });
-
it('should confirm the claim state was edited', async() => {
await page.reloadSection('claim.card.basicData');
await page.waitForSelector(selectors.claimBasicData.claimState);
const result = await page.waitToGetProperty(selectors.claimBasicData.claimState, 'value');
- expect(result).toEqual('Gestionado');
- });
-
- it('should confirm the "is paid with mana" and "Pick up" checkbox are checked', async() => {
- const hasToPickUpCheckbox = await page.checkboxState(selectors.claimBasicData.hasToPickUpCheckbox);
-
- expect(hasToPickUpCheckbox).toBe('checked');
+ expect(result).toEqual('Resuelto');
});
it('should confirm the claim packages was edited', async() => {
diff --git a/e2e/paths/13-supplier/02_basic_data.spec.js b/e2e/paths/13-supplier/02_basic_data.spec.js
index 79a9898ca..710ebd8df 100644
--- a/e2e/paths/13-supplier/02_basic_data.spec.js
+++ b/e2e/paths/13-supplier/02_basic_data.spec.js
@@ -20,7 +20,7 @@ describe('Supplier basic data path', () => {
it('should edit the basic data', async() => {
await page.clearInput(selectors.supplierBasicData.alias);
await page.write(selectors.supplierBasicData.alias, 'Plants Nick SL');
- await page.waitToClick(selectors.supplierBasicData.isSerious);
+ await page.waitToClick(selectors.supplierBasicData.isReal);
await page.waitToClick(selectors.supplierBasicData.isActive);
await page.waitToClick(selectors.supplierBasicData.isPayMethodChecked);
await page.write(selectors.supplierBasicData.notes, 'Some notes');
@@ -41,8 +41,8 @@ describe('Supplier basic data path', () => {
expect(result).toEqual('Plants Nick SL');
});
- it('should check the isSerious checkbox is now checked', async() => {
- const result = await page.checkboxState(selectors.supplierBasicData.isSerious);
+ it('should check the isReal checkbox is now checked', async() => {
+ const result = await page.checkboxState(selectors.supplierBasicData.isReal);
expect(result).toBe('checked');
});
diff --git a/e2e/paths/14-account/01_create_and_basic_data.spec.js b/e2e/paths/14-account/01_create_and_basic_data.spec.js
index e38d1aeec..e2c069d80 100644
--- a/e2e/paths/14-account/01_create_and_basic_data.spec.js
+++ b/e2e/paths/14-account/01_create_and_basic_data.spec.js
@@ -21,7 +21,7 @@ describe('Account create and basic data path', () => {
});
it('should fill the form and then save it by clicking the create button', async() => {
- await page.write(selectors.accountIndex.newName, 'Remy');
+ await page.write(selectors.accountIndex.newName, 'remy');
await page.write(selectors.accountIndex.newNickname, 'Gambit');
await page.write(selectors.accountIndex.newEmail, 'RemyEtienneLeBeau@verdnatura.es');
await page.autocompleteSearch(selectors.accountIndex.newRole, 'Trainee');
@@ -39,7 +39,7 @@ describe('Account create and basic data path', () => {
it('should check the name is as expected', async() => {
const result = await page.waitToGetProperty(selectors.accountBasicData.name, 'value');
- expect(result).toEqual('Remy');
+ expect(result).toEqual('remy');
});
it('should check the nickname is as expected', async() => {
diff --git a/e2e/paths/14-account/02_alias_create_and_basic_data.spec.js b/e2e/paths/14-account/02_alias_create_and_basic_data.spec.js
index dd35dd740..840fb8afe 100644
--- a/e2e/paths/14-account/02_alias_create_and_basic_data.spec.js
+++ b/e2e/paths/14-account/02_alias_create_and_basic_data.spec.js
@@ -8,7 +8,7 @@ describe('Account Alias create and basic data path', () => {
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
- await page.loginAndModule('developer', 'account');
+ await page.loginAndModule('itManagement', 'account');
await page.accessToSection('account.alias');
});
diff --git a/e2e/paths/14-account/05_connections.spec.js b/e2e/paths/14-account/05_connections.spec.js
index 89b286101..49d5f612d 100644
--- a/e2e/paths/14-account/05_connections.spec.js
+++ b/e2e/paths/14-account/05_connections.spec.js
@@ -22,12 +22,4 @@ describe('Account Connections path', () => {
expect(firstResult).toContain(account);
});
-
- it('should kill this connection and then get redirected to the login page', async() => {
- await page.waitToClick(selectors.accountConnections.deleteFirstConnection);
- await page.waitToClick(selectors.globalItems.acceptButton);
- const message = await page.waitForSnackbar();
-
- expect(message.text).toContain('Your session has expired, please login again');
- });
});
diff --git a/front/core/components/link-phone/index.html b/front/core/components/link-phone/index.html
index 2789ab75c..58724b0a1 100644
--- a/front/core/components/link-phone/index.html
+++ b/front/core/components/link-phone/index.html
@@ -5,7 +5,6 @@
flat
round
icon="phone"
- title="MicroSIP"
ng-click="$event.stopPropagation();"
>
diff --git a/front/core/components/searchbar/style.scss b/front/core/components/searchbar/style.scss
index eab9c126b..b8dff9474 100644
--- a/front/core/components/searchbar/style.scss
+++ b/front/core/components/searchbar/style.scss
@@ -61,10 +61,10 @@ vn-searchbar {
}
vn-icon[icon="info"] {
- position: absolute;
+ position: absolute;
top: 2px;
right: 2px
}
}
}
-}
\ No newline at end of file
+}
diff --git a/front/core/services/auth.js b/front/core/services/auth.js
index 844a5145d..753bc3fba 100644
--- a/front/core/services/auth.js
+++ b/front/core/services/auth.js
@@ -83,22 +83,27 @@ export default class Auth {
}
onLoginOk(json, now, remember) {
- this.vnToken.set(json.data.token, now, json.data.ttl, remember);
-
- return this.loadAcls().then(() => {
- let continueHash = this.$state.params.continue;
- if (continueHash)
- this.$window.location = continueHash;
- else
- this.$state.go('home');
- });
+ return this.$http.get('VnUsers/ShareToken', {
+ headers: {Authorization: json.data.token}
+ }).then(({data}) => {
+ this.vnToken.set(json.data.token, data.multimediaToken.id, now, json.data.ttl, remember);
+ this.loadAcls().then(() => {
+ let continueHash = this.$state.params.continue;
+ if (continueHash)
+ this.$window.location = continueHash;
+ else
+ this.$state.go('home');
+ });
+ }).catch(() => {});
}
logout() {
+ this.$http.post('Accounts/logout', null, {headers: {'Authorization': this.vnToken.tokenMultimedia},
+ }).catch(() => {});
+
let promise = this.$http.post('VnUsers/logout', null, {
headers: {Authorization: this.vnToken.token}
}).catch(() => {});
-
this.vnToken.unset();
this.loggedIn = false;
this.vnModules.reset();
diff --git a/front/core/services/file.js b/front/core/services/file.js
index 25ace4470..dfd2ebc83 100644
--- a/front/core/services/file.js
+++ b/front/core/services/file.js
@@ -14,7 +14,7 @@ class File {
*/
getPath(dmsUrl) {
const serializedParams = this.$httpParamSerializer({
- access_token: this.vnToken.token
+ access_token: this.vnToken.tokenMultimedia
});
return `${dmsUrl}?${serializedParams}`;
diff --git a/front/core/services/interceptor.js b/front/core/services/interceptor.js
index 0c3253c69..90d813ed4 100644
--- a/front/core/services/interceptor.js
+++ b/front/core/services/interceptor.js
@@ -19,7 +19,7 @@ function interceptor($q, vnApp, $translate) {
if (config.url.charAt(0) !== '/' && apiPath)
config.url = `${apiPath}${config.url}`;
- if (token)
+ if (token && !config.headers.Authorization)
config.headers.Authorization = token;
if ($translate.use())
config.headers['Accept-Language'] = $translate.use();
diff --git a/front/core/services/report.js b/front/core/services/report.js
index d6eb28ea4..e3579dd5a 100644
--- a/front/core/services/report.js
+++ b/front/core/services/report.js
@@ -15,7 +15,7 @@ class Report {
*/
show(path, params) {
params = Object.assign({
- access_token: this.vnToken.token
+ access_token: this.vnToken.tokenMultimedia
}, params);
const serializedParams = this.$httpParamSerializer(params);
const query = serializedParams ? `?${serializedParams}` : '';
diff --git a/front/core/services/token.js b/front/core/services/token.js
index c8cb4f6bb..125de6b9a 100644
--- a/front/core/services/token.js
+++ b/front/core/services/token.js
@@ -24,21 +24,22 @@ export default class Token {
} catch (e) {}
}
- set(token, created, ttl, remember) {
+ set(token, tokenMultimedia, created, ttl, remember) {
this.unset();
Object.assign(this, {
token,
+ tokenMultimedia,
created,
ttl,
remember
});
- this.vnInterceptor.setToken(token);
+ this.vnInterceptor.setToken(token, tokenMultimedia);
try {
if (remember)
- this.setStorage(localStorage, token, created, ttl);
+ this.setStorage(localStorage, token, tokenMultimedia, created, ttl);
else
- this.setStorage(sessionStorage, token, created, ttl);
+ this.setStorage(sessionStorage, token, tokenMultimedia, created, ttl);
} catch (err) {
console.error(err);
}
@@ -46,6 +47,7 @@ export default class Token {
unset() {
this.token = null;
+ this.tokenMultimedia = null;
this.created = null;
this.ttl = null;
this.remember = null;
@@ -57,13 +59,15 @@ export default class Token {
getStorage(storage) {
this.token = storage.getItem('vnToken');
+ this.tokenMultimedia = storage.getItem('vnTokenMultimedia');
if (!this.token) return;
const created = storage.getItem('vnTokenCreated');
this.created = created && new Date(created);
this.ttl = storage.getItem('vnTokenTtl');
}
- setStorage(storage, token, created, ttl) {
+ setStorage(storage, token, tokenMultimedia, created, ttl) {
+ storage.setItem('vnTokenMultimedia', tokenMultimedia);
storage.setItem('vnToken', token);
storage.setItem('vnTokenCreated', created.toJSON());
storage.setItem('vnTokenTtl', ttl);
@@ -71,6 +75,7 @@ export default class Token {
removeStorage(storage) {
storage.removeItem('vnToken');
+ storage.removeItem('vnTokenMultimedia');
storage.removeItem('vnTokenCreated');
storage.removeItem('vnTokenTtl');
}
diff --git a/front/salix/components/layout/index.js b/front/salix/components/layout/index.js
index 89912d4e3..e935c6d99 100644
--- a/front/salix/components/layout/index.js
+++ b/front/salix/components/layout/index.js
@@ -23,8 +23,7 @@ export class Layout extends Component {
if (!this.$.$root.user) return;
const userId = this.$.$root.user.id;
- const token = this.vnToken.token;
- return `/api/Images/user/160x160/${userId}/download?access_token=${token}`;
+ return `/api/Images/user/160x160/${userId}/download?access_token=${this.vnToken.tokenMultimedia}`;
}
refresh() {
diff --git a/front/salix/components/log/index.html b/front/salix/components/log/index.html
index c75030100..a3aaf0011 100644
--- a/front/salix/components/log/index.html
+++ b/front/salix/components/log/index.html
@@ -31,7 +31,7 @@
ng-click="$ctrl.showDescriptor($event, userLog)">
+ ng-src="/api/Images/user/160x160/{{::userLog.userFk}}/download?access_token={{::$ctrl.vnToken.tokenMultimedia}}">
@@ -181,7 +181,7 @@
val="{{::nickname}}">
+ ng-src="/api/Images/user/160x160/{{::id}}/download?access_token={{::$ctrl.vnToken.tokenMultimedia}}">