diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 769c081c5..703c67443 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -582,6 +582,7 @@ INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif` VALUES (1, 'PLANTS SL', 'Plants nick', 4100000001, 1, '06089160W', 0, util.VN_CURDATE(), 1, 'supplier address 1', 'GOTHAM', 1, 46000, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'), (2, 'FARMER KING', 'The farmer', 4000020002, 1, '87945234L', 0, util.VN_CURDATE(), 1, 'supplier address 2', 'GOTHAM', 2, 46000, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'), + (4, 'INVENTARIO', 'INVENTARIO', 4000000004, NULL, NULL, 0, util.VN_CURDATE(), 1, NULL, NULL, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, NULL, NULL), (69, 'PACKAGING', 'Packaging nick', 4100000069, 1, '94935005K', 0, util.VN_CURDATE(), 1, 'supplier address 5', 'ASGARD', 3, 46600, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'), (442, 'VERDNATURA LEVANTE SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, util.VN_CURDATE(), 1, 'supplier address 3', 'GOTHAM', 1, 46000, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V'), (567, 'HOLLAND', 'Holland nick', 4000020567, 1, '14364089Z', 0, util.VN_CURDATE(), 1, 'supplier address 6', 'ASGARD', 3, 46600, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'), @@ -1516,6 +1517,9 @@ INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed (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 9', 1, 1, ''); +INSERT INTO `vn`.`entryConfig` (`defaultEntry`, `inventorySupplierFk`, `defaultSupplierFk`) + VALUES (2, 4, 1); + INSERT INTO `bs`.`waste`(`buyerFk`, `year`, `week`, `itemFk`, `itemTypeFk`, `saleTotal`, `saleWasteQuantity`, `saleInternalWaste`, `saleExternalWaste`) VALUES ('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 1, 1, '1062', '51', '56.20', '56.20'), diff --git a/db/routines/vn/procedures/itemShelving_transfer.sql b/db/routines/vn/procedures/itemShelving_transfer.sql index 47a9a7cf0..94d2308a1 100644 --- a/db/routines/vn/procedures/itemShelving_transfer.sql +++ b/db/routines/vn/procedures/itemShelving_transfer.sql @@ -5,28 +5,26 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_transf ) BEGIN /** - * Transfiere producto de una ubicación a otra, fusionando si coincide el - * packing y la fecha. + * Transfiere producto de una ubicación a otra + * fusionando si coincide el packing y la fecha. * * @param vItemShelvingFk Identificador de itemShelving * @param vShelvingFk Identificador de shelving */ - DECLARE vNewItemShelvingFk INT DEFAULT 0; + DECLARE vNewItemShelvingFk INT; - SELECT MAX(ish.id) - INTO vNewItemShelvingFk + SELECT MAX(ish.id) INTO vNewItemShelvingFk FROM itemShelving ish JOIN ( - SELECT - itemFk, - packing, - created, - buyFk + SELECT itemFk, + packing, + created, + buyFk FROM itemShelving WHERE id = vItemShelvingFk ) ish2 ON ish2.itemFk = ish.itemFk AND ish2.packing = ish.packing - AND date(ish2.created) = date(ish.created) + AND DATE(ish2.created) = DATE(ish.created) AND ish2.buyFk = ish.buyFk WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci; @@ -39,10 +37,16 @@ BEGIN DELETE FROM itemShelving WHERE id = vItemShelvingFk; ELSE - UPDATE itemShelving - SET shelvingFk = vShelvingFk - WHERE id = vItemShelvingFk; + IF (SELECT EXISTS(SELECT id FROM shelving + WHERE code = vShelvingFk COLLATE utf8_unicode_ci)) THEN + + UPDATE itemShelving + SET shelvingFk = vShelvingFk + WHERE id = vItemShelvingFk; + ELSE + CALL util.throw('The shelving not exists'); + END IF; END IF; - SELECT true; + SELECT TRUE; END$$ -DELIMITER ; \ No newline at end of file +DELIMITER ; diff --git a/db/routines/vn/triggers/buy_beforeUpdate.sql b/db/routines/vn/triggers/buy_beforeUpdate.sql index 1e2faecdc..366681f99 100644 --- a/db/routines/vn/triggers/buy_beforeUpdate.sql +++ b/db/routines/vn/triggers/buy_beforeUpdate.sql @@ -69,6 +69,10 @@ trig:BEGIN IF NOT NEW.printedStickers <=> OLD.printedStickers THEN CALL util.throw("Stickers cannot be modified if they are inventory"); END IF; + + IF OLD.entryFk <> NEW.entryFk THEN + CALL util.throw("Cannot transfer lines to inventory entry"); + END IF; END IF; IF NEW.quantity < 0 THEN diff --git a/db/routines/vn/triggers/itemShelving _afterDelete.sql b/db/routines/vn/triggers/itemShelving_afterDelete.sql similarity index 88% rename from db/routines/vn/triggers/itemShelving _afterDelete.sql rename to db/routines/vn/triggers/itemShelving_afterDelete.sql index 9a1759eff..449ad5530 100644 --- a/db/routines/vn/triggers/itemShelving _afterDelete.sql +++ b/db/routines/vn/triggers/itemShelving_afterDelete.sql @@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_afterDel BEGIN INSERT INTO shelvingLog SET `action` = 'delete', - `changedModel` = 'itemShelving', + `changedModel` = 'ItemShelving', `changedModelId` = OLD.id, `userFk` = account.myUser_getId(); END$$ diff --git a/db/routines/vn/triggers/saleGroupDetail._beforeInsert.sql b/db/routines/vn/triggers/saleGroupDetail._beforeInsert.sql new file mode 100644 index 000000000..9513be46a --- /dev/null +++ b/db/routines/vn/triggers/saleGroupDetail._beforeInsert.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`saleGroupDetail_beforeInsert` + BEFORE INSERT ON `saleGroupDetail` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/saleGroupDetail_afterDelete.sql b/db/routines/vn/triggers/saleGroupDetail_afterDelete.sql new file mode 100644 index 000000000..1698ad8ce --- /dev/null +++ b/db/routines/vn/triggers/saleGroupDetail_afterDelete.sql @@ -0,0 +1,12 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`saleGroupDetail_afterDelete` + AFTER DELETE ON `saleGroupDetail` + FOR EACH ROW +BEGIN + INSERT INTO saleGroupLog + SET `action` = 'delete', + `changedModel` = 'SaleGroupDetail', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/saleGroupDetail_beforeUpdate.sql b/db/routines/vn/triggers/saleGroupDetail_beforeUpdate.sql new file mode 100644 index 000000000..0da18fd98 --- /dev/null +++ b/db/routines/vn/triggers/saleGroupDetail_beforeUpdate.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`saleGroupDetail_beforeUpdate` + BEFORE UPDATE ON `saleGroupDetail` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/saleGroup_afterDelete.sql b/db/routines/vn/triggers/saleGroup_afterDelete.sql index 1e0163187..7ba34c6ce 100644 --- a/db/routines/vn/triggers/saleGroup_afterDelete.sql +++ b/db/routines/vn/triggers/saleGroup_afterDelete.sql @@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`saleGroup_afterDelete AFTER DELETE ON `saleGroup` FOR EACH ROW BEGIN - INSERT INTO ticketLog + INSERT INTO saleGroupLog SET `action` = 'delete', `changedModel` = 'SaleGroup', `changedModelId` = OLD.id, diff --git a/db/versions/11183-limePhormium/00-firstScript.sql b/db/versions/11183-limePhormium/00-firstScript.sql new file mode 100644 index 000000000..a30338f9e --- /dev/null +++ b/db/versions/11183-limePhormium/00-firstScript.sql @@ -0,0 +1,23 @@ +CREATE OR REPLACE TABLE `vn`.`saleGroupLog` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `originFk` int(11) DEFAULT NULL, + `userFk` int(10) unsigned DEFAULT NULL, + `action` set('insert','update','delete','select') NOT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, + `changedModel` enum('SaleGroup', 'SaleGroupDetail') NOT NULL DEFAULT 'SaleGroup', + `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, + `reason` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `saleGroupUserFk` (`userFk`), + KEY `saleGroupLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), + KEY `saleGroupLog_originFk` (`originFk`,`creationDate`), + CONSTRAINT `saleGroupLogUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +ALTER TABLE vn.parkingLog + MODIFY COLUMN changedModel enum('Parking') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT 'Parking' NOT NULL; diff --git a/db/versions/11209-pinkOrchid/00-firstScript.sql b/db/versions/11209-pinkOrchid/00-firstScript.sql new file mode 100644 index 000000000..92a7a7569 --- /dev/null +++ b/db/versions/11209-pinkOrchid/00-firstScript.sql @@ -0,0 +1,6 @@ +ALTER TABLE vn.operator + MODIFY COLUMN sizeLimit int(10) unsigned DEFAULT NULL NULL COMMENT 'Límite de altura en una colección para la asignación de pedidos'; + +UPDATE vn.operator + SET sizeLimit = 90 + WHERE itemPackingTypeFk = 'V'; diff --git a/loopback/server/connectors/vn-mysql.js b/loopback/server/connectors/vn-mysql.js index 5edef4395..2012caf37 100644 --- a/loopback/server/connectors/vn-mysql.js +++ b/loopback/server/connectors/vn-mysql.js @@ -342,6 +342,9 @@ exports.initialize = function initialize(dataSource, callback) { } }; +// Code extracted from original Loopback MySQL connector +// since it cannot be reused, please try not to alter it. +// https://github.com/loopbackio/loopback-connector-mysql/blob/v6.2.0/lib/mysql.js MySQL.prototype.connect = function(callback) { const self = this; const options = generateOptions(this.settings); diff --git a/loopback/server/datasources.json b/loopback/server/datasources.json index 341d5d578..f1643e522 100644 --- a/loopback/server/datasources.json +++ b/loopback/server/datasources.json @@ -11,12 +11,16 @@ "port": "3306", "username": "root", "password": "root", + "connectionLimit": 100, + "queueLimit": 100, "multipleStatements": true, "legacyUtcDateProcessing": false, "timezone": "local", "connectTimeout": 40000, "acquireTimeout": 90000, - "waitForConnections": true + "waitForConnections": true, + "maxIdleTime": 60000, + "idleTimeout": 60000 }, "osticket": { "connector": "memory", diff --git a/modules/ticket/front/descriptor-menu/index.html b/modules/ticket/front/descriptor-menu/index.html index 3583b1202..82094d7b8 100644 --- a/modules/ticket/front/descriptor-menu/index.html +++ b/modules/ticket/front/descriptor-menu/index.html @@ -6,7 +6,7 @@