From 06296e7bd5fff378be03592e7a2048e813cd0c0b Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 2 Oct 2024 13:39:10 +0200 Subject: [PATCH 01/89] feat: refs #8071 travel_weeklyClone --- db/routines/vn/procedures/travel_cloneWithEntries.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/travel_cloneWithEntries.sql b/db/routines/vn/procedures/travel_cloneWithEntries.sql index ee26aea32..0199c452f 100644 --- a/db/routines/vn/procedures/travel_cloneWithEntries.sql +++ b/db/routines/vn/procedures/travel_cloneWithEntries.sql @@ -62,7 +62,7 @@ BEGIN END IF; CALL entry_cloneHeader(vAuxEntryFk, vNewEntryFk, vNewTravelFk); - CALL entry_copyBuys(vAuxEntryFk, vNewEntryFk); + CALL entry_copyBuys(vAuxEntryFk, vNewEntryFk); SELECT evaNotes INTO vEvaNotes FROM entry @@ -71,6 +71,8 @@ BEGIN UPDATE entry SET evaNotes = vEvaNotes WHERE id = vNewEntryFk; + + CALL vn.buy_recalcPricesByEntry(vNewEntryFk); END LOOP; SET @isModeInventory = FALSE; From 78a9b788bf3d77ca736694d4f3fadc259cde69e7 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 14 Oct 2024 08:42:54 +0200 Subject: [PATCH 02/89] feat: refs #7006 itemTypeLog created --- .../vn/triggers/itemType_afterDelete.sql | 12 ++++++++++ .../vn/triggers/itemType_beforeInsert.sql | 8 +++++++ .../vn/triggers/itemType_beforeUpdate.sql | 1 + .../triggers/productionConfig_afterDelete.sql | 2 +- .../11297-graySalal/00-firstScript.sql | 24 +++++++++++++++++++ modules/item/back/models/item-type-log.json | 9 +++++++ 6 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 db/routines/vn/triggers/itemType_afterDelete.sql create mode 100644 db/routines/vn/triggers/itemType_beforeInsert.sql create mode 100644 db/versions/11297-graySalal/00-firstScript.sql create mode 100644 modules/item/back/models/item-type-log.json diff --git a/db/routines/vn/triggers/itemType_afterDelete.sql b/db/routines/vn/triggers/itemType_afterDelete.sql new file mode 100644 index 000000000..32a1ba31c --- /dev/null +++ b/db/routines/vn/triggers/itemType_afterDelete.sql @@ -0,0 +1,12 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemType_afterDelete` + AFTER DELETE ON `itemType` + FOR EACH ROW +BEGIN + INSERT INTO itemTypeLog + SET `action` = 'delete', + `changedModel` = 'ItemType', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/itemType_beforeInsert.sql b/db/routines/vn/triggers/itemType_beforeInsert.sql new file mode 100644 index 000000000..d33d8fb56 --- /dev/null +++ b/db/routines/vn/triggers/itemType_beforeInsert.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemType_beforeInsert` + BEFORE INSERT ON `itemType` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/itemType_beforeUpdate.sql b/db/routines/vn/triggers/itemType_beforeUpdate.sql index 613ae8bfa..6a03d40d0 100644 --- a/db/routines/vn/triggers/itemType_beforeUpdate.sql +++ b/db/routines/vn/triggers/itemType_beforeUpdate.sql @@ -3,6 +3,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemType_beforeUpdate` BEFORE UPDATE ON `itemType` FOR EACH ROW BEGIN + SET NEW.editorFk = account.myUser_getId(); IF NEW.itemPackingTypeFk = '' THEN SET NEW.itemPackingTypeFk = NULL; diff --git a/db/routines/vn/triggers/productionConfig_afterDelete.sql b/db/routines/vn/triggers/productionConfig_afterDelete.sql index 6b6800d4f..bd485d590 100644 --- a/db/routines/vn/triggers/productionConfig_afterDelete.sql +++ b/db/routines/vn/triggers/productionConfig_afterDelete.sql @@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`productionConfig_afterD AFTER DELETE ON `productionConfig` FOR EACH ROW BEGIN - INSERT INTO productionConfig + INSERT INTO productionConfigLog SET `action` = 'delete', `changedModel` = 'ProductionConfig', `changedModelId` = OLD.id, diff --git a/db/versions/11297-graySalal/00-firstScript.sql b/db/versions/11297-graySalal/00-firstScript.sql new file mode 100644 index 000000000..d6aeb1ec2 --- /dev/null +++ b/db/versions/11297-graySalal/00-firstScript.sql @@ -0,0 +1,24 @@ +ALTER TABLE vn.itemType + ADD editorFk int(10) unsigned DEFAULT NULL NULL, + ADD CONSTRAINT itemType_user_FK FOREIGN KEY (editorFk) REFERENCES account.`user`(id); + +CREATE TABLE `vn`.`itemTypeLog` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `originFk` int(11) DEFAULT NULL, + `userFk` int(10) unsigned DEFAULT NULL, + `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('ItemType') NOT NULL DEFAULT 'ItemType', + `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, + `summaryId` varchar(30) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `itemTypeLogUserFk_idx` (`userFk`), + KEY `itemTypeLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), + KEY `itemTypeLog_originFk` (`originFk`,`creationDate`), + KEY `itemTypeLog_creationDate_IDX` (`creationDate` DESC) USING BTREE, + CONSTRAINT `itemTypeLogUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci `PAGE_COMPRESSED`=1; diff --git a/modules/item/back/models/item-type-log.json b/modules/item/back/models/item-type-log.json new file mode 100644 index 000000000..61e27e9ba --- /dev/null +++ b/modules/item/back/models/item-type-log.json @@ -0,0 +1,9 @@ +{ + "name": "ItemTypeLog", + "base": "Log", + "options": { + "mysql": { + "table": "ItemTypeLog" + } + } +} From 6c621726334adf2a4e93816c7dfceac28f9a6009 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 14 Oct 2024 09:31:35 +0200 Subject: [PATCH 03/89] feat: refs #7006 itemTypeLog created --- db/versions/11297-graySalal/00-firstScript.sql | 3 +++ modules/item/back/model-config.json | 3 +++ modules/item/back/models/item-type-log.json | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/db/versions/11297-graySalal/00-firstScript.sql b/db/versions/11297-graySalal/00-firstScript.sql index d6aeb1ec2..372af804c 100644 --- a/db/versions/11297-graySalal/00-firstScript.sql +++ b/db/versions/11297-graySalal/00-firstScript.sql @@ -22,3 +22,6 @@ CREATE TABLE `vn`.`itemTypeLog` ( KEY `itemTypeLog_creationDate_IDX` (`creationDate` DESC) USING BTREE, CONSTRAINT `itemTypeLogUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci `PAGE_COMPRESSED`=1; + +INSERT IGNORE INTO salix.ACL (model,property,principalId) + VALUES ('ItemTypeLog','*','employee'); diff --git a/modules/item/back/model-config.json b/modules/item/back/model-config.json index 5dbe4d62a..dcd973524 100644 --- a/modules/item/back/model-config.json +++ b/modules/item/back/model-config.json @@ -47,6 +47,9 @@ "ItemType": { "dataSource": "vn" }, + "ItemTypeLog": { + "dataSource": "vn" + }, "ItemTypeTag": { "dataSource": "vn" }, diff --git a/modules/item/back/models/item-type-log.json b/modules/item/back/models/item-type-log.json index 61e27e9ba..82a218aa6 100644 --- a/modules/item/back/models/item-type-log.json +++ b/modules/item/back/models/item-type-log.json @@ -3,7 +3,7 @@ "base": "Log", "options": { "mysql": { - "table": "ItemTypeLog" + "table": "itemTypeLog" } } } From 999cb2dbb44361f20471532e39e52b94a4dee038 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 17 Oct 2024 10:08:27 +0200 Subject: [PATCH 04/89] feat: refs #8119 itemCampaignQuantity --- .../vn/events/itemCampaignQuantity_add.sql | 8 ++ .../procedures/itemCampaignQuantity_add.sql | 81 +++++++++++++++++++ .../11308-redCymbidium/00-firstScript.sql | 24 ++++++ 3 files changed, 113 insertions(+) create mode 100644 db/routines/vn/events/itemCampaignQuantity_add.sql create mode 100644 db/routines/vn/procedures/itemCampaignQuantity_add.sql create mode 100644 db/versions/11308-redCymbidium/00-firstScript.sql diff --git a/db/routines/vn/events/itemCampaignQuantity_add.sql b/db/routines/vn/events/itemCampaignQuantity_add.sql new file mode 100644 index 000000000..a90a678f3 --- /dev/null +++ b/db/routines/vn/events/itemCampaignQuantity_add.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `vn`.`itemCampaignQuantity_add` + ON SCHEDULE EVERY 5 MINUTE + STARTS '2024-10-18 03:00:00.000' + ON COMPLETION PRESERVE + ENABLE +DO CALL itemCampaignQuantity_add(NULL, NULL, NULL)$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/itemCampaignQuantity_add.sql b/db/routines/vn/procedures/itemCampaignQuantity_add.sql new file mode 100644 index 000000000..af5d0e2de --- /dev/null +++ b/db/routines/vn/procedures/itemCampaignQuantity_add.sql @@ -0,0 +1,81 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemCampaignQuantity_add`( + vDateFrom DATE, + vDateTo DATE, + vCampaign VARCHAR(100) +) +proc: BEGIN +/** + * Añade registros a tabla itemCampaignQuantity. + * + * @param vDateFrom Fecha desde + * @param vDateTo Fecha hasta + * @param vCampaign Código de la campaña + */ + DECLARE vYesterday INT; + DECLARE vDefaultCampaign VARCHAR(100); + DECLARE vPreviousDaysToInsert INT; + DECLARE vDateSumFrom DATE; + DECLARE vDateSumTo DATE; + DECLARE vScopeDays DATE; + + SET vYesterday = util.yesterday(); + + IF vDateFrom IS NULL THEN + SET vDateFrom = vYesterday; + END IF; + + IF vDateTo IS NULL THEN + SET vDateTo = vYesterday; + END IF; + + IF vDateFrom > vDateTo THEN + CALL util.throw('Start date cannot be later than end date'); + END IF; + + SELECT defaultCampaign, previousDaysToInsert + INTO vDefaultCampaign, vPreviousDaysToInsert + FROM itemCampaignQuantityConfig; + + IF vCampaign IS NULL THEN + SET vCampaign = vDefaultCampaign; + END IF; + + IF vCampaign IS NULL OR vPreviousDaysToInsert IS NULL THEN + CALL util.throw('Missing values in the configuration table'); + END IF; + + SELECT dated, scopeDays INTO vDateSumTo, vScopeDays + FROM campaign + WHERE dated > util.VN_CURDATE() + AND code = vCampaign + ORDER BY dated + LIMIT 1; + + IF vDateSumTo IS NULL OR vScopeDays IS NULL THEN + CALL util.throw('Missing data in campaign table'); + END IF; + + IF NOT util.VN_CURDATE() BETWEEN vDateSumTo - INTERVAL vPreviousDaysToInsert DAY + AND vDateSumTo THEN + LEAVE proc; + END IF; + + SET vDateSumFrom = vDateSumTo - INTERVAL vScopeDays DAY; + + INSERT INTO itemCampaignQuantity(dated, itemFk, quantity, campaign) + SELECT DATE(s.created), + s.itemFk, + CASE WHEN t.shipped BETWEEN vDateSumFrom AND vDateSumTo + THEN SUM(s.quantity) + END quantity, + vCampaign + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN client c ON c.id = t.clientFk + WHERE s.created BETWEEN vDateFrom AND util.dayEnd(vDateTo) + AND c.businessTypeFk <> 'worker' + GROUP BY DATE(s.created), s.itemFk + HAVING quantity; +END$$ +DELIMITER ; diff --git a/db/versions/11308-redCymbidium/00-firstScript.sql b/db/versions/11308-redCymbidium/00-firstScript.sql new file mode 100644 index 000000000..ea3436b80 --- /dev/null +++ b/db/versions/11308-redCymbidium/00-firstScript.sql @@ -0,0 +1,24 @@ +CREATE TABLE IF NOT EXISTS vn.itemCampaignQuantity ( + dated date NOT NULL, + itemFk int(11) NOT NULL, + quantity decimal(10,2) NOT NULL, + campaign varchar(100) NOT NULL, + CONSTRAINT itemCampaignQuantity_pk PRIMARY KEY (dated,itemFk), + CONSTRAINT itemCampaignQuantity_item_FK FOREIGN KEY (itemFk) REFERENCES vn.item(id) ON DELETE RESTRICT ON UPDATE CASCADE +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8mb3 +COLLATE=utf8mb3_unicode_ci; + +CREATE TABLE IF NOT EXISTS vn.itemCampaignQuantityConfig ( + id int(10) unsigned NOT NULL PRIMARY, + defaultCampaign varchar(100) NOT NULL COMMENT 'Campaña por defecto si se le pasa NULL', + previousDaysToInsert int(10) unsigned NOT NULL COMMENT 'Días anteriores a la fecha de fin de campaña para insertar', + CONSTRAINT `itemCampaignQuantityConfig_check` CHECK (`id` = 1) +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8mb3 +COLLATE=utf8mb3_unicode_ci; + +INSERT IGNORE INTO vn.itemCampaignQuantityConfig(id, defaultCampaign, previousDaysToInsert) + VALUES (1, 'allSaints', 90); From ec13c41be327c560c3982f70f2b3c2ac159e046e Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 17 Oct 2024 10:09:57 +0200 Subject: [PATCH 05/89] feat: refs #8119 itemCampaignQuantity --- db/routines/vn/events/itemCampaignQuantity_add.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/events/itemCampaignQuantity_add.sql b/db/routines/vn/events/itemCampaignQuantity_add.sql index a90a678f3..4deb2d556 100644 --- a/db/routines/vn/events/itemCampaignQuantity_add.sql +++ b/db/routines/vn/events/itemCampaignQuantity_add.sql @@ -1,6 +1,6 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `vn`.`itemCampaignQuantity_add` - ON SCHEDULE EVERY 5 MINUTE + ON SCHEDULE EVERY 1 DAY STARTS '2024-10-18 03:00:00.000' ON COMPLETION PRESERVE ENABLE From 3628abd5bfe87c47c359e01ca54331f1a0bb99f4 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 17 Oct 2024 10:15:45 +0200 Subject: [PATCH 06/89] feat: refs #8119 itemCampaignQuantity --- db/routines/vn/procedures/itemCampaignQuantity_add.sql | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/itemCampaignQuantity_add.sql b/db/routines/vn/procedures/itemCampaignQuantity_add.sql index af5d0e2de..56e68c3b0 100644 --- a/db/routines/vn/procedures/itemCampaignQuantity_add.sql +++ b/db/routines/vn/procedures/itemCampaignQuantity_add.sql @@ -12,13 +12,15 @@ proc: BEGIN * @param vDateTo Fecha hasta * @param vCampaign Código de la campaña */ - DECLARE vYesterday INT; + DECLARE vCurdate DATE; + DECLARE vYesterday DATE; DECLARE vDefaultCampaign VARCHAR(100); DECLARE vPreviousDaysToInsert INT; DECLARE vDateSumFrom DATE; DECLARE vDateSumTo DATE; DECLARE vScopeDays DATE; + SET vCurdate = util.VN_CURDATE(); SET vYesterday = util.yesterday(); IF vDateFrom IS NULL THEN @@ -47,7 +49,7 @@ proc: BEGIN SELECT dated, scopeDays INTO vDateSumTo, vScopeDays FROM campaign - WHERE dated > util.VN_CURDATE() + WHERE dated > vCurdate AND code = vCampaign ORDER BY dated LIMIT 1; @@ -56,7 +58,7 @@ proc: BEGIN CALL util.throw('Missing data in campaign table'); END IF; - IF NOT util.VN_CURDATE() BETWEEN vDateSumTo - INTERVAL vPreviousDaysToInsert DAY + IF NOT vCurdate BETWEEN vDateSumTo - INTERVAL vPreviousDaysToInsert DAY AND vDateSumTo THEN LEAVE proc; END IF; From 41d078aaf1db20eea232fcf1600be544212f4b47 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 17 Oct 2024 10:16:26 +0200 Subject: [PATCH 07/89] feat: refs #8119 itemCampaignQuantity --- db/routines/vn/procedures/itemCampaignQuantity_add.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/itemCampaignQuantity_add.sql b/db/routines/vn/procedures/itemCampaignQuantity_add.sql index 56e68c3b0..6cadd09be 100644 --- a/db/routines/vn/procedures/itemCampaignQuantity_add.sql +++ b/db/routines/vn/procedures/itemCampaignQuantity_add.sql @@ -18,7 +18,7 @@ proc: BEGIN DECLARE vPreviousDaysToInsert INT; DECLARE vDateSumFrom DATE; DECLARE vDateSumTo DATE; - DECLARE vScopeDays DATE; + DECLARE vScopeDays INT; SET vCurdate = util.VN_CURDATE(); SET vYesterday = util.yesterday(); From 8ca69d3574185ca860ff0cdce42e732412a2d836 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 17 Oct 2024 10:21:39 +0200 Subject: [PATCH 08/89] feat: refs #8119 Minor change --- db/routines/vn/procedures/itemCampaignQuantity_add.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/itemCampaignQuantity_add.sql b/db/routines/vn/procedures/itemCampaignQuantity_add.sql index 6cadd09be..6dffb3918 100644 --- a/db/routines/vn/procedures/itemCampaignQuantity_add.sql +++ b/db/routines/vn/procedures/itemCampaignQuantity_add.sql @@ -68,9 +68,9 @@ proc: BEGIN INSERT INTO itemCampaignQuantity(dated, itemFk, quantity, campaign) SELECT DATE(s.created), s.itemFk, - CASE WHEN t.shipped BETWEEN vDateSumFrom AND vDateSumTo - THEN SUM(s.quantity) - END quantity, + SUM(CASE WHEN t.shipped BETWEEN vDateSumFrom AND vDateSumTo + THEN s.quantity + END) quantity, vCampaign FROM sale s JOIN ticket t ON t.id = s.ticketFk From 2bd98b7fb663a339e314cf7e64cdaf2fe662e712 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 17 Oct 2024 10:29:35 +0200 Subject: [PATCH 09/89] feat: refs #8119 Minor change --- db/versions/11308-redCymbidium/00-firstScript.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/db/versions/11308-redCymbidium/00-firstScript.sql b/db/versions/11308-redCymbidium/00-firstScript.sql index ea3436b80..baa703a5a 100644 --- a/db/versions/11308-redCymbidium/00-firstScript.sql +++ b/db/versions/11308-redCymbidium/00-firstScript.sql @@ -1,4 +1,4 @@ -CREATE TABLE IF NOT EXISTS vn.itemCampaignQuantity ( +CREATE TABLE IF NOT EXISTS `vn`.`itemCampaignQuantity` ( dated date NOT NULL, itemFk int(11) NOT NULL, quantity decimal(10,2) NOT NULL, @@ -10,8 +10,8 @@ ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -CREATE TABLE IF NOT EXISTS vn.itemCampaignQuantityConfig ( - id int(10) unsigned NOT NULL PRIMARY, +CREATE TABLE IF NOT EXISTS `vn`.`itemCampaignQuantityConfig` ( + id int(10) unsigned NOT NULL PRIMARY KEY, defaultCampaign varchar(100) NOT NULL COMMENT 'Campaña por defecto si se le pasa NULL', previousDaysToInsert int(10) unsigned NOT NULL COMMENT 'Días anteriores a la fecha de fin de campaña para insertar', CONSTRAINT `itemCampaignQuantityConfig_check` CHECK (`id` = 1) @@ -20,5 +20,5 @@ ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -INSERT IGNORE INTO vn.itemCampaignQuantityConfig(id, defaultCampaign, previousDaysToInsert) +INSERT IGNORE INTO `vn`.`itemCampaignQuantityConfig` (id, defaultCampaign, previousDaysToInsert) VALUES (1, 'allSaints', 90); From f85267db9262c71ddb81017009c08aba9395cd6f Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 17 Oct 2024 11:06:11 +0200 Subject: [PATCH 10/89] feat: refs #8119 Fix test --- back/methods/vn-user/specs/renew-token.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/back/methods/vn-user/specs/renew-token.spec.js b/back/methods/vn-user/specs/renew-token.spec.js index 8f1bb54c1..8941916ec 100644 --- a/back/methods/vn-user/specs/renew-token.spec.js +++ b/back/methods/vn-user/specs/renew-token.spec.js @@ -72,9 +72,9 @@ describe('Renew Token', () => { } expect(error).toBeDefined(); - const query = 'SELECT * FROM util.debug'; - const debugLog = await models.Application.rawSql(query, null); + const query = 'SELECT * FROM util.debug WHERE variable = "renewToken"'; + const debugLog = await models.Application.rawSql(query); expect(debugLog.length).toEqual(1); }); From 4bd28c62b9ffc43470ec2f883ee1d4d3b8328872 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 18 Oct 2024 07:35:36 +0200 Subject: [PATCH 11/89] feat: refs #8119 Requested changes --- db/versions/11308-redCymbidium/00-firstScript.sql | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/db/versions/11308-redCymbidium/00-firstScript.sql b/db/versions/11308-redCymbidium/00-firstScript.sql index baa703a5a..6e0afdd8b 100644 --- a/db/versions/11308-redCymbidium/00-firstScript.sql +++ b/db/versions/11308-redCymbidium/00-firstScript.sql @@ -1,14 +1,16 @@ CREATE TABLE IF NOT EXISTS `vn`.`itemCampaignQuantity` ( + `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT, dated date NOT NULL, itemFk int(11) NOT NULL, quantity decimal(10,2) NOT NULL, campaign varchar(100) NOT NULL, - CONSTRAINT itemCampaignQuantity_pk PRIMARY KEY (dated,itemFk), + UNIQUE KEY `itemCampaignQuantity_UNIQUE` (`dated`,`itemFk`), CONSTRAINT itemCampaignQuantity_item_FK FOREIGN KEY (itemFk) REFERENCES vn.item(id) ON DELETE RESTRICT ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 -COLLATE=utf8mb3_unicode_ci; +COLLATE=utf8mb3_unicode_ci +COMMENT='Tallos confirmados por día en los días de más producción de una campaña'; CREATE TABLE IF NOT EXISTS `vn`.`itemCampaignQuantityConfig` ( id int(10) unsigned NOT NULL PRIMARY KEY, From 7e604f1a19f7a993aba6c47b3d522fac3e180a07 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 18 Oct 2024 07:44:28 +0200 Subject: [PATCH 12/89] feat: refs #8119 Requested changes --- db/routines/vn/procedures/itemCampaignQuantity_add.sql | 2 +- db/versions/11308-redCymbidium/00-firstScript.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/itemCampaignQuantity_add.sql b/db/routines/vn/procedures/itemCampaignQuantity_add.sql index 6dffb3918..ca041d2d2 100644 --- a/db/routines/vn/procedures/itemCampaignQuantity_add.sql +++ b/db/routines/vn/procedures/itemCampaignQuantity_add.sql @@ -65,7 +65,7 @@ proc: BEGIN SET vDateSumFrom = vDateSumTo - INTERVAL vScopeDays DAY; - INSERT INTO itemCampaignQuantity(dated, itemFk, quantity, campaign) + REPLACE itemCampaignQuantity(dated, itemFk, quantity, campaign) SELECT DATE(s.created), s.itemFk, SUM(CASE WHEN t.shipped BETWEEN vDateSumFrom AND vDateSumTo diff --git a/db/versions/11308-redCymbidium/00-firstScript.sql b/db/versions/11308-redCymbidium/00-firstScript.sql index 6e0afdd8b..d90cd1ae6 100644 --- a/db/versions/11308-redCymbidium/00-firstScript.sql +++ b/db/versions/11308-redCymbidium/00-firstScript.sql @@ -10,7 +10,7 @@ CREATE TABLE IF NOT EXISTS `vn`.`itemCampaignQuantity` ( ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci -COMMENT='Tallos confirmados por día en los días de más producción de una campaña'; +COMMENT='Tallos confirmados por día en los días de más producción de una campaña. La tabla está pensada para que sea una foto.'; CREATE TABLE IF NOT EXISTS `vn`.`itemCampaignQuantityConfig` ( id int(10) unsigned NOT NULL PRIMARY KEY, From 34deba406bbb8d6792a5334cb4c0367fe43b35a2 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 18 Oct 2024 12:59:52 +0200 Subject: [PATCH 13/89] feat: refs #7266 First commit --- .../reports/item-label/assets/css/style.css | 113 +++++------------- .../reports/item-label/item-label.html | 66 +++++----- 2 files changed, 68 insertions(+), 111 deletions(-) diff --git a/print/templates/reports/item-label/assets/css/style.css b/print/templates/reports/item-label/assets/css/style.css index 1101604b9..0dea5a9e4 100644 --- a/print/templates/reports/item-label/assets/css/style.css +++ b/print/templates/reports/item-label/assets/css/style.css @@ -1,88 +1,37 @@ -* { - box-sizing: border-box; +html { + font-family: "Roboto", "Helvetica", "Arial", sans-serif; + font-size: 12px; } -.label { - font-size: 1.2em; -} - -.barcode { - float: left; - width: 40%; -} - -.barcode h1 { - text-align: center; - font-size: 1.8em; - margin: 0 0 10px 0 -} - -.barcode .image { - text-align: center -} - -.barcode .image img { - width: 170px -} - -.data { - float: left; - width: 60%; -} - -.data .header { - background-color: #000; - text-overflow: ellipsis; - white-space: nowrap; - overflow: hidden; - margin-bottom: 25px; - text-align: right; - font-size: 1.2em; - padding: 0.2em; - color: #FFF -} - -.data .color, -.data .producer { - text-transform: uppercase; - text-align: right; - font-size: 1.5em; - text-overflow: ellipsis; - white-space: nowrap; - overflow: hidden; -} - -.data .producer { - text-justify: inter-character; -} - -.data .details { - border-top: 4px solid #000; - padding-top: 2px; -} - -.data .details .package { - padding-right: 5px; - float: left; +table { width: 50%; + font-size: 12px; + float: right; } - -.package .packing, -.package .dated, -.package .labelNumber { - text-align: right +td { + border: 3px solid white; } - -.package .packing { - font-size: 1.8em; - font-weight: 400 -} - -.data .details .size { - background-color: #000; +.center { text-align: center; - font-size: 3em; - padding: 0.2em 0; - float: left; - width: 50%; - color: #FFF +} +.cursive { + font-style: italic; +} +.bold { + font-weight: bold; +} +.black { + background-color: black; + color: white; +} +.md { + font-size: 18px; +} +.xl { + font-size: 36px; +} +.border-black { + border: 2px solid #000000; +} +.regular-with { + width: 60px; } \ No newline at end of file diff --git a/print/templates/reports/item-label/item-label.html b/print/templates/reports/item-label/item-label.html index 66509ab38..e2526fc6b 100644 --- a/print/templates/reports/item-label/item-label.html +++ b/print/templates/reports/item-label/item-label.html @@ -1,29 +1,37 @@ - - -
-
-

{{item.id}}

-
- -
-
-
-
{{item.name}}
-
{{tags.color}}
-
{{tags.producer}}
-
-
-
{{packing()}}
-
{{formatDate(new Date(), '%W/%d')}}
-
{{labelPage}}
-
-
{{item.size}}
-
-
-
- -
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1
EUC Cinerea60
Color: LIV150
Origen: VCL
Productor: L'Arenal
Comprador: ATJF:42/11 / 50
Entrada: 358799
E622/2
+ + \ No newline at end of file From bf2d7541a5c956ba48a7f9a8c31553f36ce74418 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 21 Oct 2024 14:57:55 +0200 Subject: [PATCH 14/89] feat: refs #7266 Item label QR --- db/dump/.dump/data.sql | 2 +- loopback/locale/es.json | 4 +- .../item/{labelPdf.js => itemLabelQr.js} | 27 ++--- modules/item/back/models/item.js | 2 +- .../assets/css/import.js | 0 .../item-label-qr/assets/css/style.css | 87 ++++++++++++++ .../reports/item-label-qr/item-label-qr.html | 112 ++++++++++++++++++ .../reports/item-label-qr/item-label-qr.js | 43 +++++++ .../reports/item-label-qr/locale/es.yml | 1 + .../options.json | 2 +- .../reports/item-label-qr/sql/item.sql | 42 +++++++ .../reports/item-label/assets/css/style.css | 37 ------ .../reports/item-label/item-label.html | 37 ------ .../reports/item-label/item-label.js | 58 --------- .../reports/item-label/locale/es.yml | 1 - .../templates/reports/item-label/sql/item.sql | 14 --- .../reports/item-label/sql/itemTags.sql | 4 - 17 files changed, 298 insertions(+), 175 deletions(-) rename modules/item/back/methods/item/{labelPdf.js => itemLabelQr.js} (62%) rename print/templates/reports/{item-label => item-label-qr}/assets/css/import.js (100%) create mode 100644 print/templates/reports/item-label-qr/assets/css/style.css create mode 100644 print/templates/reports/item-label-qr/item-label-qr.html create mode 100755 print/templates/reports/item-label-qr/item-label-qr.js create mode 100644 print/templates/reports/item-label-qr/locale/es.yml rename print/templates/reports/{item-label => item-label-qr}/options.json (86%) create mode 100644 print/templates/reports/item-label-qr/sql/item.sql delete mode 100644 print/templates/reports/item-label/assets/css/style.css delete mode 100644 print/templates/reports/item-label/item-label.html delete mode 100755 print/templates/reports/item-label/item-label.js delete mode 100644 print/templates/reports/item-label/locale/es.yml delete mode 100644 print/templates/reports/item-label/sql/item.sql delete mode 100644 print/templates/reports/item-label/sql/itemTags.sql diff --git a/db/dump/.dump/data.sql b/db/dump/.dump/data.sql index ca254055b..315bfe7c5 100644 --- a/db/dump/.dump/data.sql +++ b/db/dump/.dump/data.sql @@ -1723,7 +1723,7 @@ INSERT INTO `ACL` VALUES (378,'OsTicket','osTicketReportEmail','WRITE','ALLOW',' INSERT INTO `ACL` VALUES (379,'Item','buyerWasteEmail','WRITE','ALLOW','ROLE','system',NULL); INSERT INTO `ACL` VALUES (380,'Claim','claimPickupPdf','READ','ALLOW','ROLE','employee',NULL); INSERT INTO `ACL` VALUES (381,'Claim','claimPickupEmail','WRITE','ALLOW','ROLE','claimManager',NULL); -INSERT INTO `ACL` VALUES (382,'Item','labelPdf','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (382,'Item','itemLabelQr','READ','ALLOW','ROLE','employee',NULL); INSERT INTO `ACL` VALUES (383,'Sector','*','READ','ALLOW','ROLE','employee',NULL); INSERT INTO `ACL` VALUES (384,'Sector','*','WRITE','ALLOW','ROLE','employee',NULL); INSERT INTO `ACL` VALUES (385,'Route','driverRoutePdf','READ','ALLOW','ROLE','employee',NULL); diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 6d50f634e..8e758d1ab 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -383,5 +383,5 @@ "No valid travel thermograph found": "No se encontró un termógrafo válido", "The quantity claimed cannot be greater than the quantity of the line": "La cantidad reclamada no puede ser mayor que la cantidad de la línea", "type cannot be blank": "Se debe rellenar el tipo", - "There are tickets for this area, delete them first": "Hay tickets para esta sección, borralos primero" -} + "There are tickets for this area, delete them first": "Hay tickets para esta sección, borralos primero" +} \ No newline at end of file diff --git a/modules/item/back/methods/item/labelPdf.js b/modules/item/back/methods/item/itemLabelQr.js similarity index 62% rename from modules/item/back/methods/item/labelPdf.js rename to modules/item/back/methods/item/itemLabelQr.js index d7a50397e..8d92d51e8 100644 --- a/modules/item/back/methods/item/labelPdf.js +++ b/modules/item/back/methods/item/itemLabelQr.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethodCtx('labelPdf', { + Self.remoteMethodCtx('itemLabelQr', { description: 'Returns the item label pdf', accessType: 'READ', accepts: [ @@ -11,26 +11,15 @@ module.exports = Self => { http: {source: 'path'} }, { - arg: 'recipientId', + arg: 'copies', type: 'number', - description: 'The recipient id', required: false - }, - { - arg: 'warehouseId', + }, { + arg: 'userId', type: 'number', - description: 'The warehouse id', + description: 'The user id from accessToken', + http: ctx => ctx.req.accessToken.userId, required: true - }, - { - arg: 'labelNumber', - type: 'number', - required: false - }, - { - arg: 'totalLabels', - type: 'number', - required: false } ], returns: [ @@ -49,11 +38,11 @@ module.exports = Self => { } ], http: { - path: '/:id/label-pdf', + path: '/:id/item-label-qr', verb: 'GET' }, accessScopes: ['DEFAULT', 'read:multimedia'] }); - Self.labelPdf = (ctx, id) => Self.printReport(ctx, id, 'item-label'); + Self.itemLabelQr = (ctx, id) => Self.printReport(ctx, id, 'item-label-qr'); }; diff --git a/modules/item/back/models/item.js b/modules/item/back/models/item.js index e715ab431..4fb9af8fa 100644 --- a/modules/item/back/models/item.js +++ b/modules/item/back/models/item.js @@ -15,7 +15,7 @@ module.exports = Self => { require('../methods/item/getWasteByItem')(Self); require('../methods/item/createIntrastat')(Self); require('../methods/item/buyerWasteEmail')(Self); - require('../methods/item/labelPdf')(Self); + require('../methods/item/itemLabelQr')(Self); require('../methods/item/setVisibleDiscard')(Self); require('../methods/item/get')(Self); diff --git a/print/templates/reports/item-label/assets/css/import.js b/print/templates/reports/item-label-qr/assets/css/import.js similarity index 100% rename from print/templates/reports/item-label/assets/css/import.js rename to print/templates/reports/item-label-qr/assets/css/import.js diff --git a/print/templates/reports/item-label-qr/assets/css/style.css b/print/templates/reports/item-label-qr/assets/css/style.css new file mode 100644 index 000000000..b868f3966 --- /dev/null +++ b/print/templates/reports/item-label-qr/assets/css/style.css @@ -0,0 +1,87 @@ +html { + font-family: "Roboto", "Helvetica", "Arial", sans-serif; + margin-top: -7px; +} +.leftTable { + width: 47%; + font-size: 12px; + float: left; + text-align: center; +} +.leftTable img { + width: 110px; +} +.rightTable { + width: 53%; + font-size: 14px; + float: right; +} +.rightTable td { + border: 3px solid white; +} +.center { + text-align: center; +} +.cursive { + font-style: italic; +} +.bold { + font-weight: bold; +} +.black-bg { + background-color: black; + color: white; +} +.md-txt { + font-size: 20px; +} +.xl-txt { + font-size: 36px; +} +.cell { + border: 2px solid black; + box-sizing: content-box; + width: 100%; + height: 30px; + display: flex; + justify-content: center; + align-items: center; +} +.padding { + padding: 7px; +} +.md-height { + height: 60px; + max-height: 60px; +} +.xs-width { + width: 60px; + max-width: 60px; +} +.sm-width { + width: 140px; + max-width: 140px; +} +.md-width { + width: 200px; + max-width: 200px; +} +.lg-width { + width: 270px; + max-width: 270px; +} +.overflow-multiline { + max-height: inherit; + display: -webkit-box; + overflow: hidden; + word-wrap: break-word; + line-clamp: 2; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; +} +.overflow-line { + width: inherit; + max-width: inherit; + overflow: hidden; + white-space: nowrap; +} \ No newline at end of file diff --git a/print/templates/reports/item-label-qr/item-label-qr.html b/print/templates/reports/item-label-qr/item-label-qr.html new file mode 100644 index 000000000..3b61e1542 --- /dev/null +++ b/print/templates/reports/item-label-qr/item-label-qr.html @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + +
+ + + +
+ {{item.buyFk}} +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ {{item.itemFk}} +
+
+
+ {{item.item}} +
+
+
+ {{item.size}} +
+
+
+ Color: {{item.inkFk}} +
+
+
+ {{item.packing}} +
+
+
+ {{item.stems}} +
+
+
+ Origen: {{item.origin}} +
+
+
+ Productor: {{item.producer}} +
+
+
+ Comprador: {{item.buyerName}} +
+
+
+ F: {{date}} +
+
+
+ {{`${item.labelNum} / ${totalPages}`}} +
+
+
+ Entrada: {{item.entryFk}} +
+
+
+ {{item.comment}} +
+
+ + \ No newline at end of file diff --git a/print/templates/reports/item-label-qr/item-label-qr.js b/print/templates/reports/item-label-qr/item-label-qr.js new file mode 100755 index 000000000..99744b0bd --- /dev/null +++ b/print/templates/reports/item-label-qr/item-label-qr.js @@ -0,0 +1,43 @@ +const UserError = require('vn-loopback/util/user-error'); +const moment = require('moment'); +const qrcode = require('qrcode'); + +module.exports = { + name: 'item-label-qr', + async serverPrefetch() { + this.items = await this.rawSqlFromDef('item', [this.copies || 1, this.id]); + if (!this.items.length) throw new UserError(`Empty data source`); + this.qr = await this.getQr(this.items[0].buyFk); + this.vnDate = Date.vnNew(); + this.date = moment(this.vnDate).format('YY/DD'); + this.totalPages = this.items.length; + }, + methods: { + getQr(data) { + data = { + company: 'vnl', + user: this.userId, + created: this.vnDate, + table: 'buy', + id: data + }; + return qrcode.toDataURL(JSON.stringify(data), { + margin: 0, + errorCorrectionLevel: 'H' + }); + } + }, + props: { + id: { + type: Number, + required: true, + description: 'The item id' + }, + copies: { + type: Number + }, + userId: { + type: Number + } + } +}; diff --git a/print/templates/reports/item-label-qr/locale/es.yml b/print/templates/reports/item-label-qr/locale/es.yml new file mode 100644 index 000000000..81dbc1877 --- /dev/null +++ b/print/templates/reports/item-label-qr/locale/es.yml @@ -0,0 +1 @@ +reportName: Etiqueta de artículo QR \ No newline at end of file diff --git a/print/templates/reports/item-label/options.json b/print/templates/reports/item-label-qr/options.json similarity index 86% rename from print/templates/reports/item-label/options.json rename to print/templates/reports/item-label-qr/options.json index 98c5788b1..5a3c3b1eb 100644 --- a/print/templates/reports/item-label/options.json +++ b/print/templates/reports/item-label-qr/options.json @@ -2,7 +2,7 @@ "width": "10.4cm", "height": "4.8cm", "margin": { - "top": "0cm", + "top": "0.17cm", "right": "0cm", "bottom": "0cm", "left": "0cm" diff --git a/print/templates/reports/item-label-qr/sql/item.sql b/print/templates/reports/item-label-qr/sql/item.sql new file mode 100644 index 000000000..11ee60d1a --- /dev/null +++ b/print/templates/reports/item-label-qr/sql/item.sql @@ -0,0 +1,42 @@ +WITH RECURSIVE numbers AS ( + SELECT 1 n + UNION ALL + SELECT n + 1 + FROM numbers + WHERE n < ? +) +SELECT ROW_NUMBER() OVER() labelNum, + b.id buyFk, + b.itemFk, + b.quantity, + b.packing, + b.isPickedOff, + b.entryFk, + e.sub, + o.code origin, + COALESCE(p.`name`, p.id, '') producer, + i.name item, + i.`size`, + i.category, + i.stems, + i.inkFk, + IFNULL(CONCAT(ig.longName, ' ', ig.`size`, ' ', ig.subName), i.comment) comment, + i.typeFk, + i.isLaid, + w.code buyerName, + w.code, + s.company_name companyName, + t.shipped + FROM vn.buy b + JOIN vn.item i ON i.id = b.itemFk + LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk + LEFT JOIN edi.ekt e ON e.id = b.ektFk + JOIN vn.origin o ON o.id = i.originFk + LEFT JOIN vn.producer p ON p.id = i.producerFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.worker w ON w.id = it.workerFk + LEFT JOIN edi.supplier s ON s.supplier_id = e.pro + JOIN vn.entry e2 ON e2.id = b.entryFk + JOIN vn.travel t ON t.id = e2.travelFk + JOIN numbers num + WHERE b.id = ? \ No newline at end of file diff --git a/print/templates/reports/item-label/assets/css/style.css b/print/templates/reports/item-label/assets/css/style.css deleted file mode 100644 index 0dea5a9e4..000000000 --- a/print/templates/reports/item-label/assets/css/style.css +++ /dev/null @@ -1,37 +0,0 @@ -html { - font-family: "Roboto", "Helvetica", "Arial", sans-serif; - font-size: 12px; -} -table { - width: 50%; - font-size: 12px; - float: right; -} -td { - border: 3px solid white; -} -.center { - text-align: center; -} -.cursive { - font-style: italic; -} -.bold { - font-weight: bold; -} -.black { - background-color: black; - color: white; -} -.md { - font-size: 18px; -} -.xl { - font-size: 36px; -} -.border-black { - border: 2px solid #000000; -} -.regular-with { - width: 60px; -} \ No newline at end of file diff --git a/print/templates/reports/item-label/item-label.html b/print/templates/reports/item-label/item-label.html deleted file mode 100644 index e2526fc6b..000000000 --- a/print/templates/reports/item-label/item-label.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1
EUC Cinerea60
Color: LIV150
Origen: VCL
Productor: L'Arenal
Comprador: ATJF:42/11 / 50
Entrada: 358799
E622/2
- - \ No newline at end of file diff --git a/print/templates/reports/item-label/item-label.js b/print/templates/reports/item-label/item-label.js deleted file mode 100755 index c5b9cdfd7..000000000 --- a/print/templates/reports/item-label/item-label.js +++ /dev/null @@ -1,58 +0,0 @@ -const vnReport = require('../../../core/mixins/vn-report.js'); -const qrcode = require('qrcode'); - -module.exports = { - name: 'item-label', - mixins: [vnReport], - async serverPrefetch() { - this.item = await this.findOneFromDef('item', [this.id, this.warehouseId]); - this.checkMainEntity(this.item); - this.tags = await this.fetchItemTags(this.id); - this.barcode = await this.getBarcodeBase64(this.id); - }, - - computed: { - labelPage() { - const labelNumber = this.labelNumber ? this.labelNumber : 1; - const totalLabels = this.totalLabels ? this.totalLabels : 1; - - return `${labelNumber}/${totalLabels}`; - } - }, - methods: { - fetchItemTags(id) { - return this.rawSqlFromDef('itemTags', [id]).then(rows => { - const tags = {}; - rows.forEach(row => tags[row.code] = row.value); - - return tags; - }); - }, - getBarcodeBase64(id) { - const data = String(id); - - return qrcode.toDataURL(data, {margin: 0}); - }, - packing() { - const stems = this.item.stems ? this.item.stems : 1; - return `${this.item.packing}x${stems}`; - } - }, - props: { - id: { - type: Number, - required: true, - description: 'The item id' - }, - warehouseId: { - type: Number, - required: true - }, - labelNumber: { - type: Number - }, - totalLabels: { - type: Number - } - } -}; diff --git a/print/templates/reports/item-label/locale/es.yml b/print/templates/reports/item-label/locale/es.yml deleted file mode 100644 index 278946f3e..000000000 --- a/print/templates/reports/item-label/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -reportName: Etiqueta \ No newline at end of file diff --git a/print/templates/reports/item-label/sql/item.sql b/print/templates/reports/item-label/sql/item.sql deleted file mode 100644 index 46aacc2fa..000000000 --- a/print/templates/reports/item-label/sql/item.sql +++ /dev/null @@ -1,14 +0,0 @@ -SELECT - i.id, - i.name, - i.stems, - i.size, - b.packing, - p.name as 'producer' -FROM vn.item i - JOIN cache.last_buy clb ON clb.item_id = i.id - JOIN vn.buy b ON b.id = clb.buy_id - JOIN vn.entry e ON e.id = b.entryFk - JOIN vn.producer p ON p.id = i.producerFk - -WHERE i.id = ? AND clb.warehouse_id = ? \ No newline at end of file diff --git a/print/templates/reports/item-label/sql/itemTags.sql b/print/templates/reports/item-label/sql/itemTags.sql deleted file mode 100644 index 3c20098a6..000000000 --- a/print/templates/reports/item-label/sql/itemTags.sql +++ /dev/null @@ -1,4 +0,0 @@ -SELECT t.code, t.name, it.value -FROM vn.itemTag it - JOIN vn.tag t ON t.id = it.tagFk -WHERE it.itemFk = ? \ No newline at end of file From 5162c2037b650d4c1b7dfef0d546286cbf5488e4 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 22 Oct 2024 08:41:46 +0200 Subject: [PATCH 15/89] feat: refs #8119 Requested changes --- db/routines/vn/procedures/itemCampaignQuantity_add.sql | 5 ++++- db/versions/11308-redCymbidium/00-firstScript.sql | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/itemCampaignQuantity_add.sql b/db/routines/vn/procedures/itemCampaignQuantity_add.sql index ca041d2d2..6edb97c08 100644 --- a/db/routines/vn/procedures/itemCampaignQuantity_add.sql +++ b/db/routines/vn/procedures/itemCampaignQuantity_add.sql @@ -65,12 +65,15 @@ proc: BEGIN SET vDateSumFrom = vDateSumTo - INTERVAL vScopeDays DAY; - REPLACE itemCampaignQuantity(dated, itemFk, quantity, campaign) + REPLACE itemCampaignQuantity(dated, itemFk, quantity, total, campaign) SELECT DATE(s.created), s.itemFk, SUM(CASE WHEN t.shipped BETWEEN vDateSumFrom AND vDateSumTo THEN s.quantity END) quantity, + SUM(CASE WHEN t.shipped BETWEEN vDateSumFrom AND vDateSumTo + THEN s.total + END) total, vCampaign FROM sale s JOIN ticket t ON t.id = s.ticketFk diff --git a/db/versions/11308-redCymbidium/00-firstScript.sql b/db/versions/11308-redCymbidium/00-firstScript.sql index d90cd1ae6..14fad3636 100644 --- a/db/versions/11308-redCymbidium/00-firstScript.sql +++ b/db/versions/11308-redCymbidium/00-firstScript.sql @@ -3,6 +3,7 @@ CREATE TABLE IF NOT EXISTS `vn`.`itemCampaignQuantity` ( dated date NOT NULL, itemFk int(11) NOT NULL, quantity decimal(10,2) NOT NULL, + total decimal(10,2) NOT NULL, campaign varchar(100) NOT NULL, UNIQUE KEY `itemCampaignQuantity_UNIQUE` (`dated`,`itemFk`), CONSTRAINT itemCampaignQuantity_item_FK FOREIGN KEY (itemFk) REFERENCES vn.item(id) ON DELETE RESTRICT ON UPDATE CASCADE From 0af58b20bea4025736feb55ac286ec441237691a Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 22 Oct 2024 12:02:04 +0200 Subject: [PATCH 16/89] feat: refs #7266 Item label QR finished --- db/routines/vn/functions/buy_getUltimate.sql | 31 +++++++++++++++++++ loopback/locale/es.json | 3 +- modules/item/back/methods/item/itemLabelQr.js | 11 +++++-- .../reports/item-label-qr/item-label-qr.html | 4 +-- .../reports/item-label-qr/item-label-qr.js | 28 ++++++++++++----- .../reports/item-label-qr/sql/company.sql | 6 ++++ .../reports/item-label-qr/sql/lastBuy.sql | 1 + 7 files changed, 72 insertions(+), 12 deletions(-) create mode 100644 db/routines/vn/functions/buy_getUltimate.sql create mode 100644 print/templates/reports/item-label-qr/sql/company.sql create mode 100644 print/templates/reports/item-label-qr/sql/lastBuy.sql diff --git a/db/routines/vn/functions/buy_getUltimate.sql b/db/routines/vn/functions/buy_getUltimate.sql new file mode 100644 index 000000000..173e6e01f --- /dev/null +++ b/db/routines/vn/functions/buy_getUltimate.sql @@ -0,0 +1,31 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`buy_getUltimate`( + vItemFk INT, + vWarehouseFk SMALLINT, + vDated DATE +) + RETURNS int(11) + DETERMINISTIC +BEGIN +/** + * Calcula las últimas compras realizadas hasta una fecha. + * + * @param vItemFk Id del artículo + * @param vWarehouseFk Id del almacén + * @param vDated Compras hasta fecha + * @return Id de compra + */ + DECLARE vBuyFk INT; + + CALL buy_getUltimate(vItemFk, vWarehouseFk, vDated); + + SELECT buyFk INTO vBuyFk + FROM tmp.buyUltimate; + + DROP TEMPORARY TABLE IF EXISTS + tmp.buyUltimate, + tmp.buyUltimateFromInterval; + + RETURN vBuyFk; +END$$ +DELIMITER ; diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 8e758d1ab..8f0869eb5 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -383,5 +383,6 @@ "No valid travel thermograph found": "No se encontró un termógrafo válido", "The quantity claimed cannot be greater than the quantity of the line": "La cantidad reclamada no puede ser mayor que la cantidad de la línea", "type cannot be blank": "Se debe rellenar el tipo", - "There are tickets for this area, delete them first": "Hay tickets para esta sección, borralos primero" + "There are tickets for this area, delete them first": "Hay tickets para esta sección, borralos primero", + "There is no company associated with that warehouse": "No hay ninguna empresa asociada a ese almacén" } \ No newline at end of file diff --git a/modules/item/back/methods/item/itemLabelQr.js b/modules/item/back/methods/item/itemLabelQr.js index 8d92d51e8..88d8ce950 100644 --- a/modules/item/back/methods/item/itemLabelQr.js +++ b/modules/item/back/methods/item/itemLabelQr.js @@ -9,8 +9,15 @@ module.exports = Self => { required: true, description: 'The item id', http: {source: 'path'} - }, - { + }, { + arg: 'warehouseId', + type: 'number', + required: true + }, { + arg: 'packing', + type: 'number', + required: false + }, { arg: 'copies', type: 'number', required: false diff --git a/print/templates/reports/item-label-qr/item-label-qr.html b/print/templates/reports/item-label-qr/item-label-qr.html index 3b61e1542..2ece8943e 100644 --- a/print/templates/reports/item-label-qr/item-label-qr.html +++ b/print/templates/reports/item-label-qr/item-label-qr.html @@ -52,7 +52,7 @@
- {{item.packing}} + {{packing || item.packing}}
@@ -89,7 +89,7 @@
- {{`${item.labelNum} / ${totalPages}`}} + {{`${item.labelNum}/${item.quantity / (packing || item.packing)}`}}
diff --git a/print/templates/reports/item-label-qr/item-label-qr.js b/print/templates/reports/item-label-qr/item-label-qr.js index 99744b0bd..1a0ef767b 100755 --- a/print/templates/reports/item-label-qr/item-label-qr.js +++ b/print/templates/reports/item-label-qr/item-label-qr.js @@ -5,25 +5,33 @@ const qrcode = require('qrcode'); module.exports = { name: 'item-label-qr', async serverPrefetch() { - this.items = await this.rawSqlFromDef('item', [this.copies || 1, this.id]); + this.company = await this.findOneFromDef('company', [this.warehouseId]); + if (!this.company) + throw new UserError(`There is no company associated with that warehouse`); + + this.date = Date.vnNew(); + this.lastBuy = await this.findOneFromDef('lastBuy', [ + this.id, + this.warehouseId, + this.date + ]); + this.items = await this.rawSqlFromDef('item', [this.copies || 1, this.lastBuy.id]); if (!this.items.length) throw new UserError(`Empty data source`); this.qr = await this.getQr(this.items[0].buyFk); - this.vnDate = Date.vnNew(); - this.date = moment(this.vnDate).format('YY/DD'); - this.totalPages = this.items.length; + this.date = moment(this.date).format('WW/E'); }, methods: { getQr(data) { data = { - company: 'vnl', + company: this.company, user: this.userId, - created: this.vnDate, + created: this.date, table: 'buy', id: data }; return qrcode.toDataURL(JSON.stringify(data), { margin: 0, - errorCorrectionLevel: 'H' + errorCorrectionLevel: 'L' }); } }, @@ -33,6 +41,12 @@ module.exports = { required: true, description: 'The item id' }, + warehouseId: { + type: Number + }, + packing: { + type: Number + }, copies: { type: Number }, diff --git a/print/templates/reports/item-label-qr/sql/company.sql b/print/templates/reports/item-label-qr/sql/company.sql new file mode 100644 index 000000000..e130b4033 --- /dev/null +++ b/print/templates/reports/item-label-qr/sql/company.sql @@ -0,0 +1,6 @@ +SELECT co.code + FROM warehouse w + JOIN address a ON a.id = w.addressFk + JOIN client c ON c.id = a.clientFk + JOIN company co ON co.clientFk = c.id + WHERE w.id = ? \ No newline at end of file diff --git a/print/templates/reports/item-label-qr/sql/lastBuy.sql b/print/templates/reports/item-label-qr/sql/lastBuy.sql new file mode 100644 index 000000000..d10339998 --- /dev/null +++ b/print/templates/reports/item-label-qr/sql/lastBuy.sql @@ -0,0 +1 @@ +SELECT buy_getUltimate(?, ?, ?) id \ No newline at end of file From c3f8da52c61b7070ade2de36800d8c1c91f8f698 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 22 Oct 2024 13:43:54 +0200 Subject: [PATCH 17/89] feat: refs #7266 Item label barcode --- db/dump/.dump/data.sql | 1 - .../11315-grayCamellia/00-firstScript.sql | 3 + .../item/back/methods/item/labelBarcodePdf.js | 55 ++++++++++++ .../item/{itemLabelQr.js => labelQrPdf.js} | 8 +- modules/item/back/models/item.js | 3 +- .../item-label-barcode/assets/css/import.js | 12 +++ .../item-label-barcode/assets/css/style.css | 83 ++++++++++++++++++ .../item-label-barcode.html | 87 +++++++++++++++++++ .../item-label-barcode/item-label-barcode.js | 58 +++++++++++++ .../reports/item-label-barcode/locale/es.yml | 1 + .../reports/item-label-barcode/options.json | 11 +++ .../item-label-barcode/sql/company.sql | 6 ++ .../reports/item-label-barcode/sql/item.sql | 42 +++++++++ .../item-label-barcode/sql/lastBuy.sql | 1 + .../reports/item-label-qr/item-label-qr.html | 2 +- 15 files changed, 366 insertions(+), 7 deletions(-) create mode 100644 db/versions/11315-grayCamellia/00-firstScript.sql create mode 100644 modules/item/back/methods/item/labelBarcodePdf.js rename modules/item/back/methods/item/{itemLabelQr.js => labelQrPdf.js} (86%) create mode 100644 print/templates/reports/item-label-barcode/assets/css/import.js create mode 100644 print/templates/reports/item-label-barcode/assets/css/style.css create mode 100644 print/templates/reports/item-label-barcode/item-label-barcode.html create mode 100755 print/templates/reports/item-label-barcode/item-label-barcode.js create mode 100644 print/templates/reports/item-label-barcode/locale/es.yml create mode 100644 print/templates/reports/item-label-barcode/options.json create mode 100644 print/templates/reports/item-label-barcode/sql/company.sql create mode 100644 print/templates/reports/item-label-barcode/sql/item.sql create mode 100644 print/templates/reports/item-label-barcode/sql/lastBuy.sql diff --git a/db/dump/.dump/data.sql b/db/dump/.dump/data.sql index 315bfe7c5..5f464c5e2 100644 --- a/db/dump/.dump/data.sql +++ b/db/dump/.dump/data.sql @@ -1723,7 +1723,6 @@ INSERT INTO `ACL` VALUES (378,'OsTicket','osTicketReportEmail','WRITE','ALLOW',' INSERT INTO `ACL` VALUES (379,'Item','buyerWasteEmail','WRITE','ALLOW','ROLE','system',NULL); INSERT INTO `ACL` VALUES (380,'Claim','claimPickupPdf','READ','ALLOW','ROLE','employee',NULL); INSERT INTO `ACL` VALUES (381,'Claim','claimPickupEmail','WRITE','ALLOW','ROLE','claimManager',NULL); -INSERT INTO `ACL` VALUES (382,'Item','itemLabelQr','READ','ALLOW','ROLE','employee',NULL); INSERT INTO `ACL` VALUES (383,'Sector','*','READ','ALLOW','ROLE','employee',NULL); INSERT INTO `ACL` VALUES (384,'Sector','*','WRITE','ALLOW','ROLE','employee',NULL); INSERT INTO `ACL` VALUES (385,'Route','driverRoutePdf','READ','ALLOW','ROLE','employee',NULL); diff --git a/db/versions/11315-grayCamellia/00-firstScript.sql b/db/versions/11315-grayCamellia/00-firstScript.sql new file mode 100644 index 000000000..60eea0e01 --- /dev/null +++ b/db/versions/11315-grayCamellia/00-firstScript.sql @@ -0,0 +1,3 @@ +DELETE FROM salix.ACL + WHERE property = 'labelPdf' + AND model = 'Item'; diff --git a/modules/item/back/methods/item/labelBarcodePdf.js b/modules/item/back/methods/item/labelBarcodePdf.js new file mode 100644 index 000000000..3325e3da1 --- /dev/null +++ b/modules/item/back/methods/item/labelBarcodePdf.js @@ -0,0 +1,55 @@ +module.exports = Self => { + Self.remoteMethodCtx('labelBarcodePdf', { + description: 'Returns the item label pdf with barcode', + accessType: 'READ', + accepts: [ + { + arg: 'id', + type: 'number', + required: true, + description: 'The item id', + http: {source: 'path'} + }, { + arg: 'warehouseId', + type: 'number', + required: true + }, { + arg: 'packing', + type: 'number', + required: false + }, { + arg: 'copies', + type: 'number', + required: false + }, { + arg: 'userId', + type: 'number', + description: 'The user id from accessToken', + http: ctx => ctx.req.accessToken.userId, + required: true + } + ], + returns: [ + { + arg: 'body', + type: 'file', + root: true + }, { + arg: 'Content-Type', + type: 'String', + http: {target: 'header'} + }, { + arg: 'Content-Disposition', + type: 'String', + http: {target: 'header'} + } + ], + http: { + path: '/:id/label-barcode-pdf', + verb: 'GET' + }, + accessScopes: ['DEFAULT', 'read:multimedia'] + }); + + Self.labelBarcodePdf = (ctx, id) => Self.printReport(ctx, id, 'item-label-barcode'); +}; diff --git a/modules/item/back/methods/item/itemLabelQr.js b/modules/item/back/methods/item/labelQrPdf.js similarity index 86% rename from modules/item/back/methods/item/itemLabelQr.js rename to modules/item/back/methods/item/labelQrPdf.js index 88d8ce950..4d0e34528 100644 --- a/modules/item/back/methods/item/itemLabelQr.js +++ b/modules/item/back/methods/item/labelQrPdf.js @@ -1,6 +1,6 @@ module.exports = Self => { - Self.remoteMethodCtx('itemLabelQr', { - description: 'Returns the item label pdf', + Self.remoteMethodCtx('labelQrPdf', { + description: 'Returns the item label pdf with qr', accessType: 'READ', accepts: [ { @@ -45,11 +45,11 @@ module.exports = Self => { } ], http: { - path: '/:id/item-label-qr', + path: '/:id/label-qr-pdf', verb: 'GET' }, accessScopes: ['DEFAULT', 'read:multimedia'] }); - Self.itemLabelQr = (ctx, id) => Self.printReport(ctx, id, 'item-label-qr'); + Self.labelQrPdf = (ctx, id) => Self.printReport(ctx, id, 'item-label-qr'); }; diff --git a/modules/item/back/models/item.js b/modules/item/back/models/item.js index 4fb9af8fa..d39586a90 100644 --- a/modules/item/back/models/item.js +++ b/modules/item/back/models/item.js @@ -15,7 +15,8 @@ module.exports = Self => { require('../methods/item/getWasteByItem')(Self); require('../methods/item/createIntrastat')(Self); require('../methods/item/buyerWasteEmail')(Self); - require('../methods/item/itemLabelQr')(Self); + require('../methods/item/labelBarcodePdf')(Self); + require('../methods/item/labelQrPdf')(Self); require('../methods/item/setVisibleDiscard')(Self); require('../methods/item/get')(Self); diff --git a/print/templates/reports/item-label-barcode/assets/css/import.js b/print/templates/reports/item-label-barcode/assets/css/import.js new file mode 100644 index 000000000..37a98dfdd --- /dev/null +++ b/print/templates/reports/item-label-barcode/assets/css/import.js @@ -0,0 +1,12 @@ +const Stylesheet = require(`vn-print/core/stylesheet`); + +const path = require('path'); +const vnPrintPath = path.resolve('print'); + +module.exports = new Stylesheet([ + `${vnPrintPath}/common/css/spacing.css`, + `${vnPrintPath}/common/css/misc.css`, + `${vnPrintPath}/common/css/layout.css`, + `${vnPrintPath}/common/css/report.css`, + `${__dirname}/style.css`]) + .mergeStyles(); diff --git a/print/templates/reports/item-label-barcode/assets/css/style.css b/print/templates/reports/item-label-barcode/assets/css/style.css new file mode 100644 index 000000000..48b881986 --- /dev/null +++ b/print/templates/reports/item-label-barcode/assets/css/style.css @@ -0,0 +1,83 @@ +html { + font-family: "Roboto", "Helvetica", "Arial", sans-serif; + margin-top: -7px; +} +table { + width: 100%; + font-size: 14px; +} +td { + border: 6px solid white; +} +.center { + text-align: center; +} +.right { + text-align: right; +} +.cursive { + font-style: italic; +} +.bold { + font-weight: bold; +} +.black-bg { + background-color: black; + color: white; +} +.xs-txt { + font-size: 18px; +} +.md-txt { + font-size: 26px; +} +.xl-txt { + font-size: 50px; +} +.cell { + border: 2px solid black; + box-sizing: content-box; + width: 100%; + height: 30px; + display: flex; + justify-content: center; + align-items: center; +} +.padding { + padding: 7px; +} +.xs-height { + height: 50px; + max-height: 50px; +} +.md-height { + height: 60px; + max-height: 60px; +} +.sm-width { + width: 60px; + max-width: 60px; +} +.md-width { + width: 120px; + max-width: 120px; +} +.lg-width { + width: 400px; + max-width: 400px; +} +.overflow-multiline { + max-height: inherit; + display: -webkit-box; + overflow: hidden; + word-wrap: break-word; + line-clamp: 2; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; +} +.overflow-line { + width: inherit; + max-width: inherit; + overflow: hidden; + white-space: nowrap; +} \ No newline at end of file diff --git a/print/templates/reports/item-label-barcode/item-label-barcode.html b/print/templates/reports/item-label-barcode/item-label-barcode.html new file mode 100644 index 000000000..79de49411 --- /dev/null +++ b/print/templates/reports/item-label-barcode/item-label-barcode.html @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ {{item.item}} +
+
+
+ {{item.size}} +
+
+
+ {{item.comment}} +
+
+
+ {{item.producer}} +
+
+
+ {{item.inkFk}} +
+
+
+ {{item.itemFk}} +
+
+
+ {{`${(packing || item.packing)} x ${item.stems || ''}`}} +
+
+
+
+
+ {{item.entryFk}} +
+
+
+ {{item.buyerName}} +
+
+
+ {{item.origin}} +
+
+
+ {{item.buyFk}} +
+
+
+ {{date}} +
+
+
+ {{`${item.labelNum}/${item.quantity / (packing || item.packing)}`}} +
+
+ + \ No newline at end of file diff --git a/print/templates/reports/item-label-barcode/item-label-barcode.js b/print/templates/reports/item-label-barcode/item-label-barcode.js new file mode 100755 index 000000000..29a2b9ad5 --- /dev/null +++ b/print/templates/reports/item-label-barcode/item-label-barcode.js @@ -0,0 +1,58 @@ +const UserError = require('vn-loopback/util/user-error'); +const {DOMImplementation, XMLSerializer} = require('xmldom'); +const moment = require('moment'); +const jsbarcode = require('jsbarcode'); + +module.exports = { + name: 'item-label-qr', + async serverPrefetch() { + this.company = await this.findOneFromDef('company', [this.warehouseId]); + if (!this.company) + throw new UserError(`There is no company associated with that warehouse`); + + this.date = Date.vnNew(); + this.lastBuy = await this.findOneFromDef('lastBuy', [ + this.id, + this.warehouseId, + this.date + ]); + this.items = await this.rawSqlFromDef('item', [this.copies || 1, this.lastBuy.id]); + if (!this.items.length) throw new UserError(`Empty data source`); + this.date = moment(this.date).format('WW/E'); + }, + methods: { + getBarcode(data) { + const document = new DOMImplementation().createDocument('http://www.w3.org/1999/xhtml', 'html', null); + const svgNode = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + + jsbarcode(svgNode, data, { + xmlDocument: document, + format: 'code128', + displayValue: false, + width: 3.9, + height: 85, + margin: 0 + }); + return new XMLSerializer().serializeToString(svgNode); + } + }, + props: { + id: { + type: Number, + required: true, + description: 'The item id' + }, + warehouseId: { + type: Number + }, + packing: { + type: Number + }, + copies: { + type: Number + }, + userId: { + type: Number + } + } +}; diff --git a/print/templates/reports/item-label-barcode/locale/es.yml b/print/templates/reports/item-label-barcode/locale/es.yml new file mode 100644 index 000000000..3cf8d2ce8 --- /dev/null +++ b/print/templates/reports/item-label-barcode/locale/es.yml @@ -0,0 +1 @@ +reportName: Etiqueta de artículo barcode \ No newline at end of file diff --git a/print/templates/reports/item-label-barcode/options.json b/print/templates/reports/item-label-barcode/options.json new file mode 100644 index 000000000..5a3c3b1eb --- /dev/null +++ b/print/templates/reports/item-label-barcode/options.json @@ -0,0 +1,11 @@ +{ + "width": "10.4cm", + "height": "4.8cm", + "margin": { + "top": "0.17cm", + "right": "0cm", + "bottom": "0cm", + "left": "0cm" + }, + "printBackground": true +} \ No newline at end of file diff --git a/print/templates/reports/item-label-barcode/sql/company.sql b/print/templates/reports/item-label-barcode/sql/company.sql new file mode 100644 index 000000000..e130b4033 --- /dev/null +++ b/print/templates/reports/item-label-barcode/sql/company.sql @@ -0,0 +1,6 @@ +SELECT co.code + FROM warehouse w + JOIN address a ON a.id = w.addressFk + JOIN client c ON c.id = a.clientFk + JOIN company co ON co.clientFk = c.id + WHERE w.id = ? \ No newline at end of file diff --git a/print/templates/reports/item-label-barcode/sql/item.sql b/print/templates/reports/item-label-barcode/sql/item.sql new file mode 100644 index 000000000..11ee60d1a --- /dev/null +++ b/print/templates/reports/item-label-barcode/sql/item.sql @@ -0,0 +1,42 @@ +WITH RECURSIVE numbers AS ( + SELECT 1 n + UNION ALL + SELECT n + 1 + FROM numbers + WHERE n < ? +) +SELECT ROW_NUMBER() OVER() labelNum, + b.id buyFk, + b.itemFk, + b.quantity, + b.packing, + b.isPickedOff, + b.entryFk, + e.sub, + o.code origin, + COALESCE(p.`name`, p.id, '') producer, + i.name item, + i.`size`, + i.category, + i.stems, + i.inkFk, + IFNULL(CONCAT(ig.longName, ' ', ig.`size`, ' ', ig.subName), i.comment) comment, + i.typeFk, + i.isLaid, + w.code buyerName, + w.code, + s.company_name companyName, + t.shipped + FROM vn.buy b + JOIN vn.item i ON i.id = b.itemFk + LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk + LEFT JOIN edi.ekt e ON e.id = b.ektFk + JOIN vn.origin o ON o.id = i.originFk + LEFT JOIN vn.producer p ON p.id = i.producerFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.worker w ON w.id = it.workerFk + LEFT JOIN edi.supplier s ON s.supplier_id = e.pro + JOIN vn.entry e2 ON e2.id = b.entryFk + JOIN vn.travel t ON t.id = e2.travelFk + JOIN numbers num + WHERE b.id = ? \ No newline at end of file diff --git a/print/templates/reports/item-label-barcode/sql/lastBuy.sql b/print/templates/reports/item-label-barcode/sql/lastBuy.sql new file mode 100644 index 000000000..d10339998 --- /dev/null +++ b/print/templates/reports/item-label-barcode/sql/lastBuy.sql @@ -0,0 +1 @@ +SELECT buy_getUltimate(?, ?, ?) id \ No newline at end of file diff --git a/print/templates/reports/item-label-qr/item-label-qr.html b/print/templates/reports/item-label-qr/item-label-qr.html index 2ece8943e..231c94818 100644 --- a/print/templates/reports/item-label-qr/item-label-qr.html +++ b/print/templates/reports/item-label-qr/item-label-qr.html @@ -1,6 +1,6 @@ - + - @@ -103,7 +103,11 @@ diff --git a/print/templates/reports/item-label-qr/sql/company.sql b/print/templates/reports/item-label-qr/sql/company.sql index e130b4033..4047786a9 100644 --- a/print/templates/reports/item-label-qr/sql/company.sql +++ b/print/templates/reports/item-label-qr/sql/company.sql @@ -1,6 +1,5 @@ SELECT co.code FROM warehouse w JOIN address a ON a.id = w.addressFk - JOIN client c ON c.id = a.clientFk - JOIN company co ON co.clientFk = c.id + JOIN company co ON co.clientFk = a.clientFk WHERE w.id = ? \ No newline at end of file diff --git a/print/templates/reports/item-label-qr/sql/item.sql b/print/templates/reports/item-label-qr/sql/item.sql index 11ee60d1a..3cb42d139 100644 --- a/print/templates/reports/item-label-qr/sql/item.sql +++ b/print/templates/reports/item-label-qr/sql/item.sql @@ -6,37 +6,29 @@ WITH RECURSIVE numbers AS ( WHERE n < ? ) SELECT ROW_NUMBER() OVER() labelNum, - b.id buyFk, - b.itemFk, - b.quantity, - b.packing, - b.isPickedOff, - b.entryFk, - e.sub, - o.code origin, - COALESCE(p.`name`, p.id, '') producer, - i.name item, - i.`size`, - i.category, - i.stems, - i.inkFk, - IFNULL(CONCAT(ig.longName, ' ', ig.`size`, ' ', ig.subName), i.comment) comment, - i.typeFk, - i.isLaid, - w.code buyerName, - w.code, - s.company_name companyName, - t.shipped - FROM vn.buy b - JOIN vn.item i ON i.id = b.itemFk - LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk - LEFT JOIN edi.ekt e ON e.id = b.ektFk - JOIN vn.origin o ON o.id = i.originFk - LEFT JOIN vn.producer p ON p.id = i.producerFk - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.worker w ON w.id = it.workerFk - LEFT JOIN edi.supplier s ON s.supplier_id = e.pro - JOIN vn.entry e2 ON e2.id = b.entryFk - JOIN vn.travel t ON t.id = e2.travelFk - JOIN numbers num - WHERE b.id = ? \ No newline at end of file + b.itemFk, + i.name item, + b.id buyFk, + b.quantity, + b.packing, + b.entryFk, + o.code origin, + p.`name` producerName, + p.id producerFk, + i.`size`, + i.category, + i.stems, + i.inkFk, + ig.longName, + ig.subName, + i.comment, + w.code buyerName + FROM vn.buy b + JOIN vn.item i ON i.id = b.itemFk + LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk + JOIN vn.origin o ON o.id = i.originFk + LEFT JOIN vn.producer p ON p.id = i.producerFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.worker w ON w.id = it.workerFk + JOIN numbers num + WHERE b.id = ? \ No newline at end of file From 070a5640df8c40bba1b96fedc90440fcd8575576 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 24 Oct 2024 08:16:04 +0000 Subject: [PATCH 27/89] fix: recalculatePrice not working with all ids --- modules/ticket/back/methods/sale/recalculatePrice.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/sale/recalculatePrice.js b/modules/ticket/back/methods/sale/recalculatePrice.js index fd3d6aa9b..ea71032d0 100644 --- a/modules/ticket/back/methods/sale/recalculatePrice.js +++ b/modules/ticket/back/methods/sale/recalculatePrice.js @@ -48,7 +48,7 @@ module.exports = Self => { CALL vn.sale_recalcComponent(null); DROP TEMPORARY TABLE tmp.recalculateSales;`; - const recalculation = await Self.rawSql(query, salesIds, myOptions); + const recalculation = await Self.rawSql(query, [salesIds], myOptions); if (tx) await tx.commit(); From 8569bec34ac139a3846837e278009844ed6cbaac Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 24 Oct 2024 12:18:09 +0200 Subject: [PATCH 28/89] feat: refs #7266 Minor change --- db/versions/11321-wheatChrysanthemum/00-firstScript.sql | 3 +++ .../templates/reports/item-label-barcode/item-label-barcode.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 db/versions/11321-wheatChrysanthemum/00-firstScript.sql diff --git a/db/versions/11321-wheatChrysanthemum/00-firstScript.sql b/db/versions/11321-wheatChrysanthemum/00-firstScript.sql new file mode 100644 index 000000000..e3ba70e2c --- /dev/null +++ b/db/versions/11321-wheatChrysanthemum/00-firstScript.sql @@ -0,0 +1,3 @@ +INSERT INTO vn.report (name, `method`) + VALUES ('LabelItemBarcode','Items/{id}/label-barcode-pdf'), + ('LabelItemQr','Items/{id}/label-qr-pdf'); diff --git a/print/templates/reports/item-label-barcode/item-label-barcode.js b/print/templates/reports/item-label-barcode/item-label-barcode.js index 8a294afc1..5f9a11ea1 100755 --- a/print/templates/reports/item-label-barcode/item-label-barcode.js +++ b/print/templates/reports/item-label-barcode/item-label-barcode.js @@ -4,7 +4,7 @@ const moment = require('moment'); const jsbarcode = require('jsbarcode'); module.exports = { - name: 'item-label-qr', + name: 'item-label-barcode', async serverPrefetch() { this.company = await this.findOneFromDef('company', [this.warehouseId]); if (!this.company) From 4da11c65bbe5de6e63ab3287dbcadea3938b23bd Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 24 Oct 2024 12:26:03 +0200 Subject: [PATCH 29/89] fix: refs #235425 sale priceFixed update --- modules/ticket/back/methods/sale/updatePrice.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modules/ticket/back/methods/sale/updatePrice.js b/modules/ticket/back/methods/sale/updatePrice.js index 191fd09e3..afb25c365 100644 --- a/modules/ticket/back/methods/sale/updatePrice.js +++ b/modules/ticket/back/methods/sale/updatePrice.js @@ -92,6 +92,19 @@ module.exports = Self => { }, myOptions); } await sale.updateAttributes({price: newPrice}, myOptions); + await Self.rawSql(` + UPDATE sale + SET priceFixed = ( + SELECT SUM(value) + FROM sale s + JOIN saleComponent sc ON sc.saleFk = s.id + JOIN component c ON c.id = sc.componentFk + JOIN componentType ct ON ct.id = c.typeFk + WHERE ct.isBase + AND s.id = ? + ) + WHERE id = ? + `, [id, id], myOptions); await Self.rawSql('CALL vn.manaSpellersRequery(?)', [userId], myOptions); await Self.rawSql('CALL vn.ticket_recalc(?, NULL)', [sale.ticketFk], myOptions); From 1bf900f81b7824acf144a4fb21fd55ed32ab5a5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Thu, 24 Oct 2024 12:33:47 +0200 Subject: [PATCH 30/89] feat: refs #8087 Traspasar redadas a travels --- db/dump/fixtures.before.sql | 24 +- .../procedures/availableNoRaids_refresh.sql | 2 +- .../triggers/supplyResponse_afterUpdate.sql | 8 +- .../hedera/procedures/item_getVisible.sql | 4 +- .../stock/procedures/log_refreshBuy.sql | 6 +- db/routines/vn/events/raidUpdate.sql | 8 - .../procedures/absoluteInventoryHistory.sql | 10 +- .../vn/procedures/available_traslate.sql | 12 +- db/routines/vn/procedures/clean_logiflora.sql | 2 +- .../vn/procedures/entry_cloneHeader.sql | 2 - .../vn/procedures/entry_getTransfer.sql | 4 +- db/routines/vn/procedures/inventoryMake.sql | 4 +- db/routines/vn/procedures/item_getBalance.sql | 40 +- db/routines/vn/procedures/item_getMinacum.sql | 2 +- .../vn/procedures/item_multipleBuyByDate.sql | 12 +- .../vn/procedures/item_valuateInventory.sql | 16 +- .../vn/procedures/multipleInventory.sql | 346 +++++++++--------- db/routines/vn/procedures/raidUpdate.sql | 31 -- .../vn/procedures/travelVolume_get.sql | 2 +- .../vn/procedures/travel_moveRaids.sql | 60 ++- .../vn/triggers/entry_beforeUpdate.sql | 16 +- db/routines/vn/views/itemEntryIn.sql | 2 +- db/routines/vn/views/itemEntryOut.sql | 2 +- db/routines/vn/views/lastPurchases.sql | 2 +- db/routines/vn2008/views/Entradas.sql | 1 - db/routines/vn2008/views/Entradas_Auto.sql | 5 - db/routines/vn2008/views/entrySource.sql | 2 +- db/routines/vn2008/views/travel.sql | 3 +- db/routines/vn2008/views/v_compres.sql | 7 +- .../11316-chocolateErica/00-firstScript.sql | 2 + modules/entry/back/locale/entry/en.yml | 1 - modules/entry/back/locale/entry/es.yml | 1 - modules/entry/back/methods/entry/filter.js | 2 +- modules/entry/back/methods/entry/getEntry.js | 5 +- modules/entry/back/models/entry.json | 12 +- .../travel/back/methods/travel/getTravel.js | 3 +- modules/travel/back/models/travel.json | 3 + 37 files changed, 305 insertions(+), 359 deletions(-) delete mode 100644 db/routines/vn/events/raidUpdate.sql delete mode 100644 db/routines/vn/procedures/raidUpdate.sql delete mode 100644 db/routines/vn2008/views/Entradas_Auto.sql create mode 100644 db/versions/11316-chocolateErica/00-firstScript.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index e93bb3b8e..51ffba3d0 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -1518,19 +1518,19 @@ INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseO (11, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE(), 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4), (12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4); -INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `isRaid`, `evaNotes`) +INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `evaNotes`) VALUES - (1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 442, 'IN2001', 'Movement 1', 0, 0, ''), - (2, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 442, 'IN2002', 'Movement 2', 0, 0, 'observation two'), - (3, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 0, 442, 'IN2003', 'Movement 3', 0, 0, 'observation three'), - (4, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 69, 'IN2004', 'Movement 4', 0, 0, 'observation four'), - (5, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 0, 442, 'IN2005', 'Movement 5', 0, 0, 'observation five'), - (6, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 6, 0, 442, 'IN2006', 'Movement 6', 0, 0, 'observation six'), - (7, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2007', 'Movement 7', 0, 0, 'observation seven'), - (8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1, 1, ''), - (9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, ''), - (10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 10', 1, 1, ''), - (99, 69, '2000-12-01 00:00:00.000', 11, 0, 442, 'IN2009', 'Movement 99', 0, 0, ''); + (1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 442, 'IN2001', 'Movement 1', 0, ''), + (2, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 442, 'IN2002', 'Movement 2', 0, 'observation two'), + (3, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 0, 442, 'IN2003', 'Movement 3', 0, 'observation three'), + (4, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 0, 69, 'IN2004', 'Movement 4', 0, 'observation four'), + (5, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 0, 442, 'IN2005', 'Movement 5', 0, 'observation five'), + (6, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 6, 0, 442, 'IN2006', 'Movement 6', 0, 'observation six'), + (7, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2007', 'Movement 7', 0, 'observation seven'), + (8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1,''), + (9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, ''), + (10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 10', 1, ''), + (99, 69, '2000-12-01 00:00:00.000', 11, 0, 442, 'IN2009', 'Movement 99', 0, ''); INSERT INTO `vn`.`entryConfig` (`defaultEntry`, `inventorySupplierFk`, `defaultSupplierFk`) VALUES (2, 4, 1); diff --git a/db/routines/cache/procedures/availableNoRaids_refresh.sql b/db/routines/cache/procedures/availableNoRaids_refresh.sql index 37715d270..efbbf6a13 100644 --- a/db/routines/cache/procedures/availableNoRaids_refresh.sql +++ b/db/routines/cache/procedures/availableNoRaids_refresh.sql @@ -53,7 +53,7 @@ proc: BEGIN WHERE t.landed BETWEEN vInventoryDate AND vStartDate AND t.warehouseInFk = vWarehouse AND s.name != 'INVENTARIO' - AND NOT e.isRaid + AND NOT t.daysInForward GROUP BY b.itemFk ) c JOIN vn.item i ON i.id = c.itemFk diff --git a/db/routines/edi/triggers/supplyResponse_afterUpdate.sql b/db/routines/edi/triggers/supplyResponse_afterUpdate.sql index 389ef9f1c..28a8c9466 100644 --- a/db/routines/edi/triggers/supplyResponse_afterUpdate.sql +++ b/db/routines/edi/triggers/supplyResponse_afterUpdate.sql @@ -6,16 +6,16 @@ BEGIN UPDATE vn.buy b JOIN vn.entry e ON e.id = b.entryFk - JOIN vn.travel tr ON tr.id = e.travelFk - JOIN vn.agencyMode am ON am.id = tr.agencyModeFk + JOIN vn.travel tr ON tr.id = e.travelFk + JOIN vn.agencyMode am ON am.id = tr.agencyModeFk JOIN vn.item i ON i.id = b.itemFk JOIN edi.supplyResponse sr ON i.supplyResponseFk = sr.ID SET b.quantity = NEW.NumberOfItemsPerCask * NEW.NumberOfUnits, b.stickers = NEW.NumberOfUnits WHERE i.supplyResponseFk = NEW.ID AND am.name = 'LOGIFLORA' - AND e.isRaid + AND tr.daysInForward AND tr.landed >= util.VN_CURDATE(); - + END$$ DELIMITER ; diff --git a/db/routines/hedera/procedures/item_getVisible.sql b/db/routines/hedera/procedures/item_getVisible.sql index 2f4ef32ab..365161bdf 100644 --- a/db/routines/hedera/procedures/item_getVisible.sql +++ b/db/routines/hedera/procedures/item_getVisible.sql @@ -59,7 +59,7 @@ BEGIN JOIN vn.travel t ON t.id = e.travelFk WHERE t.landed BETWEEN vDateInv AND vDate AND t.warehouseInFk = vWarehouse - AND NOT e.isRaid + AND NOT t.daysInForward UNION ALL SELECT b.itemFk, -b.quantity FROM vn.buy b @@ -67,7 +67,7 @@ BEGIN JOIN vn.travel t ON t.id = e.travelFk WHERE t.shipped BETWEEN vDateInv AND util.VN_CURDATE() AND t.warehouseOutFk = vWarehouse - AND NOT e.isRaid + AND NOT t.daysInForward AND t.isDelivered UNION ALL SELECT m.itemFk, -m.quantity diff --git a/db/routines/stock/procedures/log_refreshBuy.sql b/db/routines/stock/procedures/log_refreshBuy.sql index 488c00a28..d8e727f17 100644 --- a/db/routines/stock/procedures/log_refreshBuy.sql +++ b/db/routines/stock/procedures/log_refreshBuy.sql @@ -11,7 +11,7 @@ BEGIN e.id entryFk, t.id travelFk, b.itemFk, - e.isRaid, + t.daysInForward, ADDTIME(t.shipped, IFNULL(t.shipmentHour, '00:00:00')) shipped, t.warehouseOutFk, @@ -50,7 +50,7 @@ BEGIN itemFk, TIMESTAMPADD(DAY, life, @dated), quantity, - IF(isIn, isReceived, isDelivered) AND !isRaid + IF(isIn, isReceived, isDelivered) AND NOT daysInForward FROM tValues WHERE isIn OR !lessThanInventory; @@ -65,7 +65,7 @@ BEGIN itemFk, created, quantity, - IF(isIn, isDelivered, isReceived) AND !isRaid + IF(isIn, isDelivered, isReceived) AND NOT daysInForward FROM tValues WHERE !isIn OR !lessThanInventory; diff --git a/db/routines/vn/events/raidUpdate.sql b/db/routines/vn/events/raidUpdate.sql deleted file mode 100644 index c0c6f03c5..000000000 --- a/db/routines/vn/events/raidUpdate.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `vn`.`raidUpdate` - ON SCHEDULE EVERY 1 DAY - STARTS '2017-12-29 00:05:00.000' - ON COMPLETION PRESERVE - ENABLE -DO CALL raidUpdate$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/absoluteInventoryHistory.sql b/db/routines/vn/procedures/absoluteInventoryHistory.sql index d2a2029f0..3ea8cf4de 100644 --- a/db/routines/vn/procedures/absoluteInventoryHistory.sql +++ b/db/routines/vn/procedures/absoluteInventoryHistory.sql @@ -39,7 +39,7 @@ BEGIN AND vWarehouseFk IN (tr.warehouseInFk, 0) AND b.itemFk = vItemFk AND NOT e.isExcludedFromAvailable - AND NOT e.isRaid + AND NOT tr.daysInForward UNION ALL SELECT tr.shipped, NULL, @@ -58,7 +58,7 @@ BEGIN AND s.id <> (SELECT supplierFk FROM inventoryConfig) AND b.itemFk = vItemFk AND NOT e.isExcludedFromAvailable - AND NOT e.isRaid + AND NOT tr.daysInForward UNION ALL SELECT t.shipped, NULL, @@ -81,7 +81,7 @@ BEGIN FROM tHistoricalPast WHERE `date` < vDate; - SELECT p1.*, NULL v_virtual + SELECT p1.*, NULL v_virtual FROM ( SELECT vDate `date`, vCalculatedInventory input, @@ -96,7 +96,7 @@ BEGIN FROM tHistoricalPast WHERE `date` >= vDate ) p1; - + DROP TEMPORARY TABLE tHistoricalPast; END$$ -DELIMITER ; \ No newline at end of file +DELIMITER ; diff --git a/db/routines/vn/procedures/available_traslate.sql b/db/routines/vn/procedures/available_traslate.sql index 03eb376ab..28b187e58 100644 --- a/db/routines/vn/procedures/available_traslate.sql +++ b/db/routines/vn/procedures/available_traslate.sql @@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`available_traslate`( vWarehouseShipment INT) proc: BEGIN /** - * Calcular la disponibilidad dependiendo del almacen + * Calcular la disponibilidad dependiendo del almacen * de origen y destino según la fecha. * * @param vWarehouseLanding Almacén de llegada @@ -42,10 +42,10 @@ proc: BEGIN WHERE t.landed BETWEEN vDatedInventory AND vDatedFrom AND t.warehouseInFk = vWarehouseLanding AND NOT e.isExcludedFromAvailable - AND NOT e.isRaid + AND NOT t.daysInForward GROUP BY c.itemFk; - -- Tabla con el ultimo dia de last_buy para cada producto + -- Tabla con el ultimo dia de last_buy para cada producto -- que hace un replace de la anterior. CALL buy_getUltimate (NULL, vWarehouseShipment, util.VN_CURDATE()); @@ -57,7 +57,7 @@ proc: BEGIN JOIN travel tr ON tr.id = e.travelFk LEFT JOIN tItemRange i ON t.itemFk = i.itemFk WHERE t.warehouseFk = vWarehouseShipment - AND NOT e.isRaid + AND NOT t.daysInForward ON DUPLICATE KEY UPDATE tItemRange.dated = GREATEST(tItemRange.dated, tr.landed); @@ -94,7 +94,7 @@ proc: BEGIN JOIN tItemRangeLive ir ON ir.itemFk = b.itemFk WHERE NOT e.isExcludedFromAvailable AND b.quantity <> 0 - AND NOT e.isRaid + AND NOT t.daysInForward AND t.warehouseInFk = vWarehouseLanding AND t.landed >= vDatedFrom AND (ir.dated IS NULL OR t.landed <= ir.dated) @@ -135,4 +135,4 @@ proc: BEGIN DROP TEMPORARY TABLE tmp.itemList, tItemRange, tItemRangeLive; END$$ -DELIMITER ; \ No newline at end of file +DELIMITER ; diff --git a/db/routines/vn/procedures/clean_logiflora.sql b/db/routines/vn/procedures/clean_logiflora.sql index fd645a158..ac119631d 100644 --- a/db/routines/vn/procedures/clean_logiflora.sql +++ b/db/routines/vn/procedures/clean_logiflora.sql @@ -28,7 +28,7 @@ BEGIN JOIN agencyMode am ON am.id = tr.agencyModeFk WHERE NOT b.quantity AND am.code = 'logiflora' - AND e.isRaid; + AND tr.daysInForward; START TRANSACTION; diff --git a/db/routines/vn/procedures/entry_cloneHeader.sql b/db/routines/vn/procedures/entry_cloneHeader.sql index c988cc592..f83c5c501 100644 --- a/db/routines/vn/procedures/entry_cloneHeader.sql +++ b/db/routines/vn/procedures/entry_cloneHeader.sql @@ -17,7 +17,6 @@ BEGIN supplierFk, dated, isExcludedFromAvailable, - isRaid, commission, currencyFk, companyFk, @@ -28,7 +27,6 @@ BEGIN supplierFk, dated, isExcludedFromAvailable, - isRaid, commission, currencyFk, companyFk, diff --git a/db/routines/vn/procedures/entry_getTransfer.sql b/db/routines/vn/procedures/entry_getTransfer.sql index c83556408..9527e0bf2 100644 --- a/db/routines/vn/procedures/entry_getTransfer.sql +++ b/db/routines/vn/procedures/entry_getTransfer.sql @@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_getTransfer`( BEGIN /** * Retorna los artículos trasladables a partir de una entrada. - * + * * @param vSelf Id de entrada */ DECLARE vDateShipped DATE; @@ -166,7 +166,7 @@ BEGIN LEFT JOIN tmp.buyUltimateFromInterval bufi ON bufi.itemFk = i.id LEFT JOIN buy b3 ON b3.id = bufi.buyFk WHERE ic.display - AND NOT e.isRaid + AND NOT tr.daysInForward AND (ti.visible OR ti.available) ORDER BY i.typeFk, i.name, i.id, i.size, i.category, o.name; diff --git a/db/routines/vn/procedures/inventoryMake.sql b/db/routines/vn/procedures/inventoryMake.sql index 91065771a..65dceef3d 100644 --- a/db/routines/vn/procedures/inventoryMake.sql +++ b/db/routines/vn/procedures/inventoryMake.sql @@ -137,7 +137,7 @@ BEGIN JOIN travel tr ON tr.id = e.travelFk WHERE tr.warehouseInFk = vWarehouseFk AND tr.landed BETWEEN vDateLastInventory AND vDateYesterday - AND NOT isRaid + AND NOT tr.daysInForward GROUP BY b.itemFk; -- Transfers @@ -150,7 +150,7 @@ BEGIN JOIN travel tr ON tr.id = e.travelFk WHERE tr.warehouseOutFk = vWarehouseFk AND tr.shipped BETWEEN vDateLastInventory AND vDateYesterday - AND NOT isRaid + AND NOT tr.daysInForward GROUP BY b.itemFk ) sub ON DUPLICATE KEY UPDATE quantity = IFNULL(quantity, 0) + sub.quantityOut; diff --git a/db/routines/vn/procedures/item_getBalance.sql b/db/routines/vn/procedures/item_getBalance.sql index 4aa589d19..260f0a527 100644 --- a/db/routines/vn/procedures/item_getBalance.sql +++ b/db/routines/vn/procedures/item_getBalance.sql @@ -50,16 +50,16 @@ BEGIN JOIN vn.entry e ON e.id = b.entryFk JOIN vn.travel tr ON tr.id = e.travelFk JOIN vn.supplier s ON s.id = e.supplierFk - JOIN vn.state st ON st.`code` = IF(tr.landed < util.VN_CURDATE() + JOIN vn.state st ON st.`code` = IF(tr.landed < util.VN_CURDATE() OR (util.VN_CURDATE() AND tr.isReceived), 'DELIVERED', 'FREE') WHERE tr.landed >= vDateInventory AND tr.warehouseInFk = vWarehouseFk - AND (s.id <> vSupplierInventoryFk OR vDated IS NULL) + AND (s.id <> vSupplierInventoryFk OR vDated IS NULL) AND b.itemFk = vItemFk AND NOT e.isExcludedFromAvailable - AND NOT e.isRaid + AND NOT tr.daysInForward ), entriesOut AS ( SELECT 'entry', @@ -95,7 +95,7 @@ BEGIN AND b.itemFk = vItemFk AND NOT e.isExcludedFromAvailable AND NOT w.isFeedStock - AND NOT e.isRaid + AND NOT tr.daysInForward ), sales AS ( WITH itemSales AS ( @@ -147,10 +147,10 @@ BEGIN NULL FROM itemSales s LEFT JOIN vn.state stPrep ON stPrep.`code` = 'PREPARED' - LEFT JOIN vn.saleTracking stk ON stk.saleFk = s.saleFk + LEFT JOIN vn.saleTracking stk ON stk.saleFk = s.saleFk AND stk.stateFk = stPrep.id GROUP BY s.saleFk - ), + ), orders AS ( SELECT 'order' originType, o.id originId, @@ -215,9 +215,9 @@ BEGIN t.`in` invalue, t.`out`, @a := @a + IFNULL(t.`in`, 0) - IFNULL(t.`out`, 0) balance, - @currentLineFk := IF (@shipped < util.VN_CURDATE() + @currentLineFk := IF (@shipped < util.VN_CURDATE() OR (@shipped = util.VN_CURDATE() AND (t.isPicked OR a.`code` >= 'ON_PREPARATION')), - t.lineFk, + t.lineFk, @currentLineFk) lastPreparedLineFk, t.isTicket, t.lineFk, @@ -254,21 +254,21 @@ BEGIN UNION ALL SELECT originType, originId, - shipped, - alertlevel, - stateName, + shipped, + alertlevel, + stateName, reference, entityType, - entityId, + entityId, entityName, - `in`, - `out`, - @a := @a + IFNULL(`in`, 0) - IFNULL(`out`, 0), - 0, - isTicket, - lineFk, - isPicked, - clientType, + `in`, + `out`, + @a := @a + IFNULL(`in`, 0) - IFNULL(`out`, 0), + 0, + isTicket, + lineFk, + isPicked, + clientType, claimFk, `order` FROM tItemDiary diff --git a/db/routines/vn/procedures/item_getMinacum.sql b/db/routines/vn/procedures/item_getMinacum.sql index 85474fc3f..8a42bd737 100644 --- a/db/routines/vn/procedures/item_getMinacum.sql +++ b/db/routines/vn/procedures/item_getMinacum.sql @@ -63,7 +63,7 @@ BEGIN AND NOT e.isExcludedFromAvailable AND b.quantity <> 0 AND (vItemFk IS NULL OR b.itemFk = vItemFk) - AND NOT e.isRaid + AND NOT t.daysInForward UNION ALL SELECT r.itemFk, r.shipment, diff --git a/db/routines/vn/procedures/item_multipleBuyByDate.sql b/db/routines/vn/procedures/item_multipleBuyByDate.sql index 115202895..7bd809312 100644 --- a/db/routines/vn/procedures/item_multipleBuyByDate.sql +++ b/db/routines/vn/procedures/item_multipleBuyByDate.sql @@ -17,22 +17,22 @@ BEGIN ALTER TABLE tmp.itemInventory ADD `buy_date` datetime NOT NULL; - + CREATE OR REPLACE TEMPORARY TABLE lastBuyScope SELECT i.id, MAX(t.landed) lastLanded - FROM item i - JOIN buy b ON b.itemFk = i.id + FROM item i + JOIN buy b ON b.itemFk = i.id JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk + JOIN travel t ON t.id = e.travelFk JOIN supplier s ON s.id = e.supplierFk JOIN warehouse w ON w.id = t.warehouseInFk WHERE t.landed BETWEEN (vDated + INTERVAL - vLastBuyScope DAY) AND vDated AND NOT s.name = 'INVENTARIO' AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) AND w.isComparative - AND NOT e.isRaid + AND NOT t.daysInForward GROUP BY i.id; - + UPDATE tmp.itemInventory y JOIN lastBuyScope lbs ON lbs.id = y.id SET y.buy_date = lbs.lastLanded; diff --git a/db/routines/vn/procedures/item_valuateInventory.sql b/db/routines/vn/procedures/item_valuateInventory.sql index 5642ba812..880989101 100644 --- a/db/routines/vn/procedures/item_valuateInventory.sql +++ b/db/routines/vn/procedures/item_valuateInventory.sql @@ -25,7 +25,7 @@ BEGIN LIMIT 1; SET vHasNotInventory = (vInventoried IS NULL); - + IF vHasNotInventory THEN SELECT landed INTO vInventoryClone FROM travel tr @@ -50,7 +50,7 @@ BEGIN PRIMARY KEY (warehouseInventory, itemFk) USING HASH ) ENGINE = MEMORY; - + -- Inventario inicial IF vHasNotInventory THEN INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory) @@ -109,7 +109,7 @@ BEGIN JOIN warehouse w ON w.id = tr.warehouseInFk WHERE tr.landed BETWEEN vInventoried AND vDateDayEnd AND IF(tr.landed = util.VN_CURDATE(), tr.isReceived, TRUE) - AND NOT e.isRaid + AND NOT tr.daysInForward AND w.valuatedInventory AND t.isInventory AND e.supplierFk <> vInventorySupplierFk @@ -131,7 +131,7 @@ BEGIN JOIN itemCategory ic ON ic.id = t.categoryFk JOIN warehouse w ON w.id = tr.warehouseOutFk WHERE tr.shipped BETWEEN vInventoried AND vDateDayEnd - AND NOT e.isRaid + AND NOT t.daysInForward AND w.valuatedInventory AND t.isInventory AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL) @@ -159,7 +159,7 @@ BEGIN ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + s.quantity * IF(vHasNotInventory, 1, -1); -- Volver a poner lo que esta aun en las estanterias - IF vDated = util.VN_CURDATE() THEN + IF vDated = util.VN_CURDATE() THEN INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory) SELECT w.id, s.itemFk, @@ -196,14 +196,14 @@ BEGIN JOIN warehouse wIn ON wIn.id = tr.warehouseInFk JOIN warehouse wOut ON wOut.id = tr.warehouseOutFk WHERE vDated >= tr.shipped AND vDated < tr.landed - AND NOT isRaid + AND NOT tr.daysInForward AND wIn.valuatedInventory AND t.isInventory AND e.isConfirmed AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL) AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL) ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity); - + CALL buy_getUltimate (NULL, NULL, vDateDayEnd); DELETE FROM tInventory WHERE quantity IS NULL OR NOT quantity; @@ -233,7 +233,7 @@ BEGIN JOIN warehouse w ON w.id = warehouseFk JOIN item i ON i.id = ti.itemFk JOIN itemType tp ON tp.id = i.typeFk - JOIN itemCategory ic ON ic.id = tp.categoryFk + JOIN itemCategory ic ON ic.id = tp.categoryFk WHERE w.valuatedInventory AND ti.total > 0; diff --git a/db/routines/vn/procedures/multipleInventory.sql b/db/routines/vn/procedures/multipleInventory.sql index c051706b7..6b26e456f 100644 --- a/db/routines/vn/procedures/multipleInventory.sql +++ b/db/routines/vn/procedures/multipleInventory.sql @@ -1,173 +1,173 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`multipleInventory`( - vDate DATE, - vWarehouseFk TINYINT, - vMaxDays TINYINT -) -proc: BEGIN - DECLARE vDateTomorrow DATE DEFAULT vDate + INTERVAL 1 DAY; - DECLARE vDateFrom DATE DEFAULT vDate; - DECLARE vDateTo DATETIME; - DECLARE vDateToTomorrow DATETIME; - DECLARE vDefaultDayRange INT; - DECLARE vCalcFk INT; - - IF vDate < util.VN_CURDATE() THEN - LEAVE proc; - END IF; - - IF vDate = util.VN_CURDATE() THEN - SELECT inventoried INTO vDateFrom - FROM config; - END IF; - - SELECT defaultDayRange INTO vDefaultDayRange - FROM comparativeConfig; - - SET vDateTo = vDate + INTERVAL IFNULL(vMaxDays, vDefaultDayRange) DAY; - SET vDateToTomorrow = vDateTo + INTERVAL 1 DAY; - - ALTER TABLE tmp.itemInventory - ADD `avalaible` INT NOT NULL, - ADD `sd` INT NOT NULL, - ADD `rest` INT NOT NULL, - ADD `expected` INT NOT NULL, - ADD `inventory` INT NOT NULL, - ADD `visible` INT NOT NULL, - ADD `life` TINYINT NOT NULL DEFAULT '0'; - - -- Calculo del inventario - CREATE OR REPLACE TEMPORARY TABLE tItemInventoryCalc - (PRIMARY KEY (itemFk)) - ENGINE = MEMORY - SELECT itemFk, - SUM(quantity) quantity - FROM ( - SELECT s.itemFk, - s.quantity quantity - FROM sale s - JOIN ticket t ON t.id = s.ticketFk - JOIN warehouse w ON w.id = t.warehouseFk - WHERE t.shipped BETWEEN vDateFrom AND util.dayEnd(vDate) - AND IFNULL(vWarehouseFk, t.warehouseFk) = t.warehouseFk - AND w.isComparative - UNION ALL - SELECT b.itemFk, b.quantity - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - JOIN warehouse w ON w.id = t.warehouseInFk - WHERE t.landed BETWEEN vDateFrom AND util.dayEnd(vDate) - AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk - AND w.isComparative - AND NOT e.isExcludedFromAvailable - AND NOT e.isRaid - UNION ALL - SELECT b.itemFk, - b.quantity - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - JOIN warehouse w ON w.id = t.warehouseOutFk - WHERE t.shipped BETWEEN vDateFrom AND util.dayEnd(vDate) - AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk - AND w.isComparative - AND NOT e.isExcludedFromAvailable - AND NOT e.isRaid - ) sub - GROUP BY itemFk; - - -- Cálculo del visible - CALL cache.visible_refresh(vCalcFk, FALSE, vWarehouseFk); - - CREATE OR REPLACE TEMPORARY TABLE tItemVisibleCalc - (PRIMARY KEY (item_id)) - ENGINE = MEMORY - SELECT item_id, visible - FROM cache.visible - WHERE calc_id = vCalcFk; - - UPDATE tmp.itemInventory it - LEFT JOIN tItemInventoryCalc iic ON iic.itemFk = it.id - LEFT JOIN tItemVisibleCalc ivc ON ivc.item_id = it.id - SET it.inventory = iic.quantity, - it.visible = ivc.visible, - it.avalaible = iic.quantity, - it.sd = iic.quantity; - - -- Calculo del disponible - CREATE OR REPLACE TEMPORARY TABLE tmp.itemCalc - (INDEX (itemFk, warehouseFk)) - ENGINE = MEMORY - SELECT sub.itemFk, - vWarehouseFk warehouseFk, - sub.dated, - SUM(sub.quantity) quantity - FROM ( - SELECT s.itemFk, - DATE(t.shipped) dated, - - s.quantity quantity - FROM sale s - JOIN ticket t ON t.id = s.ticketFk - JOIN warehouse w ON w.id = t.warehouseFk - WHERE t.shipped BETWEEN vDateTomorrow AND vDateTo - AND IFNULL(vWarehouseFk, t.warehouseFk) = t.warehouseFk - AND w.isComparative - UNION ALL - SELECT b.itemFk, t.landed, b.quantity - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - JOIN warehouse w ON w.id = t.warehouseInFk - WHERE t.landed BETWEEN vDateTomorrow AND vDateTo - AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk - AND w.isComparative - AND NOT e.isExcludedFromAvailable - AND NOT e.isRaid - UNION ALL - SELECT b.itemFk, t.shipped, - b.quantity - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - JOIN warehouse w ON w.id = t.warehouseOutFk - WHERE t.shipped BETWEEN vDateTomorrow AND vDateTo - AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk - AND w.isComparative - AND NOT e.isExcludedFromAvailable - AND NOT e.isRaid - ) sub - GROUP BY sub.itemFk, sub.dated; - - CALL item_getAtp(vDate); - CALL travel_upcomingArrivals(vWarehouseFk, vDate); - - CREATE OR REPLACE TEMPORARY TABLE tItemAvailableCalc - (PRIMARY KEY (itemFk)) - ENGINE = MEMORY - SELECT it.itemFk, - SUM(it.quantity) quantity, - im.quantity minQuantity - FROM tmp.itemCalc it - JOIN tmp.itemAtp im ON im.itemFk = it.itemFk - JOIN item i ON i.id = it.itemFk - LEFT JOIN origin o ON o.id = i.originFk - LEFT JOIN tmp.itemTravel t ON t.wh = o.warehouseFk - WHERE it.dated < IF(vMaxDays < 0 AND t.landing IS NOT NULL, - t.landing, - vDateToTomorrow) - GROUP BY it.itemFk; - - UPDATE tmp.itemInventory it - JOIN tItemAvailableCalc iac ON iac.itemFk = it.id - SET it.avalaible = IF(iac.minQuantity > 0, - it.avalaible, - it.avalaible + iac.minQuantity), - it.sd = it.inventory + iac.quantity; - - DROP TEMPORARY TABLE - tmp.itemTravel, - tmp.itemCalc, - tmp.itemAtp, - tItemInventoryCalc, - tItemVisibleCalc, - tItemAvailableCalc; -END$$ -DELIMITER ; +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`multipleInventory`( + vDate DATE, + vWarehouseFk TINYINT, + vMaxDays TINYINT +) +proc: BEGIN + DECLARE vDateTomorrow DATE DEFAULT vDate + INTERVAL 1 DAY; + DECLARE vDateFrom DATE DEFAULT vDate; + DECLARE vDateTo DATETIME; + DECLARE vDateToTomorrow DATETIME; + DECLARE vDefaultDayRange INT; + DECLARE vCalcFk INT; + + IF vDate < util.VN_CURDATE() THEN + LEAVE proc; + END IF; + + IF vDate = util.VN_CURDATE() THEN + SELECT inventoried INTO vDateFrom + FROM config; + END IF; + + SELECT defaultDayRange INTO vDefaultDayRange + FROM comparativeConfig; + + SET vDateTo = vDate + INTERVAL IFNULL(vMaxDays, vDefaultDayRange) DAY; + SET vDateToTomorrow = vDateTo + INTERVAL 1 DAY; + + ALTER TABLE tmp.itemInventory + ADD `avalaible` INT NOT NULL, + ADD `sd` INT NOT NULL, + ADD `rest` INT NOT NULL, + ADD `expected` INT NOT NULL, + ADD `inventory` INT NOT NULL, + ADD `visible` INT NOT NULL, + ADD `life` TINYINT NOT NULL DEFAULT '0'; + + -- Calculo del inventario + CREATE OR REPLACE TEMPORARY TABLE tItemInventoryCalc + (PRIMARY KEY (itemFk)) + ENGINE = MEMORY + SELECT itemFk, + SUM(quantity) quantity + FROM ( + SELECT s.itemFk, - s.quantity quantity + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN warehouse w ON w.id = t.warehouseFk + WHERE t.shipped BETWEEN vDateFrom AND util.dayEnd(vDate) + AND IFNULL(vWarehouseFk, t.warehouseFk) = t.warehouseFk + AND w.isComparative + UNION ALL + SELECT b.itemFk, b.quantity + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + JOIN warehouse w ON w.id = t.warehouseInFk + WHERE t.landed BETWEEN vDateFrom AND util.dayEnd(vDate) + AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk + AND w.isComparative + AND NOT e.isExcludedFromAvailable + AND NOT t.daysInForward + UNION ALL + SELECT b.itemFk, - b.quantity + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + JOIN warehouse w ON w.id = t.warehouseOutFk + WHERE t.shipped BETWEEN vDateFrom AND util.dayEnd(vDate) + AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk + AND w.isComparative + AND NOT e.isExcludedFromAvailable + AND NOT t.daysInForward + ) sub + GROUP BY itemFk; + + -- Cálculo del visible + CALL cache.visible_refresh(vCalcFk, FALSE, vWarehouseFk); + + CREATE OR REPLACE TEMPORARY TABLE tItemVisibleCalc + (PRIMARY KEY (item_id)) + ENGINE = MEMORY + SELECT item_id, visible + FROM cache.visible + WHERE calc_id = vCalcFk; + + UPDATE tmp.itemInventory it + LEFT JOIN tItemInventoryCalc iic ON iic.itemFk = it.id + LEFT JOIN tItemVisibleCalc ivc ON ivc.item_id = it.id + SET it.inventory = iic.quantity, + it.visible = ivc.visible, + it.avalaible = iic.quantity, + it.sd = iic.quantity; + + -- Calculo del disponible + CREATE OR REPLACE TEMPORARY TABLE tmp.itemCalc + (INDEX (itemFk, warehouseFk)) + ENGINE = MEMORY + SELECT sub.itemFk, + vWarehouseFk warehouseFk, + sub.dated, + SUM(sub.quantity) quantity + FROM ( + SELECT s.itemFk, + DATE(t.shipped) dated, + - s.quantity quantity + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN warehouse w ON w.id = t.warehouseFk + WHERE t.shipped BETWEEN vDateTomorrow AND vDateTo + AND IFNULL(vWarehouseFk, t.warehouseFk) = t.warehouseFk + AND w.isComparative + UNION ALL + SELECT b.itemFk, t.landed, b.quantity + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + JOIN warehouse w ON w.id = t.warehouseInFk + WHERE t.landed BETWEEN vDateTomorrow AND vDateTo + AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk + AND w.isComparative + AND NOT e.isExcludedFromAvailable + AND NOT t.daysInForward + UNION ALL + SELECT b.itemFk, t.shipped, - b.quantity + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + JOIN warehouse w ON w.id = t.warehouseOutFk + WHERE t.shipped BETWEEN vDateTomorrow AND vDateTo + AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk + AND w.isComparative + AND NOT e.isExcludedFromAvailable + AND NOT t.daysInForward + ) sub + GROUP BY sub.itemFk, sub.dated; + + CALL item_getAtp(vDate); + CALL travel_upcomingArrivals(vWarehouseFk, vDate); + + CREATE OR REPLACE TEMPORARY TABLE tItemAvailableCalc + (PRIMARY KEY (itemFk)) + ENGINE = MEMORY + SELECT it.itemFk, + SUM(it.quantity) quantity, + im.quantity minQuantity + FROM tmp.itemCalc it + JOIN tmp.itemAtp im ON im.itemFk = it.itemFk + JOIN item i ON i.id = it.itemFk + LEFT JOIN origin o ON o.id = i.originFk + LEFT JOIN tmp.itemTravel t ON t.wh = o.warehouseFk + WHERE it.dated < IF(vMaxDays < 0 AND t.landing IS NOT NULL, + t.landing, + vDateToTomorrow) + GROUP BY it.itemFk; + + UPDATE tmp.itemInventory it + JOIN tItemAvailableCalc iac ON iac.itemFk = it.id + SET it.avalaible = IF(iac.minQuantity > 0, + it.avalaible, + it.avalaible + iac.minQuantity), + it.sd = it.inventory + iac.quantity; + + DROP TEMPORARY TABLE + tmp.itemTravel, + tmp.itemCalc, + tmp.itemAtp, + tItemInventoryCalc, + tItemVisibleCalc, + tItemAvailableCalc; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/raidUpdate.sql b/db/routines/vn/procedures/raidUpdate.sql deleted file mode 100644 index 71352868e..000000000 --- a/db/routines/vn/procedures/raidUpdate.sql +++ /dev/null @@ -1,31 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`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/travelVolume_get.sql b/db/routines/vn/procedures/travelVolume_get.sql index 99c0acbb8..bb98cacdf 100644 --- a/db/routines/vn/procedures/travelVolume_get.sql +++ b/db/routines/vn/procedures/travelVolume_get.sql @@ -10,7 +10,7 @@ BEGIN JOIN vn.entry e ON e.travelFk = tr.id JOIN vn.buy b ON b.entryFk = e.id WHERE tr.landed BETWEEN vFromDated AND vToDated - AND e.isRaid = FALSE + AND NOT tr.daysInForward AND tr.warehouseInFk = vWarehouseFk GROUP BY tr.landed , a.name ; END$$ diff --git a/db/routines/vn/procedures/travel_moveRaids.sql b/db/routines/vn/procedures/travel_moveRaids.sql index 95e02ec55..aa554a1a0 100644 --- a/db/routines/vn/procedures/travel_moveRaids.sql +++ b/db/routines/vn/procedures/travel_moveRaids.sql @@ -1,72 +1,68 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_moveRaids`() BEGIN - -/* - * Desplaza al dia siguiente los travels que contengan redadas y avisa a los compradores +/** + * Desplaza los travels en el futuro y avisa a los compradores * */ DECLARE vDone BOOL DEFAULT FALSE; - DECLARE vWorkerName VARCHAR(50); - DECLARE vRaid TEXT; - DECLARE vWorker VARCHAR(50) DEFAULT ''; + DECLARE vBuyerEmail VARCHAR(40); + DECLARE vTravelLink TEXT; DECLARE vMailBody TEXT DEFAULT ''; DECLARE vCur CURSOR FOR - SELECT GROUP_CONCAT( DISTINCT CONCAT('https://salix.verdnatura.es/#!/travel/', ttr.id, '/summary ') ORDER BY ttr.id SEPARATOR '\n\r'), - u.name - FROM tmp.travel ttr - JOIN entry e ON e.travelFk = ttr.id + SELECT GROUP_CONCAT(DISTINCT + CONCAT('https://salix.verdnatura.es/#!/travel/', + ttm.travelFk, + '/summary ') + ORDER BY ttm.travelFk SEPARATOR '\n\r') travelLink, + CONCAT(u.name, '@verdnatura.es') buyerEmail + FROM tTravelToMove ttm + JOIN entry e ON e.travelFk = ttm.travelFk JOIN buy b ON b.entryFk = e.id JOIN item i ON i.id = b.itemFk JOIN itemType it ON it.id = i.typeFk JOIN account.user u ON u.id = it.workerFk GROUP BY u.name; - DECLARE CONTINUE HANDLER FOR NOT FOUND - SET vDone = TRUE; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN ROLLBACK; RESIGNAL; END; - - DROP TEMPORARY TABLE IF EXISTS tmp.travel; - CREATE TEMPORARY TABLE tmp.travel - SELECT tr.id,tr.landed - FROM travel tr - JOIN entry e ON e.travelFk = tr.id - WHERE tr.landed = util.tomorrow() - AND e.isRaid - GROUP BY tr.id; + + CREATE OR REPLACE TEMPORARY TABLE tTravelToMove + SELECT id travelFk, + util.VN_CURDATE() + INTERVAL daysInForward DAY newLanded + FROM travel + WHERE daysInForward; START TRANSACTION; UPDATE travel tr - JOIN tmp.travel ttr ON ttr.id = tr.id - SET tr.landed = TIMESTAMPADD(DAY, 1, tr.landed); + JOIN tTravelToMove ttm ON ttm.travelFk = tr.id + SET tr.landed = ttm.newLanded; OPEN vCur; l: LOOP SET vDone = FALSE; - FETCH vCur INTO vRaid, vWorkerName; + FETCH vCur INTO vTravelLink, vBuyerEmail; IF vDone THEN LEAVE l; END IF; - CALL `vn`.`mail_insert`(CONCAT(vWorkerName, '@verdnatura.es'), - 'noreply@verdnatura.es', - 'Cambio de fecha en Redadas', - CONCAT('Se ha movido las siguientes redadas: \n\r ', vRaid) - ); - + CALL `vn`.`mail_insert`( + vBuyerEmail, + 'noreply@verdnatura.es', + 'Cambio de fecha en Redadas', + CONCAT('Se ha movido los siguientes travels: \n\r ', vTravelLink)); END LOOP; CLOSE vCur; COMMIT; - DROP TEMPORARY TABLE tmp.travel; - + DROP TEMPORARY TABLE tTravelToMove; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/entry_beforeUpdate.sql b/db/routines/vn/triggers/entry_beforeUpdate.sql index 8e5a326a0..3b999012f 100644 --- a/db/routines/vn/triggers/entry_beforeUpdate.sql +++ b/db/routines/vn/triggers/entry_beforeUpdate.sql @@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`entry_beforeUpdate` BEFORE UPDATE ON `entry` FOR EACH ROW BEGIN - DECLARE vIsVirtual BOOL; + DECLARE vDaysInForward INT; DECLARE vPrintedCount INT; DECLARE vHasDistinctWarehouses BOOL; DECLARE vTotalBuy INT; @@ -37,18 +37,20 @@ BEGIN IF NEW.travelFk IS NOT NULL THEN CALL travel_throwAwb(NEW.travelFk); END IF; - - SELECT COUNT(*) > 0 INTO vIsVirtual - FROM entryVirtual WHERE entryFk = NEW.id; + + SELECT daysInForward INTO vDaysInForward + FROM travel t + JOIN entry e ON e.travelFk = t.id + WHERE entryFk = NEW.id; SELECT NOT (o.warehouseInFk <=> n.warehouseInFk) - OR NOT (o.warehouseOutFk <=> n.warehouseOutFk) + OR NOT (o.warehouseOutFk <=> n.warehouseOutFk) INTO vHasDistinctWarehouses FROM travel o, travel n WHERE o.id = OLD.travelFk AND n.id = NEW.travelFk; - IF vIsVirtual AND vHasDistinctWarehouses THEN + IF vDaysInForward AND vHasDistinctWarehouses THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'A cloned entry cannot be moved to a travel with different warehouses'; END IF; @@ -71,7 +73,7 @@ BEGIN SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk); END IF; - IF NOT (NEW.travelFk <=> OLD.travelFk) + IF NOT (NEW.travelFk <=> OLD.travelFk) OR NOT (NEW.currencyFk <=> OLD.currencyFk) OR NOT (NEW.supplierFk <=> OLD.supplierFk) THEN diff --git a/db/routines/vn/views/itemEntryIn.sql b/db/routines/vn/views/itemEntryIn.sql index 4f7855d2b..6196e9396 100644 --- a/db/routines/vn/views/itemEntryIn.sql +++ b/db/routines/vn/views/itemEntryIn.sql @@ -6,7 +6,7 @@ AS SELECT `t`.`warehouseInFk` AS `warehouseInFk`, `b`.`itemFk` AS `itemFk`, `b`.`quantity` AS `quantity`, `t`.`isReceived` AS `isReceived`, - `e`.`isRaid` AS `isVirtualStock`, + `t`.`daysInForward` AS `isVirtualStock`, `e`.`id` AS `entryFk` FROM ( ( diff --git a/db/routines/vn/views/itemEntryOut.sql b/db/routines/vn/views/itemEntryOut.sql index 1e8718c53..f18116e61 100644 --- a/db/routines/vn/views/itemEntryOut.sql +++ b/db/routines/vn/views/itemEntryOut.sql @@ -15,5 +15,5 @@ FROM ( JOIN `vn`.`travel` `t` ON(`e`.`travelFk` = `t`.`id`) ) WHERE `e`.`isExcludedFromAvailable` = 0 - AND `e`.`isRaid` = 0 + AND NOT `t`.`daysInForward` AND `b`.`quantity` <> 0 diff --git a/db/routines/vn/views/lastPurchases.sql b/db/routines/vn/views/lastPurchases.sql index 3099acd00..9dc5ec898 100644 --- a/db/routines/vn/views/lastPurchases.sql +++ b/db/routines/vn/views/lastPurchases.sql @@ -31,5 +31,5 @@ FROM ( LEFT JOIN `edi`.`ekt` `ek` ON(`ek`.`id` = `b`.`ektFk`) ) WHERE `tr`.`landed` BETWEEN `util`.`yesterday`() AND `util`.`tomorrow`() - AND `e`.`isRaid` = 0 + AND NOT `tr`.`daysInForward` AND `b`.`stickers` > 0 diff --git a/db/routines/vn2008/views/Entradas.sql b/db/routines/vn2008/views/Entradas.sql index 63fbaa728..78b73bb24 100644 --- a/db/routines/vn2008/views/Entradas.sql +++ b/db/routines/vn2008/views/Entradas.sql @@ -8,7 +8,6 @@ AS SELECT `e`.`id` AS `Id_Entrada`, `e`.`isExcludedFromAvailable` AS `Inventario`, `e`.`isConfirmed` AS `Confirmada`, `e`.`isOrdered` AS `Pedida`, - `e`.`isRaid` AS `Redada`, `e`.`commission` AS `comision`, `e`.`created` AS `odbc_date`, `e`.`evaNotes` AS `Notas_Eva`, diff --git a/db/routines/vn2008/views/Entradas_Auto.sql b/db/routines/vn2008/views/Entradas_Auto.sql deleted file mode 100644 index 5d1266965..000000000 --- a/db/routines/vn2008/views/Entradas_Auto.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`Entradas_Auto` -AS SELECT `ev`.`entryFk` AS `Id_Entrada` -FROM `vn`.`entryVirtual` `ev` diff --git a/db/routines/vn2008/views/entrySource.sql b/db/routines/vn2008/views/entrySource.sql index 3a8df41bf..e6e874405 100644 --- a/db/routines/vn2008/views/entrySource.sql +++ b/db/routines/vn2008/views/entrySource.sql @@ -8,7 +8,7 @@ AS SELECT `e`.`gestDocFk` AS `gestdoc_id`, `e`.`isExcludedFromAvailable` AS `Inventario`, `e`.`isConfirmed` AS `Confirmada`, `e`.`isOrdered` AS `Pedida`, - `e`.`isRaid` AS `Redada`, + `tr`.`daysInForward` AS `Redada`, `e`.`evaNotes` AS `notas`, `e`.`supplierFk` AS `Id_Proveedor`, `tr`.`shipped` AS `shipment`, diff --git a/db/routines/vn2008/views/travel.sql b/db/routines/vn2008/views/travel.sql index b55dbf9b6..0e1f5acb2 100644 --- a/db/routines/vn2008/views/travel.sql +++ b/db/routines/vn2008/views/travel.sql @@ -17,5 +17,6 @@ AS SELECT `t`.`id` AS `id`, `t`.`cargoSupplierFk` AS `cargoSupplierFk`, `t`.`totalEntries` AS `totalEntries`, `t`.`appointment` AS `appointment`, - `t`.`awbFk` AS `awbFk` + `t`.`awbFk` AS `awbFk`, + `t`.`daysInForward` AS `daysInForward` FROM `vn`.`travel` `t` diff --git a/db/routines/vn2008/views/v_compres.sql b/db/routines/vn2008/views/v_compres.sql index 8bd6a4a64..324e459f6 100644 --- a/db/routines/vn2008/views/v_compres.sql +++ b/db/routines/vn2008/views/v_compres.sql @@ -28,7 +28,6 @@ AS SELECT `TP`.`Id_Tipo` AS `Familia`, `E`.`Id_Proveedor` AS `Id_Proveedor`, `E`.`Fecha` AS `Fecha`, `E`.`Confirmada` AS `Confirmada`, - `E`.`Redada` AS `Redada`, `E`.`empresa_id` AS `empresa_id`, `E`.`travel_id` AS `travel_id`, `E`.`Pedida` AS `Pedida`, @@ -85,6 +84,6 @@ FROM ( ) JOIN `vn2008`.`Cubos` `cb` ON(`cb`.`Id_Cubo` = `C`.`Id_Cubo`) ) -WHERE `W_IN`.`isFeedStock` = 0 - AND `E`.`Inventario` = 0 - AND `E`.`Redada` = 0 +WHERE NOT `W_IN`.`isFeedStock` + AND NOT `E`.`Inventario` + AND NOT `TR`.`daysInForward` diff --git a/db/versions/11316-chocolateErica/00-firstScript.sql b/db/versions/11316-chocolateErica/00-firstScript.sql new file mode 100644 index 000000000..b973d8a41 --- /dev/null +++ b/db/versions/11316-chocolateErica/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.travel ADD IF NOT EXISTS daysInForward INT UNSIGNED DEFAULT NULL NULL + COMMENT 'Número de días donde se siturá el landed de las entradas con respecto a hoy'; diff --git a/modules/entry/back/locale/entry/en.yml b/modules/entry/back/locale/entry/en.yml index 6bc2333e6..ab8c0fd1c 100644 --- a/modules/entry/back/locale/entry/en.yml +++ b/modules/entry/back/locale/entry/en.yml @@ -9,7 +9,6 @@ columns: notes: notes isConfirmed: confirmed isVirtual: virtual - isRaid: raid commission: commission isOrdered: price3 created: created diff --git a/modules/entry/back/locale/entry/es.yml b/modules/entry/back/locale/entry/es.yml index a892b05d2..18bf1ca33 100644 --- a/modules/entry/back/locale/entry/es.yml +++ b/modules/entry/back/locale/entry/es.yml @@ -9,7 +9,6 @@ columns: notes: notas isConfirmed: confirmado isVirtual: virtual - isRaid: redada commission: comisión isOrdered: pedida created: creado diff --git a/modules/entry/back/methods/entry/filter.js b/modules/entry/back/methods/entry/filter.js index f4703245c..a5c236fe4 100644 --- a/modules/entry/back/methods/entry/filter.js +++ b/modules/entry/back/methods/entry/filter.js @@ -194,7 +194,7 @@ module.exports = Self => { e.evaNotes observation, e.isConfirmed, e.isOrdered, - e.isRaid, + t.daysInForward, e.commission, e.created, e.travelFk, diff --git a/modules/entry/back/methods/entry/getEntry.js b/modules/entry/back/methods/entry/getEntry.js index cac3c65f8..4612de9a5 100644 --- a/modules/entry/back/methods/entry/getEntry.js +++ b/modules/entry/back/methods/entry/getEntry.js @@ -48,7 +48,9 @@ module.exports = Self => { 'warehouseInFk', 'isReceived', 'isDelivered', - 'ref'], + 'ref', + 'daysInForward', + ], include: [ { relation: 'agency', @@ -85,7 +87,6 @@ module.exports = Self => { } ], }; - return models.Entry.findOne(filter, myOptions); }; }; diff --git a/modules/entry/back/models/entry.json b/modules/entry/back/models/entry.json index 383585fce..4a09c7d6a 100644 --- a/modules/entry/back/models/entry.json +++ b/modules/entry/back/models/entry.json @@ -33,15 +33,6 @@ "isConfirmed": { "type": "boolean" }, - "isVirtual": { - "type": "boolean", - "mysql": { - "columnName": "isRaid" - } - }, - "isRaid": { - "type": "boolean" - }, "commission": { "type": "number" }, @@ -88,7 +79,8 @@ "travel": { "type": "belongsTo", "model": "Travel", - "foreignKey": "travelFk" + "foreignKey": "travelFk", + "daysInForward": "daysInForward" }, "company": { "type": "belongsTo", diff --git a/modules/travel/back/methods/travel/getTravel.js b/modules/travel/back/methods/travel/getTravel.js index 171b64db1..59d30a0c7 100644 --- a/modules/travel/back/methods/travel/getTravel.js +++ b/modules/travel/back/methods/travel/getTravel.js @@ -44,7 +44,6 @@ module.exports = Self => { ], }; - let travel = await Self.app.models.Travel.findOne(filter); - return travel; + return Self.app.models.Travel.findOne(filter); }; }; diff --git a/modules/travel/back/models/travel.json b/modules/travel/back/models/travel.json index 0ebf683e7..04f53f1c8 100644 --- a/modules/travel/back/models/travel.json +++ b/modules/travel/back/models/travel.json @@ -50,6 +50,9 @@ }, "landingHour": { "type": "string" + }, + "daysInForward": { + "type": "number" } }, "relations": { From 4d3bc2c8377e85041e952283561901ec91a78049 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Thu, 24 Oct 2024 19:32:02 +0200 Subject: [PATCH 31/89] feat: refs #8087 Traspasar redadas a travels --- modules/entry/front/descriptor/index.html | 130 +++++++++---------- modules/entry/front/summary/index.html | 2 +- modules/travel/back/methods/travel/filter.js | 1 + 3 files changed, 67 insertions(+), 66 deletions(-) diff --git a/modules/entry/front/descriptor/index.html b/modules/entry/front/descriptor/index.html index 3354d4155..40625a4d5 100644 --- a/modules/entry/front/descriptor/index.html +++ b/modules/entry/front/descriptor/index.html @@ -1,65 +1,65 @@ - - - - Show entry report - - - -
- - - - - - -
-
- - - - -
- -
-
- - - \ No newline at end of file + + + + Show entry report + + + +
+ + + + + + +
+
+ + + + +
+ +
+
+ + + diff --git a/modules/entry/front/summary/index.html b/modules/entry/front/summary/index.html index 22ea87bdf..e58169fa5 100644 --- a/modules/entry/front/summary/index.html +++ b/modules/entry/front/summary/index.html @@ -86,7 +86,7 @@ auto-load="true"> { t.landingHour, t.cargoSupplierFk, t.totalEntries, + t.daysInForward, am.name agencyModeName, win.name warehouseInName, wout.name warehouseOutName, From 11e13fdb200838e29e815aa8d88c547cf49815b4 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 25 Oct 2024 06:40:06 +0200 Subject: [PATCH 32/89] feat: refs #7922 refs #792 scanOrder --- db/routines/vn/procedures/expedition_getFromRoute.sql | 4 +++- db/versions/11319-redEucalyptus/00-firstScript.sql | 3 +++ .../back/methods/expedition-state/addExpeditionState.js | 2 ++ modules/ticket/back/models/expedition-state.json | 3 +++ 4 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 db/versions/11319-redEucalyptus/00-firstScript.sql diff --git a/db/routines/vn/procedures/expedition_getFromRoute.sql b/db/routines/vn/procedures/expedition_getFromRoute.sql index f95936413..8c2ab057d 100644 --- a/db/routines/vn/procedures/expedition_getFromRoute.sql +++ b/db/routines/vn/procedures/expedition_getFromRoute.sql @@ -16,7 +16,8 @@ BEGIN a.nickname, sub2.itemPackingTypeConcat, est.code, - es.isScanned + es2.isScanned, + es2.scanOrder FROM expedition e JOIN ticket t ON t.id = e.ticketFk JOIN ticketState ts ON ts.ticketFk = e.ticketFk @@ -38,6 +39,7 @@ BEGIN SELECT MAX(id) FROM expeditionState es WHERE expeditionFk = e.id) + LEFT JOIN expeditionState es2 ON es2.id = es.id WHERE t.routeFk = vRouteFk AND e.freightItemFk <> FALSE ORDER BY r.created, t.priority DESC; END$$ diff --git a/db/versions/11319-redEucalyptus/00-firstScript.sql b/db/versions/11319-redEucalyptus/00-firstScript.sql new file mode 100644 index 000000000..62bd64f4a --- /dev/null +++ b/db/versions/11319-redEucalyptus/00-firstScript.sql @@ -0,0 +1,3 @@ +USE vn; + +ALTER TABLE vn.expeditionState ADD scanOrder int(11) DEFAULT NULL NULL COMMENT 'Indica la posición al cargar la furgoneta'; diff --git a/modules/ticket/back/methods/expedition-state/addExpeditionState.js b/modules/ticket/back/methods/expedition-state/addExpeditionState.js index 80d74ee92..0ba402ff7 100644 --- a/modules/ticket/back/methods/expedition-state/addExpeditionState.js +++ b/modules/ticket/back/methods/expedition-state/addExpeditionState.js @@ -44,6 +44,7 @@ module.exports = Self => { const typeFk = expeditionStateType.id; expeditionId = expedition.expeditionFk; + expeditionPosition = expedition?.scanOrder ?? null; const isScannedExpedition = expedition.isScanned ?? false; await models.ExpeditionState.create({ @@ -51,6 +52,7 @@ module.exports = Self => { typeFk, userFk: userId, isScanned: isScannedExpedition, + scanOrder: expeditionPosition }, myOptions); } diff --git a/modules/ticket/back/models/expedition-state.json b/modules/ticket/back/models/expedition-state.json index 159a9275e..e96d2544c 100644 --- a/modules/ticket/back/models/expedition-state.json +++ b/modules/ticket/back/models/expedition-state.json @@ -26,6 +26,9 @@ }, "isScanned": { "type": "boolean" + }, + "scanOrder": { + "type": "number" } }, "relations": { From 111480f7b7f84c785cc1ceac8fef2d2eaad7c543 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 25 Oct 2024 07:22:36 +0200 Subject: [PATCH 33/89] fix: refs #235425 Requested changes --- .../ticket/back/methods/sale/updatePrice.js | 29 ++++++++++--------- modules/ticket/back/models/sale.json | 3 ++ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/modules/ticket/back/methods/sale/updatePrice.js b/modules/ticket/back/methods/sale/updatePrice.js index afb25c365..d4f128082 100644 --- a/modules/ticket/back/methods/sale/updatePrice.js +++ b/modules/ticket/back/methods/sale/updatePrice.js @@ -91,20 +91,21 @@ module.exports = Self => { value: componentValue }, myOptions); } - await sale.updateAttributes({price: newPrice}, myOptions); - await Self.rawSql(` - UPDATE sale - SET priceFixed = ( - SELECT SUM(value) - FROM sale s - JOIN saleComponent sc ON sc.saleFk = s.id - JOIN component c ON c.id = sc.componentFk - JOIN componentType ct ON ct.id = c.typeFk - WHERE ct.isBase - AND s.id = ? - ) - WHERE id = ? - `, [id, id], myOptions); + + const [priceFixed] = await Self.rawSql(` + SELECT SUM(value) value + FROM sale s + JOIN saleComponent sc ON sc.saleFk = s.id + JOIN component c ON c.id = sc.componentFk + JOIN componentType ct ON ct.id = c.typeFk + WHERE ct.isBase + AND s.id = ? + `, [id], myOptions); + + await sale.updateAttributes({ + price: newPrice, + priceFixed: priceFixed.value + }, myOptions); await Self.rawSql('CALL vn.manaSpellersRequery(?)', [userId], myOptions); await Self.rawSql('CALL vn.ticket_recalc(?, NULL)', [sale.ticketFk], myOptions); diff --git a/modules/ticket/back/models/sale.json b/modules/ticket/back/models/sale.json index 96a36bbc9..947115f5c 100644 --- a/modules/ticket/back/models/sale.json +++ b/modules/ticket/back/models/sale.json @@ -28,6 +28,9 @@ "discount": { "type": "number" }, + "priceFixed": { + "type": "number" + }, "reserved": { "type": "boolean" }, From 69e1df25042f03e5ae57f3a798dfdff6b2f8f3fc Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 25 Oct 2024 08:47:43 +0200 Subject: [PATCH 34/89] fix: refs #235425 Requested changes --- .../methods/sale/specs/updatePrice.spec.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/modules/ticket/back/methods/sale/specs/updatePrice.spec.js b/modules/ticket/back/methods/sale/specs/updatePrice.spec.js index 9d1403df0..100f74bf0 100644 --- a/modules/ticket/back/methods/sale/specs/updatePrice.spec.js +++ b/modules/ticket/back/methods/sale/specs/updatePrice.spec.js @@ -85,6 +85,25 @@ describe('sale updatePrice()', () => { } }); + it('should check if priceFixed has changed', async() => { + const tx = await models.Sale.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const price = 3; + const beforeUpdate = await models.Sale.findById(saleId, null, options); + await models.Sale.updatePrice(ctx, saleId, price, options); + const afterUpdate = await models.Sale.findById(saleId, null, options); + + expect(beforeUpdate.priceFixed).not.toEqual(afterUpdate.priceFixed); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + it('should set price as a decimal number and check the sale has the mana component changing the salesPersonMana', async() => { const tx = await models.Sale.beginTransaction({}); From 8f102607953ba587527a2122cb82537e3db0be6e Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 25 Oct 2024 11:37:45 +0200 Subject: [PATCH 35/89] feat: refs #7943 return just the required content --- modules/worker/back/models/worker.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index c334c0d05..53be3ebb7 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -204,6 +204,15 @@ ] }, "summary": { + "fields": [ + "id", + "firstName", + "lastName", + "bossFk", + "sex", + "phone", + "mobileExtension" + ], "include": [ { "relation": "user", From e775e561201d96604f0706b17948c3aeaa8af5b2 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 25 Oct 2024 13:48:27 +0200 Subject: [PATCH 36/89] feat: refs #7921 refs#7921 sendLostExpedition --- loopback/locale/en.json | 7 ++- loopback/locale/es.json | 3 +- loopback/locale/fr.json | 11 ++-- loopback/locale/pt.json | 9 +-- .../specs/addExpeditionState.spec.js | 1 + .../ticket/back/models/expedition-state.js | 62 +++++++++++++++++++ 6 files changed, 80 insertions(+), 13 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index a7e21960b..ed1f28a04 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -240,6 +240,7 @@ "There is already a tray with the same height": "There is already a tray with the same height", "The height must be greater than 50cm": "The height must be greater than 50cm", "The maximum height of the wagon is 200cm": "The maximum height of the wagon is 200cm", - "The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line", - "There are tickets for this area, delete them first": "There are tickets for this area, delete them first" -} + "The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line", + "There are tickets for this area, delete them first": "There are tickets for this area, delete them first", + "ticketLostExpedition": "The ticket [{{ticketId}}]({{{ticketUrl}}}) has the following lost expedition:{{ expeditionId }}" +} \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 9f01bd290..a31e0688b 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -385,5 +385,6 @@ "The quantity claimed cannot be greater than the quantity of the line": "La cantidad reclamada no puede ser mayor que la cantidad de la línea", "type cannot be blank": "Se debe rellenar el tipo", "There are tickets for this area, delete them first": "Hay tickets para esta sección, borralos primero", - "There is no company associated with that warehouse": "No hay ninguna empresa asociada a ese almacén" + "There is no company associated with that warehouse": "No hay ninguna empresa asociada a ese almacén", + "ticketLostExpedition": "El ticket [{{ticketId}}]({{{ticketUrl}}}) tiene la siguiente expedición perdida:{{ expeditionId }}" } \ No newline at end of file diff --git a/loopback/locale/fr.json b/loopback/locale/fr.json index 23bd5cc04..1c7923ab4 100644 --- a/loopback/locale/fr.json +++ b/loopback/locale/fr.json @@ -123,8 +123,8 @@ "Added sale to ticket": "J'ai ajouté la ligne suivante au ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}", "Changed sale discount": "J'ai changé le rabais des lignes suivantes du ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", "Created claim": "J'ai créé la réclamation [{{claimId}}]({{{claimUrl}}}) des lignes suivantes du ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "Changed sale price": " le prix de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* du ticket [{{ticketId}}]({{{ticketUrl}}})",, - "Changed sale quantity": "J'ai changé {{changes}} du ticket [{{ticketId}}]({{{ticketUrl}}})", + "Changed sale price": " le prix de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* du ticket [{{ticketId}}]({{{ticketUrl}}})", + "Changed sale quantity": "J'ai changé {{changes}} du ticket [{{ticketId}}]({{{ticketUrl}}})", "Changes in sales": "la quantité de {{itemId}} {{concept}} de {{oldQuantity}} ➔ {{newQuantity}}", "State": "État", "regular": "normal", @@ -362,6 +362,7 @@ "The invoices have been created but the PDFs could not be generated": "La facture a été émise mais le PDF n'a pas pu être généré", "It has been invoiced but the PDF of refund not be generated": "Il a été facturé mais le PDF de remboursement n'a pas été généré", "Cannot send mail": "Impossible d'envoyer le mail", - "Original invoice not found": "Facture originale introuvable", - "The quantity claimed cannot be greater than the quantity of the line": "Le montant réclamé ne peut pas être supérieur au montant de la ligne" -} + "Original invoice not found": "Facture originale introuvable", + "The quantity claimed cannot be greater than the quantity of the line": "Le montant réclamé ne peut pas être supérieur au montant de la ligne", + "ticketLostExpedition": "Le ticket [{{ticketId}}]({{{ticketUrl}}}) a l'expédition perdue suivante : {{expeditionId}}" +} \ No newline at end of file diff --git a/loopback/locale/pt.json b/loopback/locale/pt.json index f85afd607..689449163 100644 --- a/loopback/locale/pt.json +++ b/loopback/locale/pt.json @@ -124,7 +124,7 @@ "Changed sale discount": "Desconto da venda alterado no ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", "Created claim": "Reclamação criada [{{claimId}}]({{{claimUrl}}}) no ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", "Changed sale price": "Preço da venda alterado para [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* no ticket [{{ticketId}}]({{{ticketUrl}}})", - "Changed sale quantity": "Quantidade da venda alterada para {{changes}} no ticket [{{ticketId}}]({{{ticketUrl}}})", + "Changed sale quantity": "Quantidade da venda alterada para {{changes}} no ticket [{{ticketId}}]({{{ticketUrl}}})", "Changes in sales": " [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}* ", "State": "Estado", "regular": "normal", @@ -361,7 +361,8 @@ "It was not able to create the invoice": "Não foi possível criar a fatura", "The invoices have been created but the PDFs could not be generated": "Foi faturado, mas o PDF não pôde ser gerado", "It has been invoiced but the PDF of refund not be generated": "Foi faturado mas não foi gerado o PDF do reembolso", - "Original invoice not found": "Fatura original não encontrada", + "Original invoice not found": "Fatura original não encontrada", "Cannot send mail": "Não é possível enviar o email", - "The quantity claimed cannot be greater than the quantity of the line": "O valor reclamado não pode ser superior ao valor da linha" -} + "The quantity claimed cannot be greater than the quantity of the line": "O valor reclamado não pode ser superior ao valor da linha", + "ticketLostExpedition": "O ticket [{{ticketId}}]({{{ticketUrl}}}) tem a seguinte expedição perdida: {{expeditionId}}" +} \ No newline at end of file diff --git a/modules/ticket/back/methods/expedition-state/specs/addExpeditionState.spec.js b/modules/ticket/back/methods/expedition-state/specs/addExpeditionState.spec.js index 747352286..71bc453de 100644 --- a/modules/ticket/back/methods/expedition-state/specs/addExpeditionState.spec.js +++ b/modules/ticket/back/methods/expedition-state/specs/addExpeditionState.spec.js @@ -2,6 +2,7 @@ const models = require('vn-loopback/server/server').models; describe('expeditionState addExpeditionState()', () => { const ctx = beforeAll.getCtx(); + beforeAll.mockLoopBackContext(); it('should update the expedition states', async() => { const tx = await models.ExpeditionState.beginTransaction({}); try { diff --git a/modules/ticket/back/models/expedition-state.js b/modules/ticket/back/models/expedition-state.js index 496dd88d3..18bab580e 100644 --- a/modules/ticket/back/models/expedition-state.js +++ b/modules/ticket/back/models/expedition-state.js @@ -1,4 +1,66 @@ +const LoopBackContext = require('loopback-context'); + module.exports = function(Self) { require('../methods/expedition-state/filter')(Self); require('../methods/expedition-state/addExpeditionState')(Self); + + Self.observe('before save', async ctx => { + const models = Self.app.models; + const changes = ctx.data || ctx.instance; + const instance = ctx.currentInstance; + const loopBackContext = LoopBackContext.getCurrentContext(); + const httpCtx = {req: loopBackContext.active}; + const httpRequest = httpCtx.req.http.req; + const $t = httpRequest.__; + const myOptions = {}; + + if (ctx.options && ctx.options.transaction) + myOptions.transaction = ctx.options.transaction; + + const newStateType = changes?.typeFk; + if (newStateType == null) return; + + const expeditionId = changes?.expeditionFk || instance?.expeditionFk; + + const {code} = await models.ExpeditionStateType.findById( + newStateType, + { + fields: ['code'] + }, + myOptions); + + if (code !== 'LOST') return; + + const dataExpedition = await models.Expedition.findById( + expeditionId, { + fields: ['ticketFk'], + include: [{ + relation: 'ticket', + scope: { + fields: ['clientFk'], + include: [{ + relation: 'client', + scope: { + fields: ['name', 'salesPersonFk'] + } + }] + } + }], + + }, myOptions); + + const salesPersonFk = dataExpedition.toJSON().ticket?.client?.salesPersonFk; + + if (salesPersonFk) { + const url = await Self.app.models.Url.getUrl(); + const fullUrl = `${url}ticket/${dataExpedition.ticketFk}/expedition`; + const message = $t('ticketLostExpedition', { + ticketId: dataExpedition.ticketFk, + expeditionId: expeditionId, + url: fullUrl + }); + await models.Chat.sendCheckingPresence(httpCtx, salesPersonFk, message); + } + }); }; + From 80764b6495290a5e9090114956fc5260df53f42f Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 25 Oct 2024 14:17:57 +0200 Subject: [PATCH 37/89] feat: refs #7006 itemTypeLog --- db/versions/11297-graySalal/01-firstScript.sql | 3 +++ modules/item/back/models/item-type.json | 6 ++++++ 2 files changed, 9 insertions(+) create mode 100644 db/versions/11297-graySalal/01-firstScript.sql diff --git a/db/versions/11297-graySalal/01-firstScript.sql b/db/versions/11297-graySalal/01-firstScript.sql new file mode 100644 index 000000000..78ce1a540 --- /dev/null +++ b/db/versions/11297-graySalal/01-firstScript.sql @@ -0,0 +1,3 @@ +ALTER TABLE vn.itemType + ADD CONSTRAINT itemType_itemPackingType_FK FOREIGN KEY (itemPackingTypeFk) + REFERENCES vn.itemPackingType(code) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/modules/item/back/models/item-type.json b/modules/item/back/models/item-type.json index c5c920b2f..88f66899e 100644 --- a/modules/item/back/models/item-type.json +++ b/modules/item/back/models/item-type.json @@ -29,6 +29,12 @@ }, "isLaid": { "type": "boolean" + }, + "maxRefs": { + "type": "string" + }, + "isFragile": { + "type": "boolean" } }, "relations": { From 14d6eb722ee5087402b3d213a1d5f1b6399d53fe Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 25 Oct 2024 14:24:26 +0200 Subject: [PATCH 38/89] feat: refs #7006 Requested changes --- db/versions/11297-graySalal/00-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11297-graySalal/00-firstScript.sql b/db/versions/11297-graySalal/00-firstScript.sql index 372af804c..4d4711306 100644 --- a/db/versions/11297-graySalal/00-firstScript.sql +++ b/db/versions/11297-graySalal/00-firstScript.sql @@ -24,4 +24,4 @@ CREATE TABLE `vn`.`itemTypeLog` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci `PAGE_COMPRESSED`=1; INSERT IGNORE INTO salix.ACL (model,property,principalId) - VALUES ('ItemTypeLog','*','employee'); + VALUES ('ItemTypeLog','find','employee'); From fb0764bc1fa35c5ce8942c2105fe805d7cb54eba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 25 Oct 2024 14:34:51 +0200 Subject: [PATCH 39/89] feat: refs #8087 Traspasar redadas a travels --- db/dump/fixtures.before.sql | 24 +++++++++---------- .../vn/procedures/available_traslate.sql | 2 +- .../vn/procedures/item_valuateInventory.sql | 2 +- .../11316-chocolateErica/00-firstScript.sql | 7 +++++- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 51ffba3d0..63230aa08 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -1505,18 +1505,18 @@ INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk (9, '99610289193', 302, 2972, util.VN_CURDATE(), 3871, 442, 1), (10, '07546500856', 185, 2364, util.VN_CURDATE(), 5321, 442, 1); -INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyModeFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`, `awbFK`) - VALUES (1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000, 'first travel', 1, 1, 1), - (2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150.00, 2000, 'second travel', 2, 2, 2), - (3, util.VN_CURDATE(), util.VN_CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1, 3), - (4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 3, 1, 50.00, 500, 'fourth travel', 0, 2, 4), - (5, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 3, 1, 50.00, 500, 'fifth travel', 1, 1, 5), - (6, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 4, 1, 50.00, 500, 'sixth travel', 1, 2, 6), - (7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 4, 1, 50.00, 500, 'seventh travel', 2, 1, 7), - (8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10), - (10, DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10), - (11, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE(), 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4), - (12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4); +INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyModeFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`, `awbFK`, `daysInForward`) + VALUES (1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000, 'first travel', 1, 1, 1, NULL), + (2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150.00, 2000, 'second travel', 2, 2, 2, NULL), + (3, util.VN_CURDATE(), util.VN_CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1, 3, NULL), + (4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 3, 1, 50.00, 500, 'fourth travel', 0, 2, 4, NULL), + (5, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 3, 1, 50.00, 500, 'fifth travel', 1, 1, 5, NULL), + (6, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 4, 1, 50.00, 500, 'sixth travel', 1, 2, 6, NULL), + (7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 4, 1, 50.00, 500, 'seventh travel', 2, 1, 7, 2), + (8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10, NULL), + (10, DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10, 2), + (11, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE(), 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, NULL), + (12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, NULL); INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `evaNotes`) VALUES diff --git a/db/routines/vn/procedures/available_traslate.sql b/db/routines/vn/procedures/available_traslate.sql index 28b187e58..513f58e36 100644 --- a/db/routines/vn/procedures/available_traslate.sql +++ b/db/routines/vn/procedures/available_traslate.sql @@ -57,7 +57,7 @@ proc: BEGIN JOIN travel tr ON tr.id = e.travelFk LEFT JOIN tItemRange i ON t.itemFk = i.itemFk WHERE t.warehouseFk = vWarehouseShipment - AND NOT t.daysInForward + AND NOT tr.daysInForward ON DUPLICATE KEY UPDATE tItemRange.dated = GREATEST(tItemRange.dated, tr.landed); diff --git a/db/routines/vn/procedures/item_valuateInventory.sql b/db/routines/vn/procedures/item_valuateInventory.sql index 880989101..b6d687960 100644 --- a/db/routines/vn/procedures/item_valuateInventory.sql +++ b/db/routines/vn/procedures/item_valuateInventory.sql @@ -131,7 +131,7 @@ BEGIN JOIN itemCategory ic ON ic.id = t.categoryFk JOIN warehouse w ON w.id = tr.warehouseOutFk WHERE tr.shipped BETWEEN vInventoried AND vDateDayEnd - AND NOT t.daysInForward + AND NOT tr.daysInForward AND w.valuatedInventory AND t.isInventory AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL) diff --git a/db/versions/11316-chocolateErica/00-firstScript.sql b/db/versions/11316-chocolateErica/00-firstScript.sql index b973d8a41..8fd0c72de 100644 --- a/db/versions/11316-chocolateErica/00-firstScript.sql +++ b/db/versions/11316-chocolateErica/00-firstScript.sql @@ -1,2 +1,7 @@ -ALTER TABLE vn.travel ADD IF NOT EXISTS daysInForward INT UNSIGNED DEFAULT NULL NULL +ALTER TABLE vn.travel ADD IF NOT EXISTS daysInForward INT UNSIGNED DEFAULT 0 NOT NULL COMMENT 'Número de días donde se siturá el landed de las entradas con respecto a hoy'; + +ALTER TABLE vn.entry CHANGE isRaid isRaid_ tinyint(1) DEFAULT 0 NOT NULL COMMENT '@deprecated 2024-11-05'; + +RENAME TABLE vn.entryVirtual TO vn.entryVirtual__; +ALTER TABLE vn.entryVirtual__ COMMENT='@deprecated 2024-11-05'; From d8e241740f9e5df512c44c5fbc31ecdaa3f9f000 Mon Sep 17 00:00:00 2001 From: jorgep Date: Sun, 27 Oct 2024 13:47:52 +0100 Subject: [PATCH 40/89] feat: refs #7524 restrict fields --- modules/worker/back/models/worker.json | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index 53be3ebb7..937df98c0 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -256,10 +256,21 @@ } }, { - "relation": "boss" + "relation": "boss", + "scope": { + "fields": [ + "id", + "name" + ] + } }, { - "relation": "client" + "relation": "client", + "scope": { + "fields": [ + "id" + ] + } }, { "relation": "sip", @@ -281,14 +292,16 @@ "fields": [ "id", "fiDueDate", - "sex", "seniority", "fi", "isFreelance", "isSsDiscounted", "hasMachineryAuthorized", "isDisable", - "birth" + "birth", + "educationLevelFk", + "originCountryFk", + "maritalStatus" ] } } From 869c7ab598ffa951a479987b6ba2946efd2aeb5a Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 28 Oct 2024 07:37:42 +0100 Subject: [PATCH 41/89] fix: refs #6644 email and translations --- loopback/locale/en.json | 9 ++++++--- loopback/locale/es.json | 5 +++-- loopback/locale/fr.json | 3 ++- loopback/locale/pt.json | 3 ++- modules/client/back/methods/client/createWithUser.js | 3 +++ 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index a7e21960b..8c1ee7bb9 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -240,6 +240,9 @@ "There is already a tray with the same height": "There is already a tray with the same height", "The height must be greater than 50cm": "The height must be greater than 50cm", "The maximum height of the wagon is 200cm": "The maximum height of the wagon is 200cm", - "The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line", - "There are tickets for this area, delete them first": "There are tickets for this area, delete them first" -} + "The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line", + "There are tickets for this area, delete them first": "There are tickets for this area, delete them first", + "null": "null", + "Invalid or expired verification code": "Invalid or expired verification code", + "Payment method is required": "Payment method is required" +} \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 9f01bd290..144046f56 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -385,5 +385,6 @@ "The quantity claimed cannot be greater than the quantity of the line": "La cantidad reclamada no puede ser mayor que la cantidad de la línea", "type cannot be blank": "Se debe rellenar el tipo", "There are tickets for this area, delete them first": "Hay tickets para esta sección, borralos primero", - "There is no company associated with that warehouse": "No hay ninguna empresa asociada a ese almacén" -} \ No newline at end of file + "There is no company associated with that warehouse": "No hay ninguna empresa asociada a ese almacén", + "The web user's email already exists": "El correo del usuario web ya existe" +} diff --git a/loopback/locale/fr.json b/loopback/locale/fr.json index 23bd5cc04..446c2ad0d 100644 --- a/loopback/locale/fr.json +++ b/loopback/locale/fr.json @@ -363,5 +363,6 @@ "It has been invoiced but the PDF of refund not be generated": "Il a été facturé mais le PDF de remboursement n'a pas été généré", "Cannot send mail": "Impossible d'envoyer le mail", "Original invoice not found": "Facture originale introuvable", - "The quantity claimed cannot be greater than the quantity of the line": "Le montant réclamé ne peut pas être supérieur au montant de la ligne" + "The quantity claimed cannot be greater than the quantity of the line": "Le montant réclamé ne peut pas être supérieur au montant de la ligne", + "The web user's email already exists": "L'email de l'internaute existe déjà" } diff --git a/loopback/locale/pt.json b/loopback/locale/pt.json index f85afd607..4f68dfa53 100644 --- a/loopback/locale/pt.json +++ b/loopback/locale/pt.json @@ -363,5 +363,6 @@ "It has been invoiced but the PDF of refund not be generated": "Foi faturado mas não foi gerado o PDF do reembolso", "Original invoice not found": "Fatura original não encontrada", "Cannot send mail": "Não é possível enviar o email", - "The quantity claimed cannot be greater than the quantity of the line": "O valor reclamado não pode ser superior ao valor da linha" + "The quantity claimed cannot be greater than the quantity of the line": "O valor reclamado não pode ser superior ao valor da linha", + "The web user's email already exists": "O e-mail do utilizador da web já existe." } diff --git a/modules/client/back/methods/client/createWithUser.js b/modules/client/back/methods/client/createWithUser.js index c8cd282e1..1d5e71fca 100644 --- a/modules/client/back/methods/client/createWithUser.js +++ b/modules/client/back/methods/client/createWithUser.js @@ -1,3 +1,4 @@ +/* eslint max-len: ["error", { "code": 150 }]*/ const UserError = require('vn-loopback/util/user-error'); module.exports = function(Self) { @@ -98,6 +99,8 @@ module.exports = function(Self) { return client; } catch (e) { if (tx) await tx.rollback(); + if (e.message && e.message.includes(`Email already exists`)) throw new UserError(`The web user's email already exists`); + throw e; } }; From 6efc2c340c932b1437689cf5decb30bf8b7b7d3a Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 28 Oct 2024 08:57:22 +0100 Subject: [PATCH 42/89] feat: refs #7921 refs#7921 sendLostExpedition --- modules/ticket/back/models/expedition-state.js | 2 +- modules/ticket/back/models/expedition-state.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/ticket/back/models/expedition-state.js b/modules/ticket/back/models/expedition-state.js index 18bab580e..f819dc05c 100644 --- a/modules/ticket/back/models/expedition-state.js +++ b/modules/ticket/back/models/expedition-state.js @@ -49,7 +49,7 @@ module.exports = function(Self) { }, myOptions); - const salesPersonFk = dataExpedition.toJSON().ticket?.client?.salesPersonFk; + const salesPersonFk = dataExpedition.ticket()?.client()?.salesPersonFk; if (salesPersonFk) { const url = await Self.app.models.Url.getUrl(); diff --git a/modules/ticket/back/models/expedition-state.json b/modules/ticket/back/models/expedition-state.json index 159a9275e..522327031 100644 --- a/modules/ticket/back/models/expedition-state.json +++ b/modules/ticket/back/models/expedition-state.json @@ -19,7 +19,8 @@ "type": "number" }, "typeFk": { - "type": "number" + "type": "number", + "required": true }, "userFk": { "type": "number" From eb5f57285aaf242b1d54ce4a8bd881f4e69dea3b Mon Sep 17 00:00:00 2001 From: Jon Date: Mon, 28 Oct 2024 10:40:43 +0100 Subject: [PATCH 43/89] feat: refs #7193 added scope in parking model --- modules/shelving/back/models/parking.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/shelving/back/models/parking.json b/modules/shelving/back/models/parking.json index 47a3305ae..a9393fc6a 100644 --- a/modules/shelving/back/models/parking.json +++ b/modules/shelving/back/models/parking.json @@ -38,5 +38,13 @@ "model": "Sector", "foreignKey": "sectorFk" } + }, + "scope": { + "include": { + "relation": "sector", + "scope": { + "fields": ["id", "description"] + } + } } } From c43bdb502155dec92ed51787bd65ed98902cecd6 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 28 Oct 2024 11:29:15 +0100 Subject: [PATCH 44/89] feat: refs #7266 Added details and improvements in item label reports --- .../back/methods/entry/labelBarcodePdf.js | 48 ++++++++++++++++++ .../entry/back/methods/entry/labelQrPdf.js | 49 +++++++++++++++++++ modules/entry/back/models/buy.js | 2 + .../item/back/methods/item/labelBarcodePdf.js | 11 ++--- modules/item/back/methods/item/labelQrPdf.js | 12 ++--- .../item-label-barcode/assets/css/style.css | 6 +-- .../item-label-barcode.html | 5 +- .../item-label-barcode/item-label-barcode.js | 25 +++++----- .../reports/item-label-barcode/options.json | 2 +- .../reports/item-label-barcode/sql/item.sql | 3 +- .../item-label-qr/assets/css/style.css | 2 +- .../reports/item-label-qr/item-label-qr.html | 9 +++- .../reports/item-label-qr/item-label-qr.js | 24 +++++---- .../reports/item-label-qr/options.json | 2 +- .../reports/item-label-qr/sql/item.sql | 3 +- 15 files changed, 157 insertions(+), 46 deletions(-) create mode 100644 modules/entry/back/methods/entry/labelBarcodePdf.js create mode 100644 modules/entry/back/methods/entry/labelQrPdf.js diff --git a/modules/entry/back/methods/entry/labelBarcodePdf.js b/modules/entry/back/methods/entry/labelBarcodePdf.js new file mode 100644 index 000000000..847859aeb --- /dev/null +++ b/modules/entry/back/methods/entry/labelBarcodePdf.js @@ -0,0 +1,48 @@ +module.exports = Self => { + Self.remoteMethodCtx('labelBarcodePdf', { + description: 'Returns the item label pdf with barcode', + accessType: 'READ', + accepts: [ + { + arg: 'id', + type: 'number', + required: true, + description: 'The item id', + http: {source: 'path'} + }, { + arg: 'packing', + type: 'number', + required: false + }, { + arg: 'copies', + type: 'number', + required: false + } + ], + returns: [ + { + arg: 'body', + type: 'file', + root: true + }, { + arg: 'Content-Type', + type: 'String', + http: {target: 'header'} + }, { + arg: 'Content-Disposition', + type: 'String', + http: {target: 'header'} + } + ], + http: { + path: '/:id/label-barcode-pdf', + verb: 'GET' + }, + accessScopes: ['DEFAULT', 'read:multimedia'] + }); + + Self.labelBarcodePdf = (ctx, id) => { + ctx.args.typeId = 'buy'; + return Self.printReport(ctx, id, 'item-label-barcode'); + }; +}; diff --git a/modules/entry/back/methods/entry/labelQrPdf.js b/modules/entry/back/methods/entry/labelQrPdf.js new file mode 100644 index 000000000..9668dfffd --- /dev/null +++ b/modules/entry/back/methods/entry/labelQrPdf.js @@ -0,0 +1,49 @@ +module.exports = Self => { + Self.remoteMethodCtx('labelQrPdf', { + description: 'Returns the item label pdf with qr', + accessType: 'READ', + accepts: [ + { + arg: 'id', + type: 'number', + required: true, + description: 'The item id', + http: {source: 'path'} + }, { + arg: 'packing', + type: 'number', + required: false + }, { + arg: 'copies', + type: 'number', + required: false + } + ], + returns: [ + { + arg: 'body', + type: 'file', + root: true + }, { + arg: 'Content-Type', + type: 'String', + http: {target: 'header'} + }, { + arg: 'Content-Disposition', + type: 'String', + http: {target: 'header'} + } + ], + http: { + path: '/:id/label-qr-pdf', + verb: 'GET' + }, + accessScopes: ['DEFAULT', 'read:multimedia'] + }); + + Self.labelQrPdf = (ctx, id) => { + ctx.args.userId = ctx.req.accessToken.userId; + ctx.args.typeId = 'buy'; + return Self.printReport(ctx, id, 'item-label-qr'); + }; +}; diff --git a/modules/entry/back/models/buy.js b/modules/entry/back/models/buy.js index 34f19e765..70d92195c 100644 --- a/modules/entry/back/models/buy.js +++ b/modules/entry/back/models/buy.js @@ -2,4 +2,6 @@ module.exports = Self => { require('../methods/entry/editLatestBuys')(Self); require('../methods/entry/latestBuysFilter')(Self); require('../methods/entry/deleteBuys')(Self); + require('../methods/entry/labelBarcodePdf')(Self); + require('../methods/entry/labelQrPdf')(Self); }; diff --git a/modules/item/back/methods/item/labelBarcodePdf.js b/modules/item/back/methods/item/labelBarcodePdf.js index 3325e3da1..8e28ddfe2 100644 --- a/modules/item/back/methods/item/labelBarcodePdf.js +++ b/modules/item/back/methods/item/labelBarcodePdf.js @@ -21,12 +21,6 @@ module.exports = Self => { arg: 'copies', type: 'number', required: false - }, { - arg: 'userId', - type: 'number', - description: 'The user id from accessToken', - http: ctx => ctx.req.accessToken.userId, - required: true } ], returns: [ @@ -51,5 +45,8 @@ module.exports = Self => { accessScopes: ['DEFAULT', 'read:multimedia'] }); - Self.labelBarcodePdf = (ctx, id) => Self.printReport(ctx, id, 'item-label-barcode'); + Self.labelBarcodePdf = (ctx, id) => { + ctx.args.typeId = 'item'; + return Self.printReport(ctx, id, 'item-label-barcode'); + }; }; diff --git a/modules/item/back/methods/item/labelQrPdf.js b/modules/item/back/methods/item/labelQrPdf.js index 4d0e34528..2c42a978a 100644 --- a/modules/item/back/methods/item/labelQrPdf.js +++ b/modules/item/back/methods/item/labelQrPdf.js @@ -21,12 +21,6 @@ module.exports = Self => { arg: 'copies', type: 'number', required: false - }, { - arg: 'userId', - type: 'number', - description: 'The user id from accessToken', - http: ctx => ctx.req.accessToken.userId, - required: true } ], returns: [ @@ -51,5 +45,9 @@ module.exports = Self => { accessScopes: ['DEFAULT', 'read:multimedia'] }); - Self.labelQrPdf = (ctx, id) => Self.printReport(ctx, id, 'item-label-qr'); + Self.labelQrPdf = (ctx, id) => { + ctx.args.userId = ctx.req.accessToken.userId; + ctx.args.typeId = 'item'; + return Self.printReport(ctx, id, 'item-label-qr'); + }; }; diff --git a/print/templates/reports/item-label-barcode/assets/css/style.css b/print/templates/reports/item-label-barcode/assets/css/style.css index 884faef56..fabecd28e 100644 --- a/print/templates/reports/item-label-barcode/assets/css/style.css +++ b/print/templates/reports/item-label-barcode/assets/css/style.css @@ -1,7 +1,7 @@ html { font-family: "Roboto", "Helvetica", "Arial", sans-serif; margin-top: -9px; - margin-left: -6px; + margin-left: -3px; } table { width: 100%; @@ -52,8 +52,8 @@ td { max-height: 50px; } .md-height { - height: 75px; - max-height: 75px; + height: 70px; + max-height: 70px; } .sm-width { width: 60px; diff --git a/print/templates/reports/item-label-barcode/item-label-barcode.html b/print/templates/reports/item-label-barcode/item-label-barcode.html index 929ce5fe2..8bf3ce8eb 100644 --- a/print/templates/reports/item-label-barcode/item-label-barcode.html +++ b/print/templates/reports/item-label-barcode/item-label-barcode.html @@ -52,7 +52,10 @@
diff --git a/print/templates/reports/item-label-barcode/item-label-barcode.js b/print/templates/reports/item-label-barcode/item-label-barcode.js index 5f9a11ea1..e2945ae39 100755 --- a/print/templates/reports/item-label-barcode/item-label-barcode.js +++ b/print/templates/reports/item-label-barcode/item-label-barcode.js @@ -6,17 +6,18 @@ const jsbarcode = require('jsbarcode'); module.exports = { name: 'item-label-barcode', async serverPrefetch() { - this.company = await this.findOneFromDef('company', [this.warehouseId]); - if (!this.company) - throw new UserError(`There is no company associated with that warehouse`); - this.date = Date.vnNew(); - this.lastBuy = await this.findOneFromDef('lastBuy', [ - this.id, - this.warehouseId, - this.date - ]); - this.items = await this.rawSqlFromDef('item', [this.copies || 1, this.lastBuy.id]); + if (this.typeId === 'item') { + this.company = await this.findOneFromDef('company', [this.warehouseId]); + if (!this.company) + throw new UserError(`There is no company associated with that warehouse`); + this.lastBuy = await this.findOneFromDef('lastBuy', [ + this.id, + this.warehouseId, + this.date + ]); + } + this.items = await this.rawSqlFromDef('item', [this.copies || 1, this.lastBuy?.id || this.id]); if (!this.items.length) throw new UserError(`Empty data source`); this.date = moment(this.date).format('WW/E'); }, @@ -51,8 +52,8 @@ module.exports = { copies: { type: Number }, - userId: { - type: Number + typeId: { + type: String } } }; diff --git a/print/templates/reports/item-label-barcode/options.json b/print/templates/reports/item-label-barcode/options.json index 1ae2630b0..17c43e69f 100644 --- a/print/templates/reports/item-label-barcode/options.json +++ b/print/templates/reports/item-label-barcode/options.json @@ -3,7 +3,7 @@ "height": "4.9cm", "margin": { "top": "0.17cm", - "right": "0.745cm", + "right": "0.37cm", "bottom": "0cm", "left": "0cm" }, diff --git a/print/templates/reports/item-label-barcode/sql/item.sql b/print/templates/reports/item-label-barcode/sql/item.sql index 3cb42d139..c56097c8d 100644 --- a/print/templates/reports/item-label-barcode/sql/item.sql +++ b/print/templates/reports/item-label-barcode/sql/item.sql @@ -22,7 +22,8 @@ SELECT ROW_NUMBER() OVER() labelNum, ig.longName, ig.subName, i.comment, - w.code buyerName + w.code buyerName, + i.isLaid FROM vn.buy b JOIN vn.item i ON i.id = b.itemFk LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk diff --git a/print/templates/reports/item-label-qr/assets/css/style.css b/print/templates/reports/item-label-qr/assets/css/style.css index fe6668c9a..0e288704b 100644 --- a/print/templates/reports/item-label-qr/assets/css/style.css +++ b/print/templates/reports/item-label-qr/assets/css/style.css @@ -1,7 +1,7 @@ html { font-family: "Roboto", "Helvetica", "Arial", sans-serif; margin-top: -7px; - margin-left: -6px; + margin-left: -3px; } .leftTable { width: 47%; diff --git a/print/templates/reports/item-label-qr/item-label-qr.html b/print/templates/reports/item-label-qr/item-label-qr.html index 712bd6c7d..6218a4513 100644 --- a/print/templates/reports/item-label-qr/item-label-qr.html +++ b/print/templates/reports/item-label-qr/item-label-qr.html @@ -74,7 +74,14 @@ Productor: {{item.producerName || item.producerFk}} - +
From 1afb33c3064739c0a032e7a7b09f581b7b20e602 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 22 Oct 2024 15:00:16 +0200 Subject: [PATCH 18/89] feat: refs #8119 Requested changes --- ...nQuantity_add.sql => itemCampaign_add.sql} | 4 +- .../procedures/itemCampaignQuantity_add.sql | 86 ------------------- .../vn/procedures/itemCampaign_add.sql | 58 +++++++++++++ .../11308-redCymbidium/00-firstScript.sql | 26 +++--- 4 files changed, 72 insertions(+), 102 deletions(-) rename db/routines/vn/events/{itemCampaignQuantity_add.sql => itemCampaign_add.sql} (72%) delete mode 100644 db/routines/vn/procedures/itemCampaignQuantity_add.sql create mode 100644 db/routines/vn/procedures/itemCampaign_add.sql diff --git a/db/routines/vn/events/itemCampaignQuantity_add.sql b/db/routines/vn/events/itemCampaign_add.sql similarity index 72% rename from db/routines/vn/events/itemCampaignQuantity_add.sql rename to db/routines/vn/events/itemCampaign_add.sql index 4deb2d556..efb2aeb11 100644 --- a/db/routines/vn/events/itemCampaignQuantity_add.sql +++ b/db/routines/vn/events/itemCampaign_add.sql @@ -1,8 +1,8 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `vn`.`itemCampaignQuantity_add` +CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `vn`.`itemCampaig_add` ON SCHEDULE EVERY 1 DAY STARTS '2024-10-18 03:00:00.000' ON COMPLETION PRESERVE ENABLE -DO CALL itemCampaignQuantity_add(NULL, NULL, NULL)$$ +DO CALL itemCampaign_add()$$ DELIMITER ; diff --git a/db/routines/vn/procedures/itemCampaignQuantity_add.sql b/db/routines/vn/procedures/itemCampaignQuantity_add.sql deleted file mode 100644 index 6edb97c08..000000000 --- a/db/routines/vn/procedures/itemCampaignQuantity_add.sql +++ /dev/null @@ -1,86 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemCampaignQuantity_add`( - vDateFrom DATE, - vDateTo DATE, - vCampaign VARCHAR(100) -) -proc: BEGIN -/** - * Añade registros a tabla itemCampaignQuantity. - * - * @param vDateFrom Fecha desde - * @param vDateTo Fecha hasta - * @param vCampaign Código de la campaña - */ - DECLARE vCurdate DATE; - DECLARE vYesterday DATE; - DECLARE vDefaultCampaign VARCHAR(100); - DECLARE vPreviousDaysToInsert INT; - DECLARE vDateSumFrom DATE; - DECLARE vDateSumTo DATE; - DECLARE vScopeDays INT; - - SET vCurdate = util.VN_CURDATE(); - SET vYesterday = util.yesterday(); - - IF vDateFrom IS NULL THEN - SET vDateFrom = vYesterday; - END IF; - - IF vDateTo IS NULL THEN - SET vDateTo = vYesterday; - END IF; - - IF vDateFrom > vDateTo THEN - CALL util.throw('Start date cannot be later than end date'); - END IF; - - SELECT defaultCampaign, previousDaysToInsert - INTO vDefaultCampaign, vPreviousDaysToInsert - FROM itemCampaignQuantityConfig; - - IF vCampaign IS NULL THEN - SET vCampaign = vDefaultCampaign; - END IF; - - IF vCampaign IS NULL OR vPreviousDaysToInsert IS NULL THEN - CALL util.throw('Missing values in the configuration table'); - END IF; - - SELECT dated, scopeDays INTO vDateSumTo, vScopeDays - FROM campaign - WHERE dated > vCurdate - AND code = vCampaign - ORDER BY dated - LIMIT 1; - - IF vDateSumTo IS NULL OR vScopeDays IS NULL THEN - CALL util.throw('Missing data in campaign table'); - END IF; - - IF NOT vCurdate BETWEEN vDateSumTo - INTERVAL vPreviousDaysToInsert DAY - AND vDateSumTo THEN - LEAVE proc; - END IF; - - SET vDateSumFrom = vDateSumTo - INTERVAL vScopeDays DAY; - - REPLACE itemCampaignQuantity(dated, itemFk, quantity, total, campaign) - SELECT DATE(s.created), - s.itemFk, - SUM(CASE WHEN t.shipped BETWEEN vDateSumFrom AND vDateSumTo - THEN s.quantity - END) quantity, - SUM(CASE WHEN t.shipped BETWEEN vDateSumFrom AND vDateSumTo - THEN s.total - END) total, - vCampaign - FROM sale s - JOIN ticket t ON t.id = s.ticketFk - JOIN client c ON c.id = t.clientFk - WHERE s.created BETWEEN vDateFrom AND util.dayEnd(vDateTo) - AND c.businessTypeFk <> 'worker' - GROUP BY DATE(s.created), s.itemFk - HAVING quantity; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/itemCampaign_add.sql b/db/routines/vn/procedures/itemCampaign_add.sql new file mode 100644 index 000000000..1e10bc619 --- /dev/null +++ b/db/routines/vn/procedures/itemCampaign_add.sql @@ -0,0 +1,58 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemCampaign_add`() +proc: BEGIN +/** + * Añade registros a tabla itemCampaign. + * + * @param vDateFrom Fecha desde + * @param vDateTo Fecha hasta + * @param vCampaign Código de la campaña + */ + DECLARE vCurdate DATE; + DECLARE vYesterday DATE; + DECLARE vCampaign VARCHAR(100); + DECLARE vPreviousDays INT; + DECLARE vDateSumFrom DATE; + DECLARE vDateSumTo DATE; + DECLARE vScopeDays INT; + + SET vCurdate = util.VN_CURDATE(); + + SELECT dated, code, scopeDays, previousDays + INTO vDateSumTo, vCampaign, vScopeDays, vPreviousDays + FROM campaign + WHERE dated > vCurdate + ORDER BY dated + LIMIT 1; + + IF vCampaign IS NULL THEN + CALL util.throw('Missing data in campaign table'); + END IF; + + IF NOT vCurdate BETWEEN vDateSumTo - INTERVAL vPreviousDays DAY + AND vDateSumTo THEN + LEAVE proc; + END IF; + + SET vDateSumFrom = vDateSumTo - INTERVAL vScopeDays DAY; + SET vYesterday = util.yesterday(); + + REPLACE itemCampaign(dated, itemFk, quantity, total, campaign) + SELECT DATE(s.created), + s.itemFk, + SUM(CASE WHEN t.shipped BETWEEN vDateSumFrom AND vDateSumTo + THEN s.quantity + END) quantity, + SUM(CASE WHEN t.shipped BETWEEN vDateSumFrom AND vDateSumTo + THEN (s.quantity * s.price) * (100 - s.discount) / 100 + END) total, + vCampaign + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN client c ON c.id = t.clientFk + WHERE s.created BETWEEN vYesterday AND util.dayEnd(vYesterday) + AND c.typeFk = 'normal' + GROUP BY DATE(s.created), s.itemFk + HAVING quantity; +END$$ +DELIMITER ; diff --git a/db/versions/11308-redCymbidium/00-firstScript.sql b/db/versions/11308-redCymbidium/00-firstScript.sql index 14fad3636..fe76cb600 100644 --- a/db/versions/11308-redCymbidium/00-firstScript.sql +++ b/db/versions/11308-redCymbidium/00-firstScript.sql @@ -1,27 +1,25 @@ -CREATE TABLE IF NOT EXISTS `vn`.`itemCampaignQuantity` ( +CREATE TABLE IF NOT EXISTS `vn`.`itemCampaign` ( `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT, dated date NOT NULL, itemFk int(11) NOT NULL, quantity decimal(10,2) NOT NULL, total decimal(10,2) NOT NULL, campaign varchar(100) NOT NULL, - UNIQUE KEY `itemCampaignQuantity_UNIQUE` (`dated`,`itemFk`), - CONSTRAINT itemCampaignQuantity_item_FK FOREIGN KEY (itemFk) REFERENCES vn.item(id) ON DELETE RESTRICT ON UPDATE CASCADE + UNIQUE KEY `itemCampaign_UNIQUE` (`dated`,`itemFk`), + CONSTRAINT itemCampaign_item_FK FOREIGN KEY (itemFk) REFERENCES vn.item(id) ON DELETE RESTRICT ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Tallos confirmados por día en los días de más producción de una campaña. La tabla está pensada para que sea una foto.'; -CREATE TABLE IF NOT EXISTS `vn`.`itemCampaignQuantityConfig` ( - id int(10) unsigned NOT NULL PRIMARY KEY, - defaultCampaign varchar(100) NOT NULL COMMENT 'Campaña por defecto si se le pasa NULL', - previousDaysToInsert int(10) unsigned NOT NULL COMMENT 'Días anteriores a la fecha de fin de campaña para insertar', - CONSTRAINT `itemCampaignQuantityConfig_check` CHECK (`id` = 1) -) -ENGINE=InnoDB -DEFAULT CHARSET=utf8mb3 -COLLATE=utf8mb3_unicode_ci; +ALTER TABLE vn.campaign + ADD previousDays int(10) unsigned DEFAULT 30 NOT NULL COMMENT 'Días previos para calcular e insertar en la tabla itemCampaign'; -INSERT IGNORE INTO `vn`.`itemCampaignQuantityConfig` (id, defaultCampaign, previousDaysToInsert) - VALUES (1, 'allSaints', 90); +UPDATE vn.campaign + SET previousDays = 90 + WHERE code = 'allSaints'; + +UPDATE vn.campaign + SET previousDays = 60 + WHERE code IN ('valentinesDay', 'mothersDay'); From baec188ff5a784db066fb3f042433cfa57b9fd7d Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 23 Oct 2024 08:23:28 +0200 Subject: [PATCH 19/89] feat: refs #8119 Requested changes --- .../vn/procedures/itemCampaign_add.sql | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/db/routines/vn/procedures/itemCampaign_add.sql b/db/routines/vn/procedures/itemCampaign_add.sql index 1e10bc619..6291d6895 100644 --- a/db/routines/vn/procedures/itemCampaign_add.sql +++ b/db/routines/vn/procedures/itemCampaign_add.sql @@ -8,20 +8,19 @@ proc: BEGIN * @param vDateTo Fecha hasta * @param vCampaign Código de la campaña */ - DECLARE vCurdate DATE; DECLARE vYesterday DATE; DECLARE vCampaign VARCHAR(100); + DECLARE vScopeDays INT; DECLARE vPreviousDays INT; DECLARE vDateSumFrom DATE; DECLARE vDateSumTo DATE; - DECLARE vScopeDays INT; - SET vCurdate = util.VN_CURDATE(); + SET vYesterday = util.yesterday(); SELECT dated, code, scopeDays, previousDays INTO vDateSumTo, vCampaign, vScopeDays, vPreviousDays FROM campaign - WHERE dated > vCurdate + WHERE dated >= vYesterday ORDER BY dated LIMIT 1; @@ -29,30 +28,26 @@ proc: BEGIN CALL util.throw('Missing data in campaign table'); END IF; - IF NOT vCurdate BETWEEN vDateSumTo - INTERVAL vPreviousDays DAY + IF NOT vYesterday BETWEEN vDateSumTo - INTERVAL vPreviousDays DAY AND vDateSumTo THEN LEAVE proc; END IF; SET vDateSumFrom = vDateSumTo - INTERVAL vScopeDays DAY; - SET vYesterday = util.yesterday(); - REPLACE itemCampaign(dated, itemFk, quantity, total, campaign) - SELECT DATE(s.created), + INSERT INTO itemCampaign(dated, itemFk, quantity, total, campaign) + SELECT vYesterday, s.itemFk, - SUM(CASE WHEN t.shipped BETWEEN vDateSumFrom AND vDateSumTo - THEN s.quantity - END) quantity, - SUM(CASE WHEN t.shipped BETWEEN vDateSumFrom AND vDateSumTo - THEN (s.quantity * s.price) * (100 - s.discount) / 100 - END) total, + SUM(s.quantity) quantity, + SUM((s.quantity * s.price) * (100 - s.discount) / 100) total, vCampaign FROM sale s JOIN ticket t ON t.id = s.ticketFk JOIN client c ON c.id = t.clientFk - WHERE s.created BETWEEN vYesterday AND util.dayEnd(vYesterday) + WHERE t.shipped BETWEEN vDateSumFrom AND vDateSumTo AND c.typeFk = 'normal' - GROUP BY DATE(s.created), s.itemFk + AND NOT t.isDeleted + GROUP BY s.itemFk HAVING quantity; END$$ DELIMITER ; From 37050361c23bc5f6b84807e674f1f5af937da43c Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 23 Oct 2024 08:26:36 +0200 Subject: [PATCH 20/89] feat: refs #8119 Requested changes --- db/routines/vn/procedures/itemCampaign_add.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/itemCampaign_add.sql b/db/routines/vn/procedures/itemCampaign_add.sql index 6291d6895..ff92f3b25 100644 --- a/db/routines/vn/procedures/itemCampaign_add.sql +++ b/db/routines/vn/procedures/itemCampaign_add.sql @@ -44,7 +44,7 @@ proc: BEGIN FROM sale s JOIN ticket t ON t.id = s.ticketFk JOIN client c ON c.id = t.clientFk - WHERE t.shipped BETWEEN vDateSumFrom AND vDateSumTo + WHERE t.shipped BETWEEN vDateSumFrom AND util.dayEnd(vDateSumTo) AND c.typeFk = 'normal' AND NOT t.isDeleted GROUP BY s.itemFk From 31c89538bc9d17d75b72975ecc1e3d87fcd2903e Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 23 Oct 2024 08:27:07 +0200 Subject: [PATCH 21/89] feat: refs #8119 Requested changes --- db/routines/vn/procedures/itemCampaign_add.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/itemCampaign_add.sql b/db/routines/vn/procedures/itemCampaign_add.sql index ff92f3b25..6291d6895 100644 --- a/db/routines/vn/procedures/itemCampaign_add.sql +++ b/db/routines/vn/procedures/itemCampaign_add.sql @@ -44,7 +44,7 @@ proc: BEGIN FROM sale s JOIN ticket t ON t.id = s.ticketFk JOIN client c ON c.id = t.clientFk - WHERE t.shipped BETWEEN vDateSumFrom AND util.dayEnd(vDateSumTo) + WHERE t.shipped BETWEEN vDateSumFrom AND vDateSumTo AND c.typeFk = 'normal' AND NOT t.isDeleted GROUP BY s.itemFk From 3cde6b6bc65136ebfa559af9269566ef9e718fac Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 23 Oct 2024 08:30:21 +0200 Subject: [PATCH 22/89] feat: refs #8119 Requested changes --- db/routines/vn/procedures/itemCampaign_add.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/itemCampaign_add.sql b/db/routines/vn/procedures/itemCampaign_add.sql index 6291d6895..8fb40df67 100644 --- a/db/routines/vn/procedures/itemCampaign_add.sql +++ b/db/routines/vn/procedures/itemCampaign_add.sql @@ -34,6 +34,7 @@ proc: BEGIN END IF; SET vDateSumFrom = vDateSumTo - INTERVAL vScopeDays DAY; + SET vDateSumTo = vDateSumTo - INTERVAL 1 DAY; INSERT INTO itemCampaign(dated, itemFk, quantity, total, campaign) SELECT vYesterday, @@ -44,7 +45,7 @@ proc: BEGIN FROM sale s JOIN ticket t ON t.id = s.ticketFk JOIN client c ON c.id = t.clientFk - WHERE t.shipped BETWEEN vDateSumFrom AND vDateSumTo + WHERE t.shipped BETWEEN vDateSumFrom AND util.dayEnd(vDateSumTo) AND c.typeFk = 'normal' AND NOT t.isDeleted GROUP BY s.itemFk From b1a295dca450d02b03c83f4be8f72d5fe557dd6b Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 23 Oct 2024 09:46:06 +0200 Subject: [PATCH 23/89] feat: refs #7266 Print corrections --- .../item-label-barcode/assets/css/style.css | 15 ++++++++------- .../item-label-barcode/item-label-barcode.html | 2 +- .../item-label-barcode/item-label-barcode.js | 2 +- .../reports/item-label-barcode/options.json | 4 ++-- .../reports/item-label-qr/assets/css/style.css | 18 ++++++++++-------- .../reports/item-label-qr/options.json | 4 ++-- 6 files changed, 24 insertions(+), 21 deletions(-) diff --git a/print/templates/reports/item-label-barcode/assets/css/style.css b/print/templates/reports/item-label-barcode/assets/css/style.css index 48b881986..884faef56 100644 --- a/print/templates/reports/item-label-barcode/assets/css/style.css +++ b/print/templates/reports/item-label-barcode/assets/css/style.css @@ -1,6 +1,7 @@ html { font-family: "Roboto", "Helvetica", "Arial", sans-serif; - margin-top: -7px; + margin-top: -9px; + margin-left: -6px; } table { width: 100%; @@ -51,20 +52,20 @@ td { max-height: 50px; } .md-height { - height: 60px; - max-height: 60px; + height: 75px; + max-height: 75px; } .sm-width { width: 60px; max-width: 60px; } .md-width { - width: 120px; - max-width: 120px; + width: 125px; + max-width: 125px; } .lg-width { - width: 400px; - max-width: 400px; + width: 380px; + max-width: 380px; } .overflow-multiline { max-height: inherit; diff --git a/print/templates/reports/item-label-barcode/item-label-barcode.html b/print/templates/reports/item-label-barcode/item-label-barcode.html index 79de49411..224338c2f 100644 --- a/print/templates/reports/item-label-barcode/item-label-barcode.html +++ b/print/templates/reports/item-label-barcode/item-label-barcode.html @@ -8,7 +8,7 @@ {{item.item}} +
{{item.size}}
diff --git a/print/templates/reports/item-label-barcode/item-label-barcode.js b/print/templates/reports/item-label-barcode/item-label-barcode.js index 29a2b9ad5..8a294afc1 100755 --- a/print/templates/reports/item-label-barcode/item-label-barcode.js +++ b/print/templates/reports/item-label-barcode/item-label-barcode.js @@ -29,7 +29,7 @@ module.exports = { xmlDocument: document, format: 'code128', displayValue: false, - width: 3.9, + width: 3.8, height: 85, margin: 0 }); diff --git a/print/templates/reports/item-label-barcode/options.json b/print/templates/reports/item-label-barcode/options.json index 5a3c3b1eb..1ae2630b0 100644 --- a/print/templates/reports/item-label-barcode/options.json +++ b/print/templates/reports/item-label-barcode/options.json @@ -1,9 +1,9 @@ { "width": "10.4cm", - "height": "4.8cm", + "height": "4.9cm", "margin": { "top": "0.17cm", - "right": "0cm", + "right": "0.745cm", "bottom": "0cm", "left": "0cm" }, diff --git a/print/templates/reports/item-label-qr/assets/css/style.css b/print/templates/reports/item-label-qr/assets/css/style.css index b868f3966..fe6668c9a 100644 --- a/print/templates/reports/item-label-qr/assets/css/style.css +++ b/print/templates/reports/item-label-qr/assets/css/style.css @@ -1,6 +1,7 @@ html { font-family: "Roboto", "Helvetica", "Arial", sans-serif; margin-top: -7px; + margin-left: -6px; } .leftTable { width: 47%; @@ -9,6 +10,7 @@ html { text-align: center; } .leftTable img { + margin-top: 3px; width: 110px; } .rightTable { @@ -51,24 +53,24 @@ html { padding: 7px; } .md-height { - height: 60px; - max-height: 60px; + height: 68px; + max-height: 68px; } .xs-width { width: 60px; max-width: 60px; } .sm-width { - width: 140px; - max-width: 140px; + width: 130px; + max-width: 130px; } .md-width { - width: 200px; - max-width: 200px; + width: 190px; + max-width: 190px; } .lg-width { - width: 270px; - max-width: 270px; + width: 240px; + max-width: 240px; } .overflow-multiline { max-height: inherit; diff --git a/print/templates/reports/item-label-qr/options.json b/print/templates/reports/item-label-qr/options.json index 5a3c3b1eb..c3c395040 100644 --- a/print/templates/reports/item-label-qr/options.json +++ b/print/templates/reports/item-label-qr/options.json @@ -1,9 +1,9 @@ { "width": "10.4cm", - "height": "4.8cm", + "height": "4.9cm", "margin": { "top": "0.17cm", - "right": "0cm", + "right": "0.6cm", "bottom": "0cm", "left": "0cm" }, From 3da08e3a23292353eca229b7c140898bec852cf3 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 23 Oct 2024 11:33:45 +0200 Subject: [PATCH 24/89] feat: refs #8020 machineWorkerDeprecated --- .../machine-worker/specs/updateInTime.spec.js | 132 ------------------ back/methods/machine-worker/updateInTime.js | 77 ---------- back/model-config.json | 6 - back/models/machine-worker-config.json | 18 --- back/models/machine-worker.js | 3 - back/models/machine-worker.json | 33 ----- db/dump/fixtures.before.sql | 11 -- .../workerMachinery_isRegistered.sql | 23 --- .../vn/procedures/machineWorker_add.sql | 22 --- .../machineWorker_getHistorical.sql | 21 --- .../vn/procedures/machineWorker_update.sql | 38 ----- .../vn/procedures/machine_getWorkerPlate.sql | 16 --- db/routines/vn/views/workerWithoutTractor.sql | 7 +- .../11317-silverCordyline/00-firstScript.sql | 9 ++ 14 files changed, 12 insertions(+), 404 deletions(-) delete mode 100644 back/methods/machine-worker/specs/updateInTime.spec.js delete mode 100644 back/methods/machine-worker/updateInTime.js delete mode 100644 back/models/machine-worker-config.json delete mode 100644 back/models/machine-worker.js delete mode 100644 back/models/machine-worker.json delete mode 100644 db/routines/vn/functions/workerMachinery_isRegistered.sql delete mode 100644 db/routines/vn/procedures/machineWorker_add.sql delete mode 100644 db/routines/vn/procedures/machineWorker_getHistorical.sql delete mode 100644 db/routines/vn/procedures/machineWorker_update.sql delete mode 100644 db/routines/vn/procedures/machine_getWorkerPlate.sql create mode 100644 db/versions/11317-silverCordyline/00-firstScript.sql diff --git a/back/methods/machine-worker/specs/updateInTime.spec.js b/back/methods/machine-worker/specs/updateInTime.spec.js deleted file mode 100644 index f166214b0..000000000 --- a/back/methods/machine-worker/specs/updateInTime.spec.js +++ /dev/null @@ -1,132 +0,0 @@ -const {models} = require('vn-loopback/server/server'); - -describe('machineWorker updateInTime()', () => { - const itBoss = 104; - const davidCharles = 1106; - - beforeAll(async() => { - ctx = { - req: { - accessToken: {}, - headers: {origin: 'http://localhost'}, - __: value => value - } - }; - }); - - it('should throw an error if the plate does not exist', async() => { - const tx = await models.MachineWorker.beginTransaction({}); - const options = {transaction: tx}; - const plate = 'RE-123'; - ctx.req.accessToken.userId = 1106; - try { - await models.MachineWorker.updateInTime(ctx, plate, options); - await tx.rollback(); - } catch (e) { - const error = e; - - expect(error.message).toContain('the plate does not exist'); - await tx.rollback(); - } - }); - - it('should grab a machine where is not in use', async() => { - const tx = await models.MachineWorker.beginTransaction({}); - const options = {transaction: tx}; - const plate = 'RE-003'; - ctx.req.accessToken.userId = 1107; - try { - const totalBefore = await models.MachineWorker.find(null, options); - await models.MachineWorker.updateInTime(ctx, plate, options); - const totalAfter = await models.MachineWorker.find(null, options); - - expect(totalAfter.length).toEqual(totalBefore.length + 1); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - } - }); - - describe('less than 12h', () => { - const plate = 'RE-001'; - it('should trow an error if it is not himself', async() => { - const tx = await models.MachineWorker.beginTransaction({}); - const options = {transaction: tx}; - ctx.req.accessToken.userId = davidCharles; - - try { - await models.MachineWorker.updateInTime(ctx, plate, options); - await tx.rollback(); - } catch (e) { - const error = e; - - expect(error.message).toContain('This machine is already in use'); - await tx.rollback(); - } - }); - - it('should throw an error if it is himself with a different machine', async() => { - const tx = await models.MachineWorker.beginTransaction({}); - const options = {transaction: tx}; - ctx.req.accessToken.userId = itBoss; - const plate = 'RE-003'; - try { - await models.MachineWorker.updateInTime(ctx, plate, options); - await tx.rollback(); - } catch (e) { - const error = e; - - expect(error.message).toEqual('You are already using a machine'); - await tx.rollback(); - } - }); - - it('should set the out time if it is himself', async() => { - const tx = await models.MachineWorker.beginTransaction({}); - const options = {transaction: tx}; - ctx.req.accessToken.userId = itBoss; - - try { - const isNotParked = await models.MachineWorker.findOne({ - where: {workerFk: itBoss} - }, options); - await models.MachineWorker.updateInTime(ctx, plate, options); - const isParked = await models.MachineWorker.findOne({ - where: {workerFk: itBoss} - }, options); - - expect(isNotParked.outTime).toBeNull(); - expect(isParked.outTime).toBeDefined(); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - } - }); - }); - - describe('equal or more than 12h', () => { - const plate = 'RE-002'; - it('should set the out time and grab the machine', async() => { - const tx = await models.MachineWorker.beginTransaction({}); - const options = {transaction: tx}; - ctx.req.accessToken.userId = davidCharles; - const filter = { - where: {workerFk: davidCharles, machineFk: 2} - }; - try { - const isNotParked = await models.MachineWorker.findOne(filter, options); - const totalBefore = await models.MachineWorker.find(null, options); - await models.MachineWorker.updateInTime(ctx, plate, options); - const isParked = await models.MachineWorker.findOne(filter, options); - const totalAfter = await models.MachineWorker.find(null, options); - - expect(isNotParked.outTime).toBeNull(); - expect(isParked.outTime).toBeDefined(); - expect(totalAfter.length).toEqual(totalBefore.length + 1); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - } - }); - }); -}); diff --git a/back/methods/machine-worker/updateInTime.js b/back/methods/machine-worker/updateInTime.js deleted file mode 100644 index 44fad2c05..000000000 --- a/back/methods/machine-worker/updateInTime.js +++ /dev/null @@ -1,77 +0,0 @@ -const UserError = require('vn-loopback/util/user-error'); -module.exports = Self => { - Self.remoteMethodCtx('updateInTime', { - description: 'Updates the corresponding registry if the worker has been registered in the last few hours', - accessType: 'WRITE', - accepts: [ - { - arg: 'plate', - type: 'string', - } - ], - http: { - path: `/updateInTime`, - verb: 'POST' - } - }); - - Self.updateInTime = async(ctx, plate, options) => { - const models = Self.app.models; - const userId = ctx.req.accessToken.userId; - const $t = ctx.req.__; - - let tx; - const myOptions = {}; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; - } - - try { - const machine = await models.Machine.findOne({ - fields: ['id', 'plate'], - where: {plate} - }, myOptions); - - if (!machine) - throw new UserError($t('the plate does not exist', {plate})); - - const machineWorker = await Self.findOne({ - where: { - or: [{machineFk: machine.id}, {workerFk: userId}], - outTime: null, - } - }, myOptions); - - const {maxHours} = await models.MachineWorkerConfig.findOne({fields: ['maxHours']}, myOptions); - const hoursDifference = (Date.vnNow() - machineWorker?.inTime?.getTime() ?? 0) / (60 * 60 * 1000); - - if (machineWorker) { - const isHimself = userId == machineWorker.workerFk; - const isSameMachine = machine.id == machineWorker.machineFk; - - if (hoursDifference < maxHours && !isHimself) - throw new UserError($t('This machine is already in use.')); - - if (hoursDifference < maxHours && isHimself && !isSameMachine) - throw new UserError($t('You are already using a machine')); - - await machineWorker.updateAttributes({ - outTime: Date.vnNew() - }, myOptions); - } - - if (!machineWorker || hoursDifference >= maxHours) - await models.MachineWorker.create({machineFk: machine.id, workerFk: userId}, myOptions); - - if (tx) await tx.commit(); - } catch (e) { - if (tx) await tx.rollback(); - throw e; - } - }; -}; diff --git a/back/model-config.json b/back/model-config.json index b6d304675..5368769fd 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -88,12 +88,6 @@ "Machine": { "dataSource": "vn" }, - "MachineWorker": { - "dataSource": "vn" - }, - "MachineWorkerConfig": { - "dataSource": "vn" - }, "MobileAppVersionControl": { "dataSource": "vn" }, diff --git a/back/models/machine-worker-config.json b/back/models/machine-worker-config.json deleted file mode 100644 index dfb77124e..000000000 --- a/back/models/machine-worker-config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "MachineWorkerConfig", - "base": "VnModel", - "options": { - "mysql": { - "table": "vn.machineWorkerConfig" - } - }, - "properties": { - "id": { - "type": "number", - "id": true - }, - "maxHours": { - "type": "number" - } - } -} diff --git a/back/models/machine-worker.js b/back/models/machine-worker.js deleted file mode 100644 index cbc5fd53e..000000000 --- a/back/models/machine-worker.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = Self => { - require('../methods/machine-worker/updateInTime')(Self); -}; diff --git a/back/models/machine-worker.json b/back/models/machine-worker.json deleted file mode 100644 index 2244a533f..000000000 --- a/back/models/machine-worker.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "MachineWorker", - "base": "VnModel", - "options": { - "mysql": { - "table": "vn.machineWorker" - } - }, - "properties": { - "id": { - "type": "number", - "id": true - }, - "workerFk": { - "type": "number" - }, - "machineFk": { - "type": "number" - }, - "inTime": { - "type": "date", - "mysql": { - "columnName": "inTimed" - } - }, - "outTime": { - "type": "date", - "mysql": { - "columnName": "outTimed" - } - } - } -} diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index e93bb3b8e..4fbe16f33 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2842,12 +2842,6 @@ INSERT INTO `vn`.`machine` (`plate`, `maker`, `model`, `warehouseFk`, `departmen ('RE-001', 'STILL', 'LTX-20', 60, 23, 'ELECTRIC TOW', 'Drag cars', 2020, 103, 442), ('RE-002', 'STILL', 'LTX-20', 60, 23, 'ELECTRIC TOW', 'Drag cars', 2020, 103, 442); -INSERT INTO `vn`.`machineWorker` (`workerFk`, `machineFk`, `inTimed`, `outTimed`) - VALUES - (1106, 1, util.VN_CURDATE(), util.VN_CURDATE()), - (1106, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)), - (1106, 2, util.VN_CURDATE(), NULL), - (1106, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)); INSERT INTO `vn`.`zoneExclusion` (`id`, `zoneFk`, `dated`, `created`, `userFk`) VALUES @@ -3831,8 +3825,6 @@ UPDATE vn.collection UPDATE vn.sale SET isPicked =FALSE; -INSERT INTO vn.machineWorkerConfig(id, maxHours) - VALUES(1, 12); INSERT INTO vn.workerAppTester(workerFk) VALUES(66); @@ -3840,9 +3832,6 @@ INSERT INTO `vn`.`machine` (`plate`, `maker`, `model`, `warehouseFk`, `departmen 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; diff --git a/db/routines/vn/functions/workerMachinery_isRegistered.sql b/db/routines/vn/functions/workerMachinery_isRegistered.sql deleted file mode 100644 index 60f458e9e..000000000 --- a/db/routines/vn/functions/workerMachinery_isRegistered.sql +++ /dev/null @@ -1,23 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`workerMachinery_isRegistered`(vWorkerFk VARCHAR(10)) - RETURNS tinyint(1) - NOT DETERMINISTIC - READS SQL DATA -BEGIN -/** - * Comprueba si existen registros en las últimas horas (maxHours de machineWorkerConfig) del trabajador vWorkerFk y si tiene a nulo la hora outTimed (indica la hora que deja el vehículo) - * - * @param vWorkerFk id del trabajador - * @return Devuelve TRUE/FALSE en caso de que haya o no registros - */ - IF (SELECT COUNT(*) - FROM machineWorker m - WHERE m.workerFk = vWorkerFk - AND m.inTimed >= TIMESTAMPADD(HOUR , -(SELECT maxHours from machineWorkerConfig), util.VN_NOW()) AND ISNULL(m.outTimed)) - THEN - RETURN TRUE; - ELSE - RETURN FALSE; - END IF; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/machineWorker_add.sql b/db/routines/vn/procedures/machineWorker_add.sql deleted file mode 100644 index 41000f556..000000000 --- a/db/routines/vn/procedures/machineWorker_add.sql +++ /dev/null @@ -1,22 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`machineWorker_add`(vPlate VARCHAR(10), vWorkerFk INT) -BEGIN - -/** - * Inserta registro si el vWorkerFk no ha registrado nada en las últimas 12 horas - * @param vPlate número de matrícula - * @param vWorkerFk id del worker - * -*/ - UPDATE vn.machineWorker mw - JOIN vn.machine m ON m.id = mw.machineFk - SET mw.outTimed = util.VN_NOW() - WHERE (mw.workerFk = vWorkerFk OR m.plate = vPlate) - AND ISNULL(mw.outTimed); - - INSERT INTO machineWorker (machineFk, workerFk) - SELECT m.id, vWorkerFk - FROM machine m - WHERE m.plate= vPlate; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/machineWorker_getHistorical.sql b/db/routines/vn/procedures/machineWorker_getHistorical.sql deleted file mode 100644 index 67b1971a2..000000000 --- a/db/routines/vn/procedures/machineWorker_getHistorical.sql +++ /dev/null @@ -1,21 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`machineWorker_getHistorical`(vPlate VARCHAR(20), vWorkerFk INT) -BEGIN -/** - * Obtiene historial de la matrícula vPlate que el trabajador vWorkerFk escanea, - * si es jefe de producción muestra el historial completo. - * - * @param vPlate número de matrícula - * @param vWorkerFk id del trabajador - * -*/ - DECLARE vWorkerName VARCHAR(255) DEFAULT account.user_getNameFromId(vWorkerFk); - - SELECT mw.inTimed,account.user_getNameFromId(mw.workerFk) as workerName, mw.outTimed - FROM machineWorker mw - JOIN machine m ON m.plate = vPlate - WHERE mw.machineFk = m.id - AND mw.workerFk = IF(account.user_hasRole(vWorkerName, 'coolerAssist'), mw.workerFk, vWorkerFk) - ORDER BY mw.inTimed DESC; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/machineWorker_update.sql b/db/routines/vn/procedures/machineWorker_update.sql deleted file mode 100644 index f1a6e40b5..000000000 --- a/db/routines/vn/procedures/machineWorker_update.sql +++ /dev/null @@ -1,38 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`machineWorker_update`(vPlate VARCHAR(10), vWorkerFk INT) -BEGIN - -/** - * Actualiza el registro correspondiente si el vWorkerFk se ha registrado en las últimas horas (campo maxHours de machineWorkerConfig) con vPlate, - * - * @param vPlate número de matrícula - * @param vWorkerFk id del trabajador - * -*/ - - DECLARE vMachineFk INT(10); - DECLARE vMaxHours INT(10); - - SELECT m.id INTO vMachineFk - FROM machine m - WHERE m.plate = vPlate; - - SELECT maxHours INTO vMaxHours - FROM machineWorkerConfig; - - IF (SELECT COUNT(*) - FROM machineWorker m - WHERE m.workerFk = vWorkerFk - AND m.inTimed >= TIMESTAMPADD(HOUR , -vMaxHours, util.VN_NOW()) AND ISNULL(m.outTimed)) THEN - - UPDATE machineWorker m - SET m.outTimed = CURRENT_TIMESTAMP() - WHERE m.workerFk = vWorkerFk - AND m.inTimed >= TIMESTAMPADD(HOUR , -vMaxHours, util.VN_NOW()) - AND ISNULL(m.outTimed) - AND m.machineFk = vMachineFk; - - END IF; - -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/machine_getWorkerPlate.sql b/db/routines/vn/procedures/machine_getWorkerPlate.sql deleted file mode 100644 index cbb71c4cf..000000000 --- a/db/routines/vn/procedures/machine_getWorkerPlate.sql +++ /dev/null @@ -1,16 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`machine_getWorkerPlate`(vWorkerFk INT) -BEGIN -/** - * Selecciona la matrícula del vehículo del workerfk - * - * @param vWorkerFk el id del trabajador - */ - SELECT m.plate - FROM machine m - JOIN machineWorker mw ON mw.machineFk = m.id - WHERE mw.inTimed >= TIMESTAMPADD(HOUR , -12,util.VN_NOW()) - AND ISNULL(mw.outTimed) - AND mw.workerFk = vWorkerFk; -END$$ -DELIMITER ; diff --git a/db/routines/vn/views/workerWithoutTractor.sql b/db/routines/vn/views/workerWithoutTractor.sql index 205c66599..15b62d4a9 100644 --- a/db/routines/vn/views/workerWithoutTractor.sql +++ b/db/routines/vn/views/workerWithoutTractor.sql @@ -10,11 +10,10 @@ FROM ( `vn`.`collection` `c` JOIN `vn`.`client` `cl` ON(`cl`.`id` = `c`.`workerFk`) ) - LEFT JOIN `vn`.`machineWorker` `mw` ON( - `mw`.`workerFk` = `c`.`workerFk` - AND `mw`.`inTimed` > `util`.`VN_CURDATE`() + JOIN `vn`.`operator` `o` ON( + `o`.`workerFk` = `c`.`workerFk` ) ) WHERE `c`.`created` > `util`.`VN_CURDATE`() - AND `mw`.`workerFk` IS NULL + AND `o`.`machineFk` IS NULL GROUP BY `c`.`workerFk` diff --git a/db/versions/11317-silverCordyline/00-firstScript.sql b/db/versions/11317-silverCordyline/00-firstScript.sql new file mode 100644 index 000000000..35dffcd64 --- /dev/null +++ b/db/versions/11317-silverCordyline/00-firstScript.sql @@ -0,0 +1,9 @@ + +USE vn; +RENAME TABLE machineWorker TO machineWorker__; +ALTER TABLE machineWorker__ COMMENT = '@deprecated 2024-10-23 not used'; + +RENAME TABLE machineWorkerConfig TO machineWorkerConfig__; +ALTER TABLE machineWorkerConfig__ COMMENT = '@deprecated 2024-10-23 not used'; + +DELETE FROM salix.ACL WHERE model = 'MachineWorker'; From 43f8b22593574c2908fabb66f2d158807e83afdc Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 23 Oct 2024 16:10:00 +0200 Subject: [PATCH 25/89] feat: refs #8083 add field --- modules/ticket/back/methods/expedition-state/filter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/expedition-state/filter.js b/modules/ticket/back/methods/expedition-state/filter.js index 1483780f7..3a4e7a87c 100644 --- a/modules/ticket/back/methods/expedition-state/filter.js +++ b/modules/ticket/back/methods/expedition-state/filter.js @@ -29,7 +29,7 @@ module.exports = Self => { Object.assign(myOptions, options); const stmt = new ParameterizedSQL( - `SELECT es.created, u.name, u.id workerFk, est.description state + `SELECT es.created, u.name, u.id workerFk, est.description state, es.isScanned FROM vn.expeditionState es JOIN vn.expeditionStateType est ON est.id = es.typeFk JOIN account.user u ON u.id = es.userFk From 4c529da620871d1c78f824aad3a781f7ea1fd0e8 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 24 Oct 2024 07:31:26 +0200 Subject: [PATCH 26/89] feat: refs #7266 Requested changes and query optimization --- db/routines/vn/functions/buy_getUltimate.sql | 2 +- db/routines/vn/procedures/buy_getUltimate.sql | 2 +- .../item-label-barcode.html | 8 ++- .../item-label-barcode/sql/company.sql | 3 +- .../reports/item-label-barcode/sql/item.sql | 60 ++++++++----------- .../reports/item-label-qr/item-label-qr.html | 8 ++- .../reports/item-label-qr/sql/company.sql | 3 +- .../reports/item-label-qr/sql/item.sql | 60 ++++++++----------- 8 files changed, 68 insertions(+), 78 deletions(-) diff --git a/db/routines/vn/functions/buy_getUltimate.sql b/db/routines/vn/functions/buy_getUltimate.sql index 173e6e01f..8f5e9ce59 100644 --- a/db/routines/vn/functions/buy_getUltimate.sql +++ b/db/routines/vn/functions/buy_getUltimate.sql @@ -1,7 +1,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`buy_getUltimate`( vItemFk INT, - vWarehouseFk SMALLINT, + vWarehouseFk INT, vDated DATE ) RETURNS int(11) diff --git a/db/routines/vn/procedures/buy_getUltimate.sql b/db/routines/vn/procedures/buy_getUltimate.sql index 1532222ad..77e2029fc 100644 --- a/db/routines/vn/procedures/buy_getUltimate.sql +++ b/db/routines/vn/procedures/buy_getUltimate.sql @@ -1,7 +1,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buy_getUltimate`( vItemFk INT, - vWarehouseFk SMALLINT, + vWarehouseFk INT, vDated DATE ) BEGIN diff --git a/print/templates/reports/item-label-barcode/item-label-barcode.html b/print/templates/reports/item-label-barcode/item-label-barcode.html index 224338c2f..929ce5fe2 100644 --- a/print/templates/reports/item-label-barcode/item-label-barcode.html +++ b/print/templates/reports/item-label-barcode/item-label-barcode.html @@ -17,12 +17,16 @@
- {{item.comment}} + {{ + (item.longName && item.size && item.subName) + ? `${item.longName} ${item.size} ${item.subName}` + : item.comment + }}
- {{item.producer}} + {{item.producerName || item.producerFk}}
diff --git a/print/templates/reports/item-label-barcode/sql/company.sql b/print/templates/reports/item-label-barcode/sql/company.sql index e130b4033..4047786a9 100644 --- a/print/templates/reports/item-label-barcode/sql/company.sql +++ b/print/templates/reports/item-label-barcode/sql/company.sql @@ -1,6 +1,5 @@ SELECT co.code FROM warehouse w JOIN address a ON a.id = w.addressFk - JOIN client c ON c.id = a.clientFk - JOIN company co ON co.clientFk = c.id + JOIN company co ON co.clientFk = a.clientFk WHERE w.id = ? \ No newline at end of file diff --git a/print/templates/reports/item-label-barcode/sql/item.sql b/print/templates/reports/item-label-barcode/sql/item.sql index 11ee60d1a..3cb42d139 100644 --- a/print/templates/reports/item-label-barcode/sql/item.sql +++ b/print/templates/reports/item-label-barcode/sql/item.sql @@ -6,37 +6,29 @@ WITH RECURSIVE numbers AS ( WHERE n < ? ) SELECT ROW_NUMBER() OVER() labelNum, - b.id buyFk, - b.itemFk, - b.quantity, - b.packing, - b.isPickedOff, - b.entryFk, - e.sub, - o.code origin, - COALESCE(p.`name`, p.id, '') producer, - i.name item, - i.`size`, - i.category, - i.stems, - i.inkFk, - IFNULL(CONCAT(ig.longName, ' ', ig.`size`, ' ', ig.subName), i.comment) comment, - i.typeFk, - i.isLaid, - w.code buyerName, - w.code, - s.company_name companyName, - t.shipped - FROM vn.buy b - JOIN vn.item i ON i.id = b.itemFk - LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk - LEFT JOIN edi.ekt e ON e.id = b.ektFk - JOIN vn.origin o ON o.id = i.originFk - LEFT JOIN vn.producer p ON p.id = i.producerFk - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.worker w ON w.id = it.workerFk - LEFT JOIN edi.supplier s ON s.supplier_id = e.pro - JOIN vn.entry e2 ON e2.id = b.entryFk - JOIN vn.travel t ON t.id = e2.travelFk - JOIN numbers num - WHERE b.id = ? \ No newline at end of file + b.itemFk, + i.name item, + b.id buyFk, + b.quantity, + b.packing, + b.entryFk, + o.code origin, + p.`name` producerName, + p.id producerFk, + i.`size`, + i.category, + i.stems, + i.inkFk, + ig.longName, + ig.subName, + i.comment, + w.code buyerName + FROM vn.buy b + JOIN vn.item i ON i.id = b.itemFk + LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk + JOIN vn.origin o ON o.id = i.originFk + LEFT JOIN vn.producer p ON p.id = i.producerFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.worker w ON w.id = it.workerFk + JOIN numbers num + WHERE b.id = ? \ No newline at end of file diff --git a/print/templates/reports/item-label-qr/item-label-qr.html b/print/templates/reports/item-label-qr/item-label-qr.html index 231c94818..712bd6c7d 100644 --- a/print/templates/reports/item-label-qr/item-label-qr.html +++ b/print/templates/reports/item-label-qr/item-label-qr.html @@ -71,7 +71,7 @@
- Productor: {{item.producer}} + Productor: {{item.producerName || item.producerFk}}
- {{item.comment}} + {{ + (item.longName && item.size && item.subName) + ? `${item.longName} ${item.size} ${item.subName}` + : item.comment + }}
-
+
+ {{'LAID'}} +
+
{{item.entryFk}}
+
+ {{'LAID'}} +
+
+ {{item.entryFk}} +
+
diff --git a/print/templates/reports/item-label-qr/item-label-qr.js b/print/templates/reports/item-label-qr/item-label-qr.js index 1a0ef767b..ab57783a8 100755 --- a/print/templates/reports/item-label-qr/item-label-qr.js +++ b/print/templates/reports/item-label-qr/item-label-qr.js @@ -5,17 +5,18 @@ const qrcode = require('qrcode'); module.exports = { name: 'item-label-qr', async serverPrefetch() { - this.company = await this.findOneFromDef('company', [this.warehouseId]); - if (!this.company) - throw new UserError(`There is no company associated with that warehouse`); - this.date = Date.vnNew(); - this.lastBuy = await this.findOneFromDef('lastBuy', [ - this.id, - this.warehouseId, - this.date - ]); - this.items = await this.rawSqlFromDef('item', [this.copies || 1, this.lastBuy.id]); + if (this.typeId === 'item') { + this.company = await this.findOneFromDef('company', [this.warehouseId]); + if (!this.company) + throw new UserError(`There is no company associated with that warehouse`); + this.lastBuy = await this.findOneFromDef('lastBuy', [ + this.id, + this.warehouseId, + this.date + ]); + } + this.items = await this.rawSqlFromDef('item', [this.copies || 1, this.lastBuy?.id || this.id]); if (!this.items.length) throw new UserError(`Empty data source`); this.qr = await this.getQr(this.items[0].buyFk); this.date = moment(this.date).format('WW/E'); @@ -52,6 +53,9 @@ module.exports = { }, userId: { type: Number + }, + typeId: { + type: String } } }; diff --git a/print/templates/reports/item-label-qr/options.json b/print/templates/reports/item-label-qr/options.json index c3c395040..c6ffaddea 100644 --- a/print/templates/reports/item-label-qr/options.json +++ b/print/templates/reports/item-label-qr/options.json @@ -3,7 +3,7 @@ "height": "4.9cm", "margin": { "top": "0.17cm", - "right": "0.6cm", + "right": "0.3cm", "bottom": "0cm", "left": "0cm" }, diff --git a/print/templates/reports/item-label-qr/sql/item.sql b/print/templates/reports/item-label-qr/sql/item.sql index 3cb42d139..c56097c8d 100644 --- a/print/templates/reports/item-label-qr/sql/item.sql +++ b/print/templates/reports/item-label-qr/sql/item.sql @@ -22,7 +22,8 @@ SELECT ROW_NUMBER() OVER() labelNum, ig.longName, ig.subName, i.comment, - w.code buyerName + w.code buyerName, + i.isLaid FROM vn.buy b JOIN vn.item i ON i.id = b.itemFk LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk From 6031b1fe3f42f7193bd223313e4c0dbc96feb428 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 28 Oct 2024 12:17:56 +0100 Subject: [PATCH 45/89] feat: refs #8169 create table itemTextureTag --- .../00-firstScript.sql | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 db/versions/11324-salmonCataractarum/00-firstScript.sql diff --git a/db/versions/11324-salmonCataractarum/00-firstScript.sql b/db/versions/11324-salmonCataractarum/00-firstScript.sql new file mode 100644 index 000000000..3a528382a --- /dev/null +++ b/db/versions/11324-salmonCataractarum/00-firstScript.sql @@ -0,0 +1,71 @@ +CREATE TABLE IF NOT EXISTS `vn`.`itemTextureTag` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `name` varchar(50) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name_UNIQUE` (`name`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT + CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Natural y encerado'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Natural y esponjoso'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Natural y foam'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Natural y látex'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Arenosa'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Aterciopelado'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Engomado'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Flocado'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Foam'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Gasa'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Goma'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Látex'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Latón'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Mate'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Metálico'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Natural'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Natural y engomado'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Plastificado'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Plastificado y engomado'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Plastificado y rugoso'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Pluma'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Plástico'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Plástico engomado'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Poliéster'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Poliéster texturizado'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Rugoso'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Rígido'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Seminatural'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Silicona'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Suave'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela con brillo'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela con texturas'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela dura'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela engomada'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela escarchada'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela flocada'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela flocada engomada'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela foam'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela micro peach'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela plastificada'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela plástico engomado'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela poliéster'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela PVC'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela ratan'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela rigida'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela rugosa'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela rústica'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela sintética'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y cristal'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y foam'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y goma'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y látex'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y madera'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y plástico'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y seco'); + +UPDATE vn.tag + SET isFree=0, + sourceTable='itemTextureTag' + WHERE name= 'Textura'; + +GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemFarmingTag TO logisticAssist; \ No newline at end of file From 0180998683ed40e951eb4a81671bcf411dc112c0 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 28 Oct 2024 13:08:27 +0100 Subject: [PATCH 46/89] fix: refs #7283 item filters --- modules/item/back/methods/item/filter.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/modules/item/back/methods/item/filter.js b/modules/item/back/methods/item/filter.js index 909b3dff8..54dd975a4 100644 --- a/modules/item/back/methods/item/filter.js +++ b/modules/item/back/methods/item/filter.js @@ -38,13 +38,23 @@ module.exports = Self => { type: 'integer', description: 'Type id', }, + { + arg: 'producerFk', + type: 'integer', + description: 'Producer id', + }, + { + arg: 'instrastatFk', + type: 'string', + description: 'intrastat id', + }, { arg: 'isActive', type: 'boolean', description: 'Whether the item is or not active', }, { - arg: 'buyerFk', + arg: 'workerFk', type: 'integer', description: 'The buyer of the item', }, @@ -126,14 +136,16 @@ module.exports = Self => { return {'i.stemMultiplier': value}; case 'categoryFk': return {'ic.id': value}; - case 'buyerFk': + case 'workerFk': return {'it.workerFk': value}; + case 'producerFk': + return {'pr.id': value}; case 'supplierFk': return {'s.id': value}; case 'origin': return {'ori.code': value}; - case 'intrastat': - return {'intr.description': value}; + case 'intrastatFk': + return {'i.intrastatFk': value}; case 'landed': return {'lb.landed': value}; } @@ -172,6 +184,7 @@ module.exports = Self => { u.name AS userName, ori.code AS origin, ic.name AS category, + i.intrastatFk, intr.description AS intrastat, b.grouping, b.packing, From 385279b39df4c829c99bf29913b233afa5644747 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 28 Oct 2024 13:15:40 +0100 Subject: [PATCH 47/89] fix: refs #7283 tback --- modules/item/back/methods/item/specs/filter.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/item/back/methods/item/specs/filter.spec.js b/modules/item/back/methods/item/specs/filter.spec.js index 14467d1d8..a8aaca786 100644 --- a/modules/item/back/methods/item/specs/filter.spec.js +++ b/modules/item/back/methods/item/specs/filter.spec.js @@ -86,7 +86,7 @@ describe('item filter()', () => { try { const filter = {}; - const ctx = {args: {filter: filter, buyerFk: 16}, req: {accessToken: {userId: 1}}}; + const ctx = {args: {filter: filter, workerFk: 16}, req: {accessToken: {userId: 1}}}; const result = await models.Item.filter(ctx, filter, options); expect(result.length).toEqual(2); From 61026d2d34095cc2078dd18bb9473138e2a78935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Mon, 28 Oct 2024 14:02:27 +0100 Subject: [PATCH 48/89] feat: refs #8087 Traspasar redadas a travels --- db/routines/vn2008/views/entrySource.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn2008/views/entrySource.sql b/db/routines/vn2008/views/entrySource.sql index e6e874405..9c0c0f6ed 100644 --- a/db/routines/vn2008/views/entrySource.sql +++ b/db/routines/vn2008/views/entrySource.sql @@ -8,7 +8,7 @@ AS SELECT `e`.`gestDocFk` AS `gestdoc_id`, `e`.`isExcludedFromAvailable` AS `Inventario`, `e`.`isConfirmed` AS `Confirmada`, `e`.`isOrdered` AS `Pedida`, - `tr`.`daysInForward` AS `Redada`, + `tr`.`daysInForward` AS `daysInForward`, `e`.`evaNotes` AS `notas`, `e`.`supplierFk` AS `Id_Proveedor`, `tr`.`shipped` AS `shipment`, From 511c848342cad70f0ec5f8624c4438f30e0bad54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Mon, 28 Oct 2024 14:22:08 +0100 Subject: [PATCH 49/89] feat: refs #8087 Traspasar redadas a travels --- db/versions/11316-chocolateErica/00-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11316-chocolateErica/00-firstScript.sql b/db/versions/11316-chocolateErica/00-firstScript.sql index 8fd0c72de..e24f38b2e 100644 --- a/db/versions/11316-chocolateErica/00-firstScript.sql +++ b/db/versions/11316-chocolateErica/00-firstScript.sql @@ -1,5 +1,5 @@ ALTER TABLE vn.travel ADD IF NOT EXISTS daysInForward INT UNSIGNED DEFAULT 0 NOT NULL - COMMENT 'Número de días donde se siturá el landed de las entradas con respecto a hoy'; + COMMENT 'Indica si las entradas están asociadas a redadas: 0 significa que no es una redada, y un valor distinto a 0 indica el número de días para el landed respecto a hoy'; ALTER TABLE vn.entry CHANGE isRaid isRaid_ tinyint(1) DEFAULT 0 NOT NULL COMMENT '@deprecated 2024-11-05'; From bffb13f94a59ea27e5ec880aa9bacf69d17373cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Mon, 28 Oct 2024 14:24:44 +0100 Subject: [PATCH 50/89] feat: refs #8087 Traspasar redadas a travels --- db/versions/11316-chocolateErica/00-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11316-chocolateErica/00-firstScript.sql b/db/versions/11316-chocolateErica/00-firstScript.sql index e24f38b2e..9f2f15bdd 100644 --- a/db/versions/11316-chocolateErica/00-firstScript.sql +++ b/db/versions/11316-chocolateErica/00-firstScript.sql @@ -1,5 +1,5 @@ ALTER TABLE vn.travel ADD IF NOT EXISTS daysInForward INT UNSIGNED DEFAULT 0 NOT NULL - COMMENT 'Indica si las entradas están asociadas a redadas: 0 significa que no es una redada, y un valor distinto a 0 indica el número de días para el landed respecto a hoy'; + COMMENT 'Indica que sus entradas son redadas: 0 significa que no es un travel de redadas, y un valor distinto a 0 indica el número de días para el landed respecto a hoy'; ALTER TABLE vn.entry CHANGE isRaid isRaid_ tinyint(1) DEFAULT 0 NOT NULL COMMENT '@deprecated 2024-11-05'; From f05b6a46b090c0913eb248083b02ac723f92c8dd Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 28 Oct 2024 14:36:10 +0100 Subject: [PATCH 51/89] feat: refs #8071 quitar esquema --- db/routines/vn/procedures/travel_cloneWithEntries.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/travel_cloneWithEntries.sql b/db/routines/vn/procedures/travel_cloneWithEntries.sql index 0199c452f..5b2958edc 100644 --- a/db/routines/vn/procedures/travel_cloneWithEntries.sql +++ b/db/routines/vn/procedures/travel_cloneWithEntries.sql @@ -72,7 +72,7 @@ BEGIN SET evaNotes = vEvaNotes WHERE id = vNewEntryFk; - CALL vn.buy_recalcPricesByEntry(vNewEntryFk); + CALL buy_recalcPricesByEntry(vNewEntryFk); END LOOP; SET @isModeInventory = FALSE; From a37b7b71a872fc696918ae29ce54ba63d0591449 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 28 Oct 2024 14:51:19 +0100 Subject: [PATCH 52/89] feat: refs #7266 Requested changes and improvements --- modules/entry/back/methods/entry/buyLabel.js | 27 ++++++++-- ...labelBarcodePdf.js => buyLabelSupplier.js} | 21 ++------ .../entry/back/methods/entry/labelQrPdf.js | 49 ----------------- modules/entry/back/models/buy.js | 3 +- .../item/back/methods/item/labelBarcodePdf.js | 52 ------------------ modules/item/back/methods/item/labelQrPdf.js | 53 ------------------- modules/item/back/models/item.js | 2 - .../assets/css/import.js | 0 .../assets/css/style.css | 0 .../buy-label-barcode.html} | 34 ++++++------ .../buy-label-barcode.js} | 16 ++---- .../locale/es.yml | 0 .../options.json | 0 .../sql/buy.sql} | 5 +- .../assets/css/import.js | 0 .../assets/css/style.css | 0 .../buy-label-qr.html} | 36 ++++++------- .../buy-label-qr.js} | 20 ++----- .../locale/es.yml | 0 .../options.json | 0 .../sql/item.sql => buy-label-qr/sql/buy.sql} | 5 +- .../assets/css/import.js | 0 .../assets/css/style.css | 0 .../buy-label-supplier.html} | 0 .../buy-label-supplier.js} | 2 +- .../locale/en.yml | 0 .../locale/es.yml | 0 .../options.json | 0 .../sql/buy.sql | 0 .../item-label-barcode/sql/company.sql | 5 -- .../item-label-barcode/sql/lastBuy.sql | 1 - .../reports/item-label-qr/sql/company.sql | 5 -- .../reports/item-label-qr/sql/lastBuy.sql | 1 - 33 files changed, 81 insertions(+), 256 deletions(-) rename modules/entry/back/methods/entry/{labelBarcodePdf.js => buyLabelSupplier.js} (57%) delete mode 100644 modules/entry/back/methods/entry/labelQrPdf.js delete mode 100644 modules/item/back/methods/item/labelBarcodePdf.js delete mode 100644 modules/item/back/methods/item/labelQrPdf.js rename print/templates/reports/{buy-label => buy-label-barcode}/assets/css/import.js (100%) rename print/templates/reports/{item-label-barcode => buy-label-barcode}/assets/css/style.css (100%) rename print/templates/reports/{item-label-barcode/item-label-barcode.html => buy-label-barcode/buy-label-barcode.html} (69%) rename print/templates/reports/{item-label-barcode/item-label-barcode.js => buy-label-barcode/buy-label-barcode.js} (66%) rename print/templates/reports/{item-label-barcode => buy-label-barcode}/locale/es.yml (100%) rename print/templates/reports/{item-label-barcode => buy-label-barcode}/options.json (100%) rename print/templates/reports/{item-label-barcode/sql/item.sql => buy-label-barcode/sql/buy.sql} (84%) rename print/templates/reports/{item-label-barcode => buy-label-qr}/assets/css/import.js (100%) rename print/templates/reports/{item-label-qr => buy-label-qr}/assets/css/style.css (100%) rename print/templates/reports/{item-label-qr/item-label-qr.html => buy-label-qr/buy-label-qr.html} (72%) rename print/templates/reports/{item-label-qr/item-label-qr.js => buy-label-qr/buy-label-qr.js} (59%) rename print/templates/reports/{item-label-qr => buy-label-qr}/locale/es.yml (100%) rename print/templates/reports/{item-label-qr => buy-label-qr}/options.json (100%) rename print/templates/reports/{item-label-qr/sql/item.sql => buy-label-qr/sql/buy.sql} (84%) rename print/templates/reports/{item-label-qr => buy-label-supplier}/assets/css/import.js (100%) rename print/templates/reports/{buy-label => buy-label-supplier}/assets/css/style.css (100%) rename print/templates/reports/{buy-label/buy-label.html => buy-label-supplier/buy-label-supplier.html} (100%) rename print/templates/reports/{buy-label/buy-label.js => buy-label-supplier/buy-label-supplier.js} (97%) rename print/templates/reports/{buy-label => buy-label-supplier}/locale/en.yml (100%) rename print/templates/reports/{buy-label => buy-label-supplier}/locale/es.yml (100%) rename print/templates/reports/{buy-label => buy-label-supplier}/options.json (100%) rename print/templates/reports/{buy-label => buy-label-supplier}/sql/buy.sql (100%) delete mode 100644 print/templates/reports/item-label-barcode/sql/company.sql delete mode 100644 print/templates/reports/item-label-barcode/sql/lastBuy.sql delete mode 100644 print/templates/reports/item-label-qr/sql/company.sql delete mode 100644 print/templates/reports/item-label-qr/sql/lastBuy.sql diff --git a/modules/entry/back/methods/entry/buyLabel.js b/modules/entry/back/methods/entry/buyLabel.js index 919f7c4d7..fb807fb5f 100644 --- a/modules/entry/back/methods/entry/buyLabel.js +++ b/modules/entry/back/methods/entry/buyLabel.js @@ -1,14 +1,28 @@ module.exports = Self => { Self.remoteMethodCtx('buyLabel', { - description: 'Returns the entry buy labels', + description: 'Returns the buy label', accessType: 'READ', accepts: [ { arg: 'id', type: 'number', required: true, - description: 'The entry id', + description: 'The buy id', http: {source: 'path'} + }, { + arg: 'labelType', + type: 'string', + required: true, + description: 'The label type', + http: {source: 'path'} + }, { + arg: 'packing', + type: 'number', + required: false + }, { + arg: 'copies', + type: 'number', + required: false } ], returns: [ @@ -27,11 +41,16 @@ module.exports = Self => { } ], http: { - path: '/:id/buy-label', + path: '/:id/:labelType/buy-label', verb: 'GET' }, accessScopes: ['DEFAULT', 'read:multimedia'] }); - Self.buyLabel = (ctx, id) => Self.printReport(ctx, id, 'buy-label'); + Self.buyLabel = (ctx, id, labelType) => { + if (labelType == 'qr') + return Self.printReport(ctx, id, 'buy-label-qr'); + else + return Self.printReport(ctx, id, 'buy-label-barcode'); + }; }; diff --git a/modules/entry/back/methods/entry/labelBarcodePdf.js b/modules/entry/back/methods/entry/buyLabelSupplier.js similarity index 57% rename from modules/entry/back/methods/entry/labelBarcodePdf.js rename to modules/entry/back/methods/entry/buyLabelSupplier.js index 847859aeb..61938f2f8 100644 --- a/modules/entry/back/methods/entry/labelBarcodePdf.js +++ b/modules/entry/back/methods/entry/buyLabelSupplier.js @@ -1,22 +1,14 @@ module.exports = Self => { - Self.remoteMethodCtx('labelBarcodePdf', { - description: 'Returns the item label pdf with barcode', + Self.remoteMethodCtx('buyLabelSupplier', { + description: 'Returns the entry buy labels', accessType: 'READ', accepts: [ { arg: 'id', type: 'number', required: true, - description: 'The item id', + description: 'The entry id', http: {source: 'path'} - }, { - arg: 'packing', - type: 'number', - required: false - }, { - arg: 'copies', - type: 'number', - required: false } ], returns: [ @@ -35,14 +27,11 @@ module.exports = Self => { } ], http: { - path: '/:id/label-barcode-pdf', + path: '/:id/buy-label-supplier', verb: 'GET' }, accessScopes: ['DEFAULT', 'read:multimedia'] }); - Self.labelBarcodePdf = (ctx, id) => { - ctx.args.typeId = 'buy'; - return Self.printReport(ctx, id, 'item-label-barcode'); - }; + Self.buyLabelSupplier = (ctx, id) => Self.printReport(ctx, id, 'buy-label-supplier'); }; diff --git a/modules/entry/back/methods/entry/labelQrPdf.js b/modules/entry/back/methods/entry/labelQrPdf.js deleted file mode 100644 index 9668dfffd..000000000 --- a/modules/entry/back/methods/entry/labelQrPdf.js +++ /dev/null @@ -1,49 +0,0 @@ -module.exports = Self => { - Self.remoteMethodCtx('labelQrPdf', { - description: 'Returns the item label pdf with qr', - accessType: 'READ', - accepts: [ - { - arg: 'id', - type: 'number', - required: true, - description: 'The item id', - http: {source: 'path'} - }, { - arg: 'packing', - type: 'number', - required: false - }, { - arg: 'copies', - type: 'number', - required: false - } - ], - returns: [ - { - arg: 'body', - type: 'file', - root: true - }, { - arg: 'Content-Type', - type: 'String', - http: {target: 'header'} - }, { - arg: 'Content-Disposition', - type: 'String', - http: {target: 'header'} - } - ], - http: { - path: '/:id/label-qr-pdf', - verb: 'GET' - }, - accessScopes: ['DEFAULT', 'read:multimedia'] - }); - - Self.labelQrPdf = (ctx, id) => { - ctx.args.userId = ctx.req.accessToken.userId; - ctx.args.typeId = 'buy'; - return Self.printReport(ctx, id, 'item-label-qr'); - }; -}; diff --git a/modules/entry/back/models/buy.js b/modules/entry/back/models/buy.js index 70d92195c..a027a861e 100644 --- a/modules/entry/back/models/buy.js +++ b/modules/entry/back/models/buy.js @@ -2,6 +2,5 @@ module.exports = Self => { require('../methods/entry/editLatestBuys')(Self); require('../methods/entry/latestBuysFilter')(Self); require('../methods/entry/deleteBuys')(Self); - require('../methods/entry/labelBarcodePdf')(Self); - require('../methods/entry/labelQrPdf')(Self); + require('../methods/entry/buyLabel')(Self); }; diff --git a/modules/item/back/methods/item/labelBarcodePdf.js b/modules/item/back/methods/item/labelBarcodePdf.js deleted file mode 100644 index 8e28ddfe2..000000000 --- a/modules/item/back/methods/item/labelBarcodePdf.js +++ /dev/null @@ -1,52 +0,0 @@ -module.exports = Self => { - Self.remoteMethodCtx('labelBarcodePdf', { - description: 'Returns the item label pdf with barcode', - accessType: 'READ', - accepts: [ - { - arg: 'id', - type: 'number', - required: true, - description: 'The item id', - http: {source: 'path'} - }, { - arg: 'warehouseId', - type: 'number', - required: true - }, { - arg: 'packing', - type: 'number', - required: false - }, { - arg: 'copies', - type: 'number', - required: false - } - ], - returns: [ - { - arg: 'body', - type: 'file', - root: true - }, { - arg: 'Content-Type', - type: 'String', - http: {target: 'header'} - }, { - arg: 'Content-Disposition', - type: 'String', - http: {target: 'header'} - } - ], - http: { - path: '/:id/label-barcode-pdf', - verb: 'GET' - }, - accessScopes: ['DEFAULT', 'read:multimedia'] - }); - - Self.labelBarcodePdf = (ctx, id) => { - ctx.args.typeId = 'item'; - return Self.printReport(ctx, id, 'item-label-barcode'); - }; -}; diff --git a/modules/item/back/methods/item/labelQrPdf.js b/modules/item/back/methods/item/labelQrPdf.js deleted file mode 100644 index 2c42a978a..000000000 --- a/modules/item/back/methods/item/labelQrPdf.js +++ /dev/null @@ -1,53 +0,0 @@ -module.exports = Self => { - Self.remoteMethodCtx('labelQrPdf', { - description: 'Returns the item label pdf with qr', - accessType: 'READ', - accepts: [ - { - arg: 'id', - type: 'number', - required: true, - description: 'The item id', - http: {source: 'path'} - }, { - arg: 'warehouseId', - type: 'number', - required: true - }, { - arg: 'packing', - type: 'number', - required: false - }, { - arg: 'copies', - type: 'number', - required: false - } - ], - returns: [ - { - arg: 'body', - type: 'file', - root: true - }, { - arg: 'Content-Type', - type: 'String', - http: {target: 'header'} - }, { - arg: 'Content-Disposition', - type: 'String', - http: {target: 'header'} - } - ], - http: { - path: '/:id/label-qr-pdf', - verb: 'GET' - }, - accessScopes: ['DEFAULT', 'read:multimedia'] - }); - - Self.labelQrPdf = (ctx, id) => { - ctx.args.userId = ctx.req.accessToken.userId; - ctx.args.typeId = 'item'; - return Self.printReport(ctx, id, 'item-label-qr'); - }; -}; diff --git a/modules/item/back/models/item.js b/modules/item/back/models/item.js index d39586a90..44a51594c 100644 --- a/modules/item/back/models/item.js +++ b/modules/item/back/models/item.js @@ -15,8 +15,6 @@ module.exports = Self => { require('../methods/item/getWasteByItem')(Self); require('../methods/item/createIntrastat')(Self); require('../methods/item/buyerWasteEmail')(Self); - require('../methods/item/labelBarcodePdf')(Self); - require('../methods/item/labelQrPdf')(Self); require('../methods/item/setVisibleDiscard')(Self); require('../methods/item/get')(Self); diff --git a/print/templates/reports/buy-label/assets/css/import.js b/print/templates/reports/buy-label-barcode/assets/css/import.js similarity index 100% rename from print/templates/reports/buy-label/assets/css/import.js rename to print/templates/reports/buy-label-barcode/assets/css/import.js diff --git a/print/templates/reports/item-label-barcode/assets/css/style.css b/print/templates/reports/buy-label-barcode/assets/css/style.css similarity index 100% rename from print/templates/reports/item-label-barcode/assets/css/style.css rename to print/templates/reports/buy-label-barcode/assets/css/style.css diff --git a/print/templates/reports/item-label-barcode/item-label-barcode.html b/print/templates/reports/buy-label-barcode/buy-label-barcode.html similarity index 69% rename from print/templates/reports/item-label-barcode/item-label-barcode.html rename to print/templates/reports/buy-label-barcode/buy-label-barcode.html index 8bf3ce8eb..f14f0b70b 100644 --- a/print/templates/reports/item-label-barcode/item-label-barcode.html +++ b/print/templates/reports/buy-label-barcode/buy-label-barcode.html @@ -1,16 +1,16 @@ - + @@ -18,64 +18,64 @@ diff --git a/print/templates/reports/item-label-barcode/item-label-barcode.js b/print/templates/reports/buy-label-barcode/buy-label-barcode.js similarity index 66% rename from print/templates/reports/item-label-barcode/item-label-barcode.js rename to print/templates/reports/buy-label-barcode/buy-label-barcode.js index e2945ae39..8c39a7046 100755 --- a/print/templates/reports/item-label-barcode/item-label-barcode.js +++ b/print/templates/reports/buy-label-barcode/buy-label-barcode.js @@ -4,21 +4,11 @@ const moment = require('moment'); const jsbarcode = require('jsbarcode'); module.exports = { - name: 'item-label-barcode', + name: 'buy-label-barcode', async serverPrefetch() { this.date = Date.vnNew(); - if (this.typeId === 'item') { - this.company = await this.findOneFromDef('company', [this.warehouseId]); - if (!this.company) - throw new UserError(`There is no company associated with that warehouse`); - this.lastBuy = await this.findOneFromDef('lastBuy', [ - this.id, - this.warehouseId, - this.date - ]); - } - this.items = await this.rawSqlFromDef('item', [this.copies || 1, this.lastBuy?.id || this.id]); - if (!this.items.length) throw new UserError(`Empty data source`); + this.buys = await this.rawSqlFromDef('buy', [this.copies || 1, this.id]); + if (!this.buys.length) throw new UserError(`Empty data source`); this.date = moment(this.date).format('WW/E'); }, methods: { diff --git a/print/templates/reports/item-label-barcode/locale/es.yml b/print/templates/reports/buy-label-barcode/locale/es.yml similarity index 100% rename from print/templates/reports/item-label-barcode/locale/es.yml rename to print/templates/reports/buy-label-barcode/locale/es.yml diff --git a/print/templates/reports/item-label-barcode/options.json b/print/templates/reports/buy-label-barcode/options.json similarity index 100% rename from print/templates/reports/item-label-barcode/options.json rename to print/templates/reports/buy-label-barcode/options.json diff --git a/print/templates/reports/item-label-barcode/sql/item.sql b/print/templates/reports/buy-label-barcode/sql/buy.sql similarity index 84% rename from print/templates/reports/item-label-barcode/sql/item.sql rename to print/templates/reports/buy-label-barcode/sql/buy.sql index c56097c8d..739f8449f 100644 --- a/print/templates/reports/item-label-barcode/sql/item.sql +++ b/print/templates/reports/buy-label-barcode/sql/buy.sql @@ -23,7 +23,8 @@ SELECT ROW_NUMBER() OVER() labelNum, ig.subName, i.comment, w.code buyerName, - i.isLaid + i.isLaid, + c.code company FROM vn.buy b JOIN vn.item i ON i.id = b.itemFk LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk @@ -31,5 +32,7 @@ SELECT ROW_NUMBER() OVER() labelNum, LEFT JOIN vn.producer p ON p.id = i.producerFk JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.worker w ON w.id = it.workerFk + JOIN vn.entry e ON e.id = b.entryFk + JOIN vn.company c ON c.id = e.companyFk JOIN numbers num WHERE b.id = ? \ No newline at end of file diff --git a/print/templates/reports/item-label-barcode/assets/css/import.js b/print/templates/reports/buy-label-qr/assets/css/import.js similarity index 100% rename from print/templates/reports/item-label-barcode/assets/css/import.js rename to print/templates/reports/buy-label-qr/assets/css/import.js diff --git a/print/templates/reports/item-label-qr/assets/css/style.css b/print/templates/reports/buy-label-qr/assets/css/style.css similarity index 100% rename from print/templates/reports/item-label-qr/assets/css/style.css rename to print/templates/reports/buy-label-qr/assets/css/style.css diff --git a/print/templates/reports/item-label-qr/item-label-qr.html b/print/templates/reports/buy-label-qr/buy-label-qr.html similarity index 72% rename from print/templates/reports/item-label-qr/item-label-qr.html rename to print/templates/reports/buy-label-qr/buy-label-qr.html index 6218a4513..00e64b57d 100644 --- a/print/templates/reports/item-label-qr/item-label-qr.html +++ b/print/templates/reports/buy-label-qr/buy-label-qr.html @@ -1,6 +1,6 @@ - +
- {{item.item}} + {{buy.item}}
- {{item.size}} + {{buy.size}}
{{ - (item.longName && item.size && item.subName) - ? `${item.longName} ${item.size} ${item.subName}` - : item.comment + (buy.longName && buy.size && buy.subName) + ? `${buy.longName} ${buy.size} ${buy.subName}` + : buy.comment }}
- {{item.producerName || item.producerFk}} + {{buy.producerName || buy.producerFk}}
- {{item.inkFk}} + {{buy.inkFk}}
- {{item.itemFk}} + {{buy.itemFk}}
- {{`${(packing || item.packing)} x ${item.stems || ''}`}} + {{`${(packing || buy.packing)} x ${buy.stems || ''}`}}
-
+
-
+
{{'LAID'}}
- {{item.entryFk}} + {{buy.entryFk}}
- {{item.buyerName}} + {{buy.buyerName}}
- {{item.origin}} + {{buy.origin}}
- {{item.buyFk}} + {{buy.buyFk}}
@@ -85,7 +85,7 @@
- {{`${item.labelNum}/${item.quantity / (packing || item.packing)}`}} + {{`${buy.labelNum}/${buy.quantity / (packing || buy.packing)}`}}
@@ -28,65 +28,65 @@ @@ -111,9 +111,9 @@ diff --git a/print/templates/reports/item-label-qr/item-label-qr.js b/print/templates/reports/buy-label-qr/buy-label-qr.js similarity index 59% rename from print/templates/reports/item-label-qr/item-label-qr.js rename to print/templates/reports/buy-label-qr/buy-label-qr.js index ab57783a8..74470ad6d 100755 --- a/print/templates/reports/item-label-qr/item-label-qr.js +++ b/print/templates/reports/buy-label-qr/buy-label-qr.js @@ -3,28 +3,18 @@ const moment = require('moment'); const qrcode = require('qrcode'); module.exports = { - name: 'item-label-qr', + name: 'buy-label-qr', async serverPrefetch() { this.date = Date.vnNew(); - if (this.typeId === 'item') { - this.company = await this.findOneFromDef('company', [this.warehouseId]); - if (!this.company) - throw new UserError(`There is no company associated with that warehouse`); - this.lastBuy = await this.findOneFromDef('lastBuy', [ - this.id, - this.warehouseId, - this.date - ]); - } - this.items = await this.rawSqlFromDef('item', [this.copies || 1, this.lastBuy?.id || this.id]); - if (!this.items.length) throw new UserError(`Empty data source`); - this.qr = await this.getQr(this.items[0].buyFk); + this.buys = await this.rawSqlFromDef('buy', [this.copies || 1, this.id]); + if (!this.buys.length) throw new UserError(`Empty data source`); + this.qr = await this.getQr(this.buys[0].buyFk); this.date = moment(this.date).format('WW/E'); }, methods: { getQr(data) { data = { - company: this.company, + company: this.buys.company, user: this.userId, created: this.date, table: 'buy', diff --git a/print/templates/reports/item-label-qr/locale/es.yml b/print/templates/reports/buy-label-qr/locale/es.yml similarity index 100% rename from print/templates/reports/item-label-qr/locale/es.yml rename to print/templates/reports/buy-label-qr/locale/es.yml diff --git a/print/templates/reports/item-label-qr/options.json b/print/templates/reports/buy-label-qr/options.json similarity index 100% rename from print/templates/reports/item-label-qr/options.json rename to print/templates/reports/buy-label-qr/options.json diff --git a/print/templates/reports/item-label-qr/sql/item.sql b/print/templates/reports/buy-label-qr/sql/buy.sql similarity index 84% rename from print/templates/reports/item-label-qr/sql/item.sql rename to print/templates/reports/buy-label-qr/sql/buy.sql index c56097c8d..739f8449f 100644 --- a/print/templates/reports/item-label-qr/sql/item.sql +++ b/print/templates/reports/buy-label-qr/sql/buy.sql @@ -23,7 +23,8 @@ SELECT ROW_NUMBER() OVER() labelNum, ig.subName, i.comment, w.code buyerName, - i.isLaid + i.isLaid, + c.code company FROM vn.buy b JOIN vn.item i ON i.id = b.itemFk LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk @@ -31,5 +32,7 @@ SELECT ROW_NUMBER() OVER() labelNum, LEFT JOIN vn.producer p ON p.id = i.producerFk JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.worker w ON w.id = it.workerFk + JOIN vn.entry e ON e.id = b.entryFk + JOIN vn.company c ON c.id = e.companyFk JOIN numbers num WHERE b.id = ? \ No newline at end of file diff --git a/print/templates/reports/item-label-qr/assets/css/import.js b/print/templates/reports/buy-label-supplier/assets/css/import.js similarity index 100% rename from print/templates/reports/item-label-qr/assets/css/import.js rename to print/templates/reports/buy-label-supplier/assets/css/import.js diff --git a/print/templates/reports/buy-label/assets/css/style.css b/print/templates/reports/buy-label-supplier/assets/css/style.css similarity index 100% rename from print/templates/reports/buy-label/assets/css/style.css rename to print/templates/reports/buy-label-supplier/assets/css/style.css diff --git a/print/templates/reports/buy-label/buy-label.html b/print/templates/reports/buy-label-supplier/buy-label-supplier.html similarity index 100% rename from print/templates/reports/buy-label/buy-label.html rename to print/templates/reports/buy-label-supplier/buy-label-supplier.html diff --git a/print/templates/reports/buy-label/buy-label.js b/print/templates/reports/buy-label-supplier/buy-label-supplier.js similarity index 97% rename from print/templates/reports/buy-label/buy-label.js rename to print/templates/reports/buy-label-supplier/buy-label-supplier.js index 289483051..3cef5f295 100755 --- a/print/templates/reports/buy-label/buy-label.js +++ b/print/templates/reports/buy-label-supplier/buy-label-supplier.js @@ -5,7 +5,7 @@ const jsBarcode = require('jsbarcode'); const moment = require('moment'); module.exports = { - name: 'buy-label', + name: 'buy-label-supplier', mixins: [vnReport], async serverPrefetch() { const buy = await models.Buy.findById(this.id, null); diff --git a/print/templates/reports/buy-label/locale/en.yml b/print/templates/reports/buy-label-supplier/locale/en.yml similarity index 100% rename from print/templates/reports/buy-label/locale/en.yml rename to print/templates/reports/buy-label-supplier/locale/en.yml diff --git a/print/templates/reports/buy-label/locale/es.yml b/print/templates/reports/buy-label-supplier/locale/es.yml similarity index 100% rename from print/templates/reports/buy-label/locale/es.yml rename to print/templates/reports/buy-label-supplier/locale/es.yml diff --git a/print/templates/reports/buy-label/options.json b/print/templates/reports/buy-label-supplier/options.json similarity index 100% rename from print/templates/reports/buy-label/options.json rename to print/templates/reports/buy-label-supplier/options.json diff --git a/print/templates/reports/buy-label/sql/buy.sql b/print/templates/reports/buy-label-supplier/sql/buy.sql similarity index 100% rename from print/templates/reports/buy-label/sql/buy.sql rename to print/templates/reports/buy-label-supplier/sql/buy.sql diff --git a/print/templates/reports/item-label-barcode/sql/company.sql b/print/templates/reports/item-label-barcode/sql/company.sql deleted file mode 100644 index 4047786a9..000000000 --- a/print/templates/reports/item-label-barcode/sql/company.sql +++ /dev/null @@ -1,5 +0,0 @@ -SELECT co.code - FROM warehouse w - JOIN address a ON a.id = w.addressFk - JOIN company co ON co.clientFk = a.clientFk - WHERE w.id = ? \ No newline at end of file diff --git a/print/templates/reports/item-label-barcode/sql/lastBuy.sql b/print/templates/reports/item-label-barcode/sql/lastBuy.sql deleted file mode 100644 index d10339998..000000000 --- a/print/templates/reports/item-label-barcode/sql/lastBuy.sql +++ /dev/null @@ -1 +0,0 @@ -SELECT buy_getUltimate(?, ?, ?) id \ No newline at end of file diff --git a/print/templates/reports/item-label-qr/sql/company.sql b/print/templates/reports/item-label-qr/sql/company.sql deleted file mode 100644 index 4047786a9..000000000 --- a/print/templates/reports/item-label-qr/sql/company.sql +++ /dev/null @@ -1,5 +0,0 @@ -SELECT co.code - FROM warehouse w - JOIN address a ON a.id = w.addressFk - JOIN company co ON co.clientFk = a.clientFk - WHERE w.id = ? \ No newline at end of file diff --git a/print/templates/reports/item-label-qr/sql/lastBuy.sql b/print/templates/reports/item-label-qr/sql/lastBuy.sql deleted file mode 100644 index d10339998..000000000 --- a/print/templates/reports/item-label-qr/sql/lastBuy.sql +++ /dev/null @@ -1 +0,0 @@ -SELECT buy_getUltimate(?, ?, ?) id \ No newline at end of file From bfc446ab79b839d83045f82820307872ff88d235 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 28 Oct 2024 14:56:01 +0100 Subject: [PATCH 53/89] feat: refs #7266 Requested changes and improvements --- db/versions/11325-navyEucalyptus/00-firstScript.sql | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 db/versions/11325-navyEucalyptus/00-firstScript.sql diff --git a/db/versions/11325-navyEucalyptus/00-firstScript.sql b/db/versions/11325-navyEucalyptus/00-firstScript.sql new file mode 100644 index 000000000..8bc4bd82b --- /dev/null +++ b/db/versions/11325-navyEucalyptus/00-firstScript.sql @@ -0,0 +1,7 @@ +UPDATE salix.ACL + SET property='buyLabelSupplier' + WHERE property = 'buyLabel' + AND model = 'Entry'; + +INSERT IGNORE INTO salix.ACL (model,property,principalId) + VALUES ('Entry','buyLabel','employee'); From 2f0fa56040a46e81e7ed4b80b66e23a878c62424 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 29 Oct 2024 07:19:51 +0100 Subject: [PATCH 54/89] feat: refs #7266 Version --- db/versions/11326-limeOrchid/00-firstScript.sql | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 db/versions/11326-limeOrchid/00-firstScript.sql diff --git a/db/versions/11326-limeOrchid/00-firstScript.sql b/db/versions/11326-limeOrchid/00-firstScript.sql new file mode 100644 index 000000000..afec99459 --- /dev/null +++ b/db/versions/11326-limeOrchid/00-firstScript.sql @@ -0,0 +1,7 @@ +DELETE FROM vn.report + WHERE `name` = 'LabelItemQr'; + +UPDATE vn.report + SET `method` = 'Entries/{id}/{itemType}/buy-label', + `name` = 'LabelBuy' + WHERE `name` = 'LabelItemBarcode'; From 17412c5b849fe0663c760b5f51c6bd028138073c Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 29 Oct 2024 09:57:04 +0100 Subject: [PATCH 55/89] feat: refs #7266 Version --- db/versions/11326-limeOrchid/00-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11326-limeOrchid/00-firstScript.sql b/db/versions/11326-limeOrchid/00-firstScript.sql index afec99459..64d772043 100644 --- a/db/versions/11326-limeOrchid/00-firstScript.sql +++ b/db/versions/11326-limeOrchid/00-firstScript.sql @@ -2,6 +2,6 @@ DELETE FROM vn.report WHERE `name` = 'LabelItemQr'; UPDATE vn.report - SET `method` = 'Entries/{id}/{itemType}/buy-label', + SET `method` = 'Entries/{id}/{labelType}/buy-label', `name` = 'LabelBuy' WHERE `name` = 'LabelItemBarcode'; From 4c0dec19d415f384d2701ff8b90f7179dbd4ee21 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 4 Nov 2024 07:48:28 +0100 Subject: [PATCH 56/89] feat: refs #7266 buyFkForPrint --- db/routines/vn/procedures/itemShelving_get.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/itemShelving_get.sql b/db/routines/vn/procedures/itemShelving_get.sql index 606bb8bd9..58163a89f 100644 --- a/db/routines/vn/procedures/itemShelving_get.sql +++ b/db/routines/vn/procedures/itemShelving_get.sql @@ -17,7 +17,8 @@ BEGIN s.priority, ish.isChecked, ic.url, - ish.available + ish.available, + ish.buyFk FROM itemShelving ish JOIN item i ON i.id = ish.itemFk JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci From 37548e5e646cc40faee6c31a73c22274f20f78b4 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 4 Nov 2024 08:59:10 +0100 Subject: [PATCH 57/89] feat: refs #7266 buyFkForPrint --- db/routines/vn/procedures/itemShelving_get.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/itemShelving_get.sql b/db/routines/vn/procedures/itemShelving_get.sql index 58163a89f..07384b721 100644 --- a/db/routines/vn/procedures/itemShelving_get.sql +++ b/db/routines/vn/procedures/itemShelving_get.sql @@ -7,9 +7,10 @@ BEGIN * @param vSelf matrícula del carro **/ SELECT ish.itemFk item, - IFNULL(i.longName, CONCAT(i.name, ' ', i.size)) description, + i.name, + i.longName, + i.size, ish.visible, - CEIL(ish.visible/ish.packing) stickers, ish.packing, ish.grouping, p.code, From 85ded59cb36ecd3c894be58a45cb9d2b36eb7b28 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 4 Nov 2024 13:46:54 +0100 Subject: [PATCH 58/89] refactor: refs #6920 add correct role --- db/dump/fixtures.before.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 595027b09..f25a4aab4 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2454,7 +2454,7 @@ INSERT INTO `vn`.`workerTimeControl`(`userFk`, `timed`, `manual`, `direction`, ` INSERT INTO `vn`.`dmsType` (`id`, `name`, `readRoleFk`, `writeRoleFk`, `code`) VALUES - (1, 'Facturas Recibidas', NULL, NULL, 'invoiceIn'), + (1, 'Facturas Recibidas', 1, 1, 'invoiceIn'), (2, 'Doc oficial', NULL, NULL, 'officialDoc'), (3, 'Laboral', 37, 37, 'hhrrData'), (4, 'Albaranes recibidos', NULL, NULL, 'deliveryNote'), From c113d837972177d1fb2ce320847deb536d6ae7e3 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 5 Nov 2024 16:42:51 +0100 Subject: [PATCH 59/89] feat: refs #6845 userInterface --- .../vn/procedures/collection_getTickets.sql | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/db/routines/vn/procedures/collection_getTickets.sql b/db/routines/vn/procedures/collection_getTickets.sql index fed7a3eb6..a468d7582 100644 --- a/db/routines/vn/procedures/collection_getTickets.sql +++ b/db/routines/vn/procedures/collection_getTickets.sql @@ -30,7 +30,9 @@ BEGIN t.warehouseFk, w.id salesPersonFk, IFNULL(ob.description,'') observaciones, - cc.rgb + cc.rgb, + p.code parkingCode, + IF (ps.ticketFk, TRUE, FALSE) isAdvanced FROM vn.ticket t LEFT JOIN vn.ticketCollection tc ON t.id = tc.ticketFk LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk @@ -42,7 +44,10 @@ BEGIN LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk LEFT JOIN vn.client c ON c.id = t.clientFk LEFT JOIN vn.worker w ON w.id = c.salesPersonFk - LEFT JOIN observation ob ON ob.ticketFk = t.id + LEFT JOIN observation ob ON ob.ticketFk = t.id + LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id + LEFT JOIN vn.parking p ON tp.parkingFk = p.id + LEFT JOIN vn.packingSiteAdvanced ps ON ps.ticketFk = t.id WHERE t.id = vParamFk AND t.shipped >= vYesterday UNION @@ -52,7 +57,9 @@ BEGIN t.warehouseFk, w.id salesPersonFk, ob.description, - IF(NOT (vItemPackingTypeFk <=> 'V'), cc.rgb, NULL) `rgb` + IF(NOT (vItemPackingTypeFk <=> 'V'), cc.rgb, NULL) `rgb`, + p.code parkingCode, + IF (ps.ticketFk, TRUE, FALSE) isAdvanced FROM vn.ticket t JOIN vn.ticketCollection tc ON t.id = tc.ticketFk LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk @@ -64,7 +71,10 @@ BEGIN LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk LEFT JOIN vn.client c ON c.id = t.clientFk LEFT JOIN vn.worker w ON w.id = c.salesPersonFk - LEFT JOIN observation ob ON ob.ticketFk = t.id + LEFT JOIN observation ob ON ob.ticketFk = t.id + LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id + LEFT JOIN vn.parking p ON tp.parkingFk = p.id + LEFT JOIN vn.packingSiteAdvanced ps ON ps.ticketFk = t.id WHERE tc.collectionFk = vParamFk UNION SELECT sg.ticketFk, @@ -73,7 +83,9 @@ BEGIN t.warehouseFk, c.salesPersonFk, ob.description, - NULL `rgb` + NULL `rgb`, + p.code parkingCode, + IF (ps.ticketFk, TRUE, FALSE) isAdvanced FROM vn.sectorCollection sc JOIN vn.sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id JOIN vn.saleGroup sg ON sg.id = ss.saleGroupFk @@ -81,7 +93,10 @@ BEGIN LEFT JOIN vn.zone z ON z.id = t.zoneFk LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk LEFT JOIN observation ob ON ob.ticketFk = t.id - LEFT JOIN vn.client c ON c.id = t.clientFk + LEFT JOIN vn.client c ON c.id = t.clientFk + LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id + LEFT JOIN vn.parking p ON tp.parkingFk = p.id + LEFT JOIN vn.packingSiteAdvanced ps ON ps.ticketFk = t.id WHERE sc.id = vParamFk AND t.shipped >= vYesterday GROUP BY ticketFk; From d95e455ccf9ca542fd4e9b832e942bb0be1be966 Mon Sep 17 00:00:00 2001 From: jgallego Date: Thu, 7 Nov 2024 14:48:31 +0100 Subject: [PATCH 60/89] fix: refs #7935 sin modificar autonomy --- db/versions/11274-redGerbera/00-firstScript4.sql | 1 - 1 file changed, 1 deletion(-) delete mode 100644 db/versions/11274-redGerbera/00-firstScript4.sql diff --git a/db/versions/11274-redGerbera/00-firstScript4.sql b/db/versions/11274-redGerbera/00-firstScript4.sql deleted file mode 100644 index c1f574379..000000000 --- a/db/versions/11274-redGerbera/00-firstScript4.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE vn.autonomy MODIFY COLUMN isUeeMember tinyint(1) DEFAULT FALSE NOT NULL; \ No newline at end of file From fd36f7ecc3262b0c95381afc1ab5e6ff35d96d8c Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 8 Nov 2024 10:44:01 +0100 Subject: [PATCH 61/89] feat: refs #8150 movExpeditions --- modules/ticket/back/methods/expedition/moveExpeditions.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/expedition/moveExpeditions.js b/modules/ticket/back/methods/expedition/moveExpeditions.js index cef35ab86..1c6689912 100644 --- a/modules/ticket/back/methods/expedition/moveExpeditions.js +++ b/modules/ticket/back/methods/expedition/moveExpeditions.js @@ -13,7 +13,8 @@ module.exports = Self => { { arg: 'landed', type: 'date', - description: `The landing date` + description: `The landing date`, + required: true }, { arg: 'warehouseId', From 6927f4b28df4486277c11be1fc0e3760495b26a5 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 8 Nov 2024 11:51:00 +0100 Subject: [PATCH 62/89] feat: refs #6818 saysimple integration --- back/model-config.json | 3 +++ back/models/country.json | 7 ++++- back/models/say-simple-country.json | 26 +++++++++++++++++++ db/dump/fixtures.before.sql | 3 +++ .../11330-greenMoss/00-firstScript.sql | 6 +++++ modules/client/back/methods/client/summary.js | 5 +++- 6 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 back/models/say-simple-country.json create mode 100644 db/versions/11330-greenMoss/00-firstScript.sql diff --git a/back/model-config.json b/back/model-config.json index 5368769fd..efb148ee8 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -139,6 +139,9 @@ "StarredModule": { "dataSource": "vn" }, + "SaySimpleCountry": { + "dataSource": "vn" + }, "TempContainer": { "dataSource": "tempStorage" }, diff --git a/back/models/country.json b/back/models/country.json index 80d456702..ee72ae49d 100644 --- a/back/models/country.json +++ b/back/models/country.json @@ -44,6 +44,11 @@ "type": "belongsTo", "model": "Continent", "foreignKey": "continentFk" + }, + "saySimpleCountry": { + "type": "hasOne", + "model": "SaySimpleCountry", + "foreignKey": "countryFk" } }, "acls": [ @@ -54,4 +59,4 @@ "permission": "ALLOW" } ] -} +} \ No newline at end of file diff --git a/back/models/say-simple-country.json b/back/models/say-simple-country.json new file mode 100644 index 000000000..39acd5f0b --- /dev/null +++ b/back/models/say-simple-country.json @@ -0,0 +1,26 @@ +{ + "name": "SaySimpleCountry", + "base": "VnModel", + "options": { + "mysql": { + "table": "saySimpleCountry" + } + }, + "properties": { + "countryFk": { + "type": "number", + "id": true + }, + "channel": { + "type": "number" + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + } + ] +} \ No newline at end of file diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index f25a4aab4..7bb0ace84 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -4008,3 +4008,6 @@ UPDATE vn.department SET pbxQueue = '1000' WHERE name = "CAMARA"; UPDATE vn.department SET pbxQueue = '2000' WHERE name = "VENTAS"; +INSERT INTO vn.saySimpleCountry (countryFk, channel) + VALUES (19, 1169), + (8, 1183); \ No newline at end of file diff --git a/db/versions/11330-greenMoss/00-firstScript.sql b/db/versions/11330-greenMoss/00-firstScript.sql new file mode 100644 index 000000000..e0ef77e2d --- /dev/null +++ b/db/versions/11330-greenMoss/00-firstScript.sql @@ -0,0 +1,6 @@ +CREATE TABLE IF NOT EXISTS vn.saySimpleCountry( + countryFk MEDIUMINT(8) UNSIGNED, + channel INT(4) COMMENT 'channel de whatsapp de saySimple', + PRIMARY KEY (countryFk), + CONSTRAINT `saySimpleCountry_FK` FOREIGN KEY (`countryFk`) REFERENCES vn.country (`id`) ON UPDATE CASCADE +); \ No newline at end of file diff --git a/modules/client/back/methods/client/summary.js b/modules/client/back/methods/client/summary.js index 8162096f0..9242fbd44 100644 --- a/modules/client/back/methods/client/summary.js +++ b/modules/client/back/methods/client/summary.js @@ -54,7 +54,10 @@ module.exports = Self => { { relation: 'country', scope: { - fields: ['name'] + fields: ['id', 'name'], + include: { + relation: 'saySimpleCountry', + } } }, { From 9b28cf9130dff4346f627d1888a1f7de7cb4ddcd Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 8 Nov 2024 12:51:09 +0100 Subject: [PATCH 63/89] feat: refs #6818 add records --- db/dump/fixtures.before.sql | 2 +- db/versions/11330-greenMoss/00-firstScript.sql | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 7bb0ace84..ce4e9ddfc 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -4008,6 +4008,6 @@ UPDATE vn.department SET pbxQueue = '1000' WHERE name = "CAMARA"; UPDATE vn.department SET pbxQueue = '2000' WHERE name = "VENTAS"; -INSERT INTO vn.saySimpleCountry (countryFk, channel) +INSERT IGNORE INTO vn.saySimpleCountry (countryFk, channel) VALUES (19, 1169), (8, 1183); \ No newline at end of file diff --git a/db/versions/11330-greenMoss/00-firstScript.sql b/db/versions/11330-greenMoss/00-firstScript.sql index e0ef77e2d..762e456b1 100644 --- a/db/versions/11330-greenMoss/00-firstScript.sql +++ b/db/versions/11330-greenMoss/00-firstScript.sql @@ -3,4 +3,8 @@ CREATE TABLE IF NOT EXISTS vn.saySimpleCountry( channel INT(4) COMMENT 'channel de whatsapp de saySimple', PRIMARY KEY (countryFk), CONSTRAINT `saySimpleCountry_FK` FOREIGN KEY (`countryFk`) REFERENCES vn.country (`id`) ON UPDATE CASCADE -); \ No newline at end of file +); + +INSERT IGNORE INTO vn.saySimpleCountry (countryFk, channel) + VALUES (19, 1169), + (8, 1183); \ No newline at end of file From f8c3d69c5de7c144b17788dfee90f497811a12fd Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 8 Nov 2024 13:44:20 +0100 Subject: [PATCH 64/89] fix: refs #7404 remove volume from ticket sold on holland --- .../vn/procedures/stockBought_calculate.sql | 46 +++++++++++++++---- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/db/routines/vn/procedures/stockBought_calculate.sql b/db/routines/vn/procedures/stockBought_calculate.sql index 8b2a32e5d..5cd7d8859 100644 --- a/db/routines/vn/procedures/stockBought_calculate.sql +++ b/db/routines/vn/procedures/stockBought_calculate.sql @@ -13,7 +13,7 @@ proc: BEGIN LEAVE proc; END IF; - CREATE OR REPLACE TEMPORARY TABLE tStockBought + CREATE OR REPLACE TEMPORARY TABLE tCurrentData SELECT workerFk, reserve FROM stockBought WHERE dated = vDated @@ -21,15 +21,28 @@ proc: BEGIN DELETE FROM stockBought WHERE dated = vDated; + CREATE OR REPLACE TEMPORARY TABLE tStockSold + SELECT it.workerFk, + SUM(ic.cm3 * ito.quantity / vc.palletM3 / 1000000) sold + FROM itemTicketOut ito + JOIN item i ON i.id = ito.itemFk + JOIN itemType it ON it.id = i.typeFk + JOIN ticket t ON t.id = ito.ticketFk + JOIN warehouse wh ON wh.id = t.warehouseFk + JOIN itemCost ic ON ic.itemFk = ito.itemFk + AND ic.warehouseFk = t.warehouseFk + JOIN volumeConfig vc + WHERE ito.shipped BETWEEN vDated AND util.dayEnd(vDated) + AND wh.code = 'VNH' + GROUP BY it.workerFk; + CALL item_calculateStock(vDated); - INSERT INTO stockBought(workerFk, bought, dated) + CREATE OR REPLACE TEMPORARY TABLE tStockBought SELECT it.workerFk, - ROUND(SUM( - (ti.quantity / b.packing) * - buy_getVolume(b.id) - ) / vc.palletM3 / 1000000, 1) bought, - vDated + SUM((ti.quantity / b.packing) * + buy_getVolume(b.id) + ) / vc.palletM3 / 1000000 bought FROM itemType it JOIN item i ON i.typeFk = it.id LEFT JOIN tmp.item ti ON ti.itemFk = i.id @@ -43,20 +56,33 @@ proc: BEGIN GROUP BY it.workerFk HAVING bought; + + INSERT INTO stockBought(workerFk, bought, dated) + SELECT tb.workerFk, + ROUND(GREATEST(tb.bought - IFNULL(ts.sold, 0), 0), 1), + vDated + FROM tStockBought tb + LEFT JOIN tStockSold ts ON ts.workerFk = tb.workerFk; + UPDATE stockBought s - JOIN tStockBought ts ON ts.workerFk = s.workerFk + JOIN tCurrentData ts ON ts.workerFk = s.workerFk SET s.reserve = ts.reserve WHERE s.dated = vDated; INSERT INTO stockBought (workerFk, reserve, dated) SELECT ts.workerFk, ts.reserve, vDated - FROM tStockBought ts + FROM tCurrentData ts WHERE ts.workerFk NOT IN ( SELECT workerFk FROM stockBought WHERE dated = vDated ); - DROP TEMPORARY TABLE tStockBought, tmp.item, tmp.buyUltimate; + UPDATE stockBought s + JOIN tStockSold ts ON ts.workerFk = s.workerFk + SET s.bought = IF(s.bought < ts.sold, ROUND(s.bought - ts.sold, 1), 0) + WHERE s.dated = vDated; + + DROP TEMPORARY TABLE tCurrentData, tmp.item, tmp.buyUltimate, tStockSold; END$$ DELIMITER ; From 6ef1f950d17897d377cc9fb342835f4a3e745543 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 8 Nov 2024 17:47:10 +0100 Subject: [PATCH 65/89] feat: refs #6818 add config table --- back/model-config.json | 3 +++ back/models/say-simple-config.json | 26 +++++++++++++++++++ back/models/say-simple-country.json | 2 +- db/dump/fixtures.before.sql | 6 ++++- .../11330-greenMoss/00-firstScript.sql | 8 +++++- 5 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 back/models/say-simple-config.json diff --git a/back/model-config.json b/back/model-config.json index efb148ee8..364ffabdf 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -142,6 +142,9 @@ "SaySimpleCountry": { "dataSource": "vn" }, + "SaySimpleConfig": { + "dataSource": "vn" + }, "TempContainer": { "dataSource": "tempStorage" }, diff --git a/back/models/say-simple-config.json b/back/models/say-simple-config.json new file mode 100644 index 000000000..edc4caa43 --- /dev/null +++ b/back/models/say-simple-config.json @@ -0,0 +1,26 @@ +{ + "name": "SaySimpleConfig", + "base": "VnModel", + "options": { + "mysql": { + "table": "saySimpleConfig" + } + }, + "properties": { + "id": { + "type": "number", + "id": true + }, + "url": { + "type": "string" + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$authenticated", + "permission": "ALLOW" + } + ] +} \ No newline at end of file diff --git a/back/models/say-simple-country.json b/back/models/say-simple-country.json index 39acd5f0b..adddddc02 100644 --- a/back/models/say-simple-country.json +++ b/back/models/say-simple-country.json @@ -19,7 +19,7 @@ { "accessType": "READ", "principalType": "ROLE", - "principalId": "$everyone", + "principalId": "$authenticated", "permission": "ALLOW" } ] diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index ce4e9ddfc..cd2fb8b6b 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -4010,4 +4010,8 @@ UPDATE vn.department SET pbxQueue = '2000' WHERE name = "VENTAS"; INSERT IGNORE INTO vn.saySimpleCountry (countryFk, channel) VALUES (19, 1169), - (8, 1183); \ No newline at end of file + (8, 1183), + (NULL, 1320); + +INSERT IGNORE INTO vn.saySimpleConfig (url) + VALUES ('saysimle-url-mock'); \ No newline at end of file diff --git a/db/versions/11330-greenMoss/00-firstScript.sql b/db/versions/11330-greenMoss/00-firstScript.sql index 762e456b1..127c8e40e 100644 --- a/db/versions/11330-greenMoss/00-firstScript.sql +++ b/db/versions/11330-greenMoss/00-firstScript.sql @@ -5,6 +5,12 @@ CREATE TABLE IF NOT EXISTS vn.saySimpleCountry( CONSTRAINT `saySimpleCountry_FK` FOREIGN KEY (`countryFk`) REFERENCES vn.country (`id`) ON UPDATE CASCADE ); +CREATE TABLE IF NOT EXISTS vn.saySimpleConfig( + id INT AUTO_INCREMENT PRIMARY KEY, + url VARCHAR(255) NOT NULL +); + INSERT IGNORE INTO vn.saySimpleCountry (countryFk, channel) VALUES (19, 1169), - (8, 1183); \ No newline at end of file + (8, 1183), + (NULL, 1320); \ No newline at end of file From a254cb19cda0fd44fdbe6cf668924f39a57a92e2 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 11 Nov 2024 07:40:17 +0100 Subject: [PATCH 66/89] feat: refs #4948 Added ticket_selfConsumptionPackaging --- .../expedition_selfConsumptionPackaging.sql | 93 +++++++++++++++++++ .../vn/triggers/expedition_afterDelete.sql | 2 + 2 files changed, 95 insertions(+) create mode 100644 db/routines/vn/procedures/expedition_selfConsumptionPackaging.sql diff --git a/db/routines/vn/procedures/expedition_selfConsumptionPackaging.sql b/db/routines/vn/procedures/expedition_selfConsumptionPackaging.sql new file mode 100644 index 000000000..43660f215 --- /dev/null +++ b/db/routines/vn/procedures/expedition_selfConsumptionPackaging.sql @@ -0,0 +1,93 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`expedition_selfConsumptionPackaging`( + vSelf INT, + vAction ENUM('add', 'remove') +) +BEGIN +/** + * Maneja el consumo de cajas para autoconsumo, permitiendo + * añadir o quitar cajas utilizadas según la acción indicada. + * + * @param vSelf Id de expedición + */ + DECLARE vClientFk INT; + DECLARE vAddressFk INT; + DECLARE vItemFk INT; + DECLARE vItemName VARCHAR(50); + DECLARE vWarehouseFk INT; + DECLARE vCreated DATE; + DECLARE vTicketFk INT; + DECLARE vSaleFk INT; + DECLARE vQuantity INT; + + IF vAction NOT IN ('add', 'remove') THEN + CALL util.throw('Action not supported'); + END IF; + + SELECT pc.clientSelfConsumptionFk, + pc.addressSelfConsumptionFk, + i.id, + i.name, + t.warehouseFk, + e.created + INTO vClientFk, + vAddressFk, + vItemFk, + vItemName, + vWarehouseFk, + vCreated + FROM expedition e + JOIN packaging p ON p.id = e.packagingFk + JOIN item i ON i.id = p.itemFk + JOIN ticket t ON t.id = e.ticketFk + JOIN productionConfig pc + WHERE e.id = vSelf; + + IF vClientFk IS NULL OR vAddressFk IS NULL THEN + CALL util.throw('Some config parameters are not set'); + END IF; + + SET vCreated = DATE(vCreated); + + SELECT id INTO vTicketFk + FROM ticket + WHERE shipped BETWEEN vCreated AND util.dayEnd(vCreated) + AND clientFk = vClientFk + AND addressFk = vAddressFk + AND warehouseFk = vWarehouseFk; + + IF vTicketFk IS NULL AND vAction = 'add' THEN + INSERT INTO ticket(clientFk, warehouseFk, shipped, nickname, addressFk) + VALUES (vClientFk, vWarehouseFk, vCreated, 'CAJAS AUTOCONSUMO', vAddressFk); + + SET vTicketFk = LAST_INSERT_ID(); + END IF; + + SELECT id, quantity INTO vSaleFk, vQuantity + FROM sale + WHERE itemFk = vItemFk + AND ticketFk = vTicketFk + LIMIT 1; + + IF vAction = 'add' THEN + IF vSaleFk IS NOT NULL THEN + UPDATE sale + SET quantity = quantity + 1 + WHERE id = vSaleFk; + ELSE + INSERT INTO sale(itemFk, ticketFk, concept, quantity) + VALUES (vItemFk, vTicketFk, vItemName, 1); + END IF; + ELSE + IF vSaleFk IS NOT NULL THEN + IF vQuantity > 1 THEN + UPDATE sale + SET quantity = quantity - 1 + WHERE id = vSaleFk; + ELSE + DELETE FROM sale WHERE id = vSaleFk; + END IF; + END IF; + END IF; +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/expedition_afterDelete.sql b/db/routines/vn/triggers/expedition_afterDelete.sql index 5d74a71e5..0a9a37375 100644 --- a/db/routines/vn/triggers/expedition_afterDelete.sql +++ b/db/routines/vn/triggers/expedition_afterDelete.sql @@ -8,5 +8,7 @@ BEGIN `changedModel` = 'Expedition', `changedModelId` = OLD.id, `userFk` = account.myUser_getId(); + + CALL expedition_selfConsumptionPackaging(OLD.id, 'remove'); END$$ DELIMITER ; From 94ed23ca07fbe1cf8d2f3c5769ed309bd8d4303f Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 11 Nov 2024 07:51:26 +0100 Subject: [PATCH 67/89] feat: refs #8169 modifica role --- db/versions/11324-salmonCataractarum/00-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11324-salmonCataractarum/00-firstScript.sql b/db/versions/11324-salmonCataractarum/00-firstScript.sql index 3a528382a..5c17ed549 100644 --- a/db/versions/11324-salmonCataractarum/00-firstScript.sql +++ b/db/versions/11324-salmonCataractarum/00-firstScript.sql @@ -68,4 +68,4 @@ UPDATE vn.tag sourceTable='itemTextureTag' WHERE name= 'Textura'; -GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemFarmingTag TO logisticAssist; \ No newline at end of file +GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemTextureTag TO logisticAssist; From 35f4f161ab6cd4ef8f6cc6b179bae88012d4220c Mon Sep 17 00:00:00 2001 From: Pako Date: Mon, 11 Nov 2024 09:02:04 +0100 Subject: [PATCH 68/89] fix(collection_new): remove agency condition for suitable tickets Refs: #0000 --- db/routines/vn/procedures/collection_new.sql | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index f04d5241e..36e837869 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -173,8 +173,6 @@ BEGIN DELETE pb.* FROM tmp.productionBuffer pb JOIN state s ON s.id = pb.state - JOIN agencyMode am ON am.id = pb.agencyModeFk - JOIN agency a ON a.id = am.agencyFk LEFT JOIN ( SELECT pb.ticketFk, MAX(i.`size`) maxSize FROM tmp.productionBuffer pb @@ -185,7 +183,7 @@ BEGIN ) sub ON sub.ticketFk = pb.ticketFk JOIN productionConfig pc WHERE pb.shipped <> util.VN_CURDATE() - OR (pb.ubicacion IS NULL AND a.isOwn) + OR pb.ubicacion IS NULL OR (NOT s.isPreparable AND NOT s.isPrintable) OR pb.collectionH IS NOT NULL OR pb.collectionV IS NOT NULL From f7a29cd9c79bfe605e9c938da41ad5780c4a40b6 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 11 Nov 2024 10:32:17 +0100 Subject: [PATCH 69/89] feat(Supplier): refs #6828 add companySize --- db/dump/fixtures.before.sql | 3 ++- db/versions/11331-bronzeBirch/00-firstScript.sql | 2 ++ modules/supplier/back/methods/supplier/getSummary.js | 3 ++- modules/supplier/back/models/supplier.json | 3 +++ 4 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 db/versions/11331-bronzeBirch/00-firstScript.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index f25a4aab4..c9b6a2206 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2476,7 +2476,8 @@ INSERT INTO `vn`.`dmsType` (20, 'Reclamación', 1, 1, 'claim'), (21, 'Entrada', 1, 1, 'entry'), (22, 'Proveedor', 1, 1, 'supplier'), - (23, 'Termografos', 35, 35, 'thermograph'); + (23, 'Termografos', 35, 35, 'thermograph'), + (24, 'Sello de calidad', 1, 1, 'qualitySeal'); INSERT INTO `vn`.`dms`(`id`, `dmsTypeFk`, `file`, `contentType`, `workerFk`, `warehouseFk`, `companyFk`, `hardCopyNumber`, `hasFile`, `reference`, `description`, `created`) VALUES diff --git a/db/versions/11331-bronzeBirch/00-firstScript.sql b/db/versions/11331-bronzeBirch/00-firstScript.sql new file mode 100644 index 000000000..ada374182 --- /dev/null +++ b/db/versions/11331-bronzeBirch/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.supplier ADD companySize ENUM('small', 'medium', 'big') NULL; + diff --git a/modules/supplier/back/methods/supplier/getSummary.js b/modules/supplier/back/methods/supplier/getSummary.js index 67767e7b4..8fcaaa53f 100644 --- a/modules/supplier/back/methods/supplier/getSummary.js +++ b/modules/supplier/back/methods/supplier/getSummary.js @@ -43,7 +43,8 @@ module.exports = Self => { 'sageWithholdingFk', 'workerFk', 'supplierActivityFk', - 'healthRegister' + 'healthRegister', + 'companySize' ], include: [ { diff --git a/modules/supplier/back/models/supplier.json b/modules/supplier/back/models/supplier.json index 90b266ba9..b79a6b80d 100644 --- a/modules/supplier/back/models/supplier.json +++ b/modules/supplier/back/models/supplier.json @@ -113,6 +113,9 @@ }, "isVies": { "type": "boolean" + }, + "companySize": { + "type": "string" } }, "relations": { From 0dc77851c007d22a9c83086e11dea0e05e96251b Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 11 Nov 2024 11:34:37 +0100 Subject: [PATCH 70/89] fix: refs #4948 Tests --- db/dump/fixtures.before.sql | 4 ++-- db/routines/vn/triggers/expedition_afterDelete.sql | 2 -- db/routines/vn/triggers/expedition_beforeDelete.sql | 3 ++- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index f25a4aab4..b0fb3a8d9 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2954,9 +2954,9 @@ 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`, `backupPrinterNotificationDelay`) +INSERT INTO `vn`.`productionConfig` (`isPreviousPreparationRequired`, `ticketPrintedMax`, `ticketTrolleyMax`, `rookieDays`, `notBuyingMonths`, `id`, `isZoneClosedByExpeditionActivated`, `maxNotReadyCollections`, `minTicketsToCloseZone`, `movingTicketDelRoute`, `defaultZone`, `defautlAgencyMode`, `hasUniqueCollectionTime`, `maxCollectionWithoutUser`, `pendingCollectionsOrder`, `pendingCollectionsAge`, `backupPrinterNotificationDelay`, `clientSelfConsumptionFk`, `addressSelfConsumptionFk`) VALUES - (0, 8, 80, 0, 0, 1, 0, 15, 25, -1, 697, 1328, 0, 1, 8, 6, 3600); + (0, 8, 80, 0, 0, 1, 0, 15, 25, -1, 697, 1328, 0, 1, 8, 6, 3600, 1112, 12); INSERT INTO `vn`.`collection` (`id`, `created`, `workerFk`, `stateFk`, `itemPackingTypeFk`, `saleTotalCount`, `salePickedCount`, `trainFk`, `sectorFk`, `wagons`) VALUES diff --git a/db/routines/vn/triggers/expedition_afterDelete.sql b/db/routines/vn/triggers/expedition_afterDelete.sql index 0a9a37375..5d74a71e5 100644 --- a/db/routines/vn/triggers/expedition_afterDelete.sql +++ b/db/routines/vn/triggers/expedition_afterDelete.sql @@ -8,7 +8,5 @@ BEGIN `changedModel` = 'Expedition', `changedModelId` = OLD.id, `userFk` = account.myUser_getId(); - - CALL expedition_selfConsumptionPackaging(OLD.id, 'remove'); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/expedition_beforeDelete.sql b/db/routines/vn/triggers/expedition_beforeDelete.sql index 13ba19631..60d3a6ca1 100644 --- a/db/routines/vn/triggers/expedition_beforeDelete.sql +++ b/db/routines/vn/triggers/expedition_beforeDelete.sql @@ -7,6 +7,7 @@ BEGIN SET packages = (SELECT COUNT(counter)-1 FROM expedition e WHERE e.ticketFk = OLD.ticketFk and e.freightItemFk) WHERE t.id = OLD.ticketFk; - + + CALL expedition_selfConsumptionPackaging(OLD.id, 'remove'); END$$ DELIMITER ; From eaad989b3afaec94f31815516ad3dcfe8d4488e7 Mon Sep 17 00:00:00 2001 From: jgallego Date: Mon, 11 Nov 2024 13:57:49 +0100 Subject: [PATCH 71/89] fix: clean deletes also zoneEvent range records --- db/routines/vn/procedures/clean.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/clean.sql b/db/routines/vn/procedures/clean.sql index d3fed0242..fcee33c97 100644 --- a/db/routines/vn/procedures/clean.sql +++ b/db/routines/vn/procedures/clean.sql @@ -56,7 +56,7 @@ BEGIN AND ts.id IS NULL; DELETE FROM claim WHERE ticketCreated < v4Years; -- Robert ubicacion anterior de travelLog comentario para debug - DELETE FROM zoneEvent WHERE `type` = 'day' AND dated < v3Months; + DELETE FROM zoneEvent WHERE dated < v2Months OR ended < v2Months; DELETE b FROM buy b JOIN entryConfig e ON e.defaultEntry = b.entryFk WHERE b.created < v2Months; From 2dd3ae1c751ec0ad0e9cf662ae701a87f067e32f Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 12 Nov 2024 07:23:46 +0100 Subject: [PATCH 72/89] fix: refs #7404 empty commit --- db/routines/vn/procedures/stockBought_calculate.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/stockBought_calculate.sql b/db/routines/vn/procedures/stockBought_calculate.sql index 5cd7d8859..ba044604a 100644 --- a/db/routines/vn/procedures/stockBought_calculate.sql +++ b/db/routines/vn/procedures/stockBought_calculate.sql @@ -7,7 +7,7 @@ proc: BEGIN * Calculate the stock of the auction warehouse from the inventory date to vDated * without taking into account the outputs of the same day vDated * - * @param vDated Date to calculate the stock. + * @param vDated Date to calculate the stock */ IF vDated < util.VN_CURDATE() THEN LEAVE proc; From 315864403260623fede9f0471ef3d9036faf23b1 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 12 Nov 2024 07:59:07 +0100 Subject: [PATCH 73/89] fix: refs #7994 commented alter --- db/versions/11251-navyChrysanthemum/01-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11251-navyChrysanthemum/01-firstScript.sql b/db/versions/11251-navyChrysanthemum/01-firstScript.sql index e3e08e0aa..c942e0400 100644 --- a/db/versions/11251-navyChrysanthemum/01-firstScript.sql +++ b/db/versions/11251-navyChrysanthemum/01-firstScript.sql @@ -1 +1 @@ -ALTER TABLE vn.sale MODIFY COLUMN originalQuantity decimal(10,2) DEFAULT 0.00 NOT NULL COMMENT 'Se utiliza para notificar a través de rocket los cambios de quantity'; \ No newline at end of file +-- ALTER TABLE vn.sale MODIFY COLUMN originalQuantity decimal(10,2) DEFAULT 0.00 NOT NULL COMMENT 'Se utiliza para notificar a través de rocket los cambios de quantity'; \ No newline at end of file From 76d072e00f8e8ba5689ac4f3fd1273125403b333 Mon Sep 17 00:00:00 2001 From: Pako Date: Tue, 12 Nov 2024 08:28:26 +0100 Subject: [PATCH 74/89] fix: more data for fixture.before --- db/dump/fixtures.before.sql | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index bb620ac49..8544686e8 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -400,11 +400,11 @@ INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city (1108, 'Charles Xavier', '22641921P', 'PROFESSOR X', 'Beast', '3800 VICTORY PKWY, CINCINNATI, OH 45207, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 5, 1, 300, 13, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, NULL, 0, 0, 19, 0, 'florist','normal'), (1109, 'Bruce Banner', '16104829E', 'HULK', 'Black widow', 'SOMEWHERE IN NEW YORK', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 0, 0, NULL, 0, 0, 9, 0, 'florist','normal'), (1110, 'Jessica Jones', '58282869H', 'JESSICA JONES', 'Luke Cage', 'NYCC 2015 POSTER', 'Gotham', 46460, 1111111111, 222222222, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, NULL, 1, 'florist','normal'), - (1111, 'Missing', NULL, 'MISSING MAN', 'Anton', 'THE SPACE, UNIVERSE FAR AWAY', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, 'others','loses'), - (1112, 'Trash', NULL, 'GARBAGE MAN', 'Unknown name', 'NEW YORK CITY, UNDERGROUND', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, 'others','loses'); + (1111, 'Missing', NULL, 'MISSING MAN', 'Anton', 'THE SPACE, UNIVERSE FAR AWAY', 'Gotham', 46460, 1111111111, 222222222, 0, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, 'others','loses'), + (1112, 'Trash', NULL, 'GARBAGE MAN', 'Unknown name', 'NEW YORK CITY, UNDERGROUND', 'Gotham', 46460, 1111111111, 222222222, 0, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, 'others','loses'); INSERT INTO `vn`.`client`(`id`, `name`, `fi`, `socialName`, `contact`, `street`, `city`, `postcode`, `isRelevant`, `email`, `iban`,`dueDay`,`accountingAccount`, `isEqualizated`, `provinceFk`, `hasToInvoice`, `credit`, `countryFk`, `isActive`, `quality`, `payMethodFk`,`created`, `isTaxDataChecked`) - SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), UPPER(CONCAT(name, 'Social')), CONCAT(name, 'Contact'), UPPER(CONCAT(name, 'Street')), 'GOTHAM', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1 + SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), UPPER(CONCAT(name, 'Social')), CONCAT(name, 'Contact'), UPPER(CONCAT(name, 'Street')), 'GOTHAM', 46460, 0, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1 FROM `account`.`role` `r` WHERE `r`.`hasLogin` = 1; @@ -4008,4 +4008,17 @@ INSERT IGNORE INTO pbx.queueMember UPDATE vn.department SET pbxQueue = '1000' WHERE name = "CAMARA"; UPDATE vn.department SET pbxQueue = '2000' WHERE name = "VENTAS"; +INSERT INTO srt.buffer (id, x, y, `size`, `length`, stateFk, typeFk, isActive, code, stratus, hasWorkerWaiting, reserve, routeFk, dayMinute, lastUnloaded, hasStrapper, typeDefaultFk, motors, editorFk) + VALUES (0, 0, 0, 0, NULL, 3, 1, 0, 'ENT', 0, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL), + (1, 0, 9900, 0, NULL, 1, 0, 0, 'NOK', 0, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL), + (2, 0, 0, 450, 13000, 1, 0, 1, '01A', 1, 1, NULL, NULL, NULL, NULL, 0, 1, 1, NULL), + (3, 1400, 0, 450, 13000, 1, 0, 1, '01B', 1, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL), + (4, 0, 500, 500, 13000, 1, 4, 1, '02A', 2, 1, NULL, NULL, NULL, NULL, 1, 4, 13, NULL), + (5, 1400, 500, 500, 13000, 1, 4, 1, '02B', 2, 1, NULL, NULL, NULL, NULL, 1, 4, 13, NULL), + (6, 0, 1000, 500, 13000, 1, 1, 1, '03A', 3, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL), + (7, 1400, 1000, 500, 13000, 1, 1, 1, '03B', 3, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL), + (8, 0, 1500, 500, 13000, 1, 0, 1, '04A', 4, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL), + (9, 1400, 1500, 500, 13000, 1, 1, 1, '04B', 4, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL), + (10, 0, 2000, 500, 13000, 1, 1, 1, '05A', 5, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL); + From 07e59ccdbf1c9845ef22a46b3b418192258c5637 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 12 Nov 2024 08:45:40 +0100 Subject: [PATCH 75/89] build: refs #8179 dump --- db/dump/.dump/data.sql | 113 +- db/dump/.dump/privileges.sql | 37 +- db/dump/.dump/structure.sql | 2150 ++++++++++++++++++++-------------- db/dump/.dump/triggers.sql | 65 +- 4 files changed, 1413 insertions(+), 952 deletions(-) diff --git a/db/dump/.dump/data.sql b/db/dump/.dump/data.sql index ca254055b..d0824e392 100644 --- a/db/dump/.dump/data.sql +++ b/db/dump/.dump/data.sql @@ -4,7 +4,7 @@ USE `util`; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -INSERT INTO `version` VALUES ('vn-database','11278','fe10f03459a153fc213bf64e352804c043f94590','2024-10-03 07:47:47','11281'); +INSERT INTO `version` VALUES ('vn-database','11311','315864403260623fede9f0471ef3d9036faf23b1','2024-11-12 08:00:59','11336'); INSERT INTO `versionLog` VALUES ('vn-database','10107','00-firstScript.sql','jenkins@10.0.2.69','2022-04-23 10:53:53',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10112','00-firstScript.sql','jenkins@10.0.2.69','2022-05-09 09:14:53',NULL,NULL); @@ -988,6 +988,7 @@ INSERT INTO `versionLog` VALUES ('vn-database','11194','00-firstScript.sql','jen INSERT INTO `versionLog` VALUES ('vn-database','11195','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:58:01',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11196','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-18 07:28:14',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11197','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:58:01',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11198','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 07:42:49',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11201','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-08-27 13:04:26',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11204','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:58:01',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11205','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-04 13:54:55',NULL,NULL); @@ -1013,6 +1014,7 @@ INSERT INTO `versionLog` VALUES ('vn-database','11225','01-firstScript.sql','jen INSERT INTO `versionLog` VALUES ('vn-database','11225','02-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:41',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11227','00-addWorkerTimeControlMailAcl.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:41',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11229','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-16 08:24:17',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11230','00-addClientObservationType.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 07:42:52',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11234','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:42',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11235','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:43',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11236','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:43',NULL,NULL); @@ -1021,18 +1023,53 @@ INSERT INTO `versionLog` VALUES ('vn-database','11237','00-firstScript.sql','jen INSERT INTO `versionLog` VALUES ('vn-database','11239','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-17 12:57:06',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11240','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:43',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11241','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-20 09:08:25',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11242','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 07:42:52',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11246','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-18 12:39:53',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11247','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-19 12:10:08',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11248','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-23 11:12:17',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11249','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:43',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11251','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 07:43:38',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11251','01-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 07:57:30',NULL,'Connection lost: The server closed the connection.'); INSERT INTO `versionLog` VALUES ('vn-database','11253','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-20 14:41:27',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11254','00-thermographTemperature.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:13',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11254','01-thermographFk.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:15',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11255','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:43',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11256','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-23 12:18:24',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11258','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:15',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11260','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:15',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11261','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:15',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11262','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:43',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11263','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-27 12:05:32',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11264','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:15',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11271','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:15',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11272','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:15',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11273','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 10:50:51',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11274','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:16',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11274','00-firstScript2.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:29',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11274','00-firstScript3.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:30',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11274','00-firstScript5.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:35',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11274','00-firstScript6.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:35',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11274','00-firstScript7.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:36',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11277','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:36',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11278','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:43',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11279','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-10-02 08:05:24',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11280','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-02 08:46:50',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11281','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:36',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11283','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:36',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11284','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:36',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11285','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:37',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11287','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:37',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11288','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-10 08:26:34',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11289','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-15 07:01:33',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11290','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:37',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11291','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-17 09:10:30',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11294','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:37',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11295','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-10 08:45:13',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11298','00-closure.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:37',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11300','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-18 08:27:05',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11302','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:57',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11308','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-23 12:41:55',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11311','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:57',NULL,NULL); /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; @@ -1407,6 +1444,8 @@ INSERT INTO `roleInherit` VALUES (376,124,21,19336); INSERT INTO `roleInherit` VALUES (377,47,49,19295); INSERT INTO `roleInherit` VALUES (378,101,15,19294); INSERT INTO `roleInherit` VALUES (379,103,121,19294); +INSERT INTO `roleInherit` VALUES (381,119,123,19295); +INSERT INTO `roleInherit` VALUES (382,48,72,783); INSERT INTO `userPassword` VALUES (1,7,1,0,2,1); @@ -2175,7 +2214,6 @@ INSERT INTO `ACL` VALUES (892,'WorkerIncome','*','*','ALLOW','ROLE','hr',NULL); INSERT INTO `ACL` VALUES (893,'PayrollComponent','*','*','ALLOW','ROLE','hr',NULL); INSERT INTO `ACL` VALUES (894,'Worker','__get__incomes','*','ALLOW','ROLE','hr',NULL); INSERT INTO `ACL` VALUES (895,'ItemShelvingLog','*','READ','ALLOW','ROLE','production',NULL); -INSERT INTO `ACL` VALUES (897,'WorkerLog','*','READ','ALLOW','ROLE','employee',NULL); INSERT INTO `ACL` VALUES (901,'WorkerTimeControl','sendMail','WRITE','ALLOW','ROLE','system',NULL); INSERT INTO `ACL` VALUES (902,'Entry','filter','READ','ALLOW','ROLE','supplier',NULL); INSERT INTO `ACL` VALUES (903,'Entry','getBuys','READ','ALLOW','ROLE','supplier',NULL); @@ -2191,7 +2229,6 @@ INSERT INTO `ACL` VALUES (912,'Worker','__get__medicalReview','*','ALLOW','ROLE' INSERT INTO `ACL` VALUES (913,'VnToken','*','READ','ALLOW','ROLE','developer',10578); INSERT INTO `ACL` VALUES (914,'VnToken','killSession','*','ALLOW','ROLE','developer',10578); INSERT INTO `ACL` VALUES (915,'ACL','*','WRITE','ALLOW','ROLE','developerBoss',10578); -INSERT INTO `ACL` VALUES (916,'Entry','getBuysCsv','READ','ALLOW','ROLE','supplier',10578); INSERT INTO `ACL` VALUES (917,'InvoiceOut','refundAndInvoice','WRITE','ALLOW','ROLE','administrative',10578); INSERT INTO `ACL` VALUES (918,'Worker','__get__descriptor','READ','ALLOW','ROLE','employee',10578); INSERT INTO `ACL` VALUES (919,'Worker','findById','READ','ALLOW','ROLE','employee',10578); @@ -2213,6 +2250,7 @@ INSERT INTO `ACL` VALUES (935,'BankEntity','*','WRITE','ALLOW','ROLE','financial INSERT INTO `ACL` VALUES (936,'Device','handleUser','*','ALLOW','ROLE','employee',10578); INSERT INTO `ACL` VALUES (937,'WorkerTimeControlMail','count','READ','ALLOW','ROLE','employee',10578); INSERT INTO `ACL` VALUES (938,'Worker','__get__mail','READ','ALLOW','ROLE','hr',10578); +INSERT INTO `ACL` VALUES (939,'Machine','*','*','ALLOW','ROLE','productionBoss',10578); INSERT INTO `fieldAcl` VALUES (1,'Client','name','update','employee'); INSERT INTO `fieldAcl` VALUES (2,'Client','contact','update','employee'); @@ -2408,6 +2446,8 @@ INSERT INTO `claimResponsible` VALUES (22,'Paletizadores',0,'pal'); INSERT INTO `claimResponsible` VALUES (23,'Preparación Previa',0,'pre'); INSERT INTO `claimResponsible` VALUES (24,'Almacén PCA',0,'war'); INSERT INTO `claimResponsible` VALUES (25,'Huelga',0,'str'); +INSERT INTO `claimResponsible` VALUES (27,'Prep. por caja',0,''); +INSERT INTO `claimResponsible` VALUES (45,'Negativo',0,'neg'); INSERT INTO `claimReason` VALUES (1,'Prisas',0); INSERT INTO `claimReason` VALUES (2,'Novato',0); @@ -2450,6 +2490,9 @@ INSERT INTO `claimReason` VALUES (52,'Mala gestión comercial',0); INSERT INTO `claimReason` VALUES (53,'Mala gestión comprador',0); INSERT INTO `claimReason` VALUES (54,'A2',0); INSERT INTO `claimReason` VALUES (55,'Entrega 48h o más',0); +INSERT INTO `claimReason` VALUES (56,'Error cliente',0); +INSERT INTO `claimReason` VALUES (57,'A2/B1',0); +INSERT INTO `claimReason` VALUES (58,'Seguro',0); INSERT INTO `claimRedelivery` VALUES (1,'Cliente'); INSERT INTO `claimRedelivery` VALUES (2,'No dev./No especif.'); @@ -2457,6 +2500,7 @@ INSERT INTO `claimRedelivery` VALUES (3,'Reparto'); INSERT INTO `claimRedelivery` VALUES (4,'Agencia'); INSERT INTO `claimRedelivery` VALUES (5,'Tour'); INSERT INTO `claimRedelivery` VALUES (6,'Fuera Peninsula'); +INSERT INTO `claimRedelivery` VALUES (7,'Francia'); INSERT INTO `claimResult` VALUES (1,'Otros daños'); INSERT INTO `claimResult` VALUES (2,'Roces'); @@ -2534,39 +2578,39 @@ INSERT INTO `continent` VALUES (3,'África','AF'); INSERT INTO `continent` VALUES (4,'Europa','EU'); INSERT INTO `continent` VALUES (5,'Oceanía','OC'); -INSERT INTO `department` VALUES (1,'VN','VERDNATURA',1,114,763,0,0,0,0,26,NULL,'/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (1,'VN','VERDNATURA',1,116,763,0,0,0,0,26,NULL,'/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (22,'shopping','COMPRAS',2,5,NULL,72,0,0,1,1,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (23,'CMA','CAMARA',15,16,NULL,72,1,1,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,1,NULL,NULL,NULL,'PREVIOUS'); -INSERT INTO `department` VALUES (31,'it','INFORMATICA',6,7,NULL,72,0,0,1,0,1,'/1/','informatica-cau',1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (34,'accounting','CONTABILIDAD',8,9,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (35,'finance','FINANZAS',10,11,NULL,0,0,0,1,0,1,'/1/',NULL,1,'begonya@verdnatura.es',1,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (36,'labor','LABORAL',12,13,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (31,'it','INFORMATICA',6,7,NULL,72,0,0,1,0,1,'/1/','informatica-cau',1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (34,'accounting','CONTABILIDAD',8,9,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (35,'finance','FINANZAS',10,11,NULL,0,0,0,1,0,1,'/1/',NULL,1,'begonya@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (36,'labor','LABORAL',12,13,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (37,'PROD','PRODUCCION',14,37,NULL,72,1,1,1,11,1,'/1/',NULL,0,NULL,0,1,1,1,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (38,'picking','SACADO',17,18,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,'ON_PREPARATION'); +INSERT INTO `department` VALUES (38,'picking','SACADO',17,18,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,0,1,NULL,NULL,NULL,'ON_PREPARATION'); INSERT INTO `department` VALUES (39,'packing','ENCAJADO',19,20,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,'PACKING'); -INSERT INTO `department` VALUES (41,'administration','ADMINISTRACION',38,39,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (43,'VT','VENTAS',40,73,NULL,0,0,0,1,16,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (44,'management','GERENCIA',74,75,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (45,'logistic','LOGISTICA',76,77,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (46,'delivery','REPARTO',78,79,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,'DELIVERY'); -INSERT INTO `department` VALUES (48,'storage','ALMACENAJE',80,81,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'STORAGE'); -INSERT INTO `department` VALUES (49,NULL,'PROPIEDAD',82,83,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (52,NULL,'CARGA AEREA',84,85,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (53,'marketing','MARKETING Y COMUNICACIÓN',41,42,NULL,72,0,0,2,0,43,'/1/43/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (54,NULL,'ORNAMENTALES',86,87,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (41,'administration','ADMINISTRACION',38,39,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (43,'VT','VENTAS',40,75,NULL,0,0,0,1,17,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (44,'management','GERENCIA',76,77,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (45,'logistic','LOGISTICA',78,79,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (46,'delivery','REPARTO',80,81,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,'DELIVERY'); +INSERT INTO `department` VALUES (48,'storage','ALMACENAJE',82,83,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'STORAGE'); +INSERT INTO `department` VALUES (49,NULL,'PROPIEDAD',84,85,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (52,NULL,'CARGA AEREA',86,87,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (53,'marketing','MARKETING Y COMUNICACIÓN',41,42,NULL,72,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (54,NULL,'ORNAMENTALES',88,89,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (55,NULL,'TALLER NATURAL',21,22,14548,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1118,NULL,NULL,NULL); INSERT INTO `department` VALUES (56,NULL,'TALLER ARTIFICIAL',23,24,8470,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1927,NULL,NULL,NULL); -INSERT INTO `department` VALUES (58,'CMP','CAMPOS',88,91,NULL,72,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'FIELD'); -INSERT INTO `department` VALUES (59,'maintenance','MANTENIMIENTO',92,93,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (60,'claims','RECLAMACIONES',43,44,NULL,72,0,0,2,0,43,'/1/43/',NULL,0,NULL,1,1,0,0,NULL,NULL,NULL,'CLAIM'); -INSERT INTO `department` VALUES (61,NULL,'VNH',94,97,NULL,73,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (66,NULL,'VERDNAMADRID',98,99,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (58,'CMP','CAMPOS',90,93,NULL,72,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'FIELD'); +INSERT INTO `department` VALUES (59,'maintenance','MANTENIMIENTO',94,95,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (60,'claims','RECLAMACIONES',43,44,NULL,72,0,0,2,0,43,'/1/43/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,'CLAIM'); +INSERT INTO `department` VALUES (61,NULL,'VNH',96,99,NULL,73,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (66,NULL,'VERDNAMADRID',100,101,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (68,NULL,'COMPLEMENTOS',25,26,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (69,NULL,'VERDNABARNA',100,101,NULL,74,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (69,NULL,'VERDNABARNA',102,103,NULL,74,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (80,'spainTeam5','EQUIPO ESPAÑA 5',45,46,4250,0,0,0,2,0,43,'/1/43/','es5_equipo',1,'es5@verdnatura.es',0,0,0,0,NULL,NULL,'5300',NULL); -INSERT INTO `department` VALUES (86,NULL,'LIMPIEZA',102,103,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (89,NULL,'COORDINACION',104,105,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (90,NULL,'TRAILER',95,96,NULL,0,0,0,2,0,61,'/1/61/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (86,NULL,'LIMPIEZA',104,105,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (89,NULL,'COORDINACION',106,107,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (90,NULL,'TRAILER',97,98,NULL,0,0,0,2,0,61,'/1/61/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (91,'artificial','ARTIFICIAL',27,28,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'PREVIOUS'); INSERT INTO `department` VALUES (92,NULL,'EQUIPO SILVERIO',47,48,1203,0,0,0,2,0,43,'/1/43/','sdc_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (94,'spainTeam2','EQUIPO ESPAÑA 2',49,50,3797,0,0,0,2,0,43,'/1/43/','es2_equipo',1,'es2@verdnatura.es',0,0,0,0,NULL,NULL,'5100',NULL); @@ -2574,23 +2618,24 @@ INSERT INTO `department` VALUES (95,'spainTeam1','EQUIPO ESPAÑA 1',51,52,24065, INSERT INTO `department` VALUES (96,NULL,'EQUIPO C LOPEZ',53,54,4661,0,0,0,2,0,43,'/1/43/','cla_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (115,NULL,'EQUIPO CLAUDI',55,56,3810,0,0,0,2,0,43,'/1/43/','csr_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (123,NULL,'EQUIPO ELENA BASCUÑANA',57,58,7102,0,0,0,2,0,43,'/1/43/','ebt_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (124,NULL,'CONTROL INTERNO',106,107,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,1,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (124,NULL,'CONTROL INTERNO',108,109,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (125,'spainTeam3','EQUIPO ESPAÑA 3',59,60,1118,0,0,0,2,0,43,'/1/43/','es3_equipo',1,'es3@verdnatura.es',0,0,0,0,NULL,NULL,'5200',NULL); INSERT INTO `department` VALUES (126,NULL,'PRESERVADO',29,30,NULL,0,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (128,NULL,'PALETIZADO',31,32,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'PALLETIZING'); INSERT INTO `department` VALUES (130,NULL,'REVISION',33,34,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,'ON_CHECKING'); -INSERT INTO `department` VALUES (131,'greenhouse','INVERNADERO',89,90,NULL,0,0,0,2,0,58,'/1/58/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (131,'greenhouse','INVERNADERO',91,92,NULL,0,0,0,2,0,58,'/1/58/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (132,NULL,'EQUIPO DC',61,62,1731,0,0,0,2,0,43,'/1/43/','dc_equipo',1,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (133,'franceTeam','EQUIPO FRANCIA',63,64,1731,72,0,0,2,0,43,'/1/43/','fr_equipo',1,'gestionfrancia@verdnatura.es',0,0,0,0,NULL,NULL,'3300',NULL); INSERT INTO `department` VALUES (134,'portugalTeam','EQUIPO PORTUGAL',65,66,6264,0,0,0,2,0,43,'/1/43/','pt_equipo',1,'portugal@verdnatura.es',0,0,0,0,NULL,NULL,'3500',NULL); -INSERT INTO `department` VALUES (135,'routers','ENRUTADORES',108,109,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (136,'heavyVehicles','VEHICULOS PESADOS',110,111,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (137,'sorter','SORTER',112,113,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (135,'routers','ENRUTADORES',110,111,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (136,'heavyVehicles','VEHICULOS PESADOS',112,113,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (137,'sorter','SORTER',114,115,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (139,'spainTeam4','EQUIPO ESPAÑA 4',67,68,3803,0,0,0,2,0,43,'/1/43/','es4_equipo',1,'es4@verdnatura.es',0,0,0,0,NULL,NULL,'5400',NULL); -INSERT INTO `department` VALUES (140,'hollandTeam','EQUIPO HOLANDA',69,70,NULL,0,0,0,2,0,43,'/1/43/','nl_equipo',1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (140,'internationalTeam','EQUIPO INTERNACIONAL',69,70,33320,0,0,0,2,0,43,'/1/43/','int_equipo',1,'international@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (141,NULL,'PREVIA',35,36,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,'PREVIOUS'); INSERT INTO `department` VALUES (146,NULL,'VERDNACOLOMBIA',3,4,NULL,72,0,0,2,0,22,'/1/22/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (147,'spainTeamAsia','EQUIPO ESPAÑA ASIA',71,72,40214,0,0,0,2,0,43,'/1/43/','esA_equipo',0,'esA@verdnatura.es',0,0,0,0,NULL,NULL,'5500',NULL); +INSERT INTO `department` VALUES (148,NULL,'CAPTATION FRANCIA',73,74,NULL,0,0,0,2,0,43,'/1/43/',NULL,0,NULL,0,0,0,0,NULL,NULL,'6000',NULL); INSERT INTO `docuware` VALUES (1,'deliveryNote','Albaranes cliente','find','find','N__ALBAR_N',NULL); INSERT INTO `docuware` VALUES (2,'deliveryNote','Albaranes cliente','store','Archivar','N__ALBAR_N',NULL); diff --git a/db/dump/.dump/privileges.sql b/db/dump/.dump/privileges.sql index 66e553763..486bec661 100644 --- a/db/dump/.dump/privileges.sql +++ b/db/dump/.dump/privileges.sql @@ -502,7 +502,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','receipt','alexm@%','0000- INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','grafana','visitUser','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','referenceRate','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','report','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','cache','productionBoss','available','guillermo@10.5.1.2','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyerAssistant','producer','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','time','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','role','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','config__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); @@ -605,7 +605,6 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','project','jua INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','productionConfig','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','manager','productionConfig','alexm@%','0000-00-00 00:00:00','Update',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','creditInsurance','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','cache','productionBoss','visible','guillermo@10.5.1.2','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','errorProduction__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','invoiceOut','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','coolerAssist','Tickets','alexm@%','0000-00-00 00:00:00','Update',''); @@ -792,7 +791,6 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','Movimientos','alexm@% INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','buy','alexm@%','0000-00-00 00:00:00','Update',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','itemMinimumQuantity','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','receipt','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyerBoss','producer','alexm@%','0000-00-00 00:00:00','Update',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','link','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','link','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','delivery','vehicle','alexm@%','0000-00-00 00:00:00','Select',''); @@ -971,7 +969,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','officeBoss','ticketPackagingSt INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','workerRelatives','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','ticketPackagingStartingStock','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','supplierPackaging','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','workerDocument','alexm@%','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','supplierContact','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceCorrection','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ink','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','zone','alexm@%','0000-00-00 00:00:00','Select',''); @@ -1471,9 +1469,31 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','tillSerial',' INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','stockBuyed','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','alertLevel','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','workerActivityType','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','priceDelta','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','priceDelta','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','parkingLog','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','travelLog','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','supplierContact','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','workerDms','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemLog','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','account','developer','user','juan@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','claimReason','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','claimResponsible','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','claimResult','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','claimRedelivery','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','producer','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','itemStateTag','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','material','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','saleUnit','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','origin','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','itemType','jgallego@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','delivery','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','itemFarmingTag','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','itemWrappingTag','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','itemLanguageTag','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','itemStemTag','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','itemBaseTag','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','itemBreederTag','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemShelvingLog','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); /*!40000 ALTER TABLE `tables_priv` ENABLE KEYS */; /*!40000 ALTER TABLE `columns_priv` DISABLE KEYS */; @@ -1853,7 +1873,6 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','claimManager','buy_getVolumeByE INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','buy_getVolumeByEntry','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','entry_moveNotPrinted','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','buy_getVolume','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','stockbuyedbyworker','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','buy_getsplit','PROCEDURE','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','subordinategetlist','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','buy_afterUpsert','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); @@ -2001,7 +2020,6 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','logshow','PROCEDURE','alex INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyerBoss','supplierpackaging_reportsource','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financialBoss','supplierexpenses','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','grafana','firstdayofweek','FUNCTION','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','stockbuyed_add','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','mail_insert','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','duaParcialMake','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','palletizerBoss','packingsite_startcollection','PROCEDURE','alexm@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); @@ -2211,7 +2229,10 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','guest','ticketCalculatePurge',' INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','buy_getUltimate','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','cooler','buy_getUltimate','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','bs','buyerBoss','waste_addSales','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','bs','grafana','waste_addSales','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','saletracking_sectorcollectionaddprevok','PROCEDURE','alexm@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','saleSplit','PROCEDURE','carlosap@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemShelvingSale_deleteAdded','PROCEDURE','guillermo@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','buy_getUltimate','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); /*!40000 ALTER TABLE `procs_priv` ENABLE KEYS */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; diff --git a/db/dump/.dump/structure.sql b/db/dump/.dump/structure.sql index 0bd03ac32..e4e59a6bf 100644 --- a/db/dump/.dump/structure.sql +++ b/db/dump/.dump/structure.sql @@ -416,7 +416,7 @@ CREATE TABLE `user` ( `role` int(10) unsigned NOT NULL DEFAULT 2, `active` tinyint(1) NOT NULL DEFAULT 1, `email` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `emailVerified` tinyint(1) DEFAULT NULL, + `emailVerified` tinyint(1) NOT NULL DEFAULT 0, `verificationToken` varchar(512) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, `lang` char(2) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, `lastPassChange` datetime DEFAULT NULL, @@ -3815,7 +3815,7 @@ CREATE TABLE `defaulter` ( `created` date NOT NULL, `amount` double NOT NULL DEFAULT 0, `defaulterSinced` date DEFAULT NULL, - `hasChanged` tinyint(1) DEFAULT NULL, + `hasChanged` tinyint(1) NOT NULL DEFAULT 0, `frozened` date DEFAULT NULL, PRIMARY KEY (`clientFk`,`created`), KEY `client` (`clientFk`), @@ -4685,25 +4685,27 @@ BLOCK1: BEGIN DECLARE vShipped DATE; DECLARE vPreviousShipped DATE; DECLARE vDone boolean; - DECLARE cur cursor for - - SELECT clientFk, firstShipped - FROM bs.clientNewBorn; + + DECLARE cur CURSOR FOR + SELECT clientFk, firstShipped + FROM bs.clientNewBorn; DECLARE continue HANDLER FOR NOT FOUND SET vDone = TRUE; SET vDone := FALSE; DELETE FROM bs.clientNewBorn WHERE isModified = FALSE; - INSERT INTO clientNewBorn(clientFk, firstShipped, lastShipped) - SELECT c.id, MAX(t.shipped), MAX(t.shipped) - FROM vn.client c - JOIN vn.ticket t on t.clientFk = c.id - LEFT JOIN clientNewBorn cb on cb.clientFk = c.id - WHERE t.shipped BETWEEN TIMESTAMPADD(YEAR, -1, util.VN_CURDATE()) AND util.VN_CURDATE() AND cb.isModified is null - GROUP BY c.id; + INSERT INTO clientNewBorn(clientFk, firstShipped, lastShipped) + SELECT c.id, DATE(MAX(t.shipped)), DATE(MAX(t.shipped)) + FROM vn.client c + JOIN vn.ticket t ON t.clientFk = c.id + LEFT JOIN clientNewBorn cb ON cb.clientFk = c.id + WHERE t.shipped BETWEEN util.VN_CURDATE() - INTERVAL 1 YEAR + AND util.VN_CURDATE() + AND cb.isModified IS NULL + GROUP BY c.id; + OPEN cur; - LOOP1: LOOP SET vDone := FALSE; FETCH cur INTO vClientFk, vShipped; @@ -7835,7 +7837,6 @@ CREATE TABLE `expedition_PrintOut` ( `longName` varchar(30) DEFAULT NULL, `shelvingFk` varchar(5) DEFAULT NULL, `comments` varchar(100) DEFAULT NULL, - `isChecked` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Indica si la expedición ha sido revisada por un revisor', PRIMARY KEY (`expeditionFk`), KEY `expedition_PrintOut_FK` (`printerFk`), CONSTRAINT `expedition_PrintOut_FK` FOREIGN KEY (`printerFk`) REFERENCES `printer` (`id`) ON DELETE CASCADE ON UPDATE CASCADE @@ -11396,6 +11397,7 @@ CREATE TABLE `order` ( `tax` decimal(10,2) NOT NULL, `total` decimal(10,2) NOT NULL, `configured` datetime DEFAULT NULL, + `rowUpdated` datetime DEFAULT NULL COMMENT 'Timestamp for last updated record in orderRow table', PRIMARY KEY (`id`), KEY `address` (`address_id`), KEY `delivery_method` (`delivery_method_id`), @@ -13184,6 +13186,70 @@ 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 `orderRow_updateOverstocking` */; +/*!50003 SET @saved_cs_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=`vn`@`localhost` PROCEDURE `orderRow_updateOverstocking`(vOrderFk INT) +BEGIN +/** +* Set amount = 0 to avoid overbooking sales +* +* @param vOrderFk hedera.order.id +*/ + DECLARE vCalcFk INT; + DECLARE vDone BOOL; + DECLARE vWarehouseFk INT; + + DECLARE cWarehouses CURSOR FOR + SELECT DISTINCT warehouseFk + FROM orderRow + WHERE orderFk = vOrderFk + AND shipment = util.VN_CURDATE(); + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + OPEN cWarehouses; + checking: LOOP + SET vDone = FALSE; + + FETCH cWarehouses INTO vWarehouseFk; + + IF vDone THEN + LEAVE checking; + END IF; + + CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, util.VN_CURDATE()); + + UPDATE orderRow r + JOIN `order` o ON o.id = r.orderFk + JOIN orderConfig oc + JOIN cache.available a ON a.calc_id = vCalcFk AND a.item_id = r.itemFk + SET r.amount = 0 + WHERE ADDTIME(o.rowUpdated, oc.reserveTime) < util.VN_NOW() + AND a.available <= 0 + AND r.warehouseFk = vWarehouseFk + AND r.orderFk = vOrderFk; + END LOOP; + CLOSE cWarehouses; +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 `order_addItem` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -13689,6 +13755,7 @@ BEGIN * @param vUser The user identifier */ DECLARE vHasRows BOOL; + DECLARE vHas0Amount BOOL; DECLARE vDone BOOL; DECLARE vWarehouseFk INT; DECLARE vShipment DATE; @@ -13698,7 +13765,6 @@ BEGIN DECLARE vItemFk INT; DECLARE vConcept VARCHAR(30); DECLARE vAmount INT; - DECLARE vAvailable INT; DECLARE vPrice DECIMAL(10,2); DECLARE vSaleFk INT; DECLARE vRowFk INT; @@ -13708,7 +13774,6 @@ BEGIN DECLARE vClientFk INT; DECLARE vCompanyFk INT; DECLARE vAgencyModeFk INT; - DECLARE vCalcFk INT; DECLARE vIsTaxDataChecked BOOL; DECLARE vDates CURSOR FOR @@ -13774,6 +13839,20 @@ BEGIN SELECT employeeFk INTO vUserFk FROM orderConfig; END IF; + CALL orderRow_updateOverstocking(vSelf); + + -- Check if any product has a quantity of 0 + SELECT EXISTS ( + SELECT id + FROM orderRow + WHERE orderFk = vSelf + AND amount = 0 + ) INTO vHas0Amount; + + IF vHas0Amount THEN + CALL util.throw('Hay líneas vacías. Por favor, elimínelas'); + END IF; + START TRANSACTION; CALL order_checkEditable(vSelf); @@ -25827,7 +25906,7 @@ CREATE TABLE `address` ( `isActive` tinyint(4) NOT NULL DEFAULT 1, `longitude` decimal(11,7) DEFAULT NULL COMMENT 'Indica la última longitud proporcionada por tabla delivery', `latitude` decimal(11,7) DEFAULT NULL COMMENT 'Indica la última latitud proporcionada por tabla delivery', - `isEqualizated` tinyint(1) DEFAULT NULL, + `isEqualizated` tinyint(1) NOT NULL DEFAULT 0, `customsAgentFk` int(11) DEFAULT NULL, `incotermsFk` varchar(3) DEFAULT NULL, `isLogifloraAllowed` tinyint(4) NOT NULL DEFAULT 0, @@ -26035,7 +26114,7 @@ CREATE TABLE `agencyMode` ( `inflation` decimal(5,2) NOT NULL DEFAULT 0.00 COMMENT 'Este valor se utiliza para aumentar el valor del componente porte.', `isVolumetric` tinyint(1) NOT NULL DEFAULT 0, `reportMail` varchar(100) DEFAULT NULL, - `showAgencyName` tinyint(1) DEFAULT 1 COMMENT 'obsoleta', + `showAgencyName__` tinyint(1) DEFAULT 1 COMMENT '@deprecated 2024-09-24', `isActive` tinyint(1) NOT NULL DEFAULT 1, `isExternalAgency` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'obsoleta', `flag` blob DEFAULT NULL COMMENT 'obsoleta', @@ -27058,23 +27137,6 @@ CREATE TABLE `buyConfig` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `buyMark` --- - -DROP TABLE IF EXISTS `buyMark`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `buyMark` ( - `id` int(11) NOT NULL, - `comment` varchar(255) DEFAULT NULL, - `mark` tinyint(1) DEFAULT NULL, - `odbcDate` timestamp NULL DEFAULT current_timestamp(), - PRIMARY KEY (`id`), - CONSTRAINT `Compres_mark_ibfk_1` FOREIGN KEY (`id`) REFERENCES `buy` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `buyer` -- @@ -27208,9 +27270,10 @@ DROP TABLE IF EXISTS `campaign`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `campaign` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `code` enum('mothersDay','allSaints','valentinesDay') NOT NULL, + `code` enum('mothersDay','allSaints','valentinesDay','frenchMothersDay') NOT NULL, `dated` datetime NOT NULL DEFAULT current_timestamp(), `scopeDays` int(11) NOT NULL DEFAULT 15, + `previousDays` int(10) unsigned NOT NULL DEFAULT 30 COMMENT 'Días previos para calcular e insertar en la tabla itemCampaign', PRIMARY KEY (`id`), UNIQUE KEY `campaign_dated_uindex` (`dated`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; @@ -27262,7 +27325,7 @@ CREATE TABLE `chat` ( `senderFk` int(10) unsigned DEFAULT NULL, `recipient` varchar(50) DEFAULT NULL, `dated` datetime DEFAULT NULL, - `checkUserStatus` tinyint(1) DEFAULT NULL, + `checkUserStatus` tinyint(1) NOT NULL DEFAULT 0, `message` text DEFAULT NULL, `attempts` int(1) DEFAULT NULL, `error` text DEFAULT NULL, @@ -27656,7 +27719,7 @@ CREATE TABLE `client` ( `credit` decimal(10,2) unsigned NOT NULL DEFAULT 0.00, `countryFk` mediumint(8) unsigned NOT NULL DEFAULT 1, `isActive` tinyint(1) NOT NULL DEFAULT 1, - `gestdocFk` int(11) DEFAULT NULL, + `gestdocFk__` int(11) DEFAULT NULL COMMENT '@deprecated 2024-10-17', `quality` int(2) DEFAULT 11, `payMethodFk` tinyint(3) unsigned NOT NULL DEFAULT 5, `created` timestamp NULL DEFAULT current_timestamp(), @@ -27969,11 +28032,14 @@ CREATE TABLE `clientObservation` ( `text` text NOT NULL, `created` timestamp NOT NULL DEFAULT current_timestamp(), `editorFk` int(10) unsigned DEFAULT NULL, + `observationTypeFk` tinyint(3) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `Id_Trabajador` (`workerFk`), KEY `Id_Cliente` (`clientFk`), KEY `clientObservation_created_IDX` (`created`) USING BTREE, KEY `clientObservation_fk_editor` (`editorFk`), + KEY `clientObservationTypeFk` (`observationTypeFk`), + CONSTRAINT `clientObservationTypeFk` FOREIGN KEY (`observationTypeFk`) REFERENCES `observationType` (`id`), CONSTRAINT `clientObservation_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `clientObservation_ibfk_1` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `clientObservation_ibfk_2` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE @@ -29619,6 +29685,10 @@ CREATE TABLE `docuwareConfig` ( `id` int(10) unsigned NOT NULL, `url` varchar(75) DEFAULT NULL, `cookie` varchar(1000) DEFAULT NULL, + `username` varchar(100) DEFAULT NULL, + `password` varchar(100) DEFAULT NULL, + `token` text DEFAULT NULL, + `expired` int(11) DEFAULT NULL, PRIMARY KEY (`id`), CONSTRAINT `docuwareConfig_check` CHECK (`id` = 1) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; @@ -31985,6 +32055,21 @@ CREATE TABLE `itemBarcode` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `itemBaseTag` +-- + +DROP TABLE IF EXISTS `itemBaseTag`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `itemBaseTag` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(50) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name_UNIQUE` (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `itemBotanical` -- @@ -32021,6 +32106,42 @@ SET character_set_client = utf8; 1 AS `ediBotanic` */; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `itemBreederTag` +-- + +DROP TABLE IF EXISTS `itemBreederTag`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `itemBreederTag` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(50) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name_UNIQUE` (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `itemCampaign` +-- + +DROP TABLE IF EXISTS `itemCampaign`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `itemCampaign` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `dated` date NOT NULL, + `itemFk` int(11) NOT NULL, + `quantity` decimal(10,2) NOT NULL, + `total` decimal(10,2) NOT NULL, + `campaign` varchar(100) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `itemCampaign_UNIQUE` (`dated`,`itemFk`), + KEY `itemCampaign_item_FK` (`itemFk`), + CONSTRAINT `itemCampaign_item_FK` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Tallos confirmados por día en los días de más producción de una campaña. La tabla está pensada para que sea una foto.'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `itemCategory` -- @@ -32205,6 +32326,21 @@ CREATE TABLE `itemFamily` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `itemFarmingTag` +-- + +DROP TABLE IF EXISTS `itemFarmingTag`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `itemFarmingTag` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(50) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name_UNIQUE` (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `itemImageQueue` -- @@ -32256,6 +32392,21 @@ CREATE TABLE `itemLabel` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `itemLanguageTag` +-- + +DROP TABLE IF EXISTS `itemLanguageTag`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `itemLanguageTag` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(50) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name_UNIQUE` (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `itemLog` -- @@ -32470,6 +32621,7 @@ CREATE TABLE `itemShelving` ( `editorFk` int(10) unsigned DEFAULT NULL, `available` int(11) DEFAULT NULL, `isSplit` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Este valor cambia al splitar un carro que se ha quedado en holanda', + `movingState` enum('selected','printed') DEFAULT NULL, PRIMARY KEY (`id`), KEY `itemShelving_fk1_idx` (`itemFk`), KEY `itemShelving_fk2_idx` (`shelvingFk`), @@ -32478,7 +32630,7 @@ CREATE TABLE `itemShelving` ( KEY `itemShelvingBuy_FK` (`buyFk`), CONSTRAINT `itemShelvingBuy_FK` FOREIGN KEY (`buyFk`) REFERENCES `buy` (`id`), CONSTRAINT `itemShelving_fk1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `itemShelving_fk2` FOREIGN KEY (`shelvingFk`) REFERENCES `shelving` (`code`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `itemShelving_fk2` FOREIGN KEY (`shelvingFk`) REFERENCES `shelving` (`code`) ON UPDATE CASCADE, CONSTRAINT `itemShelving_fk3` FOREIGN KEY (`packagingFk`) REFERENCES `packaging` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Tabla utilizada para localizar los artículos dentro de los carros. Usado para la gestión del almacén en el altillo '; /*!40101 SET character_set_client = @saved_cs_client */; @@ -32737,6 +32889,36 @@ SET character_set_client = utf8; 1 AS `removed` */; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `itemStateTag` +-- + +DROP TABLE IF EXISTS `itemStateTag`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `itemStateTag` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(50) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name_UNIQUE` (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `itemStemTag` +-- + +DROP TABLE IF EXISTS `itemStemTag`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `itemStemTag` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(50) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name_UNIQUE` (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `itemTag` -- @@ -32957,6 +33139,36 @@ CREATE TABLE `itemTypeTag` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `itemVatRateTag` +-- + +DROP TABLE IF EXISTS `itemVatRateTag`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `itemVatRateTag` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(50) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name_UNIQUE` (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `itemWrappingTag` +-- + +DROP TABLE IF EXISTS `itemWrappingTag`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `itemWrappingTag` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(50) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name_UNIQUE` (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Temporary table structure for view `item_Free_Id` -- @@ -33809,6 +34021,7 @@ CREATE TABLE `operator` ( `volumeLimit` decimal(10,6) DEFAULT 0.500000 COMMENT 'Límite de volumen en una colección para la asignación de pedidos', `sizeLimit` int(10) unsigned DEFAULT NULL COMMENT 'Límite de altura en una colección para la asignación de pedidos', `isOnReservationMode` tinyint(1) NOT NULL DEFAULT 0, + `machineFk` int(11) DEFAULT NULL, PRIMARY KEY (`workerFk`), KEY `operator_FK` (`workerFk`), KEY `operator_FK_1` (`trainFk`), @@ -33816,11 +34029,13 @@ CREATE TABLE `operator` ( KEY `operator_FK_3` (`warehouseFk`), KEY `operator_FK_5` (`labelerFk`), KEY `operator_FK_4` (`sectorFk`), + KEY `operator_machine_FK` (`machineFk`), CONSTRAINT `operator_FK` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `operator_FK_1` FOREIGN KEY (`trainFk`) REFERENCES `train` (`id`) ON UPDATE CASCADE, CONSTRAINT `operator_FK_2` FOREIGN KEY (`itemPackingTypeFk`) REFERENCES `itemPackingType` (`code`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `operator_FK_3` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `operator_FK_4` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON UPDATE CASCADE + CONSTRAINT `operator_FK_4` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON UPDATE CASCADE, + CONSTRAINT `operator_machine_FK` FOREIGN KEY (`machineFk`) REFERENCES `machine` (`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 */; @@ -34916,7 +35131,7 @@ CREATE TABLE `priceDelta` ( `warehouseFk` smallint(6) unsigned NOT NULL, `created` timestamp NOT NULL DEFAULT current_timestamp(), `editorFk` int(10) unsigned DEFAULT NULL, - `zoneGeoFk` int(11) DEFAULT NULL, + `zoneGeoFk` int(11) DEFAULT NULL COMMENT 'Application area for the bonus component', PRIMARY KEY (`id`), KEY `priceDelta_itemType_FK` (`itemTypeFk`), KEY `priceDelta_ink_FK` (`inkFk`), @@ -36929,6 +37144,7 @@ CREATE TABLE `sector` ( `isReserve` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Sectores de reserva, como Albenfruit o Fuentes', `backupPrinterFk` int(10) unsigned DEFAULT NULL, `typeFk` int(10) unsigned NOT NULL DEFAULT 1, + `isOnReservationMode` tinyint(1) DEFAULT 0, PRIMARY KEY (`id`), UNIQUE KEY `code_UNIQUE` (`code`), KEY `sector_fk1_idx` (`warehouseFk`), @@ -37651,13 +37867,13 @@ CREATE TABLE `stockBought` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `stockBuyed` +-- Table structure for table `stockBuyed__` -- -DROP TABLE IF EXISTS `stockBuyed`; +DROP TABLE IF EXISTS `stockBuyed__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `stockBuyed` ( +CREATE TABLE `stockBuyed__` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `userFk` int(10) unsigned DEFAULT NULL, `buyed` decimal(10,2) DEFAULT NULL, @@ -37669,7 +37885,7 @@ CREATE TABLE `stockBuyed` ( PRIMARY KEY (`id`), KEY `stockBuyed_user_idx` (`userFk`), CONSTRAINT `stockBuyedUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`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='@deprecated 2024-10-01 rename and refactor to stockBought'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -38374,10 +38590,12 @@ CREATE TABLE `ticketConfig` ( `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', `defaultAttenderFk` int(10) unsigned DEFAULT NULL, + `closureDaysAgo` int(11) NOT NULL DEFAULT 2 COMMENT 'Number of days to look back for ticket closure', PRIMARY KEY (`id`), KEY `ticketConfig_worker_FK` (`defaultAttenderFk`), CONSTRAINT `ticketConfig_worker_FK` FOREIGN KEY (`defaultAttenderFk`) REFERENCES `worker` (`id`), - CONSTRAINT `ticketConfig_check` CHECK (`id` = 1) + CONSTRAINT `ticketConfig_check` CHECK (`id` = 1), + CONSTRAINT `closureDaysAgo_check` CHECK (`closureDaysAgo` > 0) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -39414,6 +39632,8 @@ CREATE TABLE `travelThermograph` ( `result` varchar(45) DEFAULT NULL, `dmsFk` int(11) DEFAULT NULL, `temperatureFk` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT 'cool' COMMENT 'En la versión de Agosto de Salix se empezará a usar este campo y se actualizaran los anteriores mirando temperature.', + `maxTemperature` decimal(5,2) DEFAULT NULL, + `minTemperature` decimal(5,2) DEFAULT NULL, `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `thermograph_fk_idx` (`thermographFk`), @@ -39422,7 +39642,7 @@ CREATE TABLE `travelThermograph` ( KEY `warehouse_id` (`warehouseFk`), KEY `travelThermographTemperatureFgn` (`temperatureFk`), KEY `travelThermograph_fk_editor` (`editorFk`), - CONSTRAINT `travelThermographDmsFgn` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) ON UPDATE CASCADE, + CONSTRAINT `travelThermographDmsFgn` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `travelThermographTemperatureFgn` FOREIGN KEY (`temperatureFk`) REFERENCES `temperature` (`code`), CONSTRAINT `travelThermographThermographFgn` FOREIGN KEY (`thermographFk`) REFERENCES `thermograph` (`id`) ON UPDATE CASCADE, CONSTRAINT `travelThermographTravelFgn` FOREIGN KEY (`travelFk`) REFERENCES `travel` (`id`), @@ -39938,8 +40158,8 @@ CREATE TABLE `warehouse` ( `isLogiflora` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Este almacén acepta productos de Logiflora', `isBionic` tinyint(1) NOT NULL DEFAULT 1, `isHalt` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Almacén en el que descargan nuestros troncales', - `isOrigin` tinyint(1) DEFAULT NULL, - `isDestiny` tinyint(1) DEFAULT NULL, + `isOrigin` tinyint(1) NOT NULL DEFAULT 0, + `isDestiny` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), UNIQUE KEY `name_UNIQUE` (`name`), KEY `Id_Paises` (`countryFk`), @@ -41174,7 +41394,7 @@ CREATE TABLE `zoneIncluded` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `zoneFk` int(11) NOT NULL, `geoFk` int(11) NOT NULL, - `isIncluded` tinyint(1) DEFAULT NULL, + `isIncluded` tinyint(1) NOT NULL DEFAULT 0, `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `unique_zone_geo` (`zoneFk`,`geoFk`), @@ -41428,6 +41648,24 @@ 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 `itemCampaig_add` */;; +DELIMITER ;; +/*!50003 SET @saved_cs_client = @@character_set_client */ ;; +/*!50003 SET @saved_cs_results = @@character_set_results */ ;; +/*!50003 SET @saved_col_connection = @@collation_connection */ ;; +/*!50003 SET character_set_client = utf8mb4 */ ;; +/*!50003 SET character_set_results = utf8mb4 */ ;; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ;; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; +/*!50003 SET @saved_time_zone = @@time_zone */ ;; +/*!50003 SET time_zone = 'SYSTEM' */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`vn`@`localhost`*/ /*!50106 EVENT `itemCampaig_add` ON SCHEDULE EVERY 1 DAY STARTS '2024-10-18 03:00:00' ON COMPLETION PRESERVE ENABLE DO CALL itemCampaign_add() */ ;; +/*!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 `itemImageQueue_check` */;; DELIMITER ;; /*!50003 SET @saved_cs_client = @@character_set_client */ ;; @@ -48028,39 +48266,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 `buy_getVolumeByAgency` */; -/*!50003 SET @saved_cs_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=`vn`@`localhost` PROCEDURE `buy_getVolumeByAgency`(vDated DATE, vAgencyFk INT) -BEGIN - - DROP TEMPORARY TABLE IF EXISTS tmp.buy; - CREATE TEMPORARY TABLE tmp.buy (buyFk INT NOT NULL, PRIMARY KEY (buyFk)) ENGINE = MEMORY; - - INSERT INTO tmp.buy - SELECT b.id - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed = vDated - AND t.agencyModeFk IN (0, vAgencyFk); - - CALL buy_getVolume(); - DROP TEMPORARY TABLE tmp.buy; - -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 `buy_getVolumeByEntry` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -49309,6 +49514,13 @@ BEGIN DELETE FROM messageInbox WHERE sendDate < v2Months; DELETE FROM messageInbox WHERE sendDate < v2Months; DELETE FROM workerTimeControl WHERE timed < v4Years; + DELETE FROM itemShelvingSale + WHERE itemShelvingFk IN ( + SELECT id + FROM itemShelving + WHERE created < util.VN_CURDATE() + AND visible = 0 + ); DELETE FROM itemShelving WHERE created < util.VN_CURDATE() AND visible = 0; DELETE FROM ticketDown WHERE created < util.yesterday(); DELETE IGNORE FROM expedition WHERE created < v26Months; @@ -49336,16 +49548,10 @@ BEGIN 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 <= v2Months; DELETE b FROM buy b JOIN entryConfig e ON e.defaultEntry = b.entryFk WHERE b.created < v2Months; - DELETE FROM stockBuyed WHERE creationDate < v2Months; + DELETE FROM stockBought WHERE dated < v2Months; DELETE FROM printQueue WHERE statusCode = 'printed' AND created < v2Months; -- Equipos duplicados DELETE w.* @@ -50287,22 +50493,19 @@ BEGIN DECLARE vIsTaxDataChecked TINYINT(1); DECLARE vHasCoreVnl BOOLEAN; DECLARE vMandateTypeFk INT; - DECLARE vHasDailyInvoice BOOLEAN; SELECT cc.defaultPayMethodFk, cc.defaultDueDay, cc.defaultCredit, cc.defaultIsTaxDataChecked, cc.defaultHasCoreVnl, - cc.defaultMandateTypeFk, - c.hasDailyInvoice + cc.defaultMandateTypeFk INTO vPayMethodFk, vDueDay, vDefaultCredit, vIsTaxDataChecked, vHasCoreVnl, - vMandateTypeFk, - vHasDailyInvoice + vMandateTypeFk FROM clientConfig cc LEFT JOIN province p ON p.id = vProvinceFk LEFT JOIN country c ON c.id = p.countryFk; @@ -50323,8 +50526,7 @@ BEGIN credit = vDefaultCredit, isTaxDataChecked = vIsTaxDataChecked, hasCoreVnl = vHasCoreVnl, - isEqualizated = FALSE, - hasDailyInvoice = vHasDailyInvoice + isEqualizated = FALSE ON duplicate KEY UPDATE payMethodFk = vPayMethodFk, dueDay = vDueDay, @@ -51057,23 +51259,23 @@ BEGIN WHERE t.id = vTicketFk; CALL cache.available_refresh( - vCacheAvailableFk, + vCacheAvailableFk, FALSE, - vWarehouseFk, + vWarehouseFk, util.VN_CURDATE()); SELECT available INTO vAvailable FROM cache.available - WHERE calc_id = vCacheAvailableFk + WHERE calc_id = vCacheAvailableFk AND item_id = vItemFk; - + IF vAvailable < vQuantity THEN SET vHasThrow = TRUE; ELSE SELECT `name`, - CONCAT(getUser(), ' ', DATE_FORMAT(util.VN_NOW(), '%H:%i'), ' ', name) + CONCAT(getUser(), ' ', DATE_FORMAT(util.VN_NOW(), '%H:%i'), ' ', name) INTO vItemName, vConcept - FROM item + FROM item WHERE id = vItemFk; START TRANSACTION; @@ -51089,7 +51291,7 @@ BEGIN CALL sale_calculateComponent(vSaleFk, NULL); CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk); - + IF NOT EXISTS (SELECT TRUE FROM itemShelvingSale WHERE saleFk = vSaleFk LIMIT 1) THEN SET vHasThrow = TRUE; END IF; @@ -51098,13 +51300,13 @@ BEGIN IF vHasThrow THEN CALL util.throw("There is no available for the selected item"); END IF; - + IF vSaleGroupFk THEN INSERT INTO saleGroupDetail SET saleFk = vSaleFk, saleGroupFk = vSaleGroupFk; END IF; - + COMMIT; END ;; DELIMITER ; @@ -51126,7 +51328,7 @@ CREATE DEFINER=`vn`@`localhost` PROCEDURE `collection_assign`( vUserFk INT, OUT vCollectionFk INT ) -BEGIN +BEGIN /** * Comprueba si existen colecciones libres que se ajustan * al perfil del usuario y le asigna la más antigua. @@ -51168,6 +51370,12 @@ BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; -- Si hay colecciones sin terminar, sale del proceso + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + CALL collection_get(vUserFk); SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0, pc.maxNotAssignedCollectionLifeTime @@ -51241,9 +51449,19 @@ BEGIN IF vCollectionFk IS NULL THEN CALL collection_new(vUserFk, vCollectionFk); - UPDATE `collection` - SET workerFk = vUserFk - WHERE id = vCollectionFk; + START TRANSACTION; + + SELECT workerFk INTO vCollectionWorker + FROM `collection` + WHERE id = vCollectionFk FOR UPDATE; + + IF vCollectionWorker IS NULL THEN + UPDATE `collection` + SET workerFk = vUserFk + WHERE id = vCollectionFk; + END IF; + + COMMIT; END IF; END ;; DELIMITER ; @@ -51318,101 +51536,140 @@ CREATE DEFINER=`vn`@`localhost` PROCEDURE `collection_getAssigned`( ) BEGIN /** - * Comprueba si existen colecciones libres que se ajustan al perfil del usuario - * y le asigna la más antigua. - * Añade un registro al semillero de colecciones y hace la reserva para la colección - * + * Comprueba si existen colecciones libres que se ajustan + * al perfil del usuario y le asigna la más antigua. + * Añade un registro al semillero de colecciones. + * * @param vUserFk Id de usuario * @param vCollectionFk Id de colección */ DECLARE vHasTooMuchCollections BOOL; - DECLARE vItemPackingTypeFk VARCHAR(1); - DECLARE vWarehouseFk INT; - DECLARE vLockName VARCHAR(215); - DECLARE vLockTime INT DEFAULT 30; + DECLARE vDone BOOL DEFAULT FALSE; + DECLARE vCollectionWorker INT; + DECLARE vMaxNotAssignedCollectionLifeTime TIME; + + DECLARE vCollections CURSOR FOR + WITH collections AS ( + SELECT tc.collectionFk, + SUM(sv.volume) volume, + c.saleTotalCount, + c.itemPackingTypeFk, + c.trainFk, + c.warehouseFk, + c.wagons + FROM vn.ticketCollection tc + JOIN vn.collection c ON c.id = tc.collectionFk + JOIN vn.saleVolume sv ON sv.ticketFk = tc.ticketFk + WHERE c.workerFk IS NULL + AND sv.shipped >= util.VN_CURDATE() + GROUP BY tc.collectionFk + ) SELECT c.collectionFk + FROM collections c + JOIN vn.operator o + WHERE o.workerFk = vUserFk + AND (c.saleTotalCount <= o.linesLimit OR o.linesLimit IS NULL) + AND (c.itemPackingTypeFk = o.itemPackingTypeFk OR o.itemPackingTypeFk IS NULL) + AND o.numberOfWagons = c.wagons + AND o.trainFk = c.trainFk + AND o.warehouseFk = c.warehouseFk; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + -- Si hay colecciones sin terminar, sale del proceso DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN - IF vLockName IS NOT NULL THEN - DO RELEASE_LOCK(vLockName); - END IF; - + ROLLBACK; RESIGNAL; END; - -- Si hay colecciones sin terminar, sale del proceso CALL collection_get(vUserFk); - SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0, - pc.collection_assign_lockname - INTO vHasTooMuchCollections, - vLockName - FROM tmp.collection c - JOIN productionConfig pc; + SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0, pc.maxNotAssignedCollectionLifeTime + INTO vHasTooMuchCollections, vMaxNotAssignedCollectionLifeTime + FROM productionConfig pc + LEFT JOIN tmp.collection ON TRUE; DROP TEMPORARY TABLE tmp.collection; IF vHasTooMuchCollections THEN - CALL util.throw('There are pending collections'); - END IF; - - SELECT warehouseFk, itemPackingTypeFk - INTO vWarehouseFk, vItemPackingTypeFk - FROM operator - WHERE workerFk = vUserFk; - - SET vLockName = CONCAT_WS('/', - vLockName, - vWarehouseFk, - vItemPackingTypeFk - ); - - IF NOT GET_LOCK(vLockName, vLockTime) THEN - CALL util.throw(CONCAT('Cannot get lock: ', vLockName)); + CALL util.throw('Hay colecciones pendientes'); END IF; -- Se eliminan las colecciones sin asignar que estan obsoletas - INSERT INTO ticketTracking(stateFk, ticketFk) - SELECT s.id, tc.ticketFk - FROM collection c - JOIN ticketCollection tc ON tc.collectionFk = c.id - JOIN state s ON s.code = 'PRINTED_AUTO' - JOIN productionConfig pc - WHERE c.workerFk IS NULL - AND TIMEDIFF(util.VN_NOW(), c.created) > pc.maxNotAssignedCollectionLifeTime; - DELETE c - FROM collection c - JOIN productionConfig pc - WHERE c.workerFk IS NULL - AND TIMEDIFF(util.VN_NOW(), c.created) > pc.maxNotAssignedCollectionLifeTime; + INSERT INTO ticketTracking(stateFk, ticketFk) + SELECT s.id, tc.ticketFk + FROM `collection` c + JOIN ticketCollection tc ON tc.collectionFk = c.id + JOIN `state` s ON s.code = 'PRINTED_AUTO' + WHERE c.workerFk IS NULL + AND TIMEDIFF(util.VN_NOW(), c.created) > vMaxNotAssignedCollectionLifeTime; + + DELETE FROM `collection` + WHERE workerFk IS NULL + AND TIMEDIFF(util.VN_NOW(), created) > vMaxNotAssignedCollectionLifeTime; -- Se añade registro al semillero - INSERT INTO collectionHotbed - SET userFk = vUserFk; + + INSERT INTO collectionHotbed(userFk) VALUES(vUserFk); -- Comprueba si hay colecciones disponibles que se ajustan a su configuracion - SELECT MIN(c.id) INTO vCollectionFk - FROM collection c - JOIN operator o ON (o.itemPackingTypeFk = c.itemPackingTypeFk - OR c.itemPackingTypeFk IS NULL) - AND o.numberOfWagons = c.wagons - AND o.trainFk = c.trainFk - AND o.warehouseFk = c.warehouseFk - AND c.workerFk IS NULL - WHERE o.workerFk = vUserFk; + + OPEN vCollections; + l: LOOP + SET vDone = FALSE; + FETCH vCollections INTO vCollectionFk; + + IF vDone THEN + LEAVE l; + END IF; + + BEGIN + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + SET vCollectionFk = NULL; + RESIGNAL; + END; + + START TRANSACTION; + + SELECT workerFk INTO vCollectionWorker + FROM `collection` + WHERE id = vCollectionFk FOR UPDATE; + + IF vCollectionWorker IS NULL THEN + UPDATE `collection` + SET workerFk = vUserFk + WHERE id = vCollectionFk; + + COMMIT; + LEAVE l; + END IF; + + ROLLBACK; + END; + END LOOP; + CLOSE vCollections; IF vCollectionFk IS NULL THEN CALL collection_new(vUserFk, vCollectionFk); + + START TRANSACTION; + + SELECT workerFk INTO vCollectionWorker + FROM `collection` + WHERE id = vCollectionFk FOR UPDATE; + + IF vCollectionWorker IS NULL THEN + UPDATE `collection` + SET workerFk = vUserFk + WHERE id = vCollectionFk; + END IF; + + COMMIT; END IF; - - UPDATE collection - SET workerFk = vUserFk - WHERE id = vCollectionFk; - CALL itemShelvingSale_addByCollection(vCollectionFk); - - DO RELEASE_LOCK(vLockName); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -51451,9 +51708,8 @@ BEGIN SELECT tob.ticketFk, tob.description FROM vn.ticketObservation tob JOIN vn.ticketCollection tc ON tc.ticketFk = tob.ticketFk - LEFT JOIN vn.observationType ot ON ot.id = tob.observationTypeFk - WHERE ot.`code` = 'itemPicker' - AND tc.collectionFk = vParamFk OR tc.ticketFk = vParamFk + JOIN vn.observationType ot ON ot.id = tob.observationTypeFk AND ot.`code` = 'itemPicker' + WHERE tc.collectionFk = vParamFk OR tc.ticketFk = vParamFk ) SELECT t.id ticketFk, IF(!(vItemPackingTypeFk <=> 'V'), cc.code, CONCAT(SUBSTRING('ABCDEFGH', tc.wagon, 1), '-', tc.`level`)) `level`, @@ -51476,7 +51732,7 @@ BEGIN LEFT JOIN observation ob ON ob.ticketFk = t.id WHERE t.id = vParamFk AND t.shipped >= vYesterday - UNION ALL + UNION SELECT t.id ticketFk, IF(NOT(vItemPackingTypeFk <=> 'V'), cc.code, CONCAT(SUBSTRING('ABCDEFGH', tc.wagon, 1), '-', tc.`level`)) `level`, am.name agencyName, @@ -51497,7 +51753,7 @@ BEGIN LEFT JOIN vn.worker w ON w.id = c.salesPersonFk LEFT JOIN observation ob ON ob.ticketFk = t.id WHERE tc.collectionFk = vParamFk - UNION ALL + UNION SELECT sg.ticketFk, NULL `level`, am.name agencyName, @@ -51514,7 +51770,8 @@ BEGIN LEFT JOIN observation ob ON ob.ticketFk = t.id LEFT JOIN vn.client c ON c.id = t.clientFk WHERE sc.id = vParamFk - AND t.shipped >= vYesterday; + AND t.shipped >= vYesterday + GROUP BY ticketFk; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -51683,7 +51940,10 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`vn`@`localhost` PROCEDURE `collection_new`(vUserFk INT, OUT vCollectionFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `collection_new`( + vUserFk INT, + OUT vCollectionFk INT +) BEGIN /** * Genera colecciones de tickets sin asignar trabajador. @@ -51696,30 +51956,29 @@ BEGIN DECLARE vLinesLimit INT; DECLARE vTicketLines INT; DECLARE vVolumeLimit DECIMAL; - DECLARE vTicketVolume DECIMAL; DECLARE vSizeLimit INT; + DECLARE vTicketVolume DECIMAL; DECLARE vMaxTickets INT; - DECLARE vStateFk VARCHAR(45); + DECLARE vStateCode VARCHAR(45); DECLARE vFirstTicketFk INT; - DECLARE vHour INT; - DECLARE vMinute INT; DECLARE vWorkerCode VARCHAR(3); - DECLARE vWagonCounter INT DEFAULT 0; + DECLARE vWagonCounter INT DEFAULT 1; DECLARE vTicketFk INT; DECLARE vItemPackingTypeFk VARCHAR(1); - DECLARE vHasAssignedTickets BOOLEAN; + DECLARE vHasAssignedTickets BOOL; DECLARE vHasUniqueCollectionTime BOOL; - DECLARE vDone INT DEFAULT FALSE; - DECLARE vLockName VARCHAR(215); - DECLARE vLockTime INT DEFAULT 30; + DECLARE vHeight INT; + DECLARE vVolume INT; + DECLARE vLiters INT; + DECLARE vLines INT; + DECLARE vTotalLines INT DEFAULT 0; + DECLARE vTotalVolume INT DEFAULT 0; DECLARE vFreeWagonFk INT; - DECLARE vErrorNumber INT; - DECLARE vErrorMsg TEXT; + DECLARE vDone INT DEFAULT FALSE; - DECLARE c1 CURSOR FOR + DECLARE vTickets CURSOR FOR SELECT ticketFk, `lines`, m3 FROM tmp.productionBuffer - WHERE ticketFk <> vFirstTicketFk ORDER BY HH, mm, productionOrder DESC, @@ -51732,26 +51991,6 @@ BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - GET DIAGNOSTICS CONDITION 1 - vErrorNumber = MYSQL_ERRNO, - vErrorMsg = MESSAGE_TEXT; - - CALL util.debugAdd('collection_new', JSON_OBJECT( - 'errorNumber', vErrorNumber, - 'errorMsg', vErrorMsg, - 'lockName', vLockName, - 'userFk', vUserFk, - 'ticketFk', vTicketFk - )); -- Tmp - - IF vLockName IS NOT NULL THEN - DO RELEASE_LOCK(vLockName); - END IF; - RESIGNAL; - END; - SELECT pc.ticketTrolleyMax * o.numberOfWagons, pc.hasUniqueCollectionTime, w.code, @@ -51762,36 +52001,26 @@ BEGIN o.trainFk, o.linesLimit, o.volumeLimit, - o.sizeLimit, - pc.collection_new_lockname + o.sizeLimit INTO vMaxTickets, - vHasUniqueCollectionTime, - vWorkerCode, - vWarehouseFk, - vItemPackingTypeFk, - vStateFk, - vWagons, - vTrainFk, - vLinesLimit, - vVolumeLimit, - vSizeLimit, - vLockName - FROM productionConfig pc - JOIN worker w ON w.id = vUserFk + vHasUniqueCollectionTime, + vWorkerCode, + vWarehouseFk, + vItemPackingTypeFk, + vStateCode, + vWagons, + vTrainFk, + vLinesLimit, + vVolumeLimit, + vSizeLimit + FROM worker w + JOIN operator o ON o.workerFk = w.id JOIN state st ON st.`code` = 'ON_PREPARATION' - JOIN operator o ON o.workerFk = vUserFk; - - SET vLockName = CONCAT_WS('/', - vLockName, - vWarehouseFk, - vItemPackingTypeFk - ); - - IF NOT GET_LOCK(vLockName, vLockTime) THEN - CALL util.throw(CONCAT('Cannot get lock: ', vLockName)); - END IF; + JOIN productionConfig pc + WHERE w.id = vUserFk; -- Se prepara el tren, con tantos vagones como sea necesario. + CREATE OR REPLACE TEMPORARY TABLE tTrain (wagon INT, shelve INT, @@ -51802,63 +52031,62 @@ BEGIN PRIMARY KEY(wagon, shelve)) ENGINE = MEMORY; - WHILE vWagons > vWagonCounter DO - SET vWagonCounter = vWagonCounter + 1; - - INSERT INTO tTrain(wagon, shelve, liters, `lines`, height) - SELECT vWagonCounter, cv.`level` , cv.liters , cv.`lines` , cv.height - FROM collectionVolumetry cv - WHERE cv.trainFk = vTrainFk + INSERT INTO tTrain (wagon, shelve, liters, `lines`, height) + WITH RECURSIVE wagonSequence AS ( + SELECT vWagonCounter wagon + UNION ALL + SELECT wagon + 1 wagon + FROM wagonSequence + WHERE wagon < vWagonCounter + vWagons -1 + ) + SELECT ws.wagon, cv.`level`, cv.liters, cv.`lines`, cv.height + FROM wagonSequence ws + JOIN vn.collectionVolumetry cv ON cv.trainFk = vTrainFk AND cv.itemPackingTypeFk = vItemPackingTypeFk; - END WHILE; -- Esto desaparecerá cuando tengamos la table cache.ticket + CALL productionControl(vWarehouseFk, 0); ALTER TABLE tmp.productionBuffer ADD COLUMN liters INT, ADD COLUMN height INT; - -- Se obtiene nº de colección. - INSERT INTO collection - SET itemPackingTypeFk = vItemPackingTypeFk, - trainFk = vTrainFk, - wagons = vWagons, - warehouseFk = vWarehouseFk; - - SELECT LAST_INSERT_ID() INTO vCollectionFk; - -- Los tickets de recogida en Algemesí sólo se sacan si están asignados. -- Los pedidos con riesgo no se sacan aunque se asignen. - DELETE pb.* + + DELETE pb FROM tmp.productionBuffer pb JOIN state s ON s.id = pb.state WHERE (pb.agency = 'REC_ALGEMESI' AND s.code <> 'PICKER_DESIGNED') OR pb.problem LIKE '%RIESGO%'; - -- Comprobamos si hay tickets asignados. En ese caso, nos centramos - -- exclusivamente en esos tickets y los sacamos independientemente - -- de problemas o tamaños - SELECT COUNT(*) INTO vHasAssignedTickets - FROM tmp.productionBuffer pb - JOIN state s ON s.id = pb.state - WHERE s.code = 'PICKER_DESIGNED' - AND pb.workerCode = vWorkerCode; + -- Si hay tickets asignados, nos centramos exclusivamente en esos tickets + -- y los sacamos independientemente de problemas o tamaños + + SELECT EXISTS ( + SELECT TRUE + FROM tmp.productionBuffer pb + JOIN state s ON s.id = pb.state + WHERE (s.code = 'PICKER_DESIGNED' + AND pb.workerCode = vWorkerCode) + OR s.code = 'LAST_CALL' + ) INTO vHasAssignedTickets; -- Se dejan en la tabla tmp.productionBuffer sólo aquellos tickets adecuados + IF vHasAssignedTickets THEN - DELETE pb.* + DELETE pb FROM tmp.productionBuffer pb JOIN state s ON s.id = pb.state - WHERE s.code <> 'PICKER_DESIGNED' - OR pb.workerCode <> vWorkerCode; + WHERE (s.code <> 'PICKER_DESIGNED' + OR pb.workerCode <> vWorkerCode) + AND s.code <> 'LAST_CALL'; ELSE - DELETE pb.* + DELETE pb FROM tmp.productionBuffer pb JOIN state s ON s.id = pb.state - JOIN agencyMode am ON am.id = pb.agencyModeFk - JOIN agency a ON a.id = am.agencyFk LEFT JOIN ( SELECT pb.ticketFk, MAX(i.`size`) maxSize FROM tmp.productionBuffer pb @@ -51869,7 +52097,7 @@ BEGIN ) sub ON sub.ticketFk = pb.ticketFk JOIN productionConfig pc WHERE pb.shipped <> util.VN_CURDATE() - OR (pb.ubicacion IS NULL AND a.isOwn) + OR pb.ubicacion IS NULL OR (NOT s.isPreparable AND NOT s.isPrintable) OR pb.collectionH IS NOT NULL OR pb.collectionV IS NOT NULL @@ -51877,26 +52105,25 @@ BEGIN OR (NOT pb.H AND pb.V > 0 AND vItemPackingTypeFk = 'H') OR (NOT pb.V AND vItemPackingTypeFk = 'V') OR (pc.isPreviousPreparationRequired AND pb.previousWithoutParking) - OR LENGTH(pb.problem) > 0 + OR LENGTH(pb.problem) OR pb.lines > vLinesLimit OR pb.m3 > vVolumeLimit OR sub.maxSize > vSizeLimit OR pb.hasPlantTray; END IF; - -- Es importante que el primer ticket se coja en todos los casos - SELECT ticketFk, - HH, - mm, - `lines`, - m3 - INTO vFirstTicketFk, - vHour, - vMinute, - vTicketLines, - vTicketVolume + -- Hay que excluir aquellos que no tengan la misma hora de preparacion, si procede + + IF vHasUniqueCollectionTime THEN + DELETE pb + FROM tmp.productionBuffer pb + JOIN tmp.productionBuffer pb2 ON pb2.ticketFk = vFirstTicketFk + AND (pb.HH <> pb2.HH OR pb.mm <> pb2.mm); + END IF; + + SELECT ticketFk INTO vFirstTicketFk FROM tmp.productionBuffer - ORDER BY HH, + ORDER BY HH, mm, productionOrder DESC, m3 DESC, @@ -51906,44 +52133,37 @@ BEGIN ticketFk LIMIT 1; - -- Hay que excluir aquellos que no tengan la misma hora de preparacion, si procede - IF vHasUniqueCollectionTime THEN - DELETE FROM tmp.productionBuffer - WHERE HH <> vHour - OR mm <> vMinute; - END IF; - - SET vTicketFk = vFirstTicketFk; - SET @lines = 0; - SET @volume = 0; - - OPEN c1; - read_loop: LOOP + OPEN vTickets; + l: LOOP SET vDone = FALSE; + FETCH vTickets INTO vTicketFk, vTicketLines, vTicketVolume; + + IF vDone THEN + LEAVE l; + END IF; -- Buscamos un ticket que cumpla con los requisitos en el listado - IF ((vTicketLines + @lines) <= vLinesLimit OR vLinesLimit IS NULL) - AND ((vTicketVolume + @volume) <= vVolumeLimit OR vVolumeLimit IS NULL) THEN + + IF (vLinesLimit IS NULL OR (vTotalLines + vTicketLines) <= vLinesLimit) + AND (vVolumeLimit IS NULL OR (vTotalVolume + vTicketVolume) <= vVolumeLimit) THEN CALL ticket_splitItemPackingType(vTicketFk, vItemPackingTypeFk); DROP TEMPORARY TABLE tmp.ticketIPT; + SELECT COUNT(*), SUM(litros), MAX(i.`size`), SUM(sv.volume) + INTO vLines, vLiters, vHeight, vVolume + FROM saleVolume sv + JOIN sale s ON s.id = sv.saleFk + JOIN item i ON i.id = s.itemFk + WHERE sv.ticketFk = vTicketFk; + + SET vTotalVolume = vTotalVolume + vVolume, + vTotalLines = vTotalLines + vLines; + UPDATE tmp.productionBuffer pb - JOIN ( - SELECT SUM(litros) liters, - @lines:= COUNT(*) + @lines, - COUNT(*) `lines`, - MAX(i.`size`) height, - @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 - WHERE sv.ticketFk = vTicketFk - ) sub - SET pb.liters = sub.liters, - pb.`lines` = sub.`lines`, - pb.height = sub.height + SET pb.liters = vLiters, + pb.`lines` = vLines, + pb.height = vHeight WHERE pb.ticketFk = vTicketFk; UPDATE tTrain tt @@ -51960,17 +52180,13 @@ BEGIN tt.height LIMIT 1; - -- Si no le encuentra una balda adecuada, intentamos darle un carro entero si queda alguno libre + -- Si no le encuentra una balda, intentamos darle un carro entero libre + IF NOT (SELECT COUNT(*) FROM tTrain WHERE ticketFk) THEN - SELECT tt.wagon - INTO vFreeWagonFk - FROM tTrain tt - LEFT JOIN ( - SELECT DISTINCT wagon - FROM tTrain - WHERE ticketFk IS NOT NULL - ) nn ON nn.wagon = tt.wagon - WHERE nn.wagon IS NULL + SELECT wagon INTO vFreeWagonFk + FROM tTrain + GROUP BY wagon + HAVING COUNT(ticketFk) = 0 ORDER BY wagon LIMIT 1; @@ -51979,38 +52195,35 @@ BEGIN 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 - WHERE ticketFk IS NOT NULL - ) nn ON nn.wagon = tt.wagon - WHERE nn.wagon IS NULL; - END IF; - END IF; + -- Se anulan el resto de carros libres, + -- máximo un carro con pedido excesivo - FETCH c1 INTO vTicketFk, vTicketLines, vTicketVolume; - IF vDone OR NOT (SELECT COUNT(*) FROM tTrain WHERE ticketFk IS NULL) THEN - LEAVE read_loop; - END IF; - ELSE - FETCH c1 INTO vTicketFk, vTicketLines, vTicketVolume; - IF vDone THEN - LEAVE read_loop; - END IF; + DELETE tt + FROM tTrain tt + JOIN (SELECT wagon + FROM tTrain + GROUP BY wagon + HAVING COUNT(ticketFk) = 0 + ) sub ON sub.wagon = tt.wagon; + END IF; + END IF; END IF; END LOOP; - CLOSE c1; + CLOSE vTickets; IF (SELECT COUNT(*) FROM tTrain WHERE ticketFk) THEN - UPDATE collection c - JOIN state st ON st.code = 'ON_PREPARATION' - SET c.stateFk = st.id - WHERE c.id = vCollectionFk; + -- Se obtiene nº de colección + + INSERT INTO collection + SET itemPackingTypeFk = vItemPackingTypeFk, + trainFk = vTrainFk, + wagons = vWagons, + warehouseFk = vWarehouseFk; + + SELECT LAST_INSERT_ID() INTO vCollectionFk; -- Asigna las bandejas + INSERT IGNORE INTO ticketCollection(ticketFk, collectionFk, `level`, wagon, liters) SELECT tt.ticketFk, vCollectionFk, tt.shelve, tt.wagon, tt.liters FROM tTrain tt @@ -52018,37 +52231,34 @@ BEGIN ORDER BY tt.wagon, tt.shelve; -- Actualiza el estado de los tickets - CALL collection_setState(vCollectionFk, vStateFk); + + CALL collection_setState(vCollectionFk, vStateCode); -- Aviso para la preparacion previa + INSERT INTO ticketDown(ticketFk, collectionFk) SELECT tc.ticketFk, tc.collectionFk FROM ticketCollection tc WHERE tc.collectionFk = vCollectionFk; - CALL sales_mergeByCollection(vCollectionFk); + CALL collection_mergeSales(vCollectionFk); UPDATE `collection` c - JOIN ( + JOIN( SELECT COUNT(*) saleTotalCount, SUM(s.isPicked <> 0) salePickedCount FROM ticketCollection tc JOIN sale s ON s.ticketFk = tc.ticketFk - WHERE tc.collectionFk = vCollectionFk - AND s.quantity > 0 - ) sub + WHERE tc.collectionFk = vCollectionFk + AND s.quantity > 0 + )sub SET c.saleTotalCount = sub.saleTotalCount, c.salePickedCount = sub.salePickedCount WHERE c.id = vCollectionFk; - ELSE - DELETE FROM `collection` - WHERE id = vCollectionFk; - SET vCollectionFk = NULL; + SET vCollectionFk = NULL; END IF; - DO RELEASE_LOCK(vLockName); - DROP TEMPORARY TABLE tTrain, tmp.productionBuffer; @@ -55362,22 +55572,26 @@ CREATE DEFINER=`vn`@`localhost` PROCEDURE `expeditionPallet_build`( vWorkerFk INT, OUT vPalletFk INT ) -BEGIN -/** Construye un pallet de expediciones. +proc: BEGIN +/** + * Builds an expedition pallet. * - * Primero comprueba si esas expediciones ya pertenecen a otro pallet, - * en cuyo caso actualiza ese pallet. + * First, it checks if these expeditions already belong to another pallet, + * in which case it returns an error. * - * @param vExpeditions JSON_ARRAY con esta estructura [exp1, exp2, exp3, ...] - * @param vArcId INT Identificador de arcRead - * @param vWorkerFk INT Identificador de worker - * @param out vPalletFk Identificador de expeditionPallet + * @param vExpeditions JSON_ARRAY with this structure [exp1, exp2, exp3, ...] + * @param vArcId INT Identifier of arcRead + * @param vWorkerFk INT Identifier of worker + * @param out vPalletFk Identifier of expeditionPallet */ + DECLARE vCounter INT; DECLARE vExpeditionFk INT; DECLARE vTruckFk INT; DECLARE vPrinterFk INT; DECLARE vExpeditionStateTypeFk INT; + DECLARE vFreeExpeditionCount INT; + DECLARE vExpeditionWithPallet INT; CREATE OR REPLACE TEMPORARY TABLE tExpedition ( expeditionFk INT, @@ -55401,48 +55615,63 @@ BEGIN WHERE e.id = vExpeditionFk; END WHILE; - SELECT palletFk INTO vPalletFk - FROM ( - SELECT palletFk, count(*) n - FROM tExpedition - WHERE palletFk > 0 - GROUP BY palletFk - ORDER BY n DESC - LIMIT 100 - ) sub - LIMIT 1; + SELECT COUNT(expeditionFk) INTO vFreeExpeditionCount + FROM tExpedition + WHERE palletFk IS NULL; - IF vPalletFk IS NULL THEN - SELECT roadmapStopFk INTO vTruckFk - FROM ( - SELECT rm.roadmapStopFk, count(*) n - FROM routesMonitor rm - JOIN tExpedition e ON e.routeFk = rm.routeFk - GROUP BY roadmapStopFk - ORDER BY n DESC - LIMIT 1 - ) sub; + SELECT COUNT(expeditionFk) INTO vExpeditionWithPallet + FROM tExpedition + WHERE palletFk; - IF vTruckFk IS NULL THEN - CALL util.throw ('TRUCK_NOT_AVAILABLE'); - END IF; - - INSERT INTO expeditionPallet SET truckFk = vTruckFk; - - SET vPalletFk = LAST_INSERT_ID(); + IF vExpeditionWithPallet THEN + UPDATE arcRead + SET error = ( + SELECT GROUP_CONCAT(expeditionFk SEPARATOR ', ') + FROM tExpedition + WHERE palletFk + ) + WHERE id = vArcId; + LEAVE proc; END IF; + IF NOT vFreeExpeditionCount THEN + CALL util.throw ('NO_FREE_EXPEDITIONS'); + END IF; + + SELECT roadmapStopFk INTO vTruckFk + FROM ( + SELECT rm.roadmapStopFk, count(*) n + FROM routesMonitor rm + JOIN tExpedition e ON e.routeFk = rm.routeFk + WHERE e.palletFk IS NULL + GROUP BY roadmapStopFk + ORDER BY n DESC + LIMIT 1 + ) sub; + + IF vTruckFk IS NULL THEN + CALL util.throw ('TRUCK_NOT_AVAILABLE'); + END IF; + + INSERT INTO expeditionPallet SET truckFk = vTruckFk; + + SET vPalletFk = LAST_INSERT_ID(); + INSERT INTO expeditionScan(expeditionFk, palletFk, workerFk) SELECT expeditionFk, vPalletFk, vWorkerFk FROM tExpedition - ON DUPLICATE KEY UPDATE palletFk = vPalletFk, workerFk = vWorkerFk; + WHERE palletFk IS NULL; SELECT id INTO vExpeditionStateTypeFk FROM expeditionStateType WHERE code = 'PALLETIZED'; - + INSERT INTO expeditionState(expeditionFk, typeFk) - SELECT expeditionFk, vExpeditionStateTypeFk FROM tExpedition; + SELECT expeditionFk, vExpeditionStateTypeFk + FROM tExpedition + WHERE palletFk IS NULL; + + UPDATE arcRead SET error = NULL WHERE id = vArcId; SELECT printerFk INTO vPrinterFk FROM arcRead WHERE id = vArcId; @@ -58550,6 +58779,75 @@ 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 `invoiceOut_newFromAddress` */; +/*!50003 SET @saved_cs_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=`vn`@`localhost` PROCEDURE `invoiceOut_newFromAddress`( + IN vAddressFk INT, + IN vSerial CHAR(2), + IN vMaxShipped DATE, + IN vCompanyFk INT, + IN vTaxArea VARCHAR(25), + IN vRef VARCHAR(25), + OUT vInvoiceId INT) +BEGIN +/** + * Factura los tickets de un consignatario hasta una fecha dada + * @param vAddressFk Id del consignatario a facturar + * @param vSerial Serie de factura + * @param vMaxShipped Fecha hasta la cual cogerá tickets para facturar + * @param vCompanyFk Id de la empresa desde la que se factura + * @param vTaxArea Tipo de iva en relacion a la empresa y al cliente, NULL por defecto + * @param vRef Referencia de la factura en caso que se quiera forzar, NULL por defecto + * @return vInvoiceId factura + */ + DECLARE vIsRefEditable BOOLEAN; + + IF vRef IS NOT NULL AND vSerial IS NOT NULL THEN + SELECT isRefEditable INTO vIsRefEditable + FROM invoiceOutSerial + WHERE code = vSerial; + + IF NOT vIsRefEditable THEN + CALL util.throw('serial non editable'); + END IF; + END IF; + + DROP TEMPORARY TABLE IF EXISTS `tmp`.`ticketToInvoice`; + CREATE TEMPORARY TABLE `tmp`.`ticketToInvoice` + (PRIMARY KEY (`id`)) + ENGINE = MEMORY + SELECT id FROM ticket t + WHERE t.addressFk = vAddressFk + AND t.refFk IS NULL + AND t.companyFk = vCompanyFk + AND t.shipped BETWEEN + util.firstDayOfYear(vMaxShipped - INTERVAL 1 YEAR) + AND util.dayend(vMaxShipped); + + CALL invoiceOut_new(vSerial, util.VN_CURDATE(), vTaxArea, vInvoiceId); + + UPDATE invoiceOut + SET `ref` = vRef + WHERE id = vInvoiceId + AND vRef IS NOT NULL; + + IF vSerial <> 'R' AND NOT ISNULL(vInvoiceId) AND vInvoiceId <> 0 THEN + CALL invoiceOutBooking(vInvoiceId); + END IF; +END ;; +DELIMITER ; +/*!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 `invoiceOut_newFromClient` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -58739,6 +59037,73 @@ ELSE INSERT INTO vn.itemBarcode(itemFk,code) VALUES (vItemFk,vCode); 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 `itemCampaign_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=`vn`@`localhost` PROCEDURE `itemCampaign_add`() +proc: BEGIN +/** + * Añade registros a tabla itemCampaign. + * + * @param vDateFrom Fecha desde + * @param vDateTo Fecha hasta + * @param vCampaign Código de la campaña + */ + DECLARE vYesterday DATE; + DECLARE vCampaign VARCHAR(100); + DECLARE vScopeDays INT; + DECLARE vPreviousDays INT; + DECLARE vDateSumFrom DATE; + DECLARE vDateSumTo DATE; + + SET vYesterday = util.yesterday(); + + SELECT dated, code, scopeDays, previousDays + INTO vDateSumTo, vCampaign, vScopeDays, vPreviousDays + FROM campaign + WHERE dated >= vYesterday + ORDER BY dated + LIMIT 1; + + IF vCampaign IS NULL THEN + CALL util.throw('Missing data in campaign table'); + END IF; + + IF NOT vYesterday BETWEEN vDateSumTo - INTERVAL vPreviousDays DAY + AND vDateSumTo THEN + LEAVE proc; + END IF; + + SET vDateSumFrom = vDateSumTo - INTERVAL vScopeDays DAY; + SET vDateSumTo = vDateSumTo - INTERVAL 1 DAY; + + INSERT INTO itemCampaign(dated, itemFk, quantity, total, campaign) + SELECT vYesterday, + s.itemFk, + SUM(s.quantity) quantity, + SUM((s.quantity * s.price) * (100 - s.discount) / 100) total, + vCampaign + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN client c ON c.id = t.clientFk + WHERE t.shipped BETWEEN vDateSumFrom AND util.dayEnd(vDateSumTo) + AND c.typeFk = 'normal' + AND NOT t.isDeleted + GROUP BY s.itemFk + HAVING quantity; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -59767,8 +60132,9 @@ proc: BEGIN DECLARE vReservedQuantity INT; DECLARE vOutStanding INT; DECLARE vUserFk INT; - DECLARE vTotalReservedQuantity INT; + DECLARE vTotalReservedQuantity INT; DECLARE vSaleQuantity INT; + DECLARE vIsRequiredTx BOOL DEFAULT NOT @@in_transaction; DECLARE vItemShelvingAvailable CURSOR FOR SELECT ish.id itemShelvingFk, @@ -59778,7 +60144,7 @@ proc: BEGIN JOIN shelving sh ON sh.code = ish.shelvingFk JOIN parking p ON p.id = sh.parkingFk JOIN sector sc ON sc.id = p.sectorFk - JOIN productionConfig pc + JOIN productionConfig pc WHERE s.id = vSaleFk AND NOT sc.isHideForPickers AND (sc.id = vSectorFk OR vSectorFk IS NULL) @@ -59793,15 +60159,15 @@ proc: BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN - ROLLBACK; + CALL util.tx_rollback(vIsRequiredTx); RESIGNAL; END; - - START TRANSACTION; - + + CALL util.tx_start(vIsRequiredTx); + SELECT id INTO vSaleFk FROM sale - WHERE id = vSaleFk + WHERE id = vSaleFk FOR UPDATE; SELECT MAX(p.pickingOrder), s.quantity - SUM(IFNULL(iss.quantity, 0)), s.quantity @@ -59814,7 +60180,7 @@ proc: BEGIN WHERE s.id = vSaleFk; IF vOutStanding <= 0 THEN - COMMIT; + CALL util.tx_commit(vIsRequiredTx); LEAVE proc; END IF; @@ -59834,7 +60200,7 @@ proc: BEGIN IF vTotalReservedQuantity <> vSaleQuantity THEN CALL util.debugAdd('itemShelvingSale_addBySale', CONCAT(vSaleFk, ' - ', vSaleQuantity,' - ', vTotalReservedQuantity,'-', vOutStanding,'-', account.myUser_getId())); - + UPDATE sale SET quantity = vTotalReservedQuantity WHERE id = vSaleFk; @@ -59842,7 +60208,7 @@ proc: BEGIN LEAVE l; END IF; - SELECT id INTO vItemShelvingFk + SELECT id INTO vItemShelvingFk FROM itemShelving WHERE id = vItemShelvingFk FOR UPDATE; @@ -59851,19 +60217,19 @@ proc: BEGIN SET vOutStanding = vOutStanding - vReservedQuantity; IF vReservedQuantity > 0 THEN - CALL util.debugAdd('itemShelvingSale_addBySale_reservedQuantity', - CONCAT(vSaleFk, ' - ', vReservedQuantity, ' - ', vOutStanding, account.myUser_getId())); - INSERT INTO itemShelvingSale( - itemShelvingFk, - saleFk, - quantity, - userFk, - isPicked) - SELECT vItemShelvingFk, - vSaleFk, - vReservedQuantity, - vUserFk, - FALSE; + CALL util.debugAdd('itemShelvingSale_addBySale_reservedQuantity', + CONCAT(vSaleFk, ' - ', vReservedQuantity, ' - ', vOutStanding, account.myUser_getId())); + INSERT INTO itemShelvingSale( + itemShelvingFk, + saleFk, + quantity, + userFk, + isPicked) + SELECT vItemShelvingFk, + vSaleFk, + vReservedQuantity, + vUserFk, + FALSE; UPDATE itemShelving SET available = available - vReservedQuantity @@ -59872,7 +60238,7 @@ proc: BEGIN END IF; END LOOP; CLOSE vItemShelvingAvailable; - COMMIT; + CALL util.tx_commit(vIsRequiredTx); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -60000,6 +60366,68 @@ 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 `itemShelvingSale_deleteAdded` */; +/*!50003 SET @saved_cs_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=`vn`@`localhost` PROCEDURE `itemShelvingSale_deleteAdded`( + vSelf INT(11) +) +proc: BEGIN +/** + * Borra una reservea devolviendo la cantidad al itemShelving + * + * @param vSelf Identificador del itemShelvingSale + */ + DECLARE vSaleFk INT; + DECLARE vHasSalesPicked BOOL; + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + START TRANSACTION; + + SELECT iss.saleFk INTO vSaleFk + FROM itemShelvingSale iss + JOIN sale s ON s.id = iss.saleFk + WHERE iss.id = vSelf AND s.isAdded + FOR UPDATE; + + IF vSaleFk IS NULL THEN + CALL util.throw('The sale can not be deleted'); + END IF; + + SELECT COUNT(*) INTO vHasSalesPicked + FROM itemShelvingSale + WHERE saleFk = vSaleFk AND isPicked; + + IF vHasSalesPicked THEN + CALL util.throw('A sale with picked sales cannot be deleted'); + END IF; + + UPDATE itemShelvingSale iss + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + SET ish.available = ish.available + iss.quantity + WHERE iss.saleFk = vSaleFk; + + DELETE FROM sale WHERE id = vSaleFk; + + 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 `itemShelvingSale_doReserve` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -60517,18 +60945,24 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelving_addList`(vShelvingFk VARCHAR(3), vList TEXT, vIsChecking BOOL, vWarehouseFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelving_addList`( + vShelvingFk VARCHAR(3), + vList TEXT, + vIsChecking BOOL, + vWarehouseFk INT +) BEGIN -/* Recorre cada elemento en la colección vList. +/** + * Recorre cada elemento en la colección vList. * Si el parámetro isChecking = FALSE, llama a itemShelving_add. * * Cuando es TRUE sólo inserta los elementos de la colección que no están ya en - * ese shelving, actualizando los valores del campo vn.itemShelving.isChecked + * ese shelving, actualizando los valores del campo itemShelving.isChecked * - * param vShelvingFk Identificador de vn.shelving - * param vList JSON array con esta estructura: '[value1, value2, ...]' - * param vIsChecking Define si hay que añadir o comprobar los items - * param vWarehouseFk Identificador de vn.warehouse + * @param vShelvingFk Identificador de shelving + * @param vList JSON array con esta estructura: '[value1, value2, ...]' + * @param vIsChecking Define si hay que añadir o comprobar los items + * @param vWarehouseFk Identificador de warehouse */ DECLARE vListLength INT DEFAULT JSON_LENGTH(vList); DECLARE vCounter INT DEFAULT 0; @@ -60538,26 +60972,27 @@ BEGIN DECLARE vIsChecked BOOL; WHILE vCounter < vListLength DO - SET vPath = CONCAT('$[',vCounter,']'); - SET vBarcode = JSON_EXTRACT(vList,vPath); + SET vPath = CONCAT('$[', vCounter, ']'); + SET vBarcode = JSON_EXTRACT(vList, vPath); SET vIsChecked = NULL; IF vIsChecking THEN SELECT barcodeToItem(vBarcode) INTO vItemFk; - SELECT COUNT(*) INTO vIsChecked - FROM vn.itemShelving + SELECT IF(COUNT(*), TRUE, FALSE) INTO vIsChecked + FROM itemShelving WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk; END IF; - IF NOT (vIsChecking AND vIsChecked) THEN - CALL vn.itemShelving_add(vShelvingFk, vBarcode, 1, NULL, NULL, NULL, vWarehouseFk); + IF NOT vIsChecking OR NOT vIsChecked THEN + CALL itemShelving_add(vShelvingFk, vBarcode, 1, NULL, NULL, NULL, vWarehouseFk); END IF; - UPDATE vn.itemShelving + UPDATE itemShelving SET isChecked = vIsChecked WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk - AND itemFk = vItemFk AND isChecked IS NULL; + AND itemFk = vItemFk + AND isChecked IS NULL; SET vCounter = vCounter + 1; END WHILE; @@ -61625,6 +62060,58 @@ SET tag8 = t.name, value8 = it.value WHERE it.priority = 4 AND (vItem IS NULL OR vItem = it.itemFk); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `item_calculateStock` */; +/*!50003 SET @saved_cs_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=`vn`@`localhost` PROCEDURE `item_calculateStock`( + vDated DATE +) +BEGIN +/** + * Calculate the stock of the auction warehouse from the inventory date to vDated + * + * @param vDated Date to calculate the stock. + * @return tmp.item, tmp.buyUltimate + */ + DECLARE vAuctionWarehouseFk INT; + + SELECT warehouseFk INTO vAuctionWarehouseFk + FROM auctionConfig; + + CREATE OR REPLACE TEMPORARY TABLE tmp.item + (UNIQUE INDEX i USING HASH (itemFk)) + ENGINE = MEMORY + SELECT itemFk, SUM(quantity) quantity + FROM itemEntryIn + WHERE landed = vDated + AND vDated >= util.VN_CURDATE() + AND warehouseInFk = vAuctionWarehouseFk + AND NOT isVirtualStock + GROUP BY itemFk + HAVING quantity; + + CALL `cache`.stock_refresh(FALSE); + + INSERT INTO tmp.item (itemFk, quantity) + SELECT item_id, amount + FROM `cache`.stock + WHERE warehouse_id = vAuctionWarehouseFk + ON DUPLICATE KEY UPDATE quantity = tmp.item.quantity + VALUES(quantity); + + CALL buy_getUltimate(NULL, vAuctionWarehouseFk, vDated); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -63380,19 +63867,23 @@ CREATE DEFINER=`vn`@`localhost` PROCEDURE `item_getSimilar`( ) BEGIN /** -* Propone articulos 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 -* @param vDaysInForward Días de alcance para las ventas -*/ + * Propone articulos 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 + * @param vDaysInForward Días de alcance para las ventas (https://redmine.verdnatura.es/issues/7956#note-4) + */ DECLARE vAvailableCalcFk INT; + DECLARE vVisibleCalcFk INT; + DECLARE vTypeFk INT; DECLARE vPriority INT DEFAULT 1; CALL cache.available_refresh(vAvailableCalcFk, FALSE, vWarehouseFk, vDated); + CALL cache.visible_refresh(vVisibleCalcFk, FALSE, vWarehouseFk); + CALL buy_getUltimate(NULL, vWarehouseFk, vDated); WITH itemTags AS ( SELECT i.id, @@ -63412,25 +63903,9 @@ BEGIN AND it.priority = vPriority LEFT JOIN vn.tag t ON t.id = it.tagFk WHERE i.id = vSelf - ), - stock AS ( - SELECT itemFk, SUM(visible) stock - FROM vn.itemShelvingStock - WHERE warehouseFk = vWarehouseFk - GROUP BY itemFk - ), - sold AS ( - SELECT SUM(s.quantity) quantity, s.itemFk - FROM vn.sale s - JOIN vn.ticket t ON t.id = s.ticketFk - LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id - WHERE t.shipped >= CURDATE() + INTERVAL vDaysInForward DAY - AND iss.saleFk IS NULL - AND t.warehouseFk = vWarehouseFk - GROUP BY s.itemFk ) SELECT i.id itemFk, - LEAST(CAST(sd.quantity AS INT), sk.stock) advanceable, + NULL advanceable, -- https://redmine.verdnatura.es/issues/7956#note-4 i.longName, i.subName, i.tag5, @@ -63452,38 +63927,38 @@ BEGIN WHEN b.groupingMode = 'packing' THEN b.packing ELSE 1 END minQuantity, - sk.stock located, + v.visible located, b.price2 FROM vn.item i - LEFT JOIN sold sd ON sd.itemFk = i.id JOIN cache.available a ON a.item_id = i.id AND a.calc_id = vAvailableCalcFk - LEFT JOIN stock sk ON sk.itemFk = i.id - LEFT JOIN cache.last_buy lb ON lb.item_id = i.id - AND lb.warehouse_id = vWarehouseFk + LEFT JOIN cache.visible v ON v.item_id = i.id + AND v.calc_id = vVisibleCalcFk + LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = i.id 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 vn.buy b ON b.id = lb.buy_id + LEFT JOIN vn.buy b ON b.id = bu.buyFk JOIN itemTags its - WHERE (a.available > 0 OR sd.quantity < sk.stock) + WHERE a.available > 0 AND (i.typeFk = its.typeFk OR NOT vShowType) AND i.id <> vSelf - ORDER BY (a.available > 0) DESC, - `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 + 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; + + DROP TEMPORARY TABLE tmp.buyUltimate; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -66055,13 +66530,11 @@ proc: BEGIN DECLARE vEndingDate DATETIME; DECLARE vIsTodayRelative BOOLEAN; - SELECT util.dayEnd(util.VN_CURDATE()) + INTERVAL LEAST(vScopeDays, maxProductionScopeDays) DAY - INTO vEndingDate - FROM productionConfig; - - SELECT isTodayRelative INTO vIsTodayRelative - FROM worker - WHERE id = getUser(); -- Cambiar por account.myUser_getId(), falta dar permisos + SELECT w.isTodayRelative, util.dayEnd(util.VN_CURDATE()) + INTERVAL LEAST(vScopeDays, pc.maxProductionScopeDays) DAY + INTO vIsTodayRelative,vEndingDate + FROM worker w + JOIN productionConfig pc + WHERE w.id = account.myUser_getId(); CALL prepareTicketList(util.yesterday(), vEndingDate); @@ -66308,15 +66781,14 @@ proc: BEGIN UPDATE tmp.productionBuffer pb JOIN sale s ON s.ticketFk = pb.ticketFk JOIN item i ON i.id = s.itemFk - JOIN cache.last_buy lb ON lb.warehouse_id = vWarehouseFk + JOIN cache.last_buy lb ON lb.warehouse_id = vWarehouseFk AND lb.item_id = s.itemFk JOIN buy b ON b.id = lb.buy_id JOIN packaging p ON p.id = b.packagingFk - JOIN productionConfig pc SET pb.hasPlantTray = TRUE WHERE p.isPlantTray AND s.quantity >= b.packing - AND pb.isOwn; + AND pb.isOwn; DROP TEMPORARY TABLE tmp.productionTicket, @@ -66691,6 +67163,47 @@ 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 `queueMember_updateQueue` */; +/*!50003 SET @saved_cs_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=`vn`@`localhost` PROCEDURE `queueMember_updateQueue`( + vBusinessFk INT +) +BEGIN + /** + * Elimina la entrada de la cola anterior y luego inserta la nueva para un trabajador. + * + * @param vBusinessFk ID del negocio + */ + DECLARE vNewQueue VARCHAR(10); + DECLARE vExtension VARCHAR(10); + DECLARE exit handler FOR SQLEXCEPTION + + SELECT d.pbxQueue, s.extension + INTO vNewQueue, vExtension + FROM business b + JOIN department d ON d.id = b.departmentFk + JOIN pbx.sip s ON s.user_id = b.workerFk + WHERE b.id = vBusinessFk; + + DELETE FROM pbx.queueMember + WHERE extension = vExtension COLLATE utf8_general_ci; + + INSERT IGNORE INTO pbx.queueMember (queue, extension) + VALUES (vNewQueue, vExtension); +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 */ ; @@ -68192,6 +68705,39 @@ 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 `saleTracking_sectorCollectionAddPrevOK` */; +/*!50003 SET @saved_cs_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=`vn`@`localhost` PROCEDURE `saleTracking_sectorCollectionAddPrevOK`( + vSectorCollectionFk INT +) +BEGIN +/** + * Inserta los registros de sectorCollection con el estado PREVIA OK si la reserva está picked + * + * @param vSectorCollectionFk Identificador de vn.sectorCollection + */ + REPLACE saleTracking(saleFk, isChecked, workerFk, stateFk) + SELECT sgd.saleFk, TRUE, sc.userFk, s.id + FROM sectorCollection sc + JOIN sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id + JOIN saleGroupDetail sgd ON sgd.saleGroupFk = scsg.saleGroupFk + JOIN state s ON s.code = 'OK PREVIOUS' + JOIN itemShelvingSale iss ON iss.saleFk = sgd.saleFk + WHERE sc.id = vSectorCollectionFk AND iss.isPicked; +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 `saleTracking_updateIsChecked` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -68834,7 +69380,7 @@ BEGIN isTooLittle BOOL DEFAULT FALSE, isVip BOOL DEFAULT FALSE, PRIMARY KEY (ticketFk, saleFk) - ) ENGINE = MEMORY; + ); -- No memory INSERT INTO tmp.sale_problems(ticketFk, saleFk, @@ -70238,13 +70784,13 @@ proc: BEGIN * Calculate the stock of the auction warehouse from the inventory date to vDated * without taking into account the outputs of the same day vDated * - * @param vDated Date to calculate the stock. + * @param vDated Date to calculate the stock */ IF vDated < util.VN_CURDATE() THEN LEAVE proc; END IF; - CREATE OR REPLACE TEMPORARY TABLE tStockBought + CREATE OR REPLACE TEMPORARY TABLE tCurrentData SELECT workerFk, reserve FROM stockBought WHERE dated = vDated @@ -70252,15 +70798,28 @@ proc: BEGIN DELETE FROM stockBought WHERE dated = vDated; + CREATE OR REPLACE TEMPORARY TABLE tStockSold + SELECT it.workerFk, + SUM(ic.cm3 * ito.quantity / vc.palletM3 / 1000000) sold + FROM itemTicketOut ito + JOIN item i ON i.id = ito.itemFk + JOIN itemType it ON it.id = i.typeFk + JOIN ticket t ON t.id = ito.ticketFk + JOIN warehouse wh ON wh.id = t.warehouseFk + JOIN itemCost ic ON ic.itemFk = ito.itemFk + AND ic.warehouseFk = t.warehouseFk + JOIN volumeConfig vc + WHERE ito.shipped BETWEEN vDated AND util.dayEnd(vDated) + AND wh.code = 'VNH' + GROUP BY it.workerFk; + CALL item_calculateStock(vDated); - INSERT INTO stockBought(workerFk, bought, dated) + CREATE OR REPLACE TEMPORARY TABLE tStockBought SELECT it.workerFk, - ROUND(SUM( - (ti.quantity / b.packing) * - buy_getVolume(b.id) - ) / vc.palletM3 / 1000000, 1) bought, - vDated + SUM((ti.quantity / b.packing) * + buy_getVolume(b.id) + ) / vc.palletM3 / 1000000 bought FROM itemType it JOIN item i ON i.typeFk = it.id LEFT JOIN tmp.item ti ON ti.itemFk = i.id @@ -70274,245 +70833,34 @@ proc: BEGIN GROUP BY it.workerFk HAVING bought; + + INSERT INTO stockBought(workerFk, bought, dated) + SELECT tb.workerFk, + ROUND(GREATEST(tb.bought - IFNULL(ts.sold, 0), 0), 1), + vDated + FROM tStockBought tb + LEFT JOIN tStockSold ts ON ts.workerFk = tb.workerFk; + UPDATE stockBought s - JOIN tStockBought ts ON ts.workerFk = s.workerFk + JOIN tCurrentData ts ON ts.workerFk = s.workerFk SET s.reserve = ts.reserve WHERE s.dated = vDated; INSERT INTO stockBought (workerFk, reserve, dated) SELECT ts.workerFk, ts.reserve, vDated - FROM tStockBought ts + FROM tCurrentData ts WHERE ts.workerFk NOT IN ( SELECT workerFk FROM stockBought WHERE dated = vDated ); - DROP TEMPORARY TABLE tStockBought, tmp.item, tmp.buyUltimate; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `stockBuyedByWorker` */; -/*!50003 SET @saved_cs_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=`vn`@`localhost` PROCEDURE `stockBuyedByWorker`( - vDated DATE, - vWorker INT -) -BEGIN -/** - * Inserta el volumen de compra de un comprador - * en stockBuyed de acuerdo con la fecha. - * - * @param vDated Fecha de compra - * @param vWorker Id de trabajador - */ - CREATE OR REPLACE TEMPORARY TABLE tStockBuyed - (INDEX (userFk)) - ENGINE = MEMORY - SELECT requested, reserved, userFk - FROM stockBuyed - WHERE dated = vDated - AND userFk = vWorker; - - DELETE FROM stockBuyed - WHERE dated = vDated - AND userFk = vWorker; - - CALL stockTraslation(vDated); - - INSERT INTO stockBuyed(userFk, buyed, `dated`, reserved, requested, description) - SELECT it.workerFk, - SUM((ti.quantity / b.packing) * buy_getVolume(b.id)) / vc.palletM3 / 1000000, - vDated, - sb.reserved, - sb.requested, - u.name - FROM itemType it - JOIN item i ON i.typeFk = it.id - LEFT JOIN tmp.item ti ON ti.itemFk = i.id - JOIN itemCategory ic ON ic.id = it.categoryFk - JOIN warehouse wh ON wh.code = 'VNH' - JOIN tmp.buyUltimate bu ON bu.itemFk = i.id - AND bu.warehouseFk = wh.id - JOIN buy b ON b.id = bu.buyFk - JOIN volumeConfig vc - JOIN account.`user` u ON u.id = it.workerFk - LEFT JOIN tStockBuyed sb ON sb.userFk = it.workerFk - WHERE ic.display - AND it.workerFk = vWorker; - - SELECT b.entryFk Id_Entrada, - i.id Id_Article, - i.name Article, - ti.quantity Cantidad, - (ac.conversionCoefficient * (ti.quantity / b.packing) * buy_getVolume(b.id)) - / (vc.trolleyM3 * 1000000) buyed, - b.packagingFk id_cubo, - b.packing - FROM tmp.item ti - JOIN item i ON i.id = ti.itemFk - JOIN itemType it ON i.typeFk = it.id - JOIN itemCategory ic ON ic.id = it.categoryFk - JOIN worker w ON w.id = it.workerFk - JOIN auctionConfig ac - JOIN tmp.buyUltimate bu ON bu.itemFk = i.id - AND bu.warehouseFk = ac.warehouseFk - JOIN buy b ON b.id = bu.buyFk - JOIN volumeConfig vc - WHERE ic.display - AND w.id = vWorker; - - DROP TEMPORARY TABLE tmp.buyUltimate, - tmp.item, - tStockBuyed; -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 `stockBuyed_add` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`vn`@`localhost` PROCEDURE `stockBuyed_add`( - vDated DATE -) -BEGIN -/** - * Inserta el volumen de compra por comprador - * en stockBuyed de acuerdo con la fecha. - * - * @param vDated Fecha de compra - */ - CREATE OR REPLACE TEMPORARY TABLE tStockBuyed - (INDEX (userFk)) - ENGINE = MEMORY - SELECT requested, reserved, userFk - FROM stockBuyed - WHERE dated = vDated; - - DELETE FROM stockBuyed WHERE dated = vDated; - - CALL stockTraslation(vDated); - - INSERT INTO stockBuyed(userFk, buyed, `dated`, description) - SELECT it.workerFk, - SUM((ti.quantity / b.packing) * buy_getVolume(b.id)) / vc.palletM3 / 1000000, - vDated, - u.name - FROM itemType it - JOIN item i ON i.typeFk = it.id - LEFT JOIN tmp.item ti ON ti.itemFk = i.id - JOIN itemCategory ic ON ic.id = it.categoryFk - JOIN warehouse wh ON wh.code = 'VNH' - JOIN tmp.buyUltimate bu ON bu.itemFk = i.id AND bu.warehouseFk = wh.id - JOIN buy b ON b.id = bu.buyFk - JOIN volumeConfig vc - JOIN account.`user` u ON u.id = it.workerFk - JOIN workerDepartment wd ON wd.workerFk = u.id - JOIN department d ON d.id = wd.departmentFk - WHERE ic.display - AND d.code IN ('shopping', 'logistic', 'franceTeam') - GROUP BY it.workerFk; - - INSERT INTO stockBuyed(buyed, dated, description) - SELECT SUM(ic.cm3 * ito.quantity / vc.palletM3 / 1000000), - vDated, - IF(c.code = 'ES', p.name, c.name) destiny - FROM itemTicketOut ito - JOIN ticket t ON t.id = ito.ticketFk - JOIN `address` a ON a.id = t.addressFk - JOIN province p ON p.id = a.provinceFk - JOIN country c ON c.id = p.countryFk - JOIN warehouse wh ON wh.id = t.warehouseFk - JOIN itemCost ic ON ic.itemFk = ito.itemFk - AND ic.warehouseFk = t.warehouseFk - JOIN volumeConfig vc - WHERE ito.shipped BETWEEN vDated AND util.dayend(vDated) - AND wh.code = 'VNH' - GROUP BY destiny; - - UPDATE stockBuyed s - JOIN tStockBuyed ts ON ts.userFk = s.userFk - SET s.requested = ts.requested, - s.reserved = ts.reserved + UPDATE stockBought s + JOIN tStockSold ts ON ts.workerFk = s.workerFk + SET s.bought = IF(s.bought < ts.sold, ROUND(s.bought - ts.sold, 1), 0) WHERE s.dated = vDated; - DROP TEMPORARY TABLE tmp.buyUltimate, - tmp.item, - tStockBuyed; -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 `stockTraslation` */; -/*!50003 SET @saved_cs_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=`vn`@`localhost` PROCEDURE `stockTraslation`( - vDated DATE -) -BEGIN -/** - * Calcula el stock del almacén de subasta desde FechaInventario hasta vDated - * sin tener en cuenta las salidas del mismo dia vDated - * para ver el transporte a reservar - * - * @param vDated Fecha hasta la cual calcula el stock - * @return tmp.item - */ - DECLARE vAuctionWarehouseFk INT; - - SELECT warehouseFk INTO vAuctionWarehouseFk - FROM auctionConfig; - - CREATE OR REPLACE TEMPORARY TABLE tmp.item - (UNIQUE INDEX i USING HASH (itemFk)) - ENGINE = MEMORY - SELECT itemFk, SUM(quantity) quantity - FROM itemEntryIn - WHERE landed = vDated - AND vDated >= util.VN_CURDATE() - AND warehouseInFk = vAuctionWarehouseFk - AND NOT isVirtualStock - GROUP BY itemFk - HAVING quantity; - - CALL `cache`.stock_refresh(FALSE); - - INSERT INTO tmp.item (itemFk, quantity) - SELECT item_id, amount - FROM `cache`.stock - WHERE warehouse_id = vAuctionWarehouseFk - ON DUPLICATE KEY UPDATE quantity = tmp.item.quantity + VALUES(quantity); - - CALL buy_getUltimate(NULL, vAuctionWarehouseFk, vDated); + DROP TEMPORARY TABLE tCurrentData, tmp.item, tmp.buyUltimate, tStockSold; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -72250,6 +72598,44 @@ 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 `ticketRefund_upsert` */; +/*!50003 SET @saved_cs_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=`vn`@`localhost` PROCEDURE `ticketRefund_upsert`( + vRefundTicketFk INT, + vOriginalTicketFk INT +) + READS SQL DATA +BEGIN +/** + * Common code for ticketRefund triggers + * + * @param vRefundTicketFk + * @param vOriginalTicketFk + */ + DECLARE vIsDeleted BOOL; + + SELECT COUNT(*) INTO vIsDeleted + FROM ticket + WHERE id IN (vRefundTicketFk, vOriginalTicketFk) + AND isDeleted; + + IF vIsDeleted THEN + CALL util.throw('The refund ticket cannot be deleted tickets'); + 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 `ticketStateToday_setState` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -72655,7 +73041,8 @@ BEGIN origin.companyFk futureCompanyFk, IFNULL(dest.nickname, origin.nickname) nickname, dest.landed, - dest.preparation + dest.preparation, + origin.departmentFk FROM ( SELECT s.ticketFk, c.salesPersonFk workerFk, @@ -72675,9 +73062,11 @@ BEGIN t.addressFk, t.warehouseFk, t.companyFk, - t.agencyModeFk + t.agencyModeFk, + wd.departmentFk FROM ticket t JOIN client c ON c.id = t.clientFk + JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk JOIN sale s ON s.ticketFk = t.id JOIN saleVolume sv ON sv.saleFk = s.id JOIN item i ON i.id = s.itemFk @@ -73394,7 +73783,7 @@ BEGIN c.isTaxDataChecked, t.companyFk, t.shipped, - IFNULL(a.hasDailyInvoice, co.hasDailyInvoice), + c.hasDailyInvoice, w.isManaged, c.hasToInvoice INTO vClientFk, @@ -73406,9 +73795,6 @@ BEGIN vHasToInvoice FROM ticket t JOIN `client` c ON c.id = t.clientFk - JOIN province p ON p.id = c.provinceFk - LEFT JOIN autonomy a ON a.id = p.autonomyFk - JOIN country co ON co.id = p.countryFk JOIN warehouse w ON w.id = t.warehouseFk WHERE t.id = vCurTicketFk; @@ -73436,7 +73822,7 @@ BEGIN IF(vHasDailyInvoice) AND vHasToInvoice THEN SELECT invoiceSerial(vClientFk, vCompanyFk, 'quick') INTO vSerial; - IF vSerial IS NULL THEN + IF vSerial IS NULL THEN CALL util.throw('Cannot booking without a serial'); END IF; @@ -74401,7 +74787,9 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_getTax`(IN vTaxArea VARCHAR(25)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_getTax`( + vTaxArea VARCHAR(25) +) BEGIN /** * Calcula la base imponible, el IVA y el recargo de equivalencia para @@ -74435,30 +74823,39 @@ BEGIN 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, - pgc.rate, - tc.code, - bp.priority - FROM tmp.ticket tmpTicket - JOIN sale s ON s.ticketFk = tmpTicket.ticketFk - JOIN item i ON i.id = s.itemFk - JOIN ticket t ON t.id = tmpTicket.ticketFk - JOIN supplier su ON su.id = t.companyFk + WITH sales AS ( + SELECT s.ticketFk, + s.itemFk, + s.quantity * s.price * (100 - s.discount) / 100 total, + t.companyFk, + t.addressFk, + su.countryFk, + ata.areaFk, + itc.taxClassFk + FROM vn.sale s + JOIN tmp.ticket tmp ON tmp.ticketFk = s.ticketFk + JOIN vn.ticket t ON t.id = s.ticketFk + JOIN vn.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 + JOIN vn.itemTaxCountry itc ON itc.itemFk = s.itemFk 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 - ) t3 + HAVING total + ) + SELECT s.ticketFk, + bp.pgcFk, + SUM(s.total) taxableBase, + pgc.rate, + tc.code, + bp.priority + FROM sales s + JOIN vn.bookingPlanner bp ON bp.countryFk = s.countryFk + AND bp.taxAreaFk = s.areaFk + AND bp.taxClassFk = s.taxClassFk + JOIN vn.pgc ON pgc.code = bp.pgcFk + JOIN vn.taxClass tc ON tc.id = bp.taxClassFk + GROUP BY s.ticketFk, pgc.code, pgc.rate + HAVING taxableBase ORDER BY priority; CREATE OR REPLACE TEMPORARY TABLE tmp.ticketServiceTax @@ -74681,12 +75078,25 @@ CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_mergeSales`( vSelf INT ) BEGIN +/** + * Para un ticket se agrupa las diferentes líneas de venta de un mismo artículo en una sola + * siempre y cuando tengan el mismo precio y dto. + * + * @param vSelf Id de ticket + */ + DECLARE vHasSalesToMerge BOOL; DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN ROLLBACK; RESIGNAL; END; + START TRANSACTION; + + SELECT id INTO vSelf + FROM ticket + WHERE id = vSelf FOR UPDATE; + CREATE OR REPLACE TEMPORARY TABLE tSalesToPreserve (PRIMARY KEY (id)) ENGINE = MEMORY @@ -74696,26 +75106,24 @@ BEGIN JOIN itemType it ON it.id = i.typeFk WHERE s.ticketFk = vSelf AND it.isMergeable - GROUP BY s.itemFk, s.price, s.discount; + GROUP BY s.itemFk, s.price, s.discount + HAVING COUNT(*) > 1; - START TRANSACTION; + SELECT COUNT(*) INTO vHasSalesToMerge FROM tSalesToPreserve; - UPDATE sale s - JOIN tSalesToPreserve stp ON stp.id = s.id - SET s.quantity = newQuantity - WHERE s.ticketFk = vSelf; + IF vHasSalesToMerge THEN + UPDATE sale s + JOIN tSalesToPreserve stp ON stp.id = s.id + SET s.quantity = newQuantity; - DELETE s.* - FROM sale s - LEFT JOIN tSalesToPreserve stp ON stp.id = s.id - JOIN item i ON i.id = s.itemFk - JOIN itemType it ON it.id = i.typeFk - WHERE s.ticketFk = vSelf - AND stp.id IS NULL - AND it.isMergeable; + DELETE s + FROM sale s + JOIN tSalesToPreserve stp ON stp.itemFk = s.itemFk + WHERE s.ticketFk = vSelf + AND s.id <> stp.id; + END IF; COMMIT; - DROP TEMPORARY TABLE tSalesToPreserve; END ;; DELIMITER ; @@ -75856,125 +76264,88 @@ CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_splitItemPackingType`( vSelf INT, vOriginalItemPackingTypeFk VARCHAR(1) ) -BEGIN +proc:BEGIN /** - * Clona y reparte las ventas de un ticket en funcion del tipo de empaquetado. - * Respeta el id inicial para el tipo propuesto. + * Clona y reparte las líneas de ventas de un ticket en funcion del tipo de empaquetado. + * Respeta el id de ticket original para el tipo de empaquetado propuesto. * * @param vSelf Id ticket - * @param vOriginalItemPackingTypeFk Tipo para el que se reserva el número de ticket original + * @param vOriginalItemPackingTypeFk Tipo empaquetado que se mantiene el ticket original * @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk) */ - DECLARE vItemPackingTypeFk VARCHAR(1) DEFAULT 'H'; - DECLARE vNewTicketFk INT; - DECLARE vPackingTypesToSplit INT; DECLARE vDone INT DEFAULT FALSE; + DECLARE vHasItemPackingType BOOL; + DECLARE vItemPackingTypeFk INT; + DECLARE vNewTicketFk INT; - DECLARE vSaleGroup CURSOR FOR - SELECT itemPackingTypeFk - FROM tSaleGroup - WHERE itemPackingTypeFk IS NOT NULL - ORDER BY (itemPackingTypeFk = vOriginalItemPackingTypeFk) DESC; + DECLARE vItemPackingTypes CURSOR FOR + SELECT DISTINCT itemPackingTypeFk + FROM tSalesToMove; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - START TRANSACTION; - - SELECT id - FROM sale - WHERE ticketFk = vSelf - AND NOT quantity - FOR UPDATE; - - DELETE FROM sale - WHERE NOT quantity - AND ticketFk = vSelf; - - CREATE OR REPLACE TEMPORARY TABLE tSale - (PRIMARY KEY (id)) - ENGINE = MEMORY - SELECT s.id, i.itemPackingTypeFk, IFNULL(sv.litros, 0) litros - FROM sale s - JOIN item i ON i.id = s.itemFk - LEFT JOIN saleVolume sv ON sv.saleFk = s.id - WHERE s.ticketFk = vSelf; - - CREATE OR REPLACE TEMPORARY TABLE tSaleGroup - ENGINE = MEMORY - SELECT itemPackingTypeFk, SUM(litros) totalLitros - FROM tSale - GROUP BY itemPackingTypeFk; - - SELECT COUNT(*) INTO vPackingTypesToSplit - FROM tSaleGroup - WHERE itemPackingTypeFk IS NOT NULL; + SELECT COUNT(*) INTO vHasItemPackingType + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN item i ON i.id = s.itemFk + WHERE t.id = vSelf + AND i.itemPackingTypeFk = vOriginalItemPackingTypeFk; CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT( ticketFk INT, itemPackingTypeFk VARCHAR(1) - ) ENGINE = MEMORY; + ) ENGINE=MEMORY + SELECT vSelf ticketFk, vOriginalItemPackingTypeFk itemPackingTypeFk; - CASE vPackingTypesToSplit - WHEN 0 THEN - INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) - VALUES(vSelf, vItemPackingTypeFk); - WHEN 1 THEN - INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) - SELECT vSelf, itemPackingTypeFk - FROM tSaleGroup - WHERE itemPackingTypeFk IS NOT NULL; - ELSE - OPEN vSaleGroup; - FETCH vSaleGroup INTO vItemPackingTypeFk; + IF NOT vHasItemPackingType THEN + LEAVE proc; + END IF; - INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) - VALUES(vSelf, vItemPackingTypeFk); + CREATE OR REPLACE TEMPORARY TABLE tSalesToMove ( + ticketFk INT, + saleFk INT, + itemPackingTypeFk INT + ) ENGINE=MEMORY; - l: LOOP - SET vDone = FALSE; - FETCH vSaleGroup INTO vItemPackingTypeFk; + INSERT INTO tSalesToMove (saleFk, itemPackingTypeFk) + SELECT s.id, i.itemPackingTypeFk + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN item i ON i.id = s.itemFk + WHERE t.id = vSelf + AND i.itemPackingTypeFk <> vOriginalItemPackingTypeFk; - IF vDone THEN - LEAVE l; - END IF; + OPEN vItemPackingTypes; - CALL ticket_Clone(vSelf, vNewTicketFk); + l: LOOP + SET vDone = FALSE; + FETCH vItemPackingTypes INTO vItemPackingTypeFk; - INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) - VALUES(vNewTicketFk, vItemPackingTypeFk); - END LOOP; + IF vDone THEN + LEAVE l; + END IF; - CLOSE vSaleGroup; + CALL ticket_Clone(vSelf, vNewTicketFk); - SELECT s.id - FROM sale s - JOIN tSale ts ON ts.id = s.id - JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk - FOR UPDATE; + UPDATE tSalesToMove + SET ticketFk = vNewTicketFk + WHERE itemPackingTypeFk = vItemPackingTypeFk; - UPDATE sale s - JOIN tSale ts ON ts.id = s.id - JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk - SET s.ticketFk = t.ticketFk; + END LOOP; - SELECT itemPackingTypeFk INTO vItemPackingTypeFk - FROM tSaleGroup sg - WHERE sg.itemPackingTypeFk IS NOT NULL - ORDER BY sg.itemPackingTypeFk - LIMIT 1; + CLOSE vItemPackingTypes; - UPDATE sale s - JOIN tSale ts ON ts.id = s.id - JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = vItemPackingTypeFk - SET s.ticketFk = t.ticketFk - WHERE ts.itemPackingTypeFk IS NULL; - END CASE; + UPDATE sale s + JOIN tSalesToMove stm ON stm.saleFk = s.id + SET s.ticketFk = stm.ticketFk + WHERE stm.ticketFk; - COMMIT; + INSERT INTO tmp.ticketIPT (ticketFk, itemPackingTypeFk) + SELECT ticketFk, itemPackingTypeFk + FROM tSalesToMove + GROUP BY ticketFk; - DROP TEMPORARY TABLE - tSale, - tSaleGroup; + DROP TEMPORARY TABLE tSalesToMove; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -80405,6 +80776,8 @@ BEGIN SET businessFk = vNewBusinessFk WHERE id = vSelf; + CALL queueMember_updateQueue(vNewBusinessFk); + IF vOldBusinessFk IS NULL THEN CALL account.account_enable(vSelf); @@ -82245,7 +82618,6 @@ SET character_set_client = utf8; 1 AS `send_mail`, 1 AS `tpv`, 1 AS `code`, - 1 AS `show_AgencyName`, 1 AS `isRiskFree` */; SET character_set_client = @saved_cs_client; @@ -82416,7 +82788,6 @@ SET character_set_client = utf8; 1 AS `credito`, 1 AS `Id_Pais`, 1 AS `activo`, - 1 AS `gestdoc_id`, 1 AS `calidad`, 1 AS `pay_met_id`, 1 AS `created`, @@ -82496,21 +82867,6 @@ SET character_set_client = utf8; 1 AS `itemOriginalFk` */; SET character_set_client = @saved_cs_client; --- --- Temporary table structure for view `Compres_mark` --- - -DROP TABLE IF EXISTS `Compres_mark`; -/*!50001 DROP VIEW IF EXISTS `Compres_mark`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `Compres_mark` AS SELECT - 1 AS `Id_Compra`, - 1 AS `comment`, - 1 AS `mark`, - 1 AS `odbc_date` */; -SET character_set_client = @saved_cs_client; - -- -- Temporary table structure for view `Consignatarios` -- @@ -88082,7 +88438,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `Agencias` AS select `am`.`id` AS `Id_Agencia`,`am`.`name` AS `Agencia`,`am`.`description` AS `description`,`am`.`deliveryMethodFk` AS `Vista`,`am`.`m3` AS `m3`,`am`.`web` AS `web`,`am`.`agencyFk` AS `agency_id`,`am`.`inflation` AS `inflacion`,`am`.`isVolumetric` AS `is_volumetric`,`am`.`reportMail` AS `send_mail`,`am`.`isActive` AS `tpv`,`am`.`code` AS `code`,`am`.`showAgencyName` AS `show_AgencyName`,`am`.`isRiskFree` AS `isRiskFree` from `vn`.`agencyMode` `am` */; +/*!50001 VIEW `Agencias` AS select `am`.`id` AS `Id_Agencia`,`am`.`name` AS `Agencia`,`am`.`description` AS `description`,`am`.`deliveryMethodFk` AS `Vista`,`am`.`m3` AS `m3`,`am`.`web` AS `web`,`am`.`agencyFk` AS `agency_id`,`am`.`inflation` AS `inflacion`,`am`.`isVolumetric` AS `is_volumetric`,`am`.`reportMail` AS `send_mail`,`am`.`isActive` AS `tpv`,`am`.`code` AS `code`,`am`.`isRiskFree` AS `isRiskFree` from `vn`.`agencyMode` `am` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -88172,7 +88528,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`.`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`.`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`.`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`.`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 */; @@ -88213,24 +88569,6 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `Compres_mark` --- - -/*!50001 DROP VIEW IF EXISTS `Compres_mark`*/; -/*!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 `Compres_mark` AS select `bm`.`id` AS `Id_Compra`,`bm`.`comment` AS `comment`,`bm`.`mark` AS `mark`,`bm`.`odbcDate` AS `odbc_date` from `vn`.`buyMark` `bm` */; -/*!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 `Consignatarios` -- @@ -90472,4 +90810,4 @@ USE `vn2008`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2024-10-03 7:42:53 +-- Dump completed on 2024-11-12 7:06:20 diff --git a/db/dump/.dump/triggers.sql b/db/dump/.dump/triggers.sql index 74190df36..7152187bb 100644 --- a/db/dump/.dump/triggers.sql +++ b/db/dump/.dump/triggers.sql @@ -1128,6 +1128,28 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_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 `hedera`.`orderRow_afterInsert` + AFTER INSERT ON `orderRow` + FOR EACH ROW +BEGIN + UPDATE `order` + SET rowUpdated = util.VN_NOW() + WHERE id = NEW.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 */ ; -- -- Current Database: `pbx` @@ -2432,11 +2454,21 @@ DELIMITER ;; AFTER UPDATE ON `business` FOR EACH ROW BEGIN + DECLARE vIsActive BOOL; + DECLARE vExtension VARCHAR(10); + CALL worker_updateBusiness(NEW.workerFk); IF NOT (OLD.workerFk <=> NEW.workerFk) THEN CALL worker_updateBusiness(OLD.workerFk); END IF; + + IF NOT (OLD.departmentFk <=> NEW.departmentFk) THEN + SELECT COUNT(*) INTO vIsActive FROM worker WHERE businessFk = NEW.id; + IF vIsActive THEN + CALL queueMember_updateQueue(NEW.id); + END IF; + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -6554,6 +6586,9 @@ BEGIN SET NEW.userFk = account.myUser_getId(); END IF; + IF NEW.shelvingFk <> OLD.shelvingFk THEN + SET NEW.movingState = NULL; + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -6654,11 +6689,11 @@ DELIMITER ;; AFTER INSERT ON `itemShelvingSale` FOR EACH ROW BEGIN - UPDATE sale s JOIN operator o ON o.workerFk = account.myUser_getId() - SET s.isPicked = IF(o.isOnReservationMode, s.isPicked, TRUE) - WHERE id = NEW.saleFk; + JOIN sector se ON se.id = o.sectorFk + SET s.isPicked = IF(IFNULL(se.isOnReservationMode, o.isOnReservationMode), s.isPicked, TRUE) + WHERE s.id = NEW.saleFk; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -9988,6 +10023,8 @@ DELIMITER ;; BEFORE INSERT ON `ticketRefund` FOR EACH ROW BEGIN + CALL ticketRefund_upsert(NEW.refundTicketFk, NEW.originalTicketFk); + SET NEW.editorFk = account.myUser_getId(); END */;; DELIMITER ; @@ -10008,6 +10045,8 @@ DELIMITER ;; BEFORE UPDATE ON `ticketRefund` FOR EACH ROW BEGIN + CALL ticketRefund_upsert(NEW.refundTicketFk, NEW.originalTicketFk); + SET NEW.editorFk = account.myUser_getId(); END */;; DELIMITER ; @@ -10678,6 +10717,15 @@ DELIMITER ;; FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); + + IF NEW.travelFk IS NULL AND + (SELECT COUNT(*) FROM travelThermograph + WHERE thermographFk = NEW.thermographFk + AND travelFk IS NULL + AND id <> NEW.id) > 0 + THEN + CALL util.throw('Duplicate thermographFk without travelFk not allowed.'); + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -10698,6 +10746,15 @@ DELIMITER ;; FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); + + IF NEW.travelFk IS NULL AND + (SELECT COUNT(*) FROM travelThermograph + WHERE thermographFk = NEW.thermographFk + AND travelFk IS NULL + AND id <> NEW.id) > 0 + THEN + CALL util.throw('Duplicate thermographFk without travelFk not allowed.'); + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -11469,4 +11526,4 @@ USE `vn2008`; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2024-10-03 7:43:14 +-- Dump completed on 2024-11-12 7:06:44 From 63425d31ae3e82e671428bf69ae436ca69eb4009 Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 12 Nov 2024 08:51:03 +0100 Subject: [PATCH 76/89] fix: refs #7404 restore stockBuyed old proc --- .../vn/procedures/stockBuyedByWorker.sql | 74 +++++++++++++++++++ db/routines/vn/procedures/stockBuyed_add.sql | 70 ++++++++++++++++++ .../11338-brownMonstera/00-firstScript.sql | 2 + 3 files changed, 146 insertions(+) create mode 100644 db/routines/vn/procedures/stockBuyedByWorker.sql create mode 100644 db/routines/vn/procedures/stockBuyed_add.sql create mode 100644 db/versions/11338-brownMonstera/00-firstScript.sql diff --git a/db/routines/vn/procedures/stockBuyedByWorker.sql b/db/routines/vn/procedures/stockBuyedByWorker.sql new file mode 100644 index 000000000..536638770 --- /dev/null +++ b/db/routines/vn/procedures/stockBuyedByWorker.sql @@ -0,0 +1,74 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`stockBuyedByWorker`( + vDated DATE, + vWorker INT +) +BEGIN +/** + * Inserta el volumen de compra de un comprador + * en stockBuyed de acuerdo con la fecha. + * + * @param vDated Fecha de compra + * @param vWorker Id de trabajador + */ + CREATE OR REPLACE TEMPORARY TABLE tStockBuyed + (INDEX (userFk)) + ENGINE = MEMORY + SELECT requested, reserved, userFk + FROM stockBuyed + WHERE dated = vDated + AND userFk = vWorker; + + DELETE FROM stockBuyed + WHERE dated = vDated + AND userFk = vWorker; + + CALL item_calculateStock(vDated); + + INSERT INTO stockBuyed(userFk, buyed, `dated`, reserved, requested, description) + SELECT it.workerFk, + SUM((ti.quantity / b.packing) * buy_getVolume(b.id)) / vc.palletM3 / 1000000, + vDated, + sb.reserved, + sb.requested, + u.name + FROM itemType it + JOIN item i ON i.typeFk = it.id + LEFT JOIN tmp.item ti ON ti.itemFk = i.id + JOIN itemCategory ic ON ic.id = it.categoryFk + JOIN warehouse wh ON wh.code = 'VNH' + JOIN tmp.buyUltimate bu ON bu.itemFk = i.id + AND bu.warehouseFk = wh.id + JOIN buy b ON b.id = bu.buyFk + JOIN volumeConfig vc + JOIN account.`user` u ON u.id = it.workerFk + LEFT JOIN tStockBuyed sb ON sb.userFk = it.workerFk + WHERE ic.display + AND it.workerFk = vWorker; + + SELECT b.entryFk Id_Entrada, + i.id Id_Article, + i.name Article, + ti.quantity Cantidad, + (ac.conversionCoefficient * (ti.quantity / b.packing) * buy_getVolume(b.id)) + / (vc.trolleyM3 * 1000000) buyed, + b.packagingFk id_cubo, + b.packing + FROM tmp.item ti + JOIN item i ON i.id = ti.itemFk + JOIN itemType it ON i.typeFk = it.id + JOIN itemCategory ic ON ic.id = it.categoryFk + JOIN worker w ON w.id = it.workerFk + JOIN auctionConfig ac + JOIN tmp.buyUltimate bu ON bu.itemFk = i.id + AND bu.warehouseFk = ac.warehouseFk + JOIN buy b ON b.id = bu.buyFk + JOIN volumeConfig vc + WHERE ic.display + AND w.id = vWorker; + + DROP TEMPORARY TABLE tmp.buyUltimate, + tmp.item, + tStockBuyed; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/stockBuyed_add.sql b/db/routines/vn/procedures/stockBuyed_add.sql new file mode 100644 index 000000000..0491c2424 --- /dev/null +++ b/db/routines/vn/procedures/stockBuyed_add.sql @@ -0,0 +1,70 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`stockBuyed_add`( + vDated DATE +) +BEGIN +/** + * Inserta el volumen de compra por comprador + * en stockBuyed de acuerdo con la fecha. + * + * @param vDated Fecha de compra + */ + CREATE OR REPLACE TEMPORARY TABLE tStockBuyed + (INDEX (userFk)) + ENGINE = MEMORY + SELECT requested, reserved, userFk + FROM stockBuyed + WHERE dated = vDated; + + DELETE FROM stockBuyed WHERE dated = vDated; + + CALL item_calculateStock(vDated); + + INSERT INTO stockBuyed(userFk, buyed, `dated`, description) + SELECT it.workerFk, + SUM((ti.quantity / b.packing) * buy_getVolume(b.id)) / vc.palletM3 / 1000000, + vDated, + u.name + FROM itemType it + JOIN item i ON i.typeFk = it.id + LEFT JOIN tmp.item ti ON ti.itemFk = i.id + JOIN itemCategory ic ON ic.id = it.categoryFk + JOIN warehouse wh ON wh.code = 'VNH' + JOIN tmp.buyUltimate bu ON bu.itemFk = i.id AND bu.warehouseFk = wh.id + JOIN buy b ON b.id = bu.buyFk + JOIN volumeConfig vc + JOIN account.`user` u ON u.id = it.workerFk + JOIN workerDepartment wd ON wd.workerFk = u.id + JOIN department d ON d.id = wd.departmentFk + WHERE ic.display + AND d.code IN ('shopping', 'logistic', 'franceTeam') + GROUP BY it.workerFk; + + INSERT INTO stockBuyed(buyed, dated, description) + SELECT SUM(ic.cm3 * ito.quantity / vc.palletM3 / 1000000), + vDated, + IF(c.code = 'ES', p.name, c.name) destiny + FROM itemTicketOut ito + JOIN ticket t ON t.id = ito.ticketFk + JOIN `address` a ON a.id = t.addressFk + JOIN province p ON p.id = a.provinceFk + JOIN country c ON c.id = p.countryFk + JOIN warehouse wh ON wh.id = t.warehouseFk + JOIN itemCost ic ON ic.itemFk = ito.itemFk + AND ic.warehouseFk = t.warehouseFk + JOIN volumeConfig vc + WHERE ito.shipped BETWEEN vDated AND util.dayend(vDated) + AND wh.code = 'VNH' + GROUP BY destiny; + + UPDATE stockBuyed s + JOIN tStockBuyed ts ON ts.userFk = s.userFk + SET s.requested = ts.requested, + s.reserved = ts.reserved + WHERE s.dated = vDated; + + DROP TEMPORARY TABLE tmp.buyUltimate, + tmp.item, + tStockBuyed; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/versions/11338-brownMonstera/00-firstScript.sql b/db/versions/11338-brownMonstera/00-firstScript.sql new file mode 100644 index 000000000..9752bb90d --- /dev/null +++ b/db/versions/11338-brownMonstera/00-firstScript.sql @@ -0,0 +1,2 @@ +-- Place your SQL code here +RENAME TABLE vn.stockBuyed__ TO vn.stockBuyed; From a921e5102314c174c85e0276581bcd048172885d Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 12 Nov 2024 09:51:48 +0100 Subject: [PATCH 77/89] refactor: refs #7715 Deleted hasNewLabelMrwMethod column --- db/versions/11337-limeAsparagus/00-firstScript.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 db/versions/11337-limeAsparagus/00-firstScript.sql diff --git a/db/versions/11337-limeAsparagus/00-firstScript.sql b/db/versions/11337-limeAsparagus/00-firstScript.sql new file mode 100644 index 000000000..4cfedc8a8 --- /dev/null +++ b/db/versions/11337-limeAsparagus/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.productionConfig DROP COLUMN hasNewLabelMrwMethod; From f989b72fab7ad2c784717296022696c65afc67e4 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 12 Nov 2024 10:18:00 +0100 Subject: [PATCH 78/89] feat: refs #8080 Added column comment --- db/versions/11339-goldenMastic/00-firstScript.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 db/versions/11339-goldenMastic/00-firstScript.sql diff --git a/db/versions/11339-goldenMastic/00-firstScript.sql b/db/versions/11339-goldenMastic/00-firstScript.sql new file mode 100644 index 000000000..f1da5798a --- /dev/null +++ b/db/versions/11339-goldenMastic/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.dua ADD comment TEXT DEFAULT NULL NULL; From 96301f8a0bfe68368761536b61373212f2cec61c Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 12 Nov 2024 10:43:05 +0100 Subject: [PATCH 79/89] fix: hotfix create order from customer --- front/core/services/app.js | 16 ++++++++++++---- modules/client/front/descriptor/index.html | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/front/core/services/app.js b/front/core/services/app.js index dba6e70bf..816167835 100644 --- a/front/core/services/app.js +++ b/front/core/services/app.js @@ -70,10 +70,18 @@ export default class App { if (this.logger.$params.q) { let tableValue = this.logger.$params.q; - const q = JSON.parse(tableValue); - if (typeof q === 'number') - tableValue = JSON.stringify({id: tableValue}); - newRoute = newRoute.concat(`?table=${tableValue}`); + if (Array.isArray(tableValue)) { + const [key, param1, param2] = tableValue; + const payload = key === 'createForm' + ? {[param1]: param2} + : {[key]: param1}; + newRoute += `?${key}=${JSON.stringify(payload)}`; + } else { + const q = JSON.parse(tableValue); + if (typeof q === 'number') + tableValue = JSON.stringify({id: tableValue}); + newRoute = newRoute.concat(`?table=${tableValue}`); + } } else if (!hasId && this.logger.$params.id && newRoute.indexOf(this.logger.$params.id) < 0) newRoute = newRoute.concat(`${this.logger.$params.id}`); diff --git a/modules/client/front/descriptor/index.html b/modules/client/front/descriptor/index.html index f2dbd64b6..cecd7ee62 100644 --- a/modules/client/front/descriptor/index.html +++ b/modules/client/front/descriptor/index.html @@ -99,7 +99,7 @@
From 699675b476b845436d56ec1b474a667526db62f7 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 12 Nov 2024 11:27:23 +0100 Subject: [PATCH 80/89] fix: hotfix --- modules/client/back/methods/client/filter.js | 1 - modules/order/back/methods/order/filter.js | 1 + modules/travel/back/methods/travel/filter.js | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/client/back/methods/client/filter.js b/modules/client/back/methods/client/filter.js index f805c4be9..7df973f19 100644 --- a/modules/client/back/methods/client/filter.js +++ b/modules/client/back/methods/client/filter.js @@ -1,4 +1,3 @@ - const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; const buildFilter = require('vn-loopback/util/filter').buildFilter; const mergeFilters = require('vn-loopback/util/filter').mergeFilters; diff --git a/modules/order/back/methods/order/filter.js b/modules/order/back/methods/order/filter.js index 758e8065c..f8df6e10e 100644 --- a/modules/order/back/methods/order/filter.js +++ b/modules/order/back/methods/order/filter.js @@ -76,6 +76,7 @@ module.exports = Self => { }); Self.filter = async(ctx, filter, options) => { + const models = Self.app.models; const conn = Self.dataSource.connector; const myOptions = {}; diff --git a/modules/travel/back/methods/travel/filter.js b/modules/travel/back/methods/travel/filter.js index e24a7659c..30c10f191 100644 --- a/modules/travel/back/methods/travel/filter.js +++ b/modules/travel/back/methods/travel/filter.js @@ -117,7 +117,6 @@ module.exports = Self => { case 'landedTo': return {'t.landed': {lte: value}}; case 'daysOnward': - today.setHours(0, 0, 0, 0); future.setDate(today.getDate() + value); future.setHours(23, 59, 59, 999); From d52f537f0cb3d993eba447dbdbe42ffb21c70c12 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 12 Nov 2024 13:04:23 +0100 Subject: [PATCH 81/89] refactor: refs #8153 Optimized order_getTax --- .../hedera/procedures/order_getTax.sql | 60 ++++++++++--------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/db/routines/hedera/procedures/order_getTax.sql b/db/routines/hedera/procedures/order_getTax.sql index d24ffe7ef..8fa965343 100644 --- a/db/routines/hedera/procedures/order_getTax.sql +++ b/db/routines/hedera/procedures/order_getTax.sql @@ -15,41 +15,47 @@ BEGIN ENGINE = MEMORY SELECT DISTINCT o.address_id addressFk, o.company_id companyFk FROM tmp.`order` tmpOrder - JOIN hedera.`order` o ON o.id = tmpOrder.orderFk; + JOIN `order` o ON o.id = tmpOrder.orderFk; - CALL vn.addressTaxArea; + CALL vn.addressTaxArea(); -- Calcula el IVA y el recargo desglosado. - - DROP TEMPORARY TABLE IF EXISTS tmp.orderTax; - CREATE TEMPORARY TABLE tmp.orderTax - (INDEX (orderFk)) + CREATE OR REPLACE TEMPORARY TABLE tmp.orderTax + (PRIMARY KEY (orderFk, code, rate)) ENGINE = MEMORY - SELECT o.id orderFk, + WITH orders AS ( + SELECT tor.orderFk, + oro.amount * oro.price total, + s.countryFk, + ata.areaFk, + itc.taxClassFk + FROM orderRow oro + JOIN tmp.order tor ON tor.orderFk = oro.orderFk + JOIN `order` o ON o.id = tor.orderFk + JOIN vn.item i ON i.id = oro.itemFk + JOIN vn.`client` c ON c.id = o.customer_id + JOIN vn.supplier s ON s.id = o.company_id + JOIN tmp.addressTaxArea ata ON ata.addressFk = o.address_id + AND ata.companyFk = o.company_id + JOIN vn.itemTaxCountry itc ON itc.itemFk = i.id + AND itc.countryFk = s.countryFk + HAVING total + ) + SELECT o.orderFk, tc.code, - SUM(m.amount * m.price) taxableBase, + SUM(o.total) taxableBase, pgc.rate - FROM tmp.`order` tmpOrder - JOIN `order` o ON o.id = tmpOrder.orderFk - JOIN orderRow m ON m.orderFk = o.id - JOIN vn.item i ON i.id = m.itemFk - JOIN vn.`client` c ON c.id = o.customer_id - JOIN vn.supplier s ON s.id = o.company_id - JOIN tmp.addressTaxArea ata - ON ata.addressFk = o.address_id AND ata.companyFk = o.company_id - JOIN vn.itemTaxCountry itc - ON itc.itemFk = i.id AND itc.countryFk = s.countryFk - JOIN vn.bookingPlanner bp - ON bp.countryFk = s.countryFk - AND bp.taxAreaFk = ata.areaFk - AND bp.taxClassFk = itc.taxClassFk - JOIN vn.pgc ON pgc.`code` = bp.pgcFk + FROM orders o + JOIN vn.bookingPlanner bp ON bp.countryFk = o.countryFk + AND bp.taxAreaFk = o.areaFk + AND bp.taxClassFk = o.taxClassFk + JOIN vn.pgc ON pgc.code = bp.pgcFk JOIN vn.taxClass tc ON tc.id = bp.taxClassFk - GROUP BY tmpOrder.orderFk, pgc.`code`, pgc.rate - HAVING taxableBase != 0; + GROUP BY o.orderFk, pgc.code, pgc.rate + HAVING taxableBase + ORDER BY bp.priority; - DROP TEMPORARY TABLE IF EXISTS tmp.orderAmount; - CREATE TEMPORARY TABLE tmp.orderAmount + CREATE OR REPLACE TEMPORARY TABLE tmp.orderAmount (INDEX (orderFk)) ENGINE = MEMORY SELECT orderFk, taxableBase, `code`, From 2ece748138d59091498ccb326823d2ccf6d20105 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 12 Nov 2024 13:13:13 +0100 Subject: [PATCH 82/89] refactor: refs #7242 Deleted select column --- db/routines/vn/procedures/item_getInfo.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/db/routines/vn/procedures/item_getInfo.sql b/db/routines/vn/procedures/item_getInfo.sql index 341142892..bd59728f7 100644 --- a/db/routines/vn/procedures/item_getInfo.sql +++ b/db/routines/vn/procedures/item_getInfo.sql @@ -42,7 +42,6 @@ BEGIN i.minimum `min`, p.name producer, o.code origin, - v.visible - IFNULL(vVisibleItemShelving, 0) unlocated, a.available, vVisibleItemShelving, v.visible, From 127c6fced0cd744794f2eda0e65d3667dfcf8bab Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 12 Nov 2024 13:25:51 +0100 Subject: [PATCH 83/89] refactor: refs #8153 Optimized order_getTax --- db/routines/hedera/procedures/order_getTax.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/db/routines/hedera/procedures/order_getTax.sql b/db/routines/hedera/procedures/order_getTax.sql index 8fa965343..90c47bfc7 100644 --- a/db/routines/hedera/procedures/order_getTax.sql +++ b/db/routines/hedera/procedures/order_getTax.sql @@ -9,6 +9,7 @@ BEGIN * @param vOrder El identificador del pedido * @return tmp.orderTax Bases imponibles, IVA y recargo de equivalencia */ + -- No poner create or replace, ya que da problemas DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany; CREATE TEMPORARY TABLE tmp.addressCompany (INDEX (addressFk, companyFk)) @@ -55,7 +56,9 @@ BEGIN HAVING taxableBase ORDER BY bp.priority; - CREATE OR REPLACE TEMPORARY TABLE tmp.orderAmount + -- No poner create or replace, ya que da problemas + DROP TEMPORARY TABLE IF EXISTS tmp.orderAmount; + CREATE TEMPORARY TABLE tmp.orderAmount (INDEX (orderFk)) ENGINE = MEMORY SELECT orderFk, taxableBase, `code`, From 4add10f3dde74909f531c0955d28a315a27580ab Mon Sep 17 00:00:00 2001 From: ivanm Date: Tue, 12 Nov 2024 17:52:51 +0100 Subject: [PATCH 84/89] feat: refs #7994 remove comment script --- db/versions/11251-navyChrysanthemum/01-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11251-navyChrysanthemum/01-firstScript.sql b/db/versions/11251-navyChrysanthemum/01-firstScript.sql index c942e0400..e3e08e0aa 100644 --- a/db/versions/11251-navyChrysanthemum/01-firstScript.sql +++ b/db/versions/11251-navyChrysanthemum/01-firstScript.sql @@ -1 +1 @@ --- ALTER TABLE vn.sale MODIFY COLUMN originalQuantity decimal(10,2) DEFAULT 0.00 NOT NULL COMMENT 'Se utiliza para notificar a través de rocket los cambios de quantity'; \ No newline at end of file +ALTER TABLE vn.sale MODIFY COLUMN originalQuantity decimal(10,2) DEFAULT 0.00 NOT NULL COMMENT 'Se utiliza para notificar a través de rocket los cambios de quantity'; \ No newline at end of file From ebc04205317fd6f5c3f6d9eea2146a3db324b05b Mon Sep 17 00:00:00 2001 From: Pako Date: Wed, 13 Nov 2024 06:50:21 +0100 Subject: [PATCH 85/89] fix: problem calculation updated --- db/routines/vn/procedures/sale_getProblems.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index b50b4784d..cd65bb81c 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -127,7 +127,7 @@ BEGIN LEFT JOIN tItemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk WHERE IFNULL(v.visible, 0) < s.quantity - AND IFNULL(av.available, 0) < s.quantity + AND IFNULL(av.available, 0) < 0 AND IFNULL(issw.visible, 0) < s.quantity AND NOT s.isPicked AND NOT s.reserved @@ -190,7 +190,7 @@ BEGIN LEFT JOIN tItemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk WHERE IFNULL(v.visible, 0) < s.quantity - AND IFNULL(av.available, 0) >= s.quantity + AND IFNULL(av.available, 0) >= 0 AND IFNULL(issw.visible, 0) < s.quantity AND s.quantity > 0 AND NOT s.isPicked From 628b67e1e58e98e594d0dd9a1ed2cd4580fd7c90 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 13 Nov 2024 07:10:52 +0100 Subject: [PATCH 86/89] fix: refs #8153 Version --- db/routines/hedera/procedures/order_getTax.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/hedera/procedures/order_getTax.sql b/db/routines/hedera/procedures/order_getTax.sql index 90c47bfc7..c33b421f3 100644 --- a/db/routines/hedera/procedures/order_getTax.sql +++ b/db/routines/hedera/procedures/order_getTax.sql @@ -30,7 +30,7 @@ BEGIN s.countryFk, ata.areaFk, itc.taxClassFk - FROM orderRow oro + FROM hedera.orderRow oro JOIN tmp.order tor ON tor.orderFk = oro.orderFk JOIN `order` o ON o.id = tor.orderFk JOIN vn.item i ON i.id = oro.itemFk From ab2e35b64cd7f0cd1f6d82816dcb6e3d6b7cb440 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 13 Nov 2024 07:12:49 +0100 Subject: [PATCH 87/89] fix: refs #8153 Version --- db/routines/hedera/procedures/order_getTax.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/hedera/procedures/order_getTax.sql b/db/routines/hedera/procedures/order_getTax.sql index c33b421f3..371416c29 100644 --- a/db/routines/hedera/procedures/order_getTax.sql +++ b/db/routines/hedera/procedures/order_getTax.sql @@ -32,7 +32,7 @@ BEGIN itc.taxClassFk FROM hedera.orderRow oro JOIN tmp.order tor ON tor.orderFk = oro.orderFk - JOIN `order` o ON o.id = tor.orderFk + JOIN hedera.`order` o ON o.id = tor.orderFk JOIN vn.item i ON i.id = oro.itemFk JOIN vn.`client` c ON c.id = o.customer_id JOIN vn.supplier s ON s.id = o.company_id From 1086981b536b8825f0ee4eace4448f088015f9bb Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 13 Nov 2024 09:35:06 +0100 Subject: [PATCH 88/89] fix: refs #7779 ticket_splitItemPackingType --- .../vn/procedures/ticket_splitItemPackingType.sql | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/db/routines/vn/procedures/ticket_splitItemPackingType.sql b/db/routines/vn/procedures/ticket_splitItemPackingType.sql index 9a4bc01eb..92ff393cd 100644 --- a/db/routines/vn/procedures/ticket_splitItemPackingType.sql +++ b/db/routines/vn/procedures/ticket_splitItemPackingType.sql @@ -14,7 +14,7 @@ proc:BEGIN */ DECLARE vDone INT DEFAULT FALSE; DECLARE vHasItemPackingType BOOL; - DECLARE vItemPackingTypeFk INT; + DECLARE vItemPackingTypeFk VARCHAR(1) DEFAULT 'H'; DECLARE vNewTicketFk INT; DECLARE vItemPackingTypes CURSOR FOR @@ -36,14 +36,10 @@ proc:BEGIN ) ENGINE=MEMORY SELECT vSelf ticketFk, vOriginalItemPackingTypeFk itemPackingTypeFk; - IF NOT vHasItemPackingType THEN - LEAVE proc; - END IF; - CREATE OR REPLACE TEMPORARY TABLE tSalesToMove ( ticketFk INT, saleFk INT, - itemPackingTypeFk INT + itemPackingTypeFk VARCHAR(1) ) ENGINE=MEMORY; INSERT INTO tSalesToMove (saleFk, itemPackingTypeFk) @@ -55,7 +51,6 @@ proc:BEGIN AND i.itemPackingTypeFk <> vOriginalItemPackingTypeFk; OPEN vItemPackingTypes; - l: LOOP SET vDone = FALSE; FETCH vItemPackingTypes INTO vItemPackingTypeFk; @@ -71,7 +66,6 @@ proc:BEGIN WHERE itemPackingTypeFk = vItemPackingTypeFk; END LOOP; - CLOSE vItemPackingTypes; UPDATE sale s From aa1c017f2203e8e7226dd3a4dd54054698201175 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 13 Nov 2024 12:17:58 +0100 Subject: [PATCH 89/89] fix: refs #7779 ticket_splitItemPackingType --- .../ticket_splitItemPackingType.sql | 145 ++++++++++++------ 1 file changed, 94 insertions(+), 51 deletions(-) diff --git a/db/routines/vn/procedures/ticket_splitItemPackingType.sql b/db/routines/vn/procedures/ticket_splitItemPackingType.sql index 92ff393cd..0ee865af5 100644 --- a/db/routines/vn/procedures/ticket_splitItemPackingType.sql +++ b/db/routines/vn/procedures/ticket_splitItemPackingType.sql @@ -3,81 +3,124 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_splitItemPacki vSelf INT, vOriginalItemPackingTypeFk VARCHAR(1) ) -proc:BEGIN +BEGIN /** - * Clona y reparte las líneas de ventas de un ticket en funcion del tipo de empaquetado. - * Respeta el id de ticket original para el tipo de empaquetado propuesto. + * Clona y reparte las ventas de un ticket en funcion del tipo de empaquetado. + * Respeta el id inicial para el tipo propuesto. * * @param vSelf Id ticket - * @param vOriginalItemPackingTypeFk Tipo empaquetado que se mantiene el ticket original + * @param vOriginalItemPackingTypeFk Tipo para el que se reserva el número de ticket original * @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk) */ - DECLARE vDone INT DEFAULT FALSE; - DECLARE vHasItemPackingType BOOL; DECLARE vItemPackingTypeFk VARCHAR(1) DEFAULT 'H'; DECLARE vNewTicketFk INT; + DECLARE vPackingTypesToSplit INT; + DECLARE vDone INT DEFAULT FALSE; - DECLARE vItemPackingTypes CURSOR FOR - SELECT DISTINCT itemPackingTypeFk - FROM tSalesToMove; + DECLARE vSaleGroup CURSOR FOR + SELECT itemPackingTypeFk + FROM tSaleGroup + WHERE itemPackingTypeFk IS NOT NULL + ORDER BY (itemPackingTypeFk = vOriginalItemPackingTypeFk) DESC; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - SELECT COUNT(*) INTO vHasItemPackingType - FROM ticket t - JOIN sale s ON s.ticketFk = t.id - JOIN item i ON i.id = s.itemFk - WHERE t.id = vSelf - AND i.itemPackingTypeFk = vOriginalItemPackingTypeFk; + START TRANSACTION; + + SELECT id + FROM sale + WHERE ticketFk = vSelf + AND NOT quantity + FOR UPDATE; + + DELETE FROM sale + WHERE NOT quantity + AND ticketFk = vSelf; + + CREATE OR REPLACE TEMPORARY TABLE tSale + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT s.id, i.itemPackingTypeFk, IFNULL(sv.litros, 0) litros + FROM sale s + JOIN item i ON i.id = s.itemFk + LEFT JOIN saleVolume sv ON sv.saleFk = s.id + WHERE s.ticketFk = vSelf; + + CREATE OR REPLACE TEMPORARY TABLE tSaleGroup + ENGINE = MEMORY + SELECT itemPackingTypeFk, SUM(litros) totalLitros + FROM tSale + GROUP BY itemPackingTypeFk; + + SELECT COUNT(*) INTO vPackingTypesToSplit + FROM tSaleGroup + WHERE itemPackingTypeFk IS NOT NULL; CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT( ticketFk INT, itemPackingTypeFk VARCHAR(1) - ) ENGINE=MEMORY - SELECT vSelf ticketFk, vOriginalItemPackingTypeFk itemPackingTypeFk; + ) ENGINE = MEMORY; - CREATE OR REPLACE TEMPORARY TABLE tSalesToMove ( - ticketFk INT, - saleFk INT, - itemPackingTypeFk VARCHAR(1) - ) ENGINE=MEMORY; + CASE vPackingTypesToSplit + WHEN 0 THEN + INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) + VALUES(vSelf, vItemPackingTypeFk); + WHEN 1 THEN + INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) + SELECT vSelf, itemPackingTypeFk + FROM tSaleGroup + WHERE itemPackingTypeFk IS NOT NULL; + ELSE + OPEN vSaleGroup; + FETCH vSaleGroup INTO vItemPackingTypeFk; - INSERT INTO tSalesToMove (saleFk, itemPackingTypeFk) - SELECT s.id, i.itemPackingTypeFk - FROM ticket t - JOIN sale s ON s.ticketFk = t.id - JOIN item i ON i.id = s.itemFk - WHERE t.id = vSelf - AND i.itemPackingTypeFk <> vOriginalItemPackingTypeFk; + INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) + VALUES(vSelf, vItemPackingTypeFk); - OPEN vItemPackingTypes; - l: LOOP - SET vDone = FALSE; - FETCH vItemPackingTypes INTO vItemPackingTypeFk; + l: LOOP + SET vDone = FALSE; + FETCH vSaleGroup INTO vItemPackingTypeFk; - IF vDone THEN - LEAVE l; - END IF; + IF vDone THEN + LEAVE l; + END IF; - CALL ticket_Clone(vSelf, vNewTicketFk); + CALL ticket_Clone(vSelf, vNewTicketFk); - UPDATE tSalesToMove - SET ticketFk = vNewTicketFk - WHERE itemPackingTypeFk = vItemPackingTypeFk; + INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) + VALUES(vNewTicketFk, vItemPackingTypeFk); + END LOOP; - END LOOP; - CLOSE vItemPackingTypes; + CLOSE vSaleGroup; - UPDATE sale s - JOIN tSalesToMove stm ON stm.saleFk = s.id - SET s.ticketFk = stm.ticketFk - WHERE stm.ticketFk; + SELECT s.id + FROM sale s + JOIN tSale ts ON ts.id = s.id + JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk + FOR UPDATE; - INSERT INTO tmp.ticketIPT (ticketFk, itemPackingTypeFk) - SELECT ticketFk, itemPackingTypeFk - FROM tSalesToMove - GROUP BY ticketFk; + UPDATE sale s + JOIN tSale ts ON ts.id = s.id + JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk + SET s.ticketFk = t.ticketFk; - DROP TEMPORARY TABLE tSalesToMove; + SELECT itemPackingTypeFk INTO vItemPackingTypeFk + FROM tSaleGroup sg + WHERE sg.itemPackingTypeFk IS NOT NULL + ORDER BY sg.itemPackingTypeFk + LIMIT 1; + + UPDATE sale s + JOIN tSale ts ON ts.id = s.id + JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = vItemPackingTypeFk + SET s.ticketFk = t.ticketFk + WHERE ts.itemPackingTypeFk IS NULL; + END CASE; + + COMMIT; + + DROP TEMPORARY TABLE + tSale, + tSaleGroup; END$$ DELIMITER ;
@@ -12,7 +12,7 @@
- {{item.buyFk}} + {{buy.buyFk}}
- {{item.itemFk}} + {{buy.itemFk}}
- {{item.item}} + {{buy.item}}
- {{item.size}} + {{buy.size}}
- Color: {{item.inkFk}} + Color: {{buy.inkFk}}
- {{packing || item.packing}} + {{packing || buy.packing}}
- {{item.stems}} + {{buy.stems}}
- Origen: {{item.origin}} + Origen: {{buy.origin}}
- Productor: {{item.producerName || item.producerFk}} + Productor: {{buy.producerName || buy.producerFk}}
-
+
{{'LAID'}}
- {{item.entryFk}} + {{buy.entryFk}}
- Comprador: {{item.buyerName}} + Comprador: {{buy.buyerName}}
@@ -96,14 +96,14 @@
- {{`${item.labelNum}/${item.quantity / (packing || item.packing)}`}} + {{`${buy.labelNum}/${buy.quantity / (packing || buy.packing)}`}}
- Entrada: {{item.entryFk}} + Entrada: {{buy.entryFk}}
{{ - (item.longName && item.size && item.subName) - ? `${item.longName} ${item.size} ${item.subName}` - : item.comment + (buy.longName && buy.size && buy.subName) + ? `${buy.longName} ${buy.size} ${buy.subName}` + : buy.comment }}