From 78eba23d1233e9d240b4ccef6dcb64d66c4db91b Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 24 Aug 2023 13:44:15 +0200 Subject: [PATCH 01/62] refs #6156 new field --- .../00-ModifyProc_ticket_canAdvance.sql | 128 ++++++++++++++++++ .../back/methods/ticket/getTicketsAdvance.js | 11 +- modules/ticket/front/advance/index.html | 12 +- modules/ticket/front/future/locale/es.yml | 1 + 4 files changed, 140 insertions(+), 12 deletions(-) create mode 100644 db/changes/233601/00-ModifyProc_ticket_canAdvance.sql diff --git a/db/changes/233601/00-ModifyProc_ticket_canAdvance.sql b/db/changes/233601/00-ModifyProc_ticket_canAdvance.sql new file mode 100644 index 000000000..b0426711f --- /dev/null +++ b/db/changes/233601/00-ModifyProc_ticket_canAdvance.sql @@ -0,0 +1,128 @@ +CREATE TABLE IF NOT EXISTS `vn`.`ticketCanAdvanceConfig` ( + `id` INT auto_increment NULL, + `destinationOrder` INT NULL, + CONSTRAINT `ticketCanAdvanceConfig_PK` PRIMARY KEY (id) +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8mb3 +COLLATE=utf8mb3_unicode_ci; + +INSERT INTO `vn`.`ticketCanAdvanceConfig` + SET `destinationOrder` = 5; + +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT) +BEGIN +/** + * Devuelve los tickets y la cantidad de lineas de venta que se pueden adelantar. + * + * @param vDateFuture Fecha de los tickets que se quieren adelantar. + * @param vDateToAdvance Fecha a cuando se quiere adelantar. + * @param vWarehouseFk Almacén + */ + DECLARE vDateInventory DATE; + + SELECT inventoried INTO vDateInventory FROM config; + + CREATE OR REPLACE TEMPORARY TABLE tStock + (itemFk INT PRIMARY KEY, amount INT) + ENGINE = MEMORY; + + INSERT INTO tStock(itemFk, amount) + SELECT itemFk, SUM(quantity) amount FROM + ( + SELECT itemFk, quantity + FROM itemTicketOut + WHERE shipped >= vDateInventory + AND shipped < vDateFuture + AND warehouseFk = vWarehouseFk + UNION ALL + SELECT itemFk, quantity + FROM itemEntryIn + WHERE landed >= vDateInventory + AND landed < vDateFuture + AND isVirtualStock = FALSE + AND warehouseInFk = vWarehouseFk + UNION ALL + SELECT itemFk, quantity + FROM itemEntryOut + WHERE shipped >= vDateInventory + AND shipped < vDateFuture + AND warehouseOutFk = vWarehouseFk + ) t + GROUP BY itemFk HAVING amount != 0; + + CREATE OR REPLACE TEMPORARY TABLE tmp.filter + (INDEX (id)) + SELECT dest.*, + origin.* + FROM ( + SELECT s.ticketFk futureId, + t.workerFk, + t.shipped futureShipped, + t.totalWithVat futureTotalWithVat, + st.name futureState, + t.addressFk futureAddressFk, + am.name futureAgency, + count(s.id) futureLines, + GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) futureIpt, + CAST(SUM(litros) AS DECIMAL(10,0)) futureLiters, + SUM((s.quantity <= IFNULL(tst.amount,0))) hasStock, + st.classColor futureClassColor, + ( + count(s.id) - + SUM((s.quantity <= IFNULL(tst.amount,0))) + ) notMovableLines, + ( + count(s.id) = + SUM((s.quantity <= IFNULL(tst.amount,0))) + ) isFullMovable + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN saleVolume sv ON sv.saleFk = s.id + JOIN item i ON i.id = s.itemFk + JOIN ticketState ts ON ts.ticketFk = t.id + JOIN `state` st ON st.id = ts.stateFk + JOIN agencyMode am ON t.agencyModeFk = am.id + LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk + LEFT JOIN tStock tst ON tst.itemFk = i.id + WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture) + AND t.warehouseFk = vWarehouseFk + GROUP BY t.id + ) origin + JOIN ( + SELECT t.id, + t.addressFk, + st.name state, + GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt, + t.shipped, + t.totalWithVat, + am.name agency, + CAST(SUM(litros) AS DECIMAL(10,0)) liters, + CAST(COUNT(*) AS DECIMAL(10,0)) `lines`, + st.classColor, + IF(HOUR(t.shipped), + HOUR(t.shipped), + COALESCE(HOUR(zc.hour),HOUR(z.hour)) + ) preparation + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN saleVolume sv ON sv.saleFk = s.id + JOIN item i ON i.id = s.itemFk + JOIN ticketState ts ON ts.ticketFk = t.id + JOIN `state` st ON st.id = ts.stateFk + JOIN agencyMode am ON t.agencyModeFk = am.id + JOIN ticketCanAdvanceConfig + LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk + LEFT JOIN `zone` z ON z.id = t.zoneFk + LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk + WHERE t.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance) + AND t.warehouseFk = vWarehouseFk + AND st.order <= destinationOrder + GROUP BY t.id + ) dest ON dest.addressFk = origin.futureAddressFk + WHERE origin.hasStock != 0; + + DROP TEMPORARY TABLE tStock; +END$$ +DELIMITER ; diff --git a/modules/ticket/back/methods/ticket/getTicketsAdvance.js b/modules/ticket/back/methods/ticket/getTicketsAdvance.js index ec9314db2..5ad5152b9 100644 --- a/modules/ticket/back/methods/ticket/getTicketsAdvance.js +++ b/modules/ticket/back/methods/ticket/getTicketsAdvance.js @@ -110,13 +110,12 @@ module.exports = Self => { stmt = new ParameterizedSQL( `CALL vn.ticket_canAdvance(?,?,?)`, - [args.dateFuture, args.dateToAdvance, args.warehouseFk]); + [args.dateFuture, args.dateToAdvance, args.warehouseFk] + ); stmts.push(stmt); - stmt = new ParameterizedSQL(` - SELECT f.* - FROM tmp.filter f`); + stmt = new ParameterizedSQL(`SELECT f.* FROM tmp.filter f`); stmt.merge(conn.makeWhere(filter.where)); @@ -124,9 +123,7 @@ module.exports = Self => { stmt.merge(conn.makeLimit(filter)); const ticketsIndex = stmts.push(stmt) - 1; - stmts.push( - `DROP TEMPORARY TABLE - tmp.filter`); + stmts.push(`DROP TEMPORARY TABLE tmp.filter`); const sql = ParameterizedSQL.join(stmts, ';'); const result = await conn.executeStmt(sql, myOptions); diff --git a/modules/ticket/front/advance/index.html b/modules/ticket/front/advance/index.html index e6f16c965..8c50325fa 100644 --- a/modules/ticket/front/advance/index.html +++ b/modules/ticket/front/advance/index.html @@ -32,8 +32,8 @@ - Destination - Origin + Destination + Origin @@ -43,8 +43,7 @@ check-field="checked"> - - + ID @@ -54,6 +53,9 @@ IPT + + Preparation + State @@ -120,6 +122,7 @@ {{::ticket.ipt | dashIfEmpty}} + {{::ticket.preparation | dashIfEmpty}} @@ -164,7 +167,6 @@ {{::(ticket.futureTotalWithVat ? ticket.futureTotalWithVat : 0) | currency: 'EUR': 2}} - diff --git a/modules/ticket/front/future/locale/es.yml b/modules/ticket/front/future/locale/es.yml index 9fceea111..3645ad8ac 100644 --- a/modules/ticket/front/future/locale/es.yml +++ b/modules/ticket/front/future/locale/es.yml @@ -14,3 +14,4 @@ Success: Tickets movidos correctamente IPT: Encajado Origin Date: Fecha origen Destination Date: Fecha destino +Preparation: Preparación From 4880d1497fe807721f094ac53fba1dbc29556ff5 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 18 Jun 2024 08:40:33 +0200 Subject: [PATCH 02/62] feat: refs #6727 Added util logClean --- db/routines/util/events/log_clean.sql | 8 ++++ db/routines/util/procedures/log_clean.sql | 41 +++++++++++++++++++ .../11107-pinkAspidistra/00-firstScript.sql | 30 ++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 db/routines/util/events/log_clean.sql create mode 100644 db/routines/util/procedures/log_clean.sql create mode 100644 db/versions/11107-pinkAspidistra/00-firstScript.sql diff --git a/db/routines/util/events/log_clean.sql b/db/routines/util/events/log_clean.sql new file mode 100644 index 000000000..8447069e6 --- /dev/null +++ b/db/routines/util/events/log_clean.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `util`.`log_clean` + ON SCHEDULE EVERY 1 DAY + STARTS '2024-07-09 00:30:00.000' + ON COMPLETION PRESERVE + ENABLE +DO CALL util.log_clean$$ +DELIMITER ; diff --git a/db/routines/util/procedures/log_clean.sql b/db/routines/util/procedures/log_clean.sql new file mode 100644 index 000000000..1401b5dd8 --- /dev/null +++ b/db/routines/util/procedures/log_clean.sql @@ -0,0 +1,41 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`log_clean`() +BEGIN +/** + * Hace limpieza de los datos de las tablas log, + * dejando únicamente los días de retención configurados. + */ + DECLARE vSchemaName VARCHAR(65); + DECLARE vTableName VARCHAR(65); + DECLARE vRetentionDays INT; + DECLARE vDated DATE; + DECLARE vDone BOOL; + + DECLARE vQueue CURSOR FOR + SELECT schemaName, tableName, retentionDays + FROM logClean + ORDER BY `order`; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + OPEN vQueue; + l: LOOP + SET vDone = FALSE; + FETCH vQueue INTO vSchemaName, vTableName, vRetentionDays; + + SET vSchemaName = util.quoteIdentifier(vSchemaName); + SET vTableName = util.quoteIdentifier(vTableName); + SET vDated = VN_CURDATE() - INTERVAL vRetentionDays DAY; + + IF vDone THEN + LEAVE l; + END IF; + + CALL util.exec(CONCAT( + 'DELETE FROM ', vSchemaName , '.', vTableName, + " WHERE creationDate < '", vDated, "'" + )); + END LOOP; + CLOSE vQueue; +END$$ +DELIMITER ; diff --git a/db/versions/11107-pinkAspidistra/00-firstScript.sql b/db/versions/11107-pinkAspidistra/00-firstScript.sql new file mode 100644 index 000000000..e702da21e --- /dev/null +++ b/db/versions/11107-pinkAspidistra/00-firstScript.sql @@ -0,0 +1,30 @@ +CREATE OR REPLACE TABLE `util`.`logClean` ( + `schemaName` varchar(64) NOT NULL, + `tableName` varchar(64) NOT NULL, + `retentionDays` int(11) NOT NULL, + `order` int(11) DEFAULT NULL, + PRIMARY KEY (`schemaName`,`tableName`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT INTO `util`.`logClean` (`schemaName`, `tableName`, `retentionDays`, `order`) + VALUES + ('account', 'roleLog', 'xxx', NULL), + ('account', 'userLog', 'xxx', NULL), + ('vn', 'entryLog', 'xxx', NULL), + ('vn', 'clientLog', 'xxx', NULL), + ('vn', 'itemLog', 'xxx', NULL), + ('vn', 'shelvingLog', 'xxx', NULL), + ('vn', 'workerLog', 'xxx', NULL), + ('vn', 'deviceProductionLog', 'xxx', NULL), + ('vn', 'zoneLog', 'xxx', NULL), + ('vn', 'rateLog', 'xxx', NULL), + ('vn', 'ticketLog', 'xxx', NULL), + ('vn', 'agencyLog', 'xxx', NULL), + ('vn', 'userLog', 'xxx', NULL), + ('vn', 'routeLog', 'xxx', NULL), + ('vn', 'claimLog', 'xxx', NULL), + ('vn', 'supplierLog', 'xxx', NULL), + ('vn', 'invoiceInLog', 'xxx', NULL), + ('vn', 'travelLog', 'xxx', NULL), + ('vn', 'packingSiteDeviceLog', 'xxx', NULL), + ('vn', 'parkingLog', 'xxx', NULL); From d61e32917a525d49ba556cbb8107821b9947a54a Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 21 Jun 2024 13:22:59 +0200 Subject: [PATCH 03/62] feat: refs #7562 Created deleteDeprecatedObjects --- db/dump/fixtures.after.sql | 4 +- .../util/events/deleteDeprecatedObjects.sql | 8 ++ .../procedures/deleteDeprecatedObjects.sql | 88 +++++++++++++++++++ .../11113-bronzeDendro/00-firstScript.sql | 22 +++++ 4 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 db/routines/util/events/deleteDeprecatedObjects.sql create mode 100644 db/routines/util/procedures/deleteDeprecatedObjects.sql create mode 100644 db/versions/11113-bronzeDendro/00-firstScript.sql diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql index 562ea02d8..a276422e3 100644 --- a/db/dump/fixtures.after.sql +++ b/db/dump/fixtures.after.sql @@ -7,8 +7,8 @@ SET foreign_key_checks = 0; -- XXX: vn-database -INSERT INTO util.config (id, environment, mockTime, mockUtcTime, mockEnabled) - VALUES (1, 'local', '2001-01-01 12:00:00', '2001-01-01 11:00:00', TRUE); +INSERT INTO util.config (id, environment, mockTime, mockUtcTime, mockEnabled, daysKeepDeprecatedObjects) + VALUES (1, 'local', '2001-01-01 12:00:00', '2001-01-01 11:00:00', TRUE, 60); INSERT INTO util.binlogQueue (code,logName, `position`) VALUES ('mylogger', 'bin.000001', 4); diff --git a/db/routines/util/events/deleteDeprecatedObjects.sql b/db/routines/util/events/deleteDeprecatedObjects.sql new file mode 100644 index 000000000..0d7878a28 --- /dev/null +++ b/db/routines/util/events/deleteDeprecatedObjects.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `util`.`deleteDeprecatedObjects` + ON SCHEDULE EVERY 1 DAY + STARTS '2024-06-09 00:01:00.000' + ON COMPLETION PRESERVE + ENABLE +DO CALL deleteDeprecatedObjects$$ +DELIMITER ; diff --git a/db/routines/util/procedures/deleteDeprecatedObjects.sql b/db/routines/util/procedures/deleteDeprecatedObjects.sql new file mode 100644 index 000000000..a46d806d7 --- /dev/null +++ b/db/routines/util/procedures/deleteDeprecatedObjects.sql @@ -0,0 +1,88 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`deleteDeprecatedObjects`() + MODIFIES SQL DATA +BEGIN +/** + * Elimina objetos deprecados de la base de datos + */ + DECLARE vQuery TEXT; + DECLARE vDated DATE + DEFAULT ( + SELECT CURDATE() - INTERVAL daysKeepDeprecatedObjects DAY + FROM config + ); + DECLARE vDone BOOL; + + DECLARE vObjects CURSOR FOR + SELECT CONCAT('ALTER TABLE ', c.TABLE_SCHEMA, '.', c.TABLE_NAME, ' DROP PRIMARY KEY;') + FROM information_schema.`COLUMNS` c + LEFT JOIN information_schema.`VIEWS` v ON v.TABLE_SCHEMA = c.TABLE_SCHEMA + AND v.TABLE_NAME = c.TABLE_NAME + JOIN information_schema.STATISTICS s ON s.TABLE_SCHEMA = c.TABLE_SCHEMA + AND s.TABLE_NAME = c.TABLE_NAME + AND s.COLUMN_NAME = c.COLUMN_NAME + WHERE c.COLUMN_NAME LIKE '%\_\_' + AND REGEXP_SUBSTR(c.COLUMN_COMMENT, '[0-9]{4}-[0-9]{2}-[0-9]{2}') < vDated + AND v.TABLE_NAME IS NULL + AND s.INDEX_NAME = 'PRIMARY' + UNION ALL + SELECT CONCAT('ALTER TABLE ', c.TABLE_SCHEMA, '.', c.TABLE_NAME, ' DROP FOREIGN KEY ', kcu.CONSTRAINT_NAME, ';') + FROM information_schema.`COLUMNS` c + LEFT JOIN information_schema.`VIEWS` v ON v.TABLE_SCHEMA = c.TABLE_SCHEMA + AND v.TABLE_NAME = c.TABLE_NAME + JOIN information_schema.KEY_COLUMN_USAGE kcu ON kcu.TABLE_SCHEMA = c.TABLE_SCHEMA + AND kcu.TABLE_NAME = c.TABLE_NAME + AND kcu.COLUMN_NAME = c.COLUMN_NAME + WHERE c.COLUMN_NAME LIKE '%\_\_' + AND REGEXP_SUBSTR(c.COLUMN_COMMENT, '[0-9]{4}-[0-9]{2}-[0-9]{2}') < vDated + AND v.TABLE_NAME IS NULL + AND kcu.REFERENCED_COLUMN_NAME IS NOT NULL + UNION ALL + SELECT CONCAT('ALTER TABLE ', c.TABLE_SCHEMA, '.', c.TABLE_NAME, ' DROP COLUMN ', c.COLUMN_NAME, ';') + FROM information_schema.`COLUMNS` c + LEFT JOIN information_schema.`VIEWS` v ON v.TABLE_SCHEMA = c.TABLE_SCHEMA + AND v.TABLE_NAME = c.TABLE_NAME + LEFT JOIN information_schema.KEY_COLUMN_USAGE kcu ON kcu.TABLE_SCHEMA = c.TABLE_SCHEMA + AND kcu.TABLE_NAME = c.TABLE_NAME + AND kcu.COLUMN_NAME = c.COLUMN_NAME + WHERE c.COLUMN_NAME LIKE '%\_\_' + AND REGEXP_SUBSTR(c.COLUMN_COMMENT, '[0-9]{4}-[0-9]{2}-[0-9]{2}') < vDated + AND v.TABLE_NAME IS NULL + UNION ALL + SELECT CONCAT('DROP TABLE ', TABLE_SCHEMA, '.', TABLE_NAME, ';') + FROM information_schema.TABLES + WHERE TABLE_NAME LIKE '%\_\_' + AND REGEXP_SUBSTR(TABLE_COMMENT, '[0-9]{4}-[0-9]{2}-[0-9]{2}') < vDated; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + CALL mail_insert( + 'cau@verdnatura.es', + NULL, + 'Error en la eliminación automática de objetos deprecados', + CONCAT('
', vQuery, '
', + '

Revisa la tabla util.eventLog para más detalles.

') + ); + RESIGNAL; + END; + + IF vDated IS NULL THEN + CALL throw('Variable config not set'); + END IF; + + OPEN vObjects; + l: LOOP + SET vDone = FALSE; + FETCH vObjects INTO vQuery; + + IF vDone THEN + LEAVE l; + END IF; + + CALL `exec`(vQuery); + END LOOP; + CLOSE vObjects; +END$$ +DELIMITER ; diff --git a/db/versions/11113-bronzeDendro/00-firstScript.sql b/db/versions/11113-bronzeDendro/00-firstScript.sql new file mode 100644 index 000000000..b9a324c5e --- /dev/null +++ b/db/versions/11113-bronzeDendro/00-firstScript.sql @@ -0,0 +1,22 @@ +ALTER TABLE util.config + ADD daysKeepDeprecatedObjects int(11) unsigned NULL COMMENT 'Número de días que se mantendrán los objetos deprecados.'; + +UPDATE IGNORE util.config + SET daysKeepDeprecatedObjects = 60; + +ALTER TABLE IF EXISTS `vn`.`payrollWorker` + MODIFY COLUMN IF EXISTS `nss__` varchar(23) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', + MODIFY COLUMN IF EXISTS `codpuesto__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', + MODIFY COLUMN IF EXISTS `codcontrato__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', + MODIFY COLUMN IF EXISTS `FAntiguedad__` date NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', + MODIFY COLUMN IF EXISTS `grupotarifa__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', + MODIFY COLUMN IF EXISTS `codcategoria__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', + MODIFY COLUMN IF EXISTS `ContratoTemporal__` tinyint(1) NOT NULL DEFAULT 0 COMMENT '@deprecated 2024-03-15 refs #6738'; + +ALTER TABLE IF EXISTS `vn`.`payrollWorkCenter` + MODIFY COLUMN IF EXISTS `Centro__` varchar(255) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', + MODIFY COLUMN IF EXISTS `nss_cotizacion__` varchar(15) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', + MODIFY COLUMN IF EXISTS `domicilio__` varchar(255) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', + MODIFY COLUMN IF EXISTS `poblacion__` varchar(45) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', + MODIFY COLUMN IF EXISTS `cp__` varchar(5) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', + MODIFY COLUMN IF EXISTS `empresa_id__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738'; From c330e8c7156a55b9b99c4f7fa1e66aadcf894af0 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 21 Jun 2024 13:24:20 +0200 Subject: [PATCH 04/62] feat: refs #7562 Minor change --- db/routines/util/procedures/deleteDeprecatedObjects.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/util/procedures/deleteDeprecatedObjects.sql b/db/routines/util/procedures/deleteDeprecatedObjects.sql index a46d806d7..5911e0ab0 100644 --- a/db/routines/util/procedures/deleteDeprecatedObjects.sql +++ b/db/routines/util/procedures/deleteDeprecatedObjects.sql @@ -8,7 +8,7 @@ BEGIN DECLARE vQuery TEXT; DECLARE vDated DATE DEFAULT ( - SELECT CURDATE() - INTERVAL daysKeepDeprecatedObjects DAY + SELECT VN_CURDATE() - INTERVAL daysKeepDeprecatedObjects DAY FROM config ); DECLARE vDone BOOL; From c0668d054f86894f8e3f6ff6a4f7b3e02519266d Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 21 Jun 2024 13:51:33 +0200 Subject: [PATCH 05/62] feat: refs #7562 Changes --- db/dump/fixtures.after.sql | 4 +- .../procedures/deleteDeprecatedObjects.sql | 38 +++++++++++-------- .../11113-bronzeDendro/00-firstScript.sql | 6 ++- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql index a276422e3..1353e481b 100644 --- a/db/dump/fixtures.after.sql +++ b/db/dump/fixtures.after.sql @@ -7,8 +7,8 @@ SET foreign_key_checks = 0; -- XXX: vn-database -INSERT INTO util.config (id, environment, mockTime, mockUtcTime, mockEnabled, daysKeepDeprecatedObjects) - VALUES (1, 'local', '2001-01-01 12:00:00', '2001-01-01 11:00:00', TRUE, 60); +INSERT INTO util.config (id, environment, mockTime, mockUtcTime, mockEnabled, dateRegex, deprecatedMarkRegex, daysKeepDeprecatedObjects) + VALUES (1, 'local', '2001-01-01 12:00:00', '2001-01-01 11:00:00', TRUE, '[0-9]{4}-[0-9]{2}-[0-9]{2}', '__$', 60); INSERT INTO util.binlogQueue (code,logName, `position`) VALUES ('mylogger', 'bin.000001', 4); diff --git a/db/routines/util/procedures/deleteDeprecatedObjects.sql b/db/routines/util/procedures/deleteDeprecatedObjects.sql index 5911e0ab0..729f3faf1 100644 --- a/db/routines/util/procedures/deleteDeprecatedObjects.sql +++ b/db/routines/util/procedures/deleteDeprecatedObjects.sql @@ -6,11 +6,9 @@ BEGIN * Elimina objetos deprecados de la base de datos */ DECLARE vQuery TEXT; - DECLARE vDated DATE - DEFAULT ( - SELECT VN_CURDATE() - INTERVAL daysKeepDeprecatedObjects DAY - FROM config - ); + DECLARE vDated DATE; + DECLARE vDateRegex VARCHAR(255); + DECLARE vMarkRegex VARCHAR(255); DECLARE vDone BOOL; DECLARE vObjects CURSOR FOR @@ -21,8 +19,8 @@ BEGIN JOIN information_schema.STATISTICS s ON s.TABLE_SCHEMA = c.TABLE_SCHEMA AND s.TABLE_NAME = c.TABLE_NAME AND s.COLUMN_NAME = c.COLUMN_NAME - WHERE c.COLUMN_NAME LIKE '%\_\_' - AND REGEXP_SUBSTR(c.COLUMN_COMMENT, '[0-9]{4}-[0-9]{2}-[0-9]{2}') < vDated + WHERE c.COLUMN_NAME REGEXP vMarkRegex COLLATE utf8mb3_unicode_ci + AND REGEXP_SUBSTR(c.COLUMN_COMMENT, vDateRegex COLLATE utf8mb3_unicode_ci) < vDated AND v.TABLE_NAME IS NULL AND s.INDEX_NAME = 'PRIMARY' UNION ALL @@ -33,8 +31,8 @@ BEGIN JOIN information_schema.KEY_COLUMN_USAGE kcu ON kcu.TABLE_SCHEMA = c.TABLE_SCHEMA AND kcu.TABLE_NAME = c.TABLE_NAME AND kcu.COLUMN_NAME = c.COLUMN_NAME - WHERE c.COLUMN_NAME LIKE '%\_\_' - AND REGEXP_SUBSTR(c.COLUMN_COMMENT, '[0-9]{4}-[0-9]{2}-[0-9]{2}') < vDated + WHERE c.COLUMN_NAME REGEXP vMarkRegex COLLATE utf8mb3_unicode_ci + AND REGEXP_SUBSTR(c.COLUMN_COMMENT, vDateRegex COLLATE utf8mb3_unicode_ci) < vDated AND v.TABLE_NAME IS NULL AND kcu.REFERENCED_COLUMN_NAME IS NOT NULL UNION ALL @@ -45,20 +43,20 @@ BEGIN LEFT JOIN information_schema.KEY_COLUMN_USAGE kcu ON kcu.TABLE_SCHEMA = c.TABLE_SCHEMA AND kcu.TABLE_NAME = c.TABLE_NAME AND kcu.COLUMN_NAME = c.COLUMN_NAME - WHERE c.COLUMN_NAME LIKE '%\_\_' - AND REGEXP_SUBSTR(c.COLUMN_COMMENT, '[0-9]{4}-[0-9]{2}-[0-9]{2}') < vDated + WHERE c.COLUMN_NAME REGEXP vMarkRegex COLLATE utf8mb3_unicode_ci + AND REGEXP_SUBSTR(c.COLUMN_COMMENT, vDateRegex COLLATE utf8mb3_unicode_ci) < vDated AND v.TABLE_NAME IS NULL UNION ALL SELECT CONCAT('DROP TABLE ', TABLE_SCHEMA, '.', TABLE_NAME, ';') FROM information_schema.TABLES - WHERE TABLE_NAME LIKE '%\_\_' - AND REGEXP_SUBSTR(TABLE_COMMENT, '[0-9]{4}-[0-9]{2}-[0-9]{2}') < vDated; + WHERE TABLE_NAME REGEXP vMarkRegex COLLATE utf8mb3_unicode_ci + AND REGEXP_SUBSTR(TABLE_COMMENT, vDateRegex COLLATE utf8mb3_unicode_ci) < vDated; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN - CALL mail_insert( + CALL vn.mail_insert( 'cau@verdnatura.es', NULL, 'Error en la eliminación automática de objetos deprecados', @@ -68,8 +66,16 @@ BEGIN RESIGNAL; END; - IF vDated IS NULL THEN - CALL throw('Variable config not set'); + SELECT dateRegex, + deprecatedMarkRegex, + VN_CURDATE() - INTERVAL daysKeepDeprecatedObjects DAY + INTO vDateRegex, + vMarkRegex, + vDated + FROM config; + + IF vDateRegex IS NULL OR vMarkRegex IS NULL OR vDated IS NULL THEN + CALL throw('Some config parameters are not set'); END IF; OPEN vObjects; diff --git a/db/versions/11113-bronzeDendro/00-firstScript.sql b/db/versions/11113-bronzeDendro/00-firstScript.sql index b9a324c5e..98ac69966 100644 --- a/db/versions/11113-bronzeDendro/00-firstScript.sql +++ b/db/versions/11113-bronzeDendro/00-firstScript.sql @@ -1,8 +1,12 @@ ALTER TABLE util.config + ADD COLUMN dateRegex varchar(255) NULL COMMENT 'Expresión regular para obtener las fechas.', + ADD deprecatedMarkRegex varchar(255) NULL COMMENT 'Expresión regular para obtener los objetos deprecados.', ADD daysKeepDeprecatedObjects int(11) unsigned NULL COMMENT 'Número de días que se mantendrán los objetos deprecados.'; UPDATE IGNORE util.config - SET daysKeepDeprecatedObjects = 60; + SET dateRegex = '[0-9]{4}-[0-9]{2}-[0-9]{2}', + deprecatedMarkRegex = '__$', + daysKeepDeprecatedObjects = 60; ALTER TABLE IF EXISTS `vn`.`payrollWorker` MODIFY COLUMN IF EXISTS `nss__` varchar(23) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', From aedc8071e1e8175a98c33add6b1c60ff9ffe7a97 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 21 Jun 2024 14:27:22 +0200 Subject: [PATCH 06/62] feat: refs #7562 Changes --- db/routines/util/procedures/deleteDeprecatedObjects.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/routines/util/procedures/deleteDeprecatedObjects.sql b/db/routines/util/procedures/deleteDeprecatedObjects.sql index 729f3faf1..a251c3d98 100644 --- a/db/routines/util/procedures/deleteDeprecatedObjects.sql +++ b/db/routines/util/procedures/deleteDeprecatedObjects.sql @@ -23,7 +23,7 @@ BEGIN AND REGEXP_SUBSTR(c.COLUMN_COMMENT, vDateRegex COLLATE utf8mb3_unicode_ci) < vDated AND v.TABLE_NAME IS NULL AND s.INDEX_NAME = 'PRIMARY' - UNION ALL + UNION SELECT CONCAT('ALTER TABLE ', c.TABLE_SCHEMA, '.', c.TABLE_NAME, ' DROP FOREIGN KEY ', kcu.CONSTRAINT_NAME, ';') FROM information_schema.`COLUMNS` c LEFT JOIN information_schema.`VIEWS` v ON v.TABLE_SCHEMA = c.TABLE_SCHEMA @@ -35,7 +35,7 @@ BEGIN AND REGEXP_SUBSTR(c.COLUMN_COMMENT, vDateRegex COLLATE utf8mb3_unicode_ci) < vDated AND v.TABLE_NAME IS NULL AND kcu.REFERENCED_COLUMN_NAME IS NOT NULL - UNION ALL + UNION SELECT CONCAT('ALTER TABLE ', c.TABLE_SCHEMA, '.', c.TABLE_NAME, ' DROP COLUMN ', c.COLUMN_NAME, ';') FROM information_schema.`COLUMNS` c LEFT JOIN information_schema.`VIEWS` v ON v.TABLE_SCHEMA = c.TABLE_SCHEMA @@ -46,7 +46,7 @@ BEGIN WHERE c.COLUMN_NAME REGEXP vMarkRegex COLLATE utf8mb3_unicode_ci AND REGEXP_SUBSTR(c.COLUMN_COMMENT, vDateRegex COLLATE utf8mb3_unicode_ci) < vDated AND v.TABLE_NAME IS NULL - UNION ALL + UNION SELECT CONCAT('DROP TABLE ', TABLE_SCHEMA, '.', TABLE_NAME, ';') FROM information_schema.TABLES WHERE TABLE_NAME REGEXP vMarkRegex COLLATE utf8mb3_unicode_ci From 930e2951b74da376cba76dba7fdab9e326bcd0ff Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 19 Jul 2024 08:27:39 +0200 Subject: [PATCH 07/62] feat: refs #6727 Added started and finished --- db/routines/util/procedures/log_clean.sql | 35 +++++++++++++------ .../11107-pinkAspidistra/00-firstScript.sql | 8 +++-- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/db/routines/util/procedures/log_clean.sql b/db/routines/util/procedures/log_clean.sql index 1401b5dd8..850b26612 100644 --- a/db/routines/util/procedures/log_clean.sql +++ b/db/routines/util/procedures/log_clean.sql @@ -13,7 +13,7 @@ BEGIN DECLARE vQueue CURSOR FOR SELECT schemaName, tableName, retentionDays - FROM logClean + FROM logCleanMultiConfig ORDER BY `order`; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; @@ -23,18 +23,31 @@ BEGIN SET vDone = FALSE; FETCH vQueue INTO vSchemaName, vTableName, vRetentionDays; - SET vSchemaName = util.quoteIdentifier(vSchemaName); - SET vTableName = util.quoteIdentifier(vTableName); - SET vDated = VN_CURDATE() - INTERVAL vRetentionDays DAY; + IF vRetentionDays THEN - IF vDone THEN - LEAVE l; + UPDATE logCleanMultiConfig + SET `started` = util.VN_NOW() + WHERE schemaName = vSchemaName + AND tableName = vTableName; + + SET vSchemaName = util.quoteIdentifier(vSchemaName); + SET vTableName = util.quoteIdentifier(vTableName); + SET vDated = VN_CURDATE() - INTERVAL vRetentionDays DAY; + + IF vDone THEN + LEAVE l; + END IF; + + CALL util.exec(CONCAT( + 'DELETE FROM ', vSchemaName , '.', vTableName, + " WHERE creationDate < '", vDated, "'" + )); + + UPDATE logCleanMultiConfig + SET `finished` = util.VN_NOW() + WHERE schemaName = vSchemaName + AND tableName = vTableName; END IF; - - CALL util.exec(CONCAT( - 'DELETE FROM ', vSchemaName , '.', vTableName, - " WHERE creationDate < '", vDated, "'" - )); END LOOP; CLOSE vQueue; END$$ diff --git a/db/versions/11107-pinkAspidistra/00-firstScript.sql b/db/versions/11107-pinkAspidistra/00-firstScript.sql index e702da21e..a1c4bb82f 100644 --- a/db/versions/11107-pinkAspidistra/00-firstScript.sql +++ b/db/versions/11107-pinkAspidistra/00-firstScript.sql @@ -1,12 +1,14 @@ -CREATE OR REPLACE TABLE `util`.`logClean` ( +CREATE OR REPLACE TABLE `util`.`logCleanMultiConfig` ( `schemaName` varchar(64) NOT NULL, `tableName` varchar(64) NOT NULL, - `retentionDays` int(11) NOT NULL, + `retentionDays` int(11) DEFAULT NULL, `order` int(11) DEFAULT NULL, + `started` datetime DEFAULT NULL, + `finished` datetime DEFAULT NULL, PRIMARY KEY (`schemaName`,`tableName`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -INSERT INTO `util`.`logClean` (`schemaName`, `tableName`, `retentionDays`, `order`) +INSERT INTO `util`.`logCleanMultiConfig` (`schemaName`, `tableName`, `retentionDays`, `order`) VALUES ('account', 'roleLog', 'xxx', NULL), ('account', 'userLog', 'xxx', NULL), From 3cf55556120df016e1f6980b2ffebc089b548aae Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 19 Jul 2024 08:58:51 +0200 Subject: [PATCH 08/62] feat: refs #6727 Fixes --- db/routines/util/procedures/log_clean.sql | 24 +++++------ .../11107-pinkAspidistra/00-firstScript.sql | 42 +++++++++---------- 2 files changed, 31 insertions(+), 35 deletions(-) diff --git a/db/routines/util/procedures/log_clean.sql b/db/routines/util/procedures/log_clean.sql index 850b26612..765d5dcbc 100644 --- a/db/routines/util/procedures/log_clean.sql +++ b/db/routines/util/procedures/log_clean.sql @@ -8,6 +8,7 @@ BEGIN DECLARE vSchemaName VARCHAR(65); DECLARE vTableName VARCHAR(65); DECLARE vRetentionDays INT; + DECLARE vStarted DATETIME; DECLARE vDated DATE; DECLARE vDone BOOL; @@ -23,28 +24,23 @@ BEGIN SET vDone = FALSE; FETCH vQueue INTO vSchemaName, vTableName, vRetentionDays; + IF vDone THEN + LEAVE l; + END IF; + IF vRetentionDays THEN - - UPDATE logCleanMultiConfig - SET `started` = util.VN_NOW() - WHERE schemaName = vSchemaName - AND tableName = vTableName; - - SET vSchemaName = util.quoteIdentifier(vSchemaName); - SET vTableName = util.quoteIdentifier(vTableName); + SET vStarted = util.VN_NOW(); SET vDated = VN_CURDATE() - INTERVAL vRetentionDays DAY; - IF vDone THEN - LEAVE l; - END IF; - CALL util.exec(CONCAT( - 'DELETE FROM ', vSchemaName , '.', vTableName, + 'DELETE FROM ', util.quoteIdentifier(vSchemaName), + '.', util.quoteIdentifier(vTableName), " WHERE creationDate < '", vDated, "'" )); UPDATE logCleanMultiConfig - SET `finished` = util.VN_NOW() + SET `started` = vStarted, + `finished` = VN_NOW() WHERE schemaName = vSchemaName AND tableName = vTableName; END IF; diff --git a/db/versions/11107-pinkAspidistra/00-firstScript.sql b/db/versions/11107-pinkAspidistra/00-firstScript.sql index a1c4bb82f..3ed3df526 100644 --- a/db/versions/11107-pinkAspidistra/00-firstScript.sql +++ b/db/versions/11107-pinkAspidistra/00-firstScript.sql @@ -8,25 +8,25 @@ CREATE OR REPLACE TABLE `util`.`logCleanMultiConfig` ( PRIMARY KEY (`schemaName`,`tableName`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -INSERT INTO `util`.`logCleanMultiConfig` (`schemaName`, `tableName`, `retentionDays`, `order`) +INSERT INTO `util`.`logCleanMultiConfig` (`schemaName`, `tableName`) VALUES - ('account', 'roleLog', 'xxx', NULL), - ('account', 'userLog', 'xxx', NULL), - ('vn', 'entryLog', 'xxx', NULL), - ('vn', 'clientLog', 'xxx', NULL), - ('vn', 'itemLog', 'xxx', NULL), - ('vn', 'shelvingLog', 'xxx', NULL), - ('vn', 'workerLog', 'xxx', NULL), - ('vn', 'deviceProductionLog', 'xxx', NULL), - ('vn', 'zoneLog', 'xxx', NULL), - ('vn', 'rateLog', 'xxx', NULL), - ('vn', 'ticketLog', 'xxx', NULL), - ('vn', 'agencyLog', 'xxx', NULL), - ('vn', 'userLog', 'xxx', NULL), - ('vn', 'routeLog', 'xxx', NULL), - ('vn', 'claimLog', 'xxx', NULL), - ('vn', 'supplierLog', 'xxx', NULL), - ('vn', 'invoiceInLog', 'xxx', NULL), - ('vn', 'travelLog', 'xxx', NULL), - ('vn', 'packingSiteDeviceLog', 'xxx', NULL), - ('vn', 'parkingLog', 'xxx', NULL); + ('account', 'roleLog' ), + ('account', 'userLog' ), + ('vn', 'entryLog' ), + ('vn', 'clientLog' ), + ('vn', 'itemLog' ), + ('vn', 'shelvingLog' ), + ('vn', 'workerLog' ), + ('vn', 'deviceProductionLog' ), + ('vn', 'zoneLog' ), + ('vn', 'rateLog' ), + ('vn', 'ticketLog' ), + ('vn', 'agencyLog' ), + ('vn', 'userLog' ), + ('vn', 'routeLog' ), + ('vn', 'claimLog' ), + ('vn', 'supplierLog' ), + ('vn', 'invoiceInLog' ), + ('vn', 'travelLog' ), + ('vn', 'packingSiteDeviceLog' ), + ('vn', 'parkingLog' ); From 11337506298dbd92f92b452ecc0d78e6a6e9bab7 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 19 Jul 2024 09:29:15 +0200 Subject: [PATCH 09/62] feat: #6727 Requested changes --- db/routines/util/procedures/log_clean.sql | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/db/routines/util/procedures/log_clean.sql b/db/routines/util/procedures/log_clean.sql index 765d5dcbc..d490165a4 100644 --- a/db/routines/util/procedures/log_clean.sql +++ b/db/routines/util/procedures/log_clean.sql @@ -6,7 +6,9 @@ BEGIN * dejando únicamente los días de retención configurados. */ DECLARE vSchemaName VARCHAR(65); + DECLARE vSchemaNameQuoted VARCHAR(65); DECLARE vTableName VARCHAR(65); + DECLARE vTableNameQuoted VARCHAR(65); DECLARE vRetentionDays INT; DECLARE vStarted DATETIME; DECLARE vDated DATE; @@ -30,13 +32,15 @@ BEGIN IF vRetentionDays THEN SET vStarted = util.VN_NOW(); + SET vSchemaNameQuoted = util.quoteIdentifier(vSchemaName); + SET vTableNameQuoted = util.quoteIdentifier(vTableName); SET vDated = VN_CURDATE() - INTERVAL vRetentionDays DAY; - CALL util.exec(CONCAT( - 'DELETE FROM ', util.quoteIdentifier(vSchemaName), - '.', util.quoteIdentifier(vTableName), + EXECUTE IMMEDIATE CONCAT( + 'DELETE FROM ', vSchemaNameQuoted, + '.', vTableNameQuoted, " WHERE creationDate < '", vDated, "'" - )); + ); UPDATE logCleanMultiConfig SET `started` = vStarted, From c94ca96226efc19101d07625ec9bf00cb2697125 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 19 Jul 2024 09:29:42 +0200 Subject: [PATCH 10/62] feat: #6727 Minor changes --- db/routines/util/procedures/log_clean.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/routines/util/procedures/log_clean.sql b/db/routines/util/procedures/log_clean.sql index d490165a4..aeed9dc44 100644 --- a/db/routines/util/procedures/log_clean.sql +++ b/db/routines/util/procedures/log_clean.sql @@ -31,9 +31,9 @@ BEGIN END IF; IF vRetentionDays THEN - SET vStarted = util.VN_NOW(); - SET vSchemaNameQuoted = util.quoteIdentifier(vSchemaName); - SET vTableNameQuoted = util.quoteIdentifier(vTableName); + SET vStarted = VN_NOW(); + SET vSchemaNameQuoted = quoteIdentifier(vSchemaName); + SET vTableNameQuoted = quoteIdentifier(vTableName); SET vDated = VN_CURDATE() - INTERVAL vRetentionDays DAY; EXECUTE IMMEDIATE CONCAT( From 57f6c6d9a1b4f5214c3bb1b3d5f612f335d137e2 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 31 Jul 2024 10:43:55 +0200 Subject: [PATCH 11/62] chore: refs #7663 WIP setWeight --- .../11178-yellowCamellia/00-aclSetWeight.sql | 9 +++ loopback/locale/es.json | 3 +- .../ticket/back/methods/ticket/setWeight.js | 75 +++++++++++++++++++ modules/ticket/back/models/ticket-methods.js | 1 + modules/ticket/front/summary/locale/es.yml | 3 +- 5 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 db/versions/11178-yellowCamellia/00-aclSetWeight.sql create mode 100644 modules/ticket/back/methods/ticket/setWeight.js diff --git a/db/versions/11178-yellowCamellia/00-aclSetWeight.sql b/db/versions/11178-yellowCamellia/00-aclSetWeight.sql new file mode 100644 index 000000000..d70287738 --- /dev/null +++ b/db/versions/11178-yellowCamellia/00-aclSetWeight.sql @@ -0,0 +1,9 @@ +-- Place your SQL code here +INSERT INTO salix.ACL + SET model = 'Ticket', + property = 'setWeight', + accessType = 'WRITE', + permission = 'ALLOW', + principalType = 'ROLE', + principalId = 'salesPerson'; + \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index acc3d69f6..eb7a2aaf2 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -368,5 +368,6 @@ "Payment method is required": "El método de pago es obligatorio", "Cannot send mail": "Não é possível enviar o email", "CONSTRAINT `supplierAccountTooShort` failed for `vn`.`supplier`": "La cuenta debe tener exactamente 10 dígitos", - "The sale not exists in the item shelving": "La venta no existe en la estantería del artículo" + "The sale not exists in the item shelving": "La venta no existe en la estantería del artículo", + "Weight already set": "El peso ya está establecido" } \ No newline at end of file diff --git a/modules/ticket/back/methods/ticket/setWeight.js b/modules/ticket/back/methods/ticket/setWeight.js new file mode 100644 index 000000000..f2a65b1d6 --- /dev/null +++ b/modules/ticket/back/methods/ticket/setWeight.js @@ -0,0 +1,75 @@ +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.remoteMethodCtx('setWeight', { + description: 'Sets weight of a ticket', + accessType: 'WRITE', + accepts: [{ + arg: 'id', + type: 'number', + required: true, + description: 'The ticket id', + http: {source: 'path'} + }, { + arg: 'weight', + type: 'number', + required: true, + description: 'The weight value', + }], + http: { + path: `/:id/setWeight`, + verb: 'POST' + } + }); + + Self.setWeight = async(ctx, ticketId, weight, invoiceable, options) => { + const models = Self.app.models; + const userId = ctx.req.accessToken.userId; + const myOptions = {userId}; + let tx; + + if (typeof options == 'object') Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + try { + if (ticket.weight) throw new UserError('Weight already set'); + + const canEdit = await models.ACL.checkAccessAcl(ctx, 'Ticket', 'updateAttributes'); + const ticket = await Self.findById(ticketId, null, myOptions); + const client = await models.Client.findById(ticket.clientFk, { + include: {relation: 'salesPersonUser'}}, + myOptions); + + if (!canEdit) { + const salesPersonUser = client.salesPersonUser(); + const workerDepartments = await models.WorkerDepartment.find({ + include: {relation: 'department'}, + where: {workerFk: {inq: [userId, salesPersonUser.id]}} + }, myOptions); + + if (workerDepartments[0].departmentFk != workerDepartments[1].departmentFk) + throw new UserError('You don\'t have enough privileges'); + } + + await ticket.updateAttribute('weight', weight, myOptions); + + const packedState = await models.State.findOne({where: {code: 'PACKED'}}, myOptions); + const ticketState = await models.TicketState.findOne({where: {ticketFk: ticketId}}, myOptions); + + const [{taxArea}] = await Self.rawSql('SELECT clientTaxArea(?,?) taxArea', + [ticket.clientFk, ticket.warehouseFk], myOptions); + + if (ticketState.alertLevel >= packedState.alertLevel && taxArea == 'WORLD' && client.hasDailyInvoice) + await Self.invoiceTicketsAndPdf(ctx, [ticketId], null, myOptions); + + if (tx) await tx.commit(); + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + }; +}; diff --git a/modules/ticket/back/models/ticket-methods.js b/modules/ticket/back/models/ticket-methods.js index 5582dde5c..457454627 100644 --- a/modules/ticket/back/models/ticket-methods.js +++ b/modules/ticket/back/models/ticket-methods.js @@ -47,4 +47,5 @@ module.exports = function(Self) { require('../methods/ticket/docuwareDownload')(Self); require('../methods/ticket/myLastModified')(Self); require('../methods/ticket/clone')(Self); + require('../methods/ticket/setWeight')(Self); }; diff --git a/modules/ticket/front/summary/locale/es.yml b/modules/ticket/front/summary/locale/es.yml index d1e6dba58..9de7ccbf4 100644 --- a/modules/ticket/front/summary/locale/es.yml +++ b/modules/ticket/front/summary/locale/es.yml @@ -3,4 +3,5 @@ Address mobile: Móv. consignatario Client phone: Tel. cliente Client mobile: Móv. cliente Go to the ticket: Ir al ticket -Change state: Cambiar estado \ No newline at end of file +Change state: Cambiar estado +Weight: Peso \ No newline at end of file From 52d62710e6347cc2b8e8d6ab8fb49effaf663757 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 13 Aug 2024 13:49:00 +0200 Subject: [PATCH 12/62] chore: refs #7663 fix logic --- .../ticket/back/methods/ticket/setWeight.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/modules/ticket/back/methods/ticket/setWeight.js b/modules/ticket/back/methods/ticket/setWeight.js index f2a65b1d6..4f9e1883e 100644 --- a/modules/ticket/back/methods/ticket/setWeight.js +++ b/modules/ticket/back/methods/ticket/setWeight.js @@ -16,13 +16,17 @@ module.exports = Self => { required: true, description: 'The weight value', }], + returns: { + type: 'boolean', + root: true + }, http: { path: `/:id/setWeight`, verb: 'POST' } }); - Self.setWeight = async(ctx, ticketId, weight, invoiceable, options) => { + Self.setWeight = async(ctx, ticketId, weight, options) => { const models = Self.app.models; const userId = ctx.req.accessToken.userId; const myOptions = {userId}; @@ -36,10 +40,10 @@ module.exports = Self => { } try { + const ticket = await Self.findById(ticketId, null, myOptions); if (ticket.weight) throw new UserError('Weight already set'); const canEdit = await models.ACL.checkAccessAcl(ctx, 'Ticket', 'updateAttributes'); - const ticket = await Self.findById(ticketId, null, myOptions); const client = await models.Client.findById(ticket.clientFk, { include: {relation: 'salesPersonUser'}}, myOptions); @@ -51,7 +55,10 @@ module.exports = Self => { where: {workerFk: {inq: [userId, salesPersonUser.id]}} }, myOptions); - if (workerDepartments[0].departmentFk != workerDepartments[1].departmentFk) + if ( + workerDepartments.length == 2 && + workerDepartments[0].departmentFk != workerDepartments[1].departmentFk + ) throw new UserError('You don\'t have enough privileges'); } @@ -63,10 +70,12 @@ module.exports = Self => { const [{taxArea}] = await Self.rawSql('SELECT clientTaxArea(?,?) taxArea', [ticket.clientFk, ticket.warehouseFk], myOptions); - if (ticketState.alertLevel >= packedState.alertLevel && taxArea == 'WORLD' && client.hasDailyInvoice) + if (ticketState.alertLevel >= packedState.alertLevel && taxArea == 'WORLD' && client.hasDailyInvoice) { await Self.invoiceTicketsAndPdf(ctx, [ticketId], null, myOptions); - + return true; + } if (tx) await tx.commit(); + return false; } catch (e) { if (tx) await tx.rollback(); throw e; From 6c9676ce9c90f145b638d3ec293e6d44d274d2db Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 13 Aug 2024 14:52:26 +0200 Subject: [PATCH 13/62] chore: refs #7663 fix logic --- modules/ticket/back/methods/ticket/setWeight.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/ticket/back/methods/ticket/setWeight.js b/modules/ticket/back/methods/ticket/setWeight.js index 4f9e1883e..91ecef634 100644 --- a/modules/ticket/back/methods/ticket/setWeight.js +++ b/modules/ticket/back/methods/ticket/setWeight.js @@ -70,12 +70,13 @@ module.exports = Self => { const [{taxArea}] = await Self.rawSql('SELECT clientTaxArea(?,?) taxArea', [ticket.clientFk, ticket.warehouseFk], myOptions); - if (ticketState.alertLevel >= packedState.alertLevel && taxArea == 'WORLD' && client.hasDailyInvoice) { - await Self.invoiceTicketsAndPdf(ctx, [ticketId], null, myOptions); - return true; - } + const isInvoiceable = ticketState.alertLevel >= packedState.alertLevel && + taxArea == 'WORLD' && client.hasDailyInvoice; + if (tx) await tx.commit(); - return false; + if (isInvoiceable) await Self.invoiceTicketsAndPdf(ctx, [ticketId]); + + return isInvoiceable; } catch (e) { if (tx) await tx.rollback(); throw e; From 2ba391fc85bacc338914002bdab00c449339e188 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 2 Sep 2024 07:57:00 +0200 Subject: [PATCH 14/62] feat: refs #7562 Deleted deleteDeprecatedObjects objects --- .../util/events/deleteDeprecatedObjects.sql | 8 -- .../procedures/deleteDeprecatedObjects.sql | 94 ------------------- 2 files changed, 102 deletions(-) delete mode 100644 db/routines/util/events/deleteDeprecatedObjects.sql delete mode 100644 db/routines/util/procedures/deleteDeprecatedObjects.sql diff --git a/db/routines/util/events/deleteDeprecatedObjects.sql b/db/routines/util/events/deleteDeprecatedObjects.sql deleted file mode 100644 index 0d7878a28..000000000 --- a/db/routines/util/events/deleteDeprecatedObjects.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `util`.`deleteDeprecatedObjects` - ON SCHEDULE EVERY 1 DAY - STARTS '2024-06-09 00:01:00.000' - ON COMPLETION PRESERVE - ENABLE -DO CALL deleteDeprecatedObjects$$ -DELIMITER ; diff --git a/db/routines/util/procedures/deleteDeprecatedObjects.sql b/db/routines/util/procedures/deleteDeprecatedObjects.sql deleted file mode 100644 index a251c3d98..000000000 --- a/db/routines/util/procedures/deleteDeprecatedObjects.sql +++ /dev/null @@ -1,94 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`deleteDeprecatedObjects`() - MODIFIES SQL DATA -BEGIN -/** - * Elimina objetos deprecados de la base de datos - */ - DECLARE vQuery TEXT; - DECLARE vDated DATE; - DECLARE vDateRegex VARCHAR(255); - DECLARE vMarkRegex VARCHAR(255); - DECLARE vDone BOOL; - - DECLARE vObjects CURSOR FOR - SELECT CONCAT('ALTER TABLE ', c.TABLE_SCHEMA, '.', c.TABLE_NAME, ' DROP PRIMARY KEY;') - FROM information_schema.`COLUMNS` c - LEFT JOIN information_schema.`VIEWS` v ON v.TABLE_SCHEMA = c.TABLE_SCHEMA - AND v.TABLE_NAME = c.TABLE_NAME - JOIN information_schema.STATISTICS s ON s.TABLE_SCHEMA = c.TABLE_SCHEMA - AND s.TABLE_NAME = c.TABLE_NAME - AND s.COLUMN_NAME = c.COLUMN_NAME - WHERE c.COLUMN_NAME REGEXP vMarkRegex COLLATE utf8mb3_unicode_ci - AND REGEXP_SUBSTR(c.COLUMN_COMMENT, vDateRegex COLLATE utf8mb3_unicode_ci) < vDated - AND v.TABLE_NAME IS NULL - AND s.INDEX_NAME = 'PRIMARY' - UNION - SELECT CONCAT('ALTER TABLE ', c.TABLE_SCHEMA, '.', c.TABLE_NAME, ' DROP FOREIGN KEY ', kcu.CONSTRAINT_NAME, ';') - FROM information_schema.`COLUMNS` c - LEFT JOIN information_schema.`VIEWS` v ON v.TABLE_SCHEMA = c.TABLE_SCHEMA - AND v.TABLE_NAME = c.TABLE_NAME - JOIN information_schema.KEY_COLUMN_USAGE kcu ON kcu.TABLE_SCHEMA = c.TABLE_SCHEMA - AND kcu.TABLE_NAME = c.TABLE_NAME - AND kcu.COLUMN_NAME = c.COLUMN_NAME - WHERE c.COLUMN_NAME REGEXP vMarkRegex COLLATE utf8mb3_unicode_ci - AND REGEXP_SUBSTR(c.COLUMN_COMMENT, vDateRegex COLLATE utf8mb3_unicode_ci) < vDated - AND v.TABLE_NAME IS NULL - AND kcu.REFERENCED_COLUMN_NAME IS NOT NULL - UNION - SELECT CONCAT('ALTER TABLE ', c.TABLE_SCHEMA, '.', c.TABLE_NAME, ' DROP COLUMN ', c.COLUMN_NAME, ';') - FROM information_schema.`COLUMNS` c - LEFT JOIN information_schema.`VIEWS` v ON v.TABLE_SCHEMA = c.TABLE_SCHEMA - AND v.TABLE_NAME = c.TABLE_NAME - LEFT JOIN information_schema.KEY_COLUMN_USAGE kcu ON kcu.TABLE_SCHEMA = c.TABLE_SCHEMA - AND kcu.TABLE_NAME = c.TABLE_NAME - AND kcu.COLUMN_NAME = c.COLUMN_NAME - WHERE c.COLUMN_NAME REGEXP vMarkRegex COLLATE utf8mb3_unicode_ci - AND REGEXP_SUBSTR(c.COLUMN_COMMENT, vDateRegex COLLATE utf8mb3_unicode_ci) < vDated - AND v.TABLE_NAME IS NULL - UNION - SELECT CONCAT('DROP TABLE ', TABLE_SCHEMA, '.', TABLE_NAME, ';') - FROM information_schema.TABLES - WHERE TABLE_NAME REGEXP vMarkRegex COLLATE utf8mb3_unicode_ci - AND REGEXP_SUBSTR(TABLE_COMMENT, vDateRegex COLLATE utf8mb3_unicode_ci) < vDated; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - CALL vn.mail_insert( - 'cau@verdnatura.es', - NULL, - 'Error en la eliminación automática de objetos deprecados', - CONCAT('
', vQuery, '
', - '

Revisa la tabla util.eventLog para más detalles.

') - ); - RESIGNAL; - END; - - SELECT dateRegex, - deprecatedMarkRegex, - VN_CURDATE() - INTERVAL daysKeepDeprecatedObjects DAY - INTO vDateRegex, - vMarkRegex, - vDated - FROM config; - - IF vDateRegex IS NULL OR vMarkRegex IS NULL OR vDated IS NULL THEN - CALL throw('Some config parameters are not set'); - END IF; - - OPEN vObjects; - l: LOOP - SET vDone = FALSE; - FETCH vObjects INTO vQuery; - - IF vDone THEN - LEAVE l; - END IF; - - CALL `exec`(vQuery); - END LOOP; - CLOSE vObjects; -END$$ -DELIMITER ; From 4c5f5c8324c8424d3bbb001fae7c7c4538694ca3 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 2 Sep 2024 17:08:23 +0200 Subject: [PATCH 15/62] fix: refs #7663 conflicts --- modules/ticket/back/models/ticket-methods.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/ticket/back/models/ticket-methods.js b/modules/ticket/back/models/ticket-methods.js index cb2baf01f..12161d5f5 100644 --- a/modules/ticket/back/models/ticket-methods.js +++ b/modules/ticket/back/models/ticket-methods.js @@ -46,6 +46,5 @@ module.exports = function(Self) { require('../methods/ticket/invoiceTicketsAndPdf')(Self); require('../methods/ticket/docuwareDownload')(Self); require('../methods/ticket/myLastModified')(Self); - require('../methods/ticket/clone')(Self); require('../methods/ticket/setWeight')(Self); }; From 9797d5e219b1c3d1a1a9a57f50163f1b7ded9087 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 3 Sep 2024 17:33:44 +0200 Subject: [PATCH 16/62] feat: refs #7663 return created invoice ids --- modules/ticket/back/methods/ticket/setWeight.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/ticket/back/methods/ticket/setWeight.js b/modules/ticket/back/methods/ticket/setWeight.js index 91ecef634..d71f2c0e5 100644 --- a/modules/ticket/back/methods/ticket/setWeight.js +++ b/modules/ticket/back/methods/ticket/setWeight.js @@ -74,9 +74,10 @@ module.exports = Self => { taxArea == 'WORLD' && client.hasDailyInvoice; if (tx) await tx.commit(); - if (isInvoiceable) await Self.invoiceTicketsAndPdf(ctx, [ticketId]); + let invoiceIds = []; + if (isInvoiceable) invoiceIds = [...await Self.invoiceTicketsAndPdf(ctx, [ticketId])]; - return isInvoiceable; + return invoiceIds; } catch (e) { if (tx) await tx.rollback(); throw e; From df5961a2a2bb196ca9e794c15fd73d80f5ce2973 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 4 Sep 2024 11:41:47 +0200 Subject: [PATCH 17/62] feat: refs #7663 wip test --- .../methods/ticket/specs/setWeight.spec.js | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 modules/ticket/back/methods/ticket/specs/setWeight.spec.js diff --git a/modules/ticket/back/methods/ticket/specs/setWeight.spec.js b/modules/ticket/back/methods/ticket/specs/setWeight.spec.js new file mode 100644 index 000000000..0d48d4adf --- /dev/null +++ b/modules/ticket/back/methods/ticket/specs/setWeight.spec.js @@ -0,0 +1,82 @@ +const {models} = require('vn-loopback/server/server'); + +fdescribe('ticket setWeight()', () => { + const ctx = beforeAll.getCtx(); + beforeAll.mockLoopBackContext(); + let opts; + let tx; + const administrativeId = 5; + + beforeEach(async() => { + opts = {transaction: tx}; + tx = await models.Ticket.beginTransaction({}); + opts.transaction = tx; + }); + + afterEach(async() => await tx.rollback()); + + xit('should throw an error if the weight is already set', async() => { + try { + const ticketId = 1; + const weight = 10; + + await models.Ticket.setWeight(ctx, ticketId, weight, opts); + } catch (e) { + expect(e.message).toEqual('Weight already set'); + } + }); + + xit('should set the weight of a ticket', async() => { + const ticketId = 31; + const weight = 15; + + await models.Ticket.setWeight(ctx, ticketId, weight, opts); + + const ticket = await models.Ticket.findById(ticketId, null, opts); + + expect(ticket.weight).toEqual(weight); + }); + + it('should throw an error if the user does not have enough privileges', async() => { + ctx.req.accessToken.userId = administrativeId; + try { + const ticketId = 10; + const weight = 20; + + await models.Ticket.setWeight(ctx, ticketId, weight, opts); + } catch (e) { + expect(e.message).toEqual('You don\'t have enough privilegs'); + } + }); + + // it('should commit the transaction and return invoice ids if the ticket is invoiceable', async() => { + // const tx = await models.Ticket.beginTransaction({}); + + // try { + // const opts = {transaction: tx}; + + // const ticketId = 4; + // const weight = 25; + + // // Mock the necessary methods and data + // jest.spyOn(models.ACL, 'checkAccessAcl').mockResolvedValue(true); + // jest.spyOn(models.Client, 'findById').mockResolvedValue({ + // hasDailyInvoice: true, + // salesPersonUser: () => ({id: 1}) + // }); + // jest.spyOn(models.State, 'findOne').mockResolvedValue({alertLevel: 2}); + // jest.spyOn(models.TicketState, 'findOne').mockResolvedValue({alertLevel: 3}); + // jest.spyOn(models.Ticket, 'rawSql').mockResolvedValue([{taxArea: 'WORLD'}]); + // jest.spyOn(models.Ticket, 'invoiceTicketsAndPdf').mockResolvedValue([1001]); + + // const invoiceIds = await models.Ticket.setWeight(ctx, ticketId, weight, opts); + + // expect(invoiceIds).toEqual([1001]); + + // await tx.rollback(); + // } catch (e) { + // await tx.rollback(); + // throw e; + // } + // }); +}); From e3015a655917c69cfcfff66c11356db7141fe1bd Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 4 Sep 2024 14:52:53 +0200 Subject: [PATCH 18/62] feat: refs #7524 no apply limit --- loopback/common/models/vn-model.js | 10 +++++++--- modules/item/back/methods/item/getBalance.js | 6 +++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index a11bed11d..269ed673d 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -28,19 +28,19 @@ module.exports = function(Self) { }); this.beforeRemote('**', async ctx => { - if (!this.hasFilter(ctx)) return; + if (this.hasNoLimit(ctx) || !this.hasFilter(ctx)) return; const defaultLimit = this.app.orm.selectLimit; const filter = ctx.args.filter || {limit: defaultLimit}; - if (filter.limit > defaultLimit) { + if (!filter.limit || filter.limit > defaultLimit) { filter.limit = defaultLimit; ctx.args.filter = filter; } }); this.afterRemote('**', async ctx => { - if (!this.hasFilter(ctx)) return; + if (this.hasNoLimit(ctx) || !this.hasFilter(ctx)) return; const {result} = ctx; const length = Array.isArray(result) ? result.length : result ? 1 : 0; @@ -351,6 +351,10 @@ module.exports = function(Self) { hasFilter(ctx) { return ctx.req.method.toUpperCase() === 'GET' && ctx.method.accepts.some(x => x.arg === 'filter' && x.type.toLowerCase() === 'object'); + }, + + hasNoLimit(ctx) { + return ctx.method.accepts.some(x => x.arg.toLowerCase() === 'nolimit') && ctx.args.noLimit; } }); diff --git a/modules/item/back/methods/item/getBalance.js b/modules/item/back/methods/item/getBalance.js index 207f8020f..1a4c7999d 100644 --- a/modules/item/back/methods/item/getBalance.js +++ b/modules/item/back/methods/item/getBalance.js @@ -8,6 +8,10 @@ module.exports = Self => { required: true, description: 'Filter defining where and paginated data', http: {source: 'query'} + }, { + arg: 'noLimit', + type: 'Boolean', + required: false, }], returns: { type: ['Object'], @@ -19,7 +23,7 @@ module.exports = Self => { } }); - Self.getBalance = async(ctx, filter, options) => { + Self.getBalance = async(ctx, filter, noLimit, options) => { const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') From d82f9b2cd6e2f946ff37621e4226e4bdf91ac35b Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 4 Sep 2024 14:55:59 +0200 Subject: [PATCH 19/62] chore: refs #7524 fix test --- modules/item/back/methods/item/specs/getBalance.spec.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/item/back/methods/item/specs/getBalance.spec.js b/modules/item/back/methods/item/specs/getBalance.spec.js index 95de3cc50..cef206411 100644 --- a/modules/item/back/methods/item/specs/getBalance.spec.js +++ b/modules/item/back/methods/item/specs/getBalance.spec.js @@ -23,7 +23,7 @@ describe('item getBalance()', () => { date: null } }; - const results = await models.Item.getBalance(ctx, filter, options); + const results = await models.Item.getBalance(ctx, filter, true, options); const result = results.find(element => element.clientType == 'loses'); @@ -57,8 +57,8 @@ describe('item getBalance()', () => { } }; - const firstItemBalance = await models.Item.getBalance(ctx, firstFilter, options); - const secondItemBalance = await models.Item.getBalance(ctx, secondFilter, options); + const firstItemBalance = await models.Item.getBalance(ctx, firstFilter, true, options); + const secondItemBalance = await models.Item.getBalance(ctx, secondFilter, true, options); expect(firstItemBalance[9].claimFk).toEqual(null); expect(secondItemBalance[7].claimFk).toEqual(1); From 998d3865a357be22c63c3c9759c65fc45133048e Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 5 Sep 2024 08:56:15 +0200 Subject: [PATCH 20/62] chore: refs #7663 fix test --- .../methods/ticket/specs/setWeight.spec.js | 52 +++++++------------ 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/modules/ticket/back/methods/ticket/specs/setWeight.spec.js b/modules/ticket/back/methods/ticket/specs/setWeight.spec.js index 0d48d4adf..c26ae7aaf 100644 --- a/modules/ticket/back/methods/ticket/specs/setWeight.spec.js +++ b/modules/ticket/back/methods/ticket/specs/setWeight.spec.js @@ -1,21 +1,23 @@ const {models} = require('vn-loopback/server/server'); -fdescribe('ticket setWeight()', () => { +describe('ticket setWeight()', () => { const ctx = beforeAll.getCtx(); beforeAll.mockLoopBackContext(); let opts; let tx; + const employeeId = 1; const administrativeId = 5; beforeEach(async() => { opts = {transaction: tx}; tx = await models.Ticket.beginTransaction({}); opts.transaction = tx; + ctx.req.accessToken.userId = administrativeId; }); afterEach(async() => await tx.rollback()); - xit('should throw an error if the weight is already set', async() => { + it('should throw an error if the weight is already set', async() => { try { const ticketId = 1; const weight = 10; @@ -26,7 +28,7 @@ fdescribe('ticket setWeight()', () => { } }); - xit('should set the weight of a ticket', async() => { + it('should set the weight of a ticket', async() => { const ticketId = 31; const weight = 15; @@ -38,45 +40,31 @@ fdescribe('ticket setWeight()', () => { }); it('should throw an error if the user does not have enough privileges', async() => { - ctx.req.accessToken.userId = administrativeId; + ctx.req.accessToken.userId = employeeId; try { const ticketId = 10; const weight = 20; await models.Ticket.setWeight(ctx, ticketId, weight, opts); } catch (e) { - expect(e.message).toEqual('You don\'t have enough privilegs'); + expect(e.message).toEqual('You don\'t have enough privileges'); } }); - // it('should commit the transaction and return invoice ids if the ticket is invoiceable', async() => { - // const tx = await models.Ticket.beginTransaction({}); + it('should call invoiceTicketsAndPdf if the ticket is invoiceable', async() => { + const ticketId = 10; + const weight = 25; - // try { - // const opts = {transaction: tx}; + spyOn(models.Client, 'findById').and.returnValue({ + hasDailyInvoice: true, + salesPersonUser: () => ({id: 1}) + }); + spyOn(models.TicketState, 'findOne').and.returnValue({alertLevel: 3}); + spyOn(models.Ticket, 'rawSql').and.returnValue([{taxArea: 'WORLD'}]); + spyOn(models.Ticket, 'invoiceTicketsAndPdf').and.returnValue([10]); - // const ticketId = 4; - // const weight = 25; + const invoiceIds = await models.Ticket.setWeight(ctx, ticketId, weight, opts); - // // Mock the necessary methods and data - // jest.spyOn(models.ACL, 'checkAccessAcl').mockResolvedValue(true); - // jest.spyOn(models.Client, 'findById').mockResolvedValue({ - // hasDailyInvoice: true, - // salesPersonUser: () => ({id: 1}) - // }); - // jest.spyOn(models.State, 'findOne').mockResolvedValue({alertLevel: 2}); - // jest.spyOn(models.TicketState, 'findOne').mockResolvedValue({alertLevel: 3}); - // jest.spyOn(models.Ticket, 'rawSql').mockResolvedValue([{taxArea: 'WORLD'}]); - // jest.spyOn(models.Ticket, 'invoiceTicketsAndPdf').mockResolvedValue([1001]); - - // const invoiceIds = await models.Ticket.setWeight(ctx, ticketId, weight, opts); - - // expect(invoiceIds).toEqual([1001]); - - // await tx.rollback(); - // } catch (e) { - // await tx.rollback(); - // throw e; - // } - // }); + expect(invoiceIds.length).toBeGreaterThan(0); + }); }); From 7486c4a3c6d5eefc8046f5997f88d8e0216d7532 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 6 Sep 2024 07:48:53 +0200 Subject: [PATCH 21/62] feat: refs #7562 refs #7532 Requested changes --- db/dump/fixtures.after.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql index b3fcad6af..59730d592 100644 --- a/db/dump/fixtures.after.sql +++ b/db/dump/fixtures.after.sql @@ -7,8 +7,8 @@ SET foreign_key_checks = 0; -- XXX: vn-database -INSERT INTO util.config (id, environment, mockTime, mockUtcTime, mockEnabled, dateRegex, deprecatedMarkRegex, daysKeepDeprecatedObjects) - VALUES (1, 'local', '2001-01-01 12:00:00', '2001-01-01 11:00:00', TRUE, '[0-9]{4}-[0-9]{2}-[0-9]{2}', '__$', 60); +INSERT INTO util.config (id, environment, mockTime, mockUtcTime, mockEnabled) + VALUES (1, 'local', '2001-01-01 12:00:00', '2001-01-01 11:00:00', TRUE); /* #5483 INSERT INTO vn.entryConfig (defaultEntry, mailToNotify, inventorySupplierFk, maxLockTime, defaultSupplierFk) From 4daea90b1b6ecc05b43aa1b4411ebe044db5108e Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 6 Sep 2024 08:25:21 +0200 Subject: [PATCH 22/62] feat: refs #7562 refs #7759 Requested changes --- myt.config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/myt.config.yml b/myt.config.yml index ffa4188b2..683090ecc 100755 --- a/myt.config.yml +++ b/myt.config.yml @@ -2,6 +2,7 @@ code: vn-database versionSchema: util replace: true sumViews: false +defaultDefiner: vn@localhost mockDate: '2001-01-01 12:00:00' subdir: db schemas: From 99ce15863291525340c4c35677776906c033d933 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 6 Sep 2024 11:33:15 +0200 Subject: [PATCH 23/62] chore: refs #7663 return correct type --- modules/ticket/back/methods/ticket/setWeight.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/setWeight.js b/modules/ticket/back/methods/ticket/setWeight.js index d71f2c0e5..47087d384 100644 --- a/modules/ticket/back/methods/ticket/setWeight.js +++ b/modules/ticket/back/methods/ticket/setWeight.js @@ -17,7 +17,7 @@ module.exports = Self => { description: 'The weight value', }], returns: { - type: 'boolean', + type: 'Array', root: true }, http: { From 56eb3e093d8058b5e71eb31d54ba51ee61023709 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 9 Sep 2024 09:39:10 +0200 Subject: [PATCH 24/62] feat: refs #6727 Added indexes in creationDate --- .../11107-pinkAspidistra/00-firstScript.sql | 23 ++----------------- .../11107-pinkAspidistra/01-firstScript.sql | 1 + .../11107-pinkAspidistra/02-firstScript.sql | 1 + .../11107-pinkAspidistra/03-firstScript.sql | 1 + .../11107-pinkAspidistra/04-firstScript.sql | 1 + .../11107-pinkAspidistra/05-firstScript.sql | 1 + .../11107-pinkAspidistra/06-firstScript.sql | 1 + .../11107-pinkAspidistra/07-firstScript.sql | 1 + .../11107-pinkAspidistra/08-firstScript.sql | 1 + .../11107-pinkAspidistra/09-firstScript.sql | 1 + .../11107-pinkAspidistra/10-firstScript.sql | 1 + .../11107-pinkAspidistra/11-firstScript.sql | 1 + .../11107-pinkAspidistra/12-firstScript.sql | 1 + .../11107-pinkAspidistra/13-firstScript.sql | 1 + .../11107-pinkAspidistra/14-firstScript.sql | 1 + .../11107-pinkAspidistra/15-firstScript.sql | 1 + .../11107-pinkAspidistra/16-firstScript.sql | 1 + .../11107-pinkAspidistra/17-firstScript.sql | 1 + .../11107-pinkAspidistra/18-firstScript.sql | 1 + .../11107-pinkAspidistra/19-firstScript.sql | 1 + .../11107-pinkAspidistra/20-firstScript.sql | 1 + .../11107-pinkAspidistra/21-firstScript.sql | 1 + .../11107-pinkAspidistra/22-firstScript.sql | 1 + .../11107-pinkAspidistra/23-firstScript.sql | 1 + .../11107-pinkAspidistra/24-firstScript.sql | 1 + 25 files changed, 26 insertions(+), 21 deletions(-) create mode 100644 db/versions/11107-pinkAspidistra/01-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/02-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/03-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/04-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/05-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/06-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/07-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/08-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/09-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/10-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/11-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/12-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/13-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/14-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/15-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/16-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/17-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/18-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/19-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/20-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/21-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/22-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/23-firstScript.sql create mode 100644 db/versions/11107-pinkAspidistra/24-firstScript.sql diff --git a/db/versions/11107-pinkAspidistra/00-firstScript.sql b/db/versions/11107-pinkAspidistra/00-firstScript.sql index 3ed3df526..62af9c306 100644 --- a/db/versions/11107-pinkAspidistra/00-firstScript.sql +++ b/db/versions/11107-pinkAspidistra/00-firstScript.sql @@ -9,24 +9,5 @@ CREATE OR REPLACE TABLE `util`.`logCleanMultiConfig` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; INSERT INTO `util`.`logCleanMultiConfig` (`schemaName`, `tableName`) - VALUES - ('account', 'roleLog' ), - ('account', 'userLog' ), - ('vn', 'entryLog' ), - ('vn', 'clientLog' ), - ('vn', 'itemLog' ), - ('vn', 'shelvingLog' ), - ('vn', 'workerLog' ), - ('vn', 'deviceProductionLog' ), - ('vn', 'zoneLog' ), - ('vn', 'rateLog' ), - ('vn', 'ticketLog' ), - ('vn', 'agencyLog' ), - ('vn', 'userLog' ), - ('vn', 'routeLog' ), - ('vn', 'claimLog' ), - ('vn', 'supplierLog' ), - ('vn', 'invoiceInLog' ), - ('vn', 'travelLog' ), - ('vn', 'packingSiteDeviceLog' ), - ('vn', 'parkingLog' ); + SELECT TABLE_SCHEMA, TABLE_NAME FROM information_schema.`COLUMNS` + WHERE COLUMN_NAME IN ('newInstance', 'newInstance'); diff --git a/db/versions/11107-pinkAspidistra/01-firstScript.sql b/db/versions/11107-pinkAspidistra/01-firstScript.sql new file mode 100644 index 000000000..426fcc5b8 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/01-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX userLog_creationDate_IDX USING BTREE ON account.userLog (creationDate DESC); diff --git a/db/versions/11107-pinkAspidistra/02-firstScript.sql b/db/versions/11107-pinkAspidistra/02-firstScript.sql new file mode 100644 index 000000000..e916754e3 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/02-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX roleLog_creationDate_IDX USING BTREE ON account.roleLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/03-firstScript.sql b/db/versions/11107-pinkAspidistra/03-firstScript.sql new file mode 100644 index 000000000..f7400c866 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/03-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX ACLLog_creationDate_IDX USING BTREE ON salix.ACLLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/04-firstScript.sql b/db/versions/11107-pinkAspidistra/04-firstScript.sql new file mode 100644 index 000000000..0c118284e --- /dev/null +++ b/db/versions/11107-pinkAspidistra/04-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX supplierLog_creationDate_IDX USING BTREE ON vn.supplierLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/05-firstScript.sql b/db/versions/11107-pinkAspidistra/05-firstScript.sql new file mode 100644 index 000000000..5cb4070bb --- /dev/null +++ b/db/versions/11107-pinkAspidistra/05-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX deviceProductionLog_creationDate_IDX USING BTREE ON vn.deviceProductionLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/06-firstScript.sql b/db/versions/11107-pinkAspidistra/06-firstScript.sql new file mode 100644 index 000000000..332b8a60a --- /dev/null +++ b/db/versions/11107-pinkAspidistra/06-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX routeLog_creationDate_IDX USING BTREE ON vn.routeLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/07-firstScript.sql b/db/versions/11107-pinkAspidistra/07-firstScript.sql new file mode 100644 index 000000000..b80f8b75f --- /dev/null +++ b/db/versions/11107-pinkAspidistra/07-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX itemLog_creationDate_IDX USING BTREE ON vn.itemLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/08-firstScript.sql b/db/versions/11107-pinkAspidistra/08-firstScript.sql new file mode 100644 index 000000000..315f9b256 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/08-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX userLog_creationDate_IDX USING BTREE ON vn.userLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/09-firstScript.sql b/db/versions/11107-pinkAspidistra/09-firstScript.sql new file mode 100644 index 000000000..7bb604915 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/09-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX invoiceInLog_creationDate_IDX USING BTREE ON vn.invoiceInLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/10-firstScript.sql b/db/versions/11107-pinkAspidistra/10-firstScript.sql new file mode 100644 index 000000000..06e186e0e --- /dev/null +++ b/db/versions/11107-pinkAspidistra/10-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX zoneLog_creationDate_IDX USING BTREE ON vn.zoneLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/11-firstScript.sql b/db/versions/11107-pinkAspidistra/11-firstScript.sql new file mode 100644 index 000000000..be539e7b0 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/11-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX clientLog_creationDate_IDX USING BTREE ON vn.clientLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/12-firstScript.sql b/db/versions/11107-pinkAspidistra/12-firstScript.sql new file mode 100644 index 000000000..4abc284b6 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/12-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX workerLog_creationDate_IDX USING BTREE ON vn.workerLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/13-firstScript.sql b/db/versions/11107-pinkAspidistra/13-firstScript.sql new file mode 100644 index 000000000..cc901e13c --- /dev/null +++ b/db/versions/11107-pinkAspidistra/13-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX ticketLog_creationDate_IDX USING BTREE ON vn.ticketLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/14-firstScript.sql b/db/versions/11107-pinkAspidistra/14-firstScript.sql new file mode 100644 index 000000000..02d2a37b0 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/14-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX rateLog_creationDate_IDX USING BTREE ON vn.rateLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/15-firstScript.sql b/db/versions/11107-pinkAspidistra/15-firstScript.sql new file mode 100644 index 000000000..ad75ff6d0 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/15-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX claimLog_creationDate_IDX USING BTREE ON vn.claimLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/16-firstScript.sql b/db/versions/11107-pinkAspidistra/16-firstScript.sql new file mode 100644 index 000000000..50c7b61a8 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/16-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX saleGroupLog_creationDate_IDX USING BTREE ON vn.saleGroupLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/17-firstScript.sql b/db/versions/11107-pinkAspidistra/17-firstScript.sql new file mode 100644 index 000000000..3de084bcf --- /dev/null +++ b/db/versions/11107-pinkAspidistra/17-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX packingSiteDeviceLog_creationDate_IDX USING BTREE ON vn.packingSiteDeviceLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/18-firstScript.sql b/db/versions/11107-pinkAspidistra/18-firstScript.sql new file mode 100644 index 000000000..1181f8263 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/18-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX travelLog_creationDate_IDX USING BTREE ON vn.travelLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/19-firstScript.sql b/db/versions/11107-pinkAspidistra/19-firstScript.sql new file mode 100644 index 000000000..e95f93031 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/19-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX shelvingLog_creationDate_IDX USING BTREE ON vn.shelvingLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/20-firstScript.sql b/db/versions/11107-pinkAspidistra/20-firstScript.sql new file mode 100644 index 000000000..d3598466d --- /dev/null +++ b/db/versions/11107-pinkAspidistra/20-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX productionConfigLog_creationDate_IDX USING BTREE ON vn.productionConfigLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/21-firstScript.sql b/db/versions/11107-pinkAspidistra/21-firstScript.sql new file mode 100644 index 000000000..5db8d3c63 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/21-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX entryLog_creationDate_IDX USING BTREE ON vn.entryLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/22-firstScript.sql b/db/versions/11107-pinkAspidistra/22-firstScript.sql new file mode 100644 index 000000000..91e68c43b --- /dev/null +++ b/db/versions/11107-pinkAspidistra/22-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX agencyLog_creationDate_IDX USING BTREE ON vn.agencyLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/23-firstScript.sql b/db/versions/11107-pinkAspidistra/23-firstScript.sql new file mode 100644 index 000000000..edd79473e --- /dev/null +++ b/db/versions/11107-pinkAspidistra/23-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX parkingLog_creationDate_IDX USING BTREE ON vn.parkingLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/24-firstScript.sql b/db/versions/11107-pinkAspidistra/24-firstScript.sql new file mode 100644 index 000000000..81e84c405 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/24-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX bufferLog_creationDate_IDX USING BTREE ON srt.bufferLog (creationDate DESC); \ No newline at end of file From 261bebbc3bad07ed317bccbf457d80764efe61d3 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 9 Sep 2024 09:41:40 +0200 Subject: [PATCH 25/62] feat: refs #6727 Deleted duplicated indexes --- db/versions/11107-pinkAspidistra/13-firstScript.sql | 1 - .../00-firstScript.sql} | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 db/versions/11107-pinkAspidistra/13-firstScript.sql rename db/versions/{11107-pinkAspidistra/16-firstScript.sql => 11219-goldenCataractarum/00-firstScript.sql} (67%) diff --git a/db/versions/11107-pinkAspidistra/13-firstScript.sql b/db/versions/11107-pinkAspidistra/13-firstScript.sql deleted file mode 100644 index cc901e13c..000000000 --- a/db/versions/11107-pinkAspidistra/13-firstScript.sql +++ /dev/null @@ -1 +0,0 @@ -CREATE INDEX ticketLog_creationDate_IDX USING BTREE ON vn.ticketLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/16-firstScript.sql b/db/versions/11219-goldenCataractarum/00-firstScript.sql similarity index 67% rename from db/versions/11107-pinkAspidistra/16-firstScript.sql rename to db/versions/11219-goldenCataractarum/00-firstScript.sql index 50c7b61a8..4c4b9eac5 100644 --- a/db/versions/11107-pinkAspidistra/16-firstScript.sql +++ b/db/versions/11219-goldenCataractarum/00-firstScript.sql @@ -1 +1 @@ -CREATE INDEX saleGroupLog_creationDate_IDX USING BTREE ON vn.saleGroupLog (creationDate DESC); \ No newline at end of file +CREATE INDEX saleGroupLog_creationDate_IDX USING BTREE ON vn.saleGroupLog (creationDate DESC); From 31b04cba75e57d98cb0914acec72249a4017f498 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 9 Sep 2024 12:08:12 +0200 Subject: [PATCH 26/62] feat(salix): refs #6156 #6156 Move to myt version --- .../00-ModifyProc_ticket_canAdvance.sql | 128 ------------- .../vn/procedures/ticket_canAdvance.sql | 181 +++++++++--------- .../11221-chocolateSalal/00-firstScript.sql | 12 ++ 3 files changed, 98 insertions(+), 223 deletions(-) delete mode 100644 db/changes/233601/00-ModifyProc_ticket_canAdvance.sql create mode 100644 db/versions/11221-chocolateSalal/00-firstScript.sql diff --git a/db/changes/233601/00-ModifyProc_ticket_canAdvance.sql b/db/changes/233601/00-ModifyProc_ticket_canAdvance.sql deleted file mode 100644 index b0426711f..000000000 --- a/db/changes/233601/00-ModifyProc_ticket_canAdvance.sql +++ /dev/null @@ -1,128 +0,0 @@ -CREATE TABLE IF NOT EXISTS `vn`.`ticketCanAdvanceConfig` ( - `id` INT auto_increment NULL, - `destinationOrder` INT NULL, - CONSTRAINT `ticketCanAdvanceConfig_PK` PRIMARY KEY (id) -) -ENGINE=InnoDB -DEFAULT CHARSET=utf8mb3 -COLLATE=utf8mb3_unicode_ci; - -INSERT INTO `vn`.`ticketCanAdvanceConfig` - SET `destinationOrder` = 5; - -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT) -BEGIN -/** - * Devuelve los tickets y la cantidad de lineas de venta que se pueden adelantar. - * - * @param vDateFuture Fecha de los tickets que se quieren adelantar. - * @param vDateToAdvance Fecha a cuando se quiere adelantar. - * @param vWarehouseFk Almacén - */ - DECLARE vDateInventory DATE; - - SELECT inventoried INTO vDateInventory FROM config; - - CREATE OR REPLACE TEMPORARY TABLE tStock - (itemFk INT PRIMARY KEY, amount INT) - ENGINE = MEMORY; - - INSERT INTO tStock(itemFk, amount) - SELECT itemFk, SUM(quantity) amount FROM - ( - SELECT itemFk, quantity - FROM itemTicketOut - WHERE shipped >= vDateInventory - AND shipped < vDateFuture - AND warehouseFk = vWarehouseFk - UNION ALL - SELECT itemFk, quantity - FROM itemEntryIn - WHERE landed >= vDateInventory - AND landed < vDateFuture - AND isVirtualStock = FALSE - AND warehouseInFk = vWarehouseFk - UNION ALL - SELECT itemFk, quantity - FROM itemEntryOut - WHERE shipped >= vDateInventory - AND shipped < vDateFuture - AND warehouseOutFk = vWarehouseFk - ) t - GROUP BY itemFk HAVING amount != 0; - - CREATE OR REPLACE TEMPORARY TABLE tmp.filter - (INDEX (id)) - SELECT dest.*, - origin.* - FROM ( - SELECT s.ticketFk futureId, - t.workerFk, - t.shipped futureShipped, - t.totalWithVat futureTotalWithVat, - st.name futureState, - t.addressFk futureAddressFk, - am.name futureAgency, - count(s.id) futureLines, - GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) futureIpt, - CAST(SUM(litros) AS DECIMAL(10,0)) futureLiters, - SUM((s.quantity <= IFNULL(tst.amount,0))) hasStock, - st.classColor futureClassColor, - ( - count(s.id) - - SUM((s.quantity <= IFNULL(tst.amount,0))) - ) notMovableLines, - ( - count(s.id) = - SUM((s.quantity <= IFNULL(tst.amount,0))) - ) isFullMovable - FROM ticket t - JOIN sale s ON s.ticketFk = t.id - JOIN saleVolume sv ON sv.saleFk = s.id - JOIN item i ON i.id = s.itemFk - JOIN ticketState ts ON ts.ticketFk = t.id - JOIN `state` st ON st.id = ts.stateFk - JOIN agencyMode am ON t.agencyModeFk = am.id - LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk - LEFT JOIN tStock tst ON tst.itemFk = i.id - WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture) - AND t.warehouseFk = vWarehouseFk - GROUP BY t.id - ) origin - JOIN ( - SELECT t.id, - t.addressFk, - st.name state, - GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt, - t.shipped, - t.totalWithVat, - am.name agency, - CAST(SUM(litros) AS DECIMAL(10,0)) liters, - CAST(COUNT(*) AS DECIMAL(10,0)) `lines`, - st.classColor, - IF(HOUR(t.shipped), - HOUR(t.shipped), - COALESCE(HOUR(zc.hour),HOUR(z.hour)) - ) preparation - FROM ticket t - JOIN sale s ON s.ticketFk = t.id - JOIN saleVolume sv ON sv.saleFk = s.id - JOIN item i ON i.id = s.itemFk - JOIN ticketState ts ON ts.ticketFk = t.id - JOIN `state` st ON st.id = ts.stateFk - JOIN agencyMode am ON t.agencyModeFk = am.id - JOIN ticketCanAdvanceConfig - LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk - LEFT JOIN `zone` z ON z.id = t.zoneFk - LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk - WHERE t.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance) - AND t.warehouseFk = vWarehouseFk - AND st.order <= destinationOrder - GROUP BY t.id - ) dest ON dest.addressFk = origin.futureAddressFk - WHERE origin.hasStock != 0; - - DROP TEMPORARY TABLE tStock; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_canAdvance.sql b/db/routines/vn/procedures/ticket_canAdvance.sql index 44149126a..58b09e404 100644 --- a/db/routines/vn/procedures/ticket_canAdvance.sql +++ b/db/routines/vn/procedures/ticket_canAdvance.sql @@ -1,5 +1,7 @@ + + DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT) BEGIN /** * Devuelve los tickets y la cantidad de lineas de venta que se pueden adelantar. @@ -8,91 +10,79 @@ BEGIN * @param vDateToAdvance Fecha a cuando se quiere adelantar. * @param vWarehouseFk Almacén */ + DECLARE vDateInventory DATE; - CALL item_getStock(vWarehouseFk, vDateToAdvance, NULL); - CALL item_getMinacum( - vWarehouseFk, - vDateToAdvance, - DATEDIFF(DATE_SUB(vDateFuture, INTERVAL 1 DAY), vDateToAdvance), - NULL - ); + SELECT inventoried INTO vDateInventory FROM config; + + CREATE OR REPLACE TEMPORARY TABLE tStock + (itemFk INT PRIMARY KEY, amount INT) + ENGINE = MEMORY; + + INSERT INTO tStock(itemFk, amount) + SELECT itemFk, SUM(quantity) amount FROM + ( + SELECT itemFk, quantity + FROM itemTicketOut + WHERE shipped >= vDateInventory + AND shipped < vDateFuture + AND warehouseFk = vWarehouseFk + UNION ALL + SELECT itemFk, quantity + FROM itemEntryIn + WHERE landed >= vDateInventory + AND landed < vDateFuture + AND isVirtualStock = FALSE + AND warehouseInFk = vWarehouseFk + UNION ALL + SELECT itemFk, quantity + FROM itemEntryOut + WHERE shipped >= vDateInventory + AND shipped < vDateFuture + AND warehouseOutFk = vWarehouseFk + ) t + GROUP BY itemFk HAVING amount != 0; CREATE OR REPLACE TEMPORARY TABLE tmp.filter (INDEX (id)) - SELECT - origin.ticketFk futureId, - dest.ticketFk id, - dest.state, - origin.futureState, - origin.futureIpt, - dest.ipt, - origin.workerFk, - origin.futureLiters, - origin.futureLines, - dest.shipped, - origin.shipped futureShipped, - dest.totalWithVat, - origin.totalWithVat futureTotalWithVat, - dest.agency, - dest.agencyModeFk, - origin.futureAgency, - origin.agencyModeFk futureAgencyModeFk, - dest.lines, - dest.liters, - origin.futureLines - origin.hasStock AS notMovableLines, - (origin.futureLines = origin.hasStock) AS isFullMovable, - dest.zoneFk, - origin.futureZoneFk, - origin.futureZoneName, - origin.classColor futureClassColor, - dest.classColor, - origin.clientFk futureClientFk, - origin.addressFk futureAddressFk, - origin.warehouseFk futureWarehouseFk, - origin.companyFk futureCompanyFk, - IFNULL(dest.nickname, origin.nickname) nickname, - dest.landed + SELECT dest.*, + origin.* FROM ( - SELECT - s.ticketFk, - c.salesPersonFk workerFk, - t.shipped, - t.totalWithVat, - st.name futureState, - am.name futureAgency, - count(s.id) futureLines, - GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) futureIpt, - CAST(SUM(litros) AS DECIMAL(10,0)) futureLiters, - SUM(s.quantity <= (IFNULL(il.stock,0) + IFNULL(im.amount, 0))) hasStock, - z.id futureZoneFk, - z.name futureZoneName, - st.classColor, - t.clientFk, - t.nickname, + SELECT s.ticketFk futureId, + t.workerFk, + t.shipped futureShipped, + t.totalWithVat futureTotalWithVat, + st.name futureState, + t.addressFk futureAddressFk, + am.name futureAgency, + count(s.id) futureLines, + GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) futureIpt, + CAST(SUM(litros) AS DECIMAL(10,0)) futureLiters, + SUM((s.quantity <= IFNULL(tst.amount,0))) hasStock, + st.classColor futureClassColor, + ( + count(s.id) - + SUM((s.quantity <= IFNULL(tst.amount,0))) + ) notMovableLines, + ( + count(s.id) = + SUM((s.quantity <= IFNULL(tst.amount,0))) + ) isFullMovable + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN saleVolume sv ON sv.saleFk = s.id + JOIN item i ON i.id = s.itemFk + JOIN ticketState ts ON ts.ticketFk = t.id + JOIN `state` st ON st.id = ts.stateFk + JOIN agencyMode am ON t.agencyModeFk = am.id + LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk + LEFT JOIN tStock tst ON tst.itemFk = i.id + WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture) + AND t.warehouseFk = vWarehouseFk + GROUP BY t.id + ) origin + JOIN ( + SELECT t.id, t.addressFk, - t.warehouseFk, - t.companyFk, - t.agencyModeFk - FROM ticket t - JOIN client c ON c.id = t.clientFk - JOIN sale s ON s.ticketFk = t.id - JOIN saleVolume sv ON sv.saleFk = s.id - JOIN item i ON i.id = s.itemFk - JOIN ticketState ts ON ts.ticketFk = t.id - JOIN state st ON st.id = ts.stateFk - JOIN agencyMode am ON t.agencyModeFk = am.id - JOIN zone z ON t.zoneFk = z.id - LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk - LEFT JOIN tmp.itemMinacum im ON im.itemFk = i.id - AND im.warehouseFk = vWarehouseFk - LEFT JOIN tmp.itemList il ON il.itemFk = i.id - WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture) - AND t.warehouseFk = vWarehouseFk - GROUP BY t.id - ) origin - LEFT JOIN ( - SELECT - t.id ticketFk, st.name state, GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt, t.shipped, @@ -101,31 +91,32 @@ BEGIN CAST(SUM(litros) AS DECIMAL(10,0)) liters, CAST(COUNT(*) AS DECIMAL(10,0)) `lines`, st.classColor, - t.clientFk, - t.nickname, - t.addressFk, - t.zoneFk, - t.warehouseFk, - t.companyFk, - t.landed, - t.agencyModeFk + CONCAT_WS(':', + IF(HOUR(t.shipped), + HOUR(t.shipped), + COALESCE(HOUR(zc.hour),HOUR(z.hour))), + IF(MINUTE(t.shipped), + MINUTE(t.shipped), + COALESCE(MINUTE(zc.hour),MINUTE(z.hour))) + ) preparation FROM ticket t JOIN sale s ON s.ticketFk = t.id JOIN saleVolume sv ON sv.saleFk = s.id JOIN item i ON i.id = s.itemFk JOIN ticketState ts ON ts.ticketFk = t.id - JOIN state st ON st.id = ts.stateFk + JOIN `state` st ON st.id = ts.stateFk JOIN agencyMode am ON t.agencyModeFk = am.id + JOIN ticketCanAdvanceConfig LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk + LEFT JOIN `zone` z ON z.id = t.zoneFk + LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk WHERE t.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance) AND t.warehouseFk = vWarehouseFk - AND st.order <= 5 + AND st.order <= destinationOrder GROUP BY t.id - ) dest ON dest.addressFk = origin.addressFk - WHERE origin.hasStock; + ) dest ON dest.addressFk = origin.futureAddressFk + WHERE origin.hasStock != 0; - DROP TEMPORARY TABLE IF EXISTS - tmp.itemList, - tmp.itemMinacum; + DROP TEMPORARY TABLE tStock; END$$ DELIMITER ; diff --git a/db/versions/11221-chocolateSalal/00-firstScript.sql b/db/versions/11221-chocolateSalal/00-firstScript.sql new file mode 100644 index 000000000..8dba40cb3 --- /dev/null +++ b/db/versions/11221-chocolateSalal/00-firstScript.sql @@ -0,0 +1,12 @@ +-- Place your SQL code here +CREATE TABLE IF NOT EXISTS `vn`.`ticketCanAdvanceConfig` ( + `id` INT auto_increment NULL, + `destinationOrder` INT NULL, + CONSTRAINT `ticketCanAdvanceConfig_PK` PRIMARY KEY (id) +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8mb3 +COLLATE=utf8mb3_unicode_ci; + +INSERT INTO `vn`.`ticketCanAdvanceConfig` + SET `destinationOrder` = 5; From f15b33778cd337fd850732697aae9fd14482ec32 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 9 Sep 2024 14:21:42 +0200 Subject: [PATCH 27/62] feat(salix): refs #5938 #5938 replace variables --- e2e/helpers/selectors.js | 2 +- e2e/paths/05-ticket/21_future.spec.js | 4 +- .../back/methods/ticket/getTicketsFuture.js | 12 ++--- .../ticket/specs/getTicketsFuture.spec.js | 48 +++++++++---------- .../front/future-search-panel/index.html | 8 ++-- modules/ticket/front/future/index.js | 4 +- 6 files changed, 39 insertions(+), 39 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 097c6e1ab..cfc641a5d 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -688,7 +688,7 @@ export default { searchResult: 'vn-ticket-future tbody tr', openAdvancedSearchButton: 'vn-searchbar .append vn-icon[icon="arrow_drop_down"]', originDated: 'vn-date-picker[label="Origin date"]', - futureDated: 'vn-date-picker[label="Destination date"]', + futureScopeDays: 'vn-date-picker[label="Destination date"]', linesMax: 'vn-textfield[label="Max Lines"]', litersMax: 'vn-textfield[label="Max Liters"]', ipt: 'vn-autocomplete[label="Origin IPT"]', diff --git a/e2e/paths/05-ticket/21_future.spec.js b/e2e/paths/05-ticket/21_future.spec.js index 7b7d478f7..294d79cda 100644 --- a/e2e/paths/05-ticket/21_future.spec.js +++ b/e2e/paths/05-ticket/21_future.spec.js @@ -30,11 +30,11 @@ describe('Ticket Future path', () => { expect(message.text).toContain('warehouseFk is a required argument'); await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.clearInput(selectors.ticketFuture.futureDated); + await page.clearInput(selectors.ticketFuture.futureScopeDays); await page.waitToClick(selectors.ticketFuture.submit); message = await page.waitForSnackbar(); - expect(message.text).toContain('futureDated is a required argument'); + expect(message.text).toContain('futureScopeDays is a required argument'); await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); await page.clearInput(selectors.ticketFuture.originDated); diff --git a/modules/ticket/back/methods/ticket/getTicketsFuture.js b/modules/ticket/back/methods/ticket/getTicketsFuture.js index abd269e5e..247924591 100644 --- a/modules/ticket/back/methods/ticket/getTicketsFuture.js +++ b/modules/ticket/back/methods/ticket/getTicketsFuture.js @@ -9,13 +9,13 @@ module.exports = Self => { accessType: 'READ', accepts: [ { - arg: 'originDated', + arg: 'originScopeDays', type: 'date', description: 'The date in question', required: true }, { - arg: 'futureDated', + arg: 'futureScopeDays', type: 'date', description: 'The date to probe', required: true @@ -129,9 +129,9 @@ module.exports = Self => { ] }; case 'state': - return {'f.stateCode': {like: `%${value}%`}}; + return {'f.alertLevel': value}; case 'futureState': - return {'f.futureStateCode': {like: `%${value}%`}}; + return {'f.futureAlertLevel': value}; } }); @@ -141,7 +141,7 @@ module.exports = Self => { stmt = new ParameterizedSQL( `CALL vn.ticket_canbePostponed(?,?,?)`, - [args.originDated, args.futureDated, args.warehouseFk]); + [args.originScopeDays, args.futureScopeDays, args.warehouseFk]); stmts.push(stmt); @@ -170,7 +170,7 @@ module.exports = Self => { LEFT JOIN tmp.ticket_problems tp ON tp.ticketFk = f.id `); - if (args.problems != undefined && (!args.originDated && !args.futureDated)) + if (args.problems != undefined && (!args.originScopeDays && !args.futureScopeDays)) throw new UserError('Choose a date range or days forward'); let condition; diff --git a/modules/ticket/back/methods/ticket/specs/getTicketsFuture.spec.js b/modules/ticket/back/methods/ticket/specs/getTicketsFuture.spec.js index 4b28f34ea..e1e9a0ed2 100644 --- a/modules/ticket/back/methods/ticket/specs/getTicketsFuture.spec.js +++ b/modules/ticket/back/methods/ticket/specs/getTicketsFuture.spec.js @@ -12,8 +12,8 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, }; @@ -35,8 +35,8 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, problems: true }; @@ -60,8 +60,8 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, problems: false }; @@ -85,8 +85,8 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, problems: null }; @@ -110,8 +110,8 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, state: 'OK' }; @@ -135,8 +135,8 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, futureState: 'OK' }; @@ -160,8 +160,8 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, ipt: null }; @@ -185,8 +185,8 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, ipt: 'H' }; @@ -210,8 +210,8 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, futureIpt: null }; @@ -235,8 +235,8 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, futureIpt: 'H' }; @@ -260,8 +260,8 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, id: 13 }; @@ -285,8 +285,8 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, futureId: 12 }; diff --git a/modules/ticket/front/future-search-panel/index.html b/modules/ticket/front/future-search-panel/index.html index d873fbc37..d74a0f2a0 100644 --- a/modules/ticket/front/future-search-panel/index.html +++ b/modules/ticket/front/future-search-panel/index.html @@ -1,7 +1,7 @@
@@ -9,13 +9,13 @@ diff --git a/modules/ticket/front/future/index.js b/modules/ticket/front/future/index.js index f18dfa17e..a7d579681 100644 --- a/modules/ticket/front/future/index.js +++ b/modules/ticket/front/future/index.js @@ -65,8 +65,8 @@ export default class Controller extends Section { this.$http.get(`UserConfigs/getUserConfig`) .then(res => { this.filterParams = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: res.data.warehouseFk }; this.$.model.applyFilter(null, this.filterParams); From 89c2d2705c7dfed5be92f4f5409e3873f07b7e27 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 9 Sep 2024 14:21:59 +0200 Subject: [PATCH 28/62] feat(salix): refs #5938 #5938 change value-field --- modules/ticket/front/future-search-panel/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ticket/front/future-search-panel/index.html b/modules/ticket/front/future-search-panel/index.html index d74a0f2a0..bcf6e5fe3 100644 --- a/modules/ticket/front/future-search-panel/index.html +++ b/modules/ticket/front/future-search-panel/index.html @@ -59,7 +59,7 @@ @@ -69,7 +69,7 @@ From bf1a43a23ec43d1a129e2b02ef03f301cd1ecd71 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 9 Sep 2024 14:43:16 +0200 Subject: [PATCH 29/62] refactor: refs #7900 Deleted sectorProdPriority column --- db/routines/vn/procedures/productionSectorList.sql | 1 - db/routines/vn/views/itemShelvingAvailable.sql | 1 - db/routines/vn2008/views/state.sql | 1 - db/versions/11222-azureCordyline/00-firstScript.sql | 1 + 4 files changed, 1 insertion(+), 3 deletions(-) create mode 100644 db/versions/11222-azureCordyline/00-firstScript.sql diff --git a/db/routines/vn/procedures/productionSectorList.sql b/db/routines/vn/procedures/productionSectorList.sql index f61ec7ec9..ed6eff147 100644 --- a/db/routines/vn/procedures/productionSectorList.sql +++ b/db/routines/vn/procedures/productionSectorList.sql @@ -55,7 +55,6 @@ BEGIN i.itemPackingTypeFk, isa.`size`, isa.Estado, - isa.sectorProdPriority, isa.available, isa.sectorFk, isa.matricula, diff --git a/db/routines/vn/views/itemShelvingAvailable.sql b/db/routines/vn/views/itemShelvingAvailable.sql index 561569285..15083e6cc 100644 --- a/db/routines/vn/views/itemShelvingAvailable.sql +++ b/db/routines/vn/views/itemShelvingAvailable.sql @@ -10,7 +10,6 @@ AS SELECT `s`.`id` AS `saleFk`, `s`.`concept` AS `concept`, `i`.`size` AS `size`, `st`.`name` AS `Estado`, - `st`.`sectorProdPriority` AS `sectorProdPriority`, `stock`.`visible` AS `available`, `stock`.`sectorFk` AS `sectorFk`, `stock`.`shelvingFk` AS `matricula`, diff --git a/db/routines/vn2008/views/state.sql b/db/routines/vn2008/views/state.sql index 63f6589af..9f7fcccd8 100644 --- a/db/routines/vn2008/views/state.sql +++ b/db/routines/vn2008/views/state.sql @@ -6,7 +6,6 @@ AS SELECT `s`.`id` AS `id`, `s`.`order` AS `order`, `s`.`alertLevel` AS `alert_level`, `s`.`code` AS `code`, - `s`.`sectorProdPriority` AS `sectorProdPriority`, `s`.`nextStateFk` AS `nextStateFk`, `s`.`isPreviousPreparable` AS `isPreviousPreparable`, `s`.`isPicked` AS `isPicked` diff --git a/db/versions/11222-azureCordyline/00-firstScript.sql b/db/versions/11222-azureCordyline/00-firstScript.sql new file mode 100644 index 000000000..c63228911 --- /dev/null +++ b/db/versions/11222-azureCordyline/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.state DROP COLUMN sectorProdPriority; From a5f6fe95ea5b874504142ce4cb9d48b278f1ec80 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 9 Sep 2024 14:58:02 +0200 Subject: [PATCH 30/62] feat(salix): refs #5938 #5938 add futureAlertLevel --- db/routines/vn/procedures/ticket_canbePostponed.sql | 2 ++ e2e/helpers/selectors.js | 2 +- e2e/paths/05-ticket/21_future.spec.js | 8 ++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/procedures/ticket_canbePostponed.sql b/db/routines/vn/procedures/ticket_canbePostponed.sql index 871cafddc..1f3c43057 100644 --- a/db/routines/vn/procedures/ticket_canbePostponed.sql +++ b/db/routines/vn/procedures/ticket_canbePostponed.sql @@ -21,6 +21,7 @@ BEGIN t.clientFk, t.warehouseFk, ts.alertLevel, + sub2.alertLevel futureAlertLevel, t.shipped, t.totalWithVat, sub2.shipped futureShipped, @@ -47,6 +48,7 @@ BEGIN t.addressFk, t.id, t.shipped, + ts.alertLevel, st.name state, st.code, st.classColor, diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index cfc641a5d..0a3892c86 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -687,7 +687,7 @@ export default { ticketFuture: { searchResult: 'vn-ticket-future tbody tr', openAdvancedSearchButton: 'vn-searchbar .append vn-icon[icon="arrow_drop_down"]', - originDated: 'vn-date-picker[label="Origin date"]', + originScopeDays: 'vn-date-picker[label="Origin date"]', futureScopeDays: 'vn-date-picker[label="Destination date"]', linesMax: 'vn-textfield[label="Max Lines"]', litersMax: 'vn-textfield[label="Max Liters"]', diff --git a/e2e/paths/05-ticket/21_future.spec.js b/e2e/paths/05-ticket/21_future.spec.js index 294d79cda..60bb9c38d 100644 --- a/e2e/paths/05-ticket/21_future.spec.js +++ b/e2e/paths/05-ticket/21_future.spec.js @@ -37,11 +37,11 @@ describe('Ticket Future path', () => { expect(message.text).toContain('futureScopeDays is a required argument'); await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.clearInput(selectors.ticketFuture.originDated); + await page.clearInput(selectors.ticketFuture.originScopeDays); await page.waitToClick(selectors.ticketFuture.submit); message = await page.waitForSnackbar(); - expect(message.text).toContain('originDated is a required argument'); + expect(message.text).toContain('originScopeDays is a required argument'); await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); await page.waitToClick(selectors.ticketFuture.submit); @@ -71,7 +71,7 @@ describe('Ticket Future path', () => { await page.autocompleteSearch(selectors.ticketFuture.state, 'Free'); await page.waitToClick(selectors.ticketFuture.submit); - expect(httpRequest).toContain('state=FREE'); + expect(httpRequest).toContain('state=0'); await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); @@ -80,7 +80,7 @@ describe('Ticket Future path', () => { await page.autocompleteSearch(selectors.ticketFuture.futureState, 'Free'); await page.waitToClick(selectors.ticketFuture.submit); - expect(httpRequest).toContain('futureState=FREE'); + expect(httpRequest).toContain('futureState=0'); await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); await page.clearInput(selectors.ticketFuture.state); From 1aa888b1a30f20adac3372a9428281710be8d113 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 9 Sep 2024 15:11:09 +0200 Subject: [PATCH 31/62] feat(WorkerDms_filter): refs #7182 split code. fix: filter --- .../back/methods/worker-dms/docuwareFilter.js | 74 +++++++++++++++ .../worker/back/methods/worker-dms/filter.js | 90 ++++++------------- 2 files changed, 99 insertions(+), 65 deletions(-) create mode 100644 modules/worker/back/methods/worker-dms/docuwareFilter.js diff --git a/modules/worker/back/methods/worker-dms/docuwareFilter.js b/modules/worker/back/methods/worker-dms/docuwareFilter.js new file mode 100644 index 000000000..0311153b0 --- /dev/null +++ b/modules/worker/back/methods/worker-dms/docuwareFilter.js @@ -0,0 +1,74 @@ +module.exports = Self => { + Self.remoteMethodCtx('filter', { + description: 'Find docuware documents', + accessType: 'READ', + accepts: [ + { + arg: 'id', + type: 'number', + description: 'The worker id', + http: {source: 'path'} + } + ], + returns: { + type: ['object'], + root: true + }, + http: { + path: `/:id/filter`, + verb: 'GET' + } + }); + + Self.filter = async(ctx, id) => { + const models = Self.app.models; + + const {dmsTypeFk} = await models.Docuware.findOne({ + fields: ['dmsTypeFk'], + where: {code: 'hr', action: 'find'} + }); + + if (!await models.DmsType.hasReadRole(ctx, dmsTypeFk)) return []; + + let workerDocuware = []; + const worker = await models.Worker.findById(id, {fields: ['fi', 'firstName', 'lastName']}); + const docuwareParse = { + 'Filename': 'dmsFk', + 'Tipo Documento': 'description', + 'Stored on': 'created', + 'Document ID': 'id', + 'URL': 'download', + 'Stored by': 'name', + 'Estado': 'state' + }; + + workerDocuware = + await models.Docuware.getById('hr', worker.lastName + ' ' + worker.firstName, docuwareParse) ?? []; + const url = (await Self.app.models.Url.getUrl('docuware')) + 'WebClient'; + for (document of workerDocuware) { + const docuwareId = document.id; + const defaultData = { + id: docuwareId, + workerFk: id, + dmsFk: docuwareId, + dms: { + id: docuwareId, + file: docuwareId + '.pdf', + isDocuware: true, + hasFile: false, + reference: worker.fi, + dmsFk: docuwareId, + url, + description: document.description + ' - ' + document.state, + download: document.download, + created: document.created, + dmsType: {name: 'Docuware'}, + worker: {id: null, user: {name: document.name}}, + } + }; + Object.assign(document, defaultData); + } + }; + + return workerDocuware; +}; diff --git a/modules/worker/back/methods/worker-dms/filter.js b/modules/worker/back/methods/worker-dms/filter.js index b7802a689..b92ba139b 100644 --- a/modules/worker/back/methods/worker-dms/filter.js +++ b/modules/worker/back/methods/worker-dms/filter.js @@ -8,19 +8,19 @@ module.exports = Self => { accepts: [ { arg: 'id', - type: 'Number', + type: 'number', description: 'The worker id', http: {source: 'path'} }, { arg: 'filter', - type: 'Object', + type: 'object', description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string', http: {source: 'query'} } ], returns: { - type: ['Object'], + type: ['object'], root: true }, http: { @@ -36,6 +36,7 @@ module.exports = Self => { // Get ids alloweds const account = await models.VnUser.findById(userId); + const stmt = new ParameterizedSQL( `SELECT d.id, d.id dmsFk FROM workerDocument wd @@ -44,68 +45,27 @@ module.exports = Self => { LEFT JOIN account.roleRole rr ON rr.inheritsFrom = dt.readRoleFk AND rr.role = ? `, [account.roleFk] ); - const yourOwnDms = {and: [{isReadableByWorker: true}, {worker: userId}]}; - const where = { - or: [yourOwnDms, { - role: { - neq: null - } - }] - }; - stmt.merge(conn.makeSuffix(mergeWhere(filter.where, where))); - - // Get workerDms alloweds - const dmsIds = await conn.executeStmt(stmt); - const allowedIds = dmsIds.map(dms => dms.id); - const allowedFilter = mergeFilters(filter, {where: {dmsFk: {inq: allowedIds}, workerFk: id}}); - let workerDms = await models.WorkerDms.find(allowedFilter); - - // Get docuware info - const docuware = await models.Docuware.findOne({ - fields: ['dmsTypeFk'], - where: {code: 'hr', action: 'find'} - }); - const docuwareDmsType = docuware.dmsTypeFk; - let workerDocuware = []; - if (!filter.skip && (!docuwareDmsType || (docuwareDmsType && await models.DmsType.hasReadRole(ctx, docuwareDmsType)))) { - const worker = await models.Worker.findById(id, {fields: ['fi', 'firstName', 'lastName']}); - const docuwareParse = { - 'Filename': 'dmsFk', - 'Tipo Documento': 'description', - 'Stored on': 'created', - 'Document ID': 'id', - 'URL': 'download', - 'Stored by': 'name', - 'Estado': 'state' - }; - - workerDocuware = - await models.Docuware.getById('hr', worker.lastName + ' ' + worker.firstName, docuwareParse) ?? []; - const url = (await Self.app.models.Url.getUrl('docuware')) + 'WebClient'; - for (document of workerDocuware) { - const docuwareId = document.id; - const defaultData = { - id: docuwareId, - workerFk: id, - dmsFk: docuwareId, - dms: { - id: docuwareId, - file: docuwareId + '.pdf', - isDocuware: true, - hasFile: false, - reference: worker.fi, - dmsFk: docuwareId, - url, - description: document.description + ' - ' + document.state, - download: document.download, - created: document.created, - dmsType: {name: 'Docuware'}, - worker: {id: null, user: {name: document.name}}, + const yourOwnDms = { + or: [ + {and: [ + {isReadableByWorker: true}, + {worker: userId} + ]}, + { + role: { + neq: null } - }; - Object.assign(document, defaultData); - } - } - return workerDms.concat(workerDocuware); + }] + }; + const where = mergeWhere(filter.where, yourOwnDms); + stmt.merge(conn.makeSuffix({where})); + const dmsIds = await conn.executeStmt(stmt); + + const allowedIds = dmsIds.map(dms => dms.id); + const allowedFilter = mergeFilters(filter, {where: {dmsFk: {inq: allowedIds}}}); + + const find = await models.WorkerDms.find(allowedFilter); + + return find; }; }; From 773933ca3c32bec8745457afd9e23fb80d96c0fe Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 9 Sep 2024 15:11:55 +0200 Subject: [PATCH 32/62] feat(salix): refs #6156 #6156 change config sql --- db/versions/11221-chocolateSalal/00-firstScript.sql | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/db/versions/11221-chocolateSalal/00-firstScript.sql b/db/versions/11221-chocolateSalal/00-firstScript.sql index 8dba40cb3..680f0ee0e 100644 --- a/db/versions/11221-chocolateSalal/00-firstScript.sql +++ b/db/versions/11221-chocolateSalal/00-firstScript.sql @@ -1,12 +1,12 @@ -- Place your SQL code here -CREATE TABLE IF NOT EXISTS `vn`.`ticketCanAdvanceConfig` ( - `id` INT auto_increment NULL, - `destinationOrder` INT NULL, - CONSTRAINT `ticketCanAdvanceConfig_PK` PRIMARY KEY (id) +CREATE TABLE IF NOT EXISTS vn.ticketCanAdvanceConfig ( + id INT NOT NULL unsigned PRIMARY KEY, + destinationOrder INT NULL, + CONSTRAINT ticketCanAdvanceConfig_PK PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -INSERT INTO `vn`.`ticketCanAdvanceConfig` - SET `destinationOrder` = 5; +INSERT INTO vn.ticketCanAdvanceConfig + SET destinationOrder = 5; From f70f475223313874abe7e9ea787a4f9e12667db8 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 9 Sep 2024 15:12:44 +0200 Subject: [PATCH 33/62] feat(salix): refs #6156 #6156 change user definer --- db/routines/vn/procedures/ticket_canAdvance.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/ticket_canAdvance.sql b/db/routines/vn/procedures/ticket_canAdvance.sql index 58b09e404..b9e27784d 100644 --- a/db/routines/vn/procedures/ticket_canAdvance.sql +++ b/db/routines/vn/procedures/ticket_canAdvance.sql @@ -1,7 +1,7 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT) BEGIN /** * Devuelve los tickets y la cantidad de lineas de venta que se pueden adelantar. From f9a25617f0eed7ab6e5c6e0a0eba104dd2263e47 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 9 Sep 2024 15:13:08 +0200 Subject: [PATCH 34/62] feat(salix): refs #6156 #6156 add missing values --- db/routines/vn/procedures/ticket_canAdvance.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/ticket_canAdvance.sql b/db/routines/vn/procedures/ticket_canAdvance.sql index b9e27784d..b1f135e5f 100644 --- a/db/routines/vn/procedures/ticket_canAdvance.sql +++ b/db/routines/vn/procedures/ticket_canAdvance.sql @@ -45,7 +45,10 @@ BEGIN CREATE OR REPLACE TEMPORARY TABLE tmp.filter (INDEX (id)) SELECT dest.*, - origin.* + origin.*, + IFNULL(dest.nickname, origin.nickname) nickname, + (origin.futureLines = origin.hasStock) AS isFullMovable, + origin.futureLines - origin.hasStock AS notMovableLines FROM ( SELECT s.ticketFk futureId, t.workerFk, From 615f57b2e6d5fd2951bee7f5cd9822f61af87ee5 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 9 Sep 2024 15:13:32 +0200 Subject: [PATCH 35/62] feat(salix): refs #6156 #6156 simplify CONCAT_WS --- db/routines/vn/procedures/ticket_canAdvance.sql | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/db/routines/vn/procedures/ticket_canAdvance.sql b/db/routines/vn/procedures/ticket_canAdvance.sql index b1f135e5f..5be8d7d7f 100644 --- a/db/routines/vn/procedures/ticket_canAdvance.sql +++ b/db/routines/vn/procedures/ticket_canAdvance.sql @@ -95,13 +95,9 @@ BEGIN CAST(COUNT(*) AS DECIMAL(10,0)) `lines`, st.classColor, CONCAT_WS(':', - IF(HOUR(t.shipped), - HOUR(t.shipped), - COALESCE(HOUR(zc.hour),HOUR(z.hour))), - IF(MINUTE(t.shipped), - MINUTE(t.shipped), - COALESCE(MINUTE(zc.hour),MINUTE(z.hour))) - ) preparation + COALESCE(HOUR(t.shipped), HOUR(zc.hour), HOUR(z.hour)), + COALESCE(MINUTE(t.shipped), MINUTE(zc.hour), MINUTE(z.hour)) + ) preparation FROM ticket t JOIN sale s ON s.ticketFk = t.id JOIN saleVolume sv ON sv.saleFk = s.id From c407dde7a021c3defe5ca8003758dbf163995159 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 9 Sep 2024 15:14:01 +0200 Subject: [PATCH 36/62] feat(salix): refs #6156 #6156 remove redundant condition --- db/routines/vn/procedures/ticket_canAdvance.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/ticket_canAdvance.sql b/db/routines/vn/procedures/ticket_canAdvance.sql index 5be8d7d7f..c5b918def 100644 --- a/db/routines/vn/procedures/ticket_canAdvance.sql +++ b/db/routines/vn/procedures/ticket_canAdvance.sql @@ -114,7 +114,7 @@ BEGIN AND st.order <= destinationOrder GROUP BY t.id ) dest ON dest.addressFk = origin.futureAddressFk - WHERE origin.hasStock != 0; + WHERE origin.hasStock; DROP TEMPORARY TABLE tStock; END$$ From 91abf2eefe7a68473b19fbf16794200fe37a03ea Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 10 Sep 2024 09:50:02 +0200 Subject: [PATCH 37/62] refactor: refs #7663 accurate error --- loopback/locale/es.json | 3 ++- modules/ticket/back/methods/ticket/setWeight.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index e9e9cd212..064ea4a95 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -373,5 +373,6 @@ "Too many records": "Demasiados registros", "Original invoice not found": "Factura original no encontrada", "The entry has no lines or does not exist": "La entrada no tiene lineas o no existe", - "Weight already set": "El peso ya está establecido" + "Weight already set": "El peso ya está establecido", + "This ticket is not allocated to your department": "Este ticket no está asignado a tu departamento" } \ No newline at end of file diff --git a/modules/ticket/back/methods/ticket/setWeight.js b/modules/ticket/back/methods/ticket/setWeight.js index 47087d384..b3b505832 100644 --- a/modules/ticket/back/methods/ticket/setWeight.js +++ b/modules/ticket/back/methods/ticket/setWeight.js @@ -59,7 +59,7 @@ module.exports = Self => { workerDepartments.length == 2 && workerDepartments[0].departmentFk != workerDepartments[1].departmentFk ) - throw new UserError('You don\'t have enough privileges'); + throw new UserError('This ticket is not allocated to your department'); } await ticket.updateAttribute('weight', weight, myOptions); From 0bbf10ca4f7d928cb3754889b1d289c67fe902d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 10 Sep 2024 12:59:07 +0200 Subject: [PATCH 38/62] fix: refs #7213 change rounding problems --- .../vn/procedures/sale_getProblems.sql | 24 ++++-- .../vn/procedures/sale_setProblemRounding.sql | 37 --------- .../sale_setProblemRoundingByBuy.sql | 75 ------------------- .../procedures/ticket_setProblemRounding.sql | 37 --------- 4 files changed, 19 insertions(+), 154 deletions(-) delete mode 100644 db/routines/vn/procedures/sale_setProblemRounding.sql delete mode 100644 db/routines/vn/procedures/sale_setProblemRoundingByBuy.sql delete mode 100644 db/routines/vn/procedures/ticket_setProblemRounding.sql diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index 7c5204e0d..352f7de4f 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -51,7 +51,6 @@ BEGIN hasTicketRequest, isTaxDataChecked, hasComponentLack, - hasRounding, isTooLittle) SELECT sgp.ticketFk, s.id, @@ -62,10 +61,6 @@ BEGIN IF(FIND_IN_SET('hasTicketRequest', t.problem), TRUE, FALSE) hasTicketRequest, IF(FIND_IN_SET('isTaxDataChecked', t.problem), FALSE, TRUE) isTaxDataChecked, IF(FIND_IN_SET('hasComponentLack', s.problem), TRUE, FALSE) hasComponentLack, - IF(FIND_IN_SET('hasRounding', s.problem), - LEFT(GROUP_CONCAT('RE: ', i.id, ' ', IFNULL(i.longName,'') SEPARATOR ', '), 250), - NULL - ) hasRounding, IF(FIND_IN_SET('isTooLittle', t.problem) AND util.VN_NOW() < (util.VN_CURDATE() + INTERVAL HOUR(zc.`hour`) HOUR) + INTERVAL MINUTE(zc.`hour`) MINUTE, TRUE, FALSE) isTooLittle @@ -208,6 +203,25 @@ BEGIN GROUP BY sgp.ticketFk ) sub ON DUPLICATE KEY UPDATE itemDelay = sub.problem, saleFk = sub.saleFk; + + CALL buyUltimate(vWarehouseFk, vDate); + INSERT INTO tmp.sale_problems(ticketFk, hasRounding, saleFk) + SELECT ticketFk, problem ,saleFk + FROM ( + SELECT tl.ticketFk, + s.id saleFk, + LEFT(GROUP_CONCAT('RE: ',i.id, ' ', IFNULL(i.longName,'') SEPARATOR ', '), 250) problem + FROM tmp.ticket_list tl + JOIN ticket t ON t.id = tl.ticketFk + AND t.warehouseFk = vWarehouseFk + JOIN sale s ON s.ticketFk = tl.ticketFk + JOIN item i ON i.id = s.itemFk + JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk + JOIN buy b ON b.id = bu.buyFk + WHERE MOD(s.quantity, b.`grouping`) + GROUP BY tl.ticketFk + )sub + ON DUPLICATE KEY UPDATE hasRounding = sub.problem, saleFk = sub.saleFk; END LOOP; CLOSE vCursor; diff --git a/db/routines/vn/procedures/sale_setProblemRounding.sql b/db/routines/vn/procedures/sale_setProblemRounding.sql deleted file mode 100644 index 894749c7b..000000000 --- a/db/routines/vn/procedures/sale_setProblemRounding.sql +++ /dev/null @@ -1,37 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_setProblemRounding`( - vSelf INT -) -BEGIN -/** - * Update the rounding problem for a sales line - * @param vSelf Id sale - */ - DECLARE vItemFk INT; - DECLARE vWarehouseFk INT; - DECLARE vShipped DATE; - DECLARE vQuantity INT; - DECLARE vIsProblemCalcNeeded BOOL; - - SELECT s.itemFk, t.warehouseFk, t.shipped, s.quantity, ticket_isProblemCalcNeeded(t.id) - INTO vItemFk, vWarehouseFk, vShipped, vQuantity, vIsProblemCalcNeeded - FROM sale s - JOIN ticket t ON t.id = s.ticketFk - WHERE s.id = vSelf; - - CALL buy_getUltimate(vItemFk, vWarehouseFk, vShipped); - - CREATE OR REPLACE TEMPORARY TABLE tmp.sale - SELECT vSelf saleFk, - MOD(vQuantity, b.`grouping`) hasProblem, - vIsProblemCalcNeeded isProblemCalcNeeded - FROM tmp.buyUltimate bu - JOIN buy b ON b.id = bu.buyFk - WHERE bu.itemFk = vItemFk; - - CALL sale_setProblem('hasRounding'); - - DROP TEMPORARY TABLE tmp.sale; - DROP TEMPORARY TABLE tmp.buyUltimate; -END$$ -DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/sale_setProblemRoundingByBuy.sql b/db/routines/vn/procedures/sale_setProblemRoundingByBuy.sql deleted file mode 100644 index b0e286d25..000000000 --- a/db/routines/vn/procedures/sale_setProblemRoundingByBuy.sql +++ /dev/null @@ -1,75 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_setProblemRoundingByBuy`( - vBuyFk INT -) -BEGIN -/** - * Update rounding problem for all sales related to a buy. - * - * @param vBuyFk Buy id - */ - DECLARE vItemFk INT; - DECLARE vWarehouseFk INT; - DECLARE vMaxDated DATE; - DECLARE vMinDated DATE; - DECLARE vLanding DATE; - DECLARE vLastBuy INT; - DECLARE vCurrentBuy INT; - DECLARE vGrouping INT; - - SELECT b.itemFk, t.warehouseInFk - INTO vItemFk, vWarehouseFk - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE b.id = vBuyFk; - - IF vItemFk AND vWarehouseFk THEN - SELECT DATE(MAX(t.shipped)) + INTERVAL 1 DAY, DATE(MIN(t.shipped)) - INTO vMaxDated, vMinDated - FROM sale s - JOIN ticket t ON t.id = s.ticketFk - WHERE t.shipped >= util.VN_CURDATE() - AND s.itemFk = vItemFk - AND s.quantity > 0; - - CALL buy_getUltimate(vItemFk, vWarehouseFk, vMinDated); - - SELECT bu.buyFk, b.grouping INTO vLastBuy, vGrouping - FROM tmp.buyUltimate bu - JOIN buy b ON b.id = bu.buyFk; - - DROP TEMPORARY TABLE tmp.buyUltimate; - - SET vLanding = vMaxDated; - - WHILE vCurrentBuy <> vLastBuy OR vLanding > vMinDated DO - SET vMaxDated = vLanding - INTERVAL 1 DAY; - - CALL buy_getUltimate(vItemFk, vWarehouseFk, vMaxDated); - - SELECT buyFk, landing - INTO vCurrentBuy, vLanding - FROM tmp.buyUltimate; - - DROP TEMPORARY TABLE tmp.buyUltimate; - END WHILE; - - CREATE OR REPLACE TEMPORARY TABLE tmp.sale - (INDEX(saleFk, isProblemCalcNeeded)) - ENGINE = MEMORY - SELECT s.id saleFk, - MOD(s.quantity, vGrouping) hasProblem, - ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded - FROM sale s - JOIN ticket t ON t.id = s.ticketFk - WHERE s.itemFk = vItemFk - AND s.quantity > 0 - AND t.shipped BETWEEN vMinDated AND util.dayEnd(vMaxDated); - - CALL sale_setProblem('hasRounding'); - - DROP TEMPORARY TABLE tmp.sale; - END IF; -END$$ -DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/ticket_setProblemRounding.sql b/db/routines/vn/procedures/ticket_setProblemRounding.sql deleted file mode 100644 index 551cf67d1..000000000 --- a/db/routines/vn/procedures/ticket_setProblemRounding.sql +++ /dev/null @@ -1,37 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblemRounding`( - vSelf INT -) -BEGIN -/** - * Update the rounding problem for the sales lines of a ticket - * - * @param vSelf Id de ticket - */ - DECLARE vWarehouseFk INT; - DECLARE vDated DATE; - - SELECT warehouseFk, shipped - INTO vWarehouseFk, vDated - FROM ticket - WHERE id = vSelf; - - CALL buy_getUltimate(NULL, vWarehouseFk, vDated); - - CREATE OR REPLACE TEMPORARY TABLE tmp.sale - (INDEX(saleFk, isProblemCalcNeeded)) - SELECT s.id saleFk , - MOD(s.quantity, b.`grouping`) hasProblem, - ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded - FROM ticket t - JOIN sale s ON s.ticketFk = t.id - JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk - JOIN buy b ON b.id = bu.buyFk - WHERE t.id = vSelf; - - CALL sale_setProblem('hasRounding'); - - DROP TEMPORARY TABLE tmp.sale; - DROP TEMPORARY TABLE tmp.buyUltimate; -END$$ -DELIMITER ; \ No newline at end of file From d98f0a24936e1bf9b4091f006c10926a9eaa4d0a Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 10 Sep 2024 13:15:58 +0200 Subject: [PATCH 39/62] chore: refs #7524 rollback --- modules/item/back/methods/item/getBalance.js | 9 +++------ modules/item/back/methods/item/specs/getBalance.spec.js | 6 +++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/modules/item/back/methods/item/getBalance.js b/modules/item/back/methods/item/getBalance.js index 1a4c7999d..c835cd56f 100644 --- a/modules/item/back/methods/item/getBalance.js +++ b/modules/item/back/methods/item/getBalance.js @@ -8,10 +8,6 @@ module.exports = Self => { required: true, description: 'Filter defining where and paginated data', http: {source: 'query'} - }, { - arg: 'noLimit', - type: 'Boolean', - required: false, }], returns: { type: ['Object'], @@ -20,10 +16,11 @@ module.exports = Self => { http: { path: `/getBalance`, verb: 'GET' - } + }, + noLimit: true }); - Self.getBalance = async(ctx, filter, noLimit, options) => { + Self.getBalance = async(ctx, filter, options) => { const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') diff --git a/modules/item/back/methods/item/specs/getBalance.spec.js b/modules/item/back/methods/item/specs/getBalance.spec.js index cef206411..95de3cc50 100644 --- a/modules/item/back/methods/item/specs/getBalance.spec.js +++ b/modules/item/back/methods/item/specs/getBalance.spec.js @@ -23,7 +23,7 @@ describe('item getBalance()', () => { date: null } }; - const results = await models.Item.getBalance(ctx, filter, true, options); + const results = await models.Item.getBalance(ctx, filter, options); const result = results.find(element => element.clientType == 'loses'); @@ -57,8 +57,8 @@ describe('item getBalance()', () => { } }; - const firstItemBalance = await models.Item.getBalance(ctx, firstFilter, true, options); - const secondItemBalance = await models.Item.getBalance(ctx, secondFilter, true, options); + const firstItemBalance = await models.Item.getBalance(ctx, firstFilter, options); + const secondItemBalance = await models.Item.getBalance(ctx, secondFilter, options); expect(firstItemBalance[9].claimFk).toEqual(null); expect(secondItemBalance[7].claimFk).toEqual(1); From 8fd7c1a8ddd775a7871631ee1d444e7c43bc5822 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 10 Sep 2024 13:16:15 +0200 Subject: [PATCH 40/62] fix: refs #7213 change rounding problems --- db/routines/vn/procedures/sale_getProblems.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index 352f7de4f..40b72a878 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -208,18 +208,18 @@ BEGIN INSERT INTO tmp.sale_problems(ticketFk, hasRounding, saleFk) SELECT ticketFk, problem ,saleFk FROM ( - SELECT tl.ticketFk, + SELECT sgp.ticketFk, s.id saleFk, LEFT(GROUP_CONCAT('RE: ',i.id, ' ', IFNULL(i.longName,'') SEPARATOR ', '), 250) problem - FROM tmp.ticket_list tl - JOIN ticket t ON t.id = tl.ticketFk + FROM tmp.sale_getProblems sgp + JOIN ticket t ON t.id = sgp.ticketFk AND t.warehouseFk = vWarehouseFk - JOIN sale s ON s.ticketFk = tl.ticketFk + JOIN sale s ON s.ticketFk = sgp.ticketFk JOIN item i ON i.id = s.itemFk JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk JOIN buy b ON b.id = bu.buyFk WHERE MOD(s.quantity, b.`grouping`) - GROUP BY tl.ticketFk + GROUP BY sgp.ticketFk )sub ON DUPLICATE KEY UPDATE hasRounding = sub.problem, saleFk = sub.saleFk; END LOOP; From 1ff1a97f29e9638fddabb1bbaa6fc3d539d815d4 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 10 Sep 2024 13:21:56 +0200 Subject: [PATCH 41/62] feat: refs #7524 check noLimit method key --- loopback/common/models/vn-model.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index 269ed673d..596ec0967 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -28,7 +28,7 @@ module.exports = function(Self) { }); this.beforeRemote('**', async ctx => { - if (this.hasNoLimit(ctx) || !this.hasFilter(ctx)) return; + if (ctx.method.noLimit || !this.hasFilter(ctx)) return; const defaultLimit = this.app.orm.selectLimit; const filter = ctx.args.filter || {limit: defaultLimit}; @@ -40,7 +40,7 @@ module.exports = function(Self) { }); this.afterRemote('**', async ctx => { - if (this.hasNoLimit(ctx) || !this.hasFilter(ctx)) return; + if (ctx.method.noLimit || !this.hasFilter(ctx)) return; const {result} = ctx; const length = Array.isArray(result) ? result.length : result ? 1 : 0; @@ -352,10 +352,5 @@ module.exports = function(Self) { return ctx.req.method.toUpperCase() === 'GET' && ctx.method.accepts.some(x => x.arg === 'filter' && x.type.toLowerCase() === 'object'); }, - - hasNoLimit(ctx) { - return ctx.method.accepts.some(x => x.arg.toLowerCase() === 'nolimit') && ctx.args.noLimit; - } - }); }; From e3b51c81f9a4bd67cffa95e7e5ced1c80971c08a Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 10 Sep 2024 16:37:46 +0200 Subject: [PATCH 42/62] refactor: refs #7524 wrap it up in a fn --- loopback/common/models/vn-model.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index 596ec0967..e24653d13 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -28,7 +28,7 @@ module.exports = function(Self) { }); this.beforeRemote('**', async ctx => { - if (ctx.method.noLimit || !this.hasFilter(ctx)) return; + if (!this.hasFilter(ctx)) return; const defaultLimit = this.app.orm.selectLimit; const filter = ctx.args.filter || {limit: defaultLimit}; @@ -40,7 +40,7 @@ module.exports = function(Self) { }); this.afterRemote('**', async ctx => { - if (ctx.method.noLimit || !this.hasFilter(ctx)) return; + if (!this.hasFilter(ctx)) return; const {result} = ctx; const length = Array.isArray(result) ? result.length : result ? 1 : 0; @@ -349,8 +349,10 @@ module.exports = function(Self) { }, hasFilter(ctx) { - return ctx.req.method.toUpperCase() === 'GET' && - ctx.method.accepts.some(x => x.arg === 'filter' && x.type.toLowerCase() === 'object'); + const {method, req} = ctx; + if (method.noLimit) return false; + return req.method.toUpperCase() === 'GET' && + method.accepts.some(x => x.arg === 'filter' && x.type.toLowerCase() === 'object'); }, }); }; From bebd49f08a84cde0acbf4a9a52362424e9293da0 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 11 Sep 2024 07:08:36 +0200 Subject: [PATCH 43/62] fix: debugAdd refs #6861 --- .../vn/procedures/itemShelvingSale_addBySectorCollection.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/db/routines/vn/procedures/itemShelvingSale_addBySectorCollection.sql b/db/routines/vn/procedures/itemShelvingSale_addBySectorCollection.sql index 26e661d9a..4f69c9a90 100644 --- a/db/routines/vn/procedures/itemShelvingSale_addBySectorCollection.sql +++ b/db/routines/vn/procedures/itemShelvingSale_addBySectorCollection.sql @@ -30,6 +30,8 @@ BEGIN FROM operator WHERE workerFk = account.myUser_getId(); + CALL util.debugAdd('itemShelvingSale_addBySectorCollection',CONCAT(vSectorCollectionFk,' - ', account.myUser_getId())); + OPEN vSales; l: LOOP SET vDone = FALSE; From 8dc83e244473b172cac65892ceef5b6de2183d3e Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 11 Sep 2024 08:16:21 +0200 Subject: [PATCH 44/62] feat: refs #7182 optimize workerDms filter --- .../worker/back/methods/worker-dms/filter.js | 57 ++++++++++++++++++- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/modules/worker/back/methods/worker-dms/filter.js b/modules/worker/back/methods/worker-dms/filter.js index b92ba139b..ed0490f54 100644 --- a/modules/worker/back/methods/worker-dms/filter.js +++ b/modules/worker/back/methods/worker-dms/filter.js @@ -57,15 +57,66 @@ module.exports = Self => { } }] }; + const where = mergeWhere(filter.where, yourOwnDms); stmt.merge(conn.makeSuffix({where})); const dmsIds = await conn.executeStmt(stmt); const allowedIds = dmsIds.map(dms => dms.id); - const allowedFilter = mergeFilters(filter, {where: {dmsFk: {inq: allowedIds}}}); + const allowedFilter = mergeFilters(filter, {where: {dmsFk: {inq: allowedIds}, workerFk: id}}); - const find = await models.WorkerDms.find(allowedFilter); + const workerDms = await models.WorkerDms.find(allowedFilter); - return find; + const workerDocuware = filter.skip ? [] : await getDocuwareasync(ctx, id); + return workerDms.concat(workerDocuware); + + async function getDocuwareasync(ctx, id) { + const {dmsTypeFk} = await models.Docuware.findOne({ + fields: ['dmsTypeFk'], + where: {code: 'hr', action: 'find'} + }); + + if (!await models.DmsType.hasReadRole(ctx, dmsTypeFk)) return []; + + let workerDocuware = []; + const worker = await models.Worker.findById(id, {fields: ['fi', 'firstName', 'lastName']}); + const docuwareParse = { + 'Filename': 'dmsFk', + 'Tipo Documento': 'description', + 'Stored on': 'created', + 'Document ID': 'id', + 'URL': 'download', + 'Stored by': 'name', + 'Estado': 'state' + }; + + workerDocuware = + await models.Docuware.getById('hr', worker.lastName + ' ' + worker.firstName, docuwareParse) ?? []; + const url = (await Self.app.models.Url.getUrl('docuware')) + 'WebClient'; + for (document of workerDocuware) { + const docuwareId = document.id; + const defaultData = { + id: docuwareId, + workerFk: id, + dmsFk: docuwareId, + dms: { + id: docuwareId, + file: docuwareId + '.pdf', + isDocuware: true, + hasFile: false, + reference: worker.fi, + dmsFk: docuwareId, + url, + description: document.description + ' - ' + document.state, + download: document.download, + created: document.created, + dmsType: {name: 'Docuware'}, + worker: {id: null, user: {name: document.name}}, + } + }; + Object.assign(document, defaultData); + } + return workerDocuware; + } }; }; From fbfbf21e06f044ee929820e19d79279e8dd9433f Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 11 Sep 2024 08:17:18 +0200 Subject: [PATCH 45/62] fix: refs #7182 unnesesary file --- .../back/methods/worker-dms/docuwareFilter.js | 74 ------------------- 1 file changed, 74 deletions(-) delete mode 100644 modules/worker/back/methods/worker-dms/docuwareFilter.js diff --git a/modules/worker/back/methods/worker-dms/docuwareFilter.js b/modules/worker/back/methods/worker-dms/docuwareFilter.js deleted file mode 100644 index 0311153b0..000000000 --- a/modules/worker/back/methods/worker-dms/docuwareFilter.js +++ /dev/null @@ -1,74 +0,0 @@ -module.exports = Self => { - Self.remoteMethodCtx('filter', { - description: 'Find docuware documents', - accessType: 'READ', - accepts: [ - { - arg: 'id', - type: 'number', - description: 'The worker id', - http: {source: 'path'} - } - ], - returns: { - type: ['object'], - root: true - }, - http: { - path: `/:id/filter`, - verb: 'GET' - } - }); - - Self.filter = async(ctx, id) => { - const models = Self.app.models; - - const {dmsTypeFk} = await models.Docuware.findOne({ - fields: ['dmsTypeFk'], - where: {code: 'hr', action: 'find'} - }); - - if (!await models.DmsType.hasReadRole(ctx, dmsTypeFk)) return []; - - let workerDocuware = []; - const worker = await models.Worker.findById(id, {fields: ['fi', 'firstName', 'lastName']}); - const docuwareParse = { - 'Filename': 'dmsFk', - 'Tipo Documento': 'description', - 'Stored on': 'created', - 'Document ID': 'id', - 'URL': 'download', - 'Stored by': 'name', - 'Estado': 'state' - }; - - workerDocuware = - await models.Docuware.getById('hr', worker.lastName + ' ' + worker.firstName, docuwareParse) ?? []; - const url = (await Self.app.models.Url.getUrl('docuware')) + 'WebClient'; - for (document of workerDocuware) { - const docuwareId = document.id; - const defaultData = { - id: docuwareId, - workerFk: id, - dmsFk: docuwareId, - dms: { - id: docuwareId, - file: docuwareId + '.pdf', - isDocuware: true, - hasFile: false, - reference: worker.fi, - dmsFk: docuwareId, - url, - description: document.description + ' - ' + document.state, - download: document.download, - created: document.created, - dmsType: {name: 'Docuware'}, - worker: {id: null, user: {name: document.name}}, - } - }; - Object.assign(document, defaultData); - } - }; - - return workerDocuware; -}; From ccaf56f8429052b824f6404f621758bbc8f374bd Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 11 Sep 2024 08:35:19 +0200 Subject: [PATCH 46/62] fix: setDeleted --- modules/ticket/back/methods/ticket/setDeleted.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/setDeleted.js b/modules/ticket/back/methods/ticket/setDeleted.js index 2afdf44ac..5000805b8 100644 --- a/modules/ticket/back/methods/ticket/setDeleted.js +++ b/modules/ticket/back/methods/ticket/setDeleted.js @@ -127,7 +127,7 @@ module.exports = Self => { id: id, url: `${url}ticket/${id}/summary` }); - await models.Chat.send(ctx, `@${salesPersonUser.name}`, message); + await models.Chat.sendCheckingPresence(ctx, `${salesPersonUser.id}`, message); } const updatedTicket = await ticket.updateAttribute('isDeleted', true, myOptions); From 838b8f541fb2e81d2ac9e64f2a1b48a2d628f97d Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 11 Sep 2024 08:45:00 +0200 Subject: [PATCH 47/62] fix: setDeleted --- modules/ticket/back/methods/ticket/setDeleted.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/setDeleted.js b/modules/ticket/back/methods/ticket/setDeleted.js index 5000805b8..8dfe42bf8 100644 --- a/modules/ticket/back/methods/ticket/setDeleted.js +++ b/modules/ticket/back/methods/ticket/setDeleted.js @@ -127,7 +127,7 @@ module.exports = Self => { id: id, url: `${url}ticket/${id}/summary` }); - await models.Chat.sendCheckingPresence(ctx, `${salesPersonUser.id}`, message); + await models.Chat.sendCheckingPresence(ctx, salesPersonUser.id, message); } const updatedTicket = await ticket.updateAttribute('isDeleted', true, myOptions); From 2ee0c93e246335e157141af1bb49f38a3ecfbe2d Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 11 Sep 2024 09:35:26 +0200 Subject: [PATCH 48/62] chore: refs #7663 fix test --- modules/ticket/back/methods/ticket/specs/setWeight.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ticket/back/methods/ticket/specs/setWeight.spec.js b/modules/ticket/back/methods/ticket/specs/setWeight.spec.js index c26ae7aaf..f6ef1f8e7 100644 --- a/modules/ticket/back/methods/ticket/specs/setWeight.spec.js +++ b/modules/ticket/back/methods/ticket/specs/setWeight.spec.js @@ -39,7 +39,7 @@ describe('ticket setWeight()', () => { expect(ticket.weight).toEqual(weight); }); - it('should throw an error if the user does not have enough privileges', async() => { + it('should throw an error if the user is not allocated to the same department', async() => { ctx.req.accessToken.userId = employeeId; try { const ticketId = 10; @@ -47,7 +47,7 @@ describe('ticket setWeight()', () => { await models.Ticket.setWeight(ctx, ticketId, weight, opts); } catch (e) { - expect(e.message).toEqual('You don\'t have enough privileges'); + expect(e.message).toEqual('This ticket is not allocated to your department'); } }); From ad8f27ea810b39bbc087ff32ceaf6cbf8827ecf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 11 Sep 2024 10:15:37 +0200 Subject: [PATCH 49/62] fix: refs #7213 change rounding problems --- .../vn/procedures/sale_getProblems.sql | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index 40b72a878..133f3995a 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -204,9 +204,10 @@ BEGIN ) sub ON DUPLICATE KEY UPDATE itemDelay = sub.problem, saleFk = sub.saleFk; + -- Redondeo: cantidad incorrecta con respecto al grouping CALL buyUltimate(vWarehouseFk, vDate); INSERT INTO tmp.sale_problems(ticketFk, hasRounding, saleFk) - SELECT ticketFk, problem ,saleFk + SELECT ticketFk, problem, saleFk FROM ( SELECT sgp.ticketFk, s.id saleFk, @@ -222,24 +223,11 @@ BEGIN GROUP BY sgp.ticketFk )sub ON DUPLICATE KEY UPDATE hasRounding = sub.problem, saleFk = sub.saleFk; + + DROP TEMPORARY TABLE tmp.buyUltimate; END LOOP; CLOSE vCursor; - INSERT INTO tmp.sale_problems(ticketFk, hasRounding, saleFk) - SELECT ticketFk, problem, saleFk - FROM ( - SELECT sgp.ticketFk, - s.id saleFk, - LEFT(GROUP_CONCAT('RE: ', i.id, ' ', IFNULL(i.longName,'') SEPARATOR ', '), 250) problem - FROM tmp.sale_getProblems sgp - JOIN ticket t ON t.id = sgp.ticketFk - JOIN sale s ON s.ticketFk = sgp.ticketFk - JOIN item i ON i.id = s.itemFk - WHERE FIND_IN_SET('hasRounding', s.problem) - GROUP BY sgp.ticketFk - ) sub - ON DUPLICATE KEY UPDATE hasRounding = sub.problem, saleFk = sub.saleFk; - DROP TEMPORARY TABLE tItemShelvingStock_byWarehouse; END$$ DELIMITER ; From 92f305b9fd5458f13291e8f8ff5b86bdb6e864f5 Mon Sep 17 00:00:00 2001 From: pablone Date: Wed, 11 Sep 2024 10:19:55 +0200 Subject: [PATCH 50/62] fix: refs #6156 proc and version --- .../vn/procedures/ticket_canAdvance.sql | 142 ++++++++++-------- .../11221-chocolateSalal/00-firstScript.sql | 15 +- 2 files changed, 85 insertions(+), 72 deletions(-) diff --git a/db/routines/vn/procedures/ticket_canAdvance.sql b/db/routines/vn/procedures/ticket_canAdvance.sql index c5b918def..57c3f4235 100644 --- a/db/routines/vn/procedures/ticket_canAdvance.sql +++ b/db/routines/vn/procedures/ticket_canAdvance.sql @@ -1,5 +1,3 @@ - - DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT) BEGIN @@ -10,82 +8,90 @@ BEGIN * @param vDateToAdvance Fecha a cuando se quiere adelantar. * @param vWarehouseFk Almacén */ - DECLARE vDateInventory DATE; - SELECT inventoried INTO vDateInventory FROM config; - - CREATE OR REPLACE TEMPORARY TABLE tStock - (itemFk INT PRIMARY KEY, amount INT) - ENGINE = MEMORY; - - INSERT INTO tStock(itemFk, amount) - SELECT itemFk, SUM(quantity) amount FROM - ( - SELECT itemFk, quantity - FROM itemTicketOut - WHERE shipped >= vDateInventory - AND shipped < vDateFuture - AND warehouseFk = vWarehouseFk - UNION ALL - SELECT itemFk, quantity - FROM itemEntryIn - WHERE landed >= vDateInventory - AND landed < vDateFuture - AND isVirtualStock = FALSE - AND warehouseInFk = vWarehouseFk - UNION ALL - SELECT itemFk, quantity - FROM itemEntryOut - WHERE shipped >= vDateInventory - AND shipped < vDateFuture - AND warehouseOutFk = vWarehouseFk - ) t - GROUP BY itemFk HAVING amount != 0; + CALL item_getStock(vWarehouseFk, vDateToAdvance, NULL); + CALL item_getMinacum( + vWarehouseFk, + vDateToAdvance, + DATEDIFF(DATE_SUB(vDateFuture, INTERVAL 1 DAY), vDateToAdvance), + NULL + ); CREATE OR REPLACE TEMPORARY TABLE tmp.filter (INDEX (id)) - SELECT dest.*, - origin.*, - IFNULL(dest.nickname, origin.nickname) nickname, + SELECT origin.ticketFk futureId, + dest.ticketFk id, + dest.state, + origin.futureState, + origin.futureIpt, + dest.ipt, + origin.workerFk, + origin.futureLiters, + origin.futureLines, + dest.shipped, + origin.shipped futureShipped, + dest.totalWithVat, + origin.totalWithVat futureTotalWithVat, + dest.agency, + dest.agencyModeFk, + origin.futureAgency, + origin.agencyModeFk futureAgencyModeFk, + dest.lines, + dest.liters, + origin.futureLines - origin.hasStock AS notMovableLines, (origin.futureLines = origin.hasStock) AS isFullMovable, - origin.futureLines - origin.hasStock AS notMovableLines + dest.zoneFk, + origin.futureZoneFk, + origin.futureZoneName, + origin.classColor futureClassColor, + dest.classColor, + origin.clientFk futureClientFk, + origin.addressFk futureAddressFk, + origin.warehouseFk futureWarehouseFk, + origin.companyFk futureCompanyFk, + IFNULL(dest.nickname, origin.nickname) nickname, + dest.landed, + dest.preparation FROM ( - SELECT s.ticketFk futureId, - t.workerFk, - t.shipped futureShipped, - t.totalWithVat futureTotalWithVat, + SELECT s.ticketFk, + c.salesPersonFk workerFk, + t.shipped, + t.totalWithVat, st.name futureState, - t.addressFk futureAddressFk, am.name futureAgency, count(s.id) futureLines, GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) futureIpt, CAST(SUM(litros) AS DECIMAL(10,0)) futureLiters, - SUM((s.quantity <= IFNULL(tst.amount,0))) hasStock, - st.classColor futureClassColor, - ( - count(s.id) - - SUM((s.quantity <= IFNULL(tst.amount,0))) - ) notMovableLines, - ( - count(s.id) = - SUM((s.quantity <= IFNULL(tst.amount,0))) - ) isFullMovable + SUM(s.quantity <= (IFNULL(il.stock,0) + IFNULL(im.amount, 0))) hasStock, + z.id futureZoneFk, + z.name futureZoneName, + st.classColor, + t.clientFk, + t.nickname, + t.addressFk, + t.warehouseFk, + t.companyFk, + t.agencyModeFk FROM ticket t + JOIN client c ON c.id = t.clientFk JOIN sale s ON s.ticketFk = t.id JOIN saleVolume sv ON sv.saleFk = s.id JOIN item i ON i.id = s.itemFk JOIN ticketState ts ON ts.ticketFk = t.id JOIN `state` st ON st.id = ts.stateFk JOIN agencyMode am ON t.agencyModeFk = am.id + JOIN `zone` z ON t.zoneFk = z.id + LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk - LEFT JOIN tStock tst ON tst.itemFk = i.id + LEFT JOIN tmp.itemMinacum im ON im.itemFk = i.id + AND im.warehouseFk = vWarehouseFk + LEFT JOIN tmp.itemList il ON il.itemFk = i.id WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture) AND t.warehouseFk = vWarehouseFk GROUP BY t.id - ) origin - JOIN ( - SELECT t.id, - t.addressFk, + ) origin + LEFT JOIN ( + SELECT t.id ticketFk, st.name state, GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt, t.shipped, @@ -94,9 +100,17 @@ BEGIN CAST(SUM(litros) AS DECIMAL(10,0)) liters, CAST(COUNT(*) AS DECIMAL(10,0)) `lines`, st.classColor, - CONCAT_WS(':', - COALESCE(HOUR(t.shipped), HOUR(zc.hour), HOUR(z.hour)), - COALESCE(MINUTE(t.shipped), MINUTE(zc.hour), MINUTE(z.hour)) + t.clientFk, + t.nickname, + t.addressFk, + t.zoneFk, + t.warehouseFk, + t.companyFk, + t.landed, + t.agencyModeFk, + SEC_TO_TIME( + COALESCE(HOUR(t.shipped), HOUR(zc.hour), HOUR(z.hour)) * 3600 + + COALESCE(MINUTE(t.shipped), MINUTE(zc.hour), MINUTE(z.hour)) * 60 ) preparation FROM ticket t JOIN sale s ON s.ticketFk = t.id @@ -105,17 +119,19 @@ BEGIN JOIN ticketState ts ON ts.ticketFk = t.id JOIN `state` st ON st.id = ts.stateFk JOIN agencyMode am ON t.agencyModeFk = am.id - JOIN ticketCanAdvanceConfig LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk LEFT JOIN `zone` z ON z.id = t.zoneFk LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk + JOIN ticketCanAdvanceConfig tc WHERE t.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance) AND t.warehouseFk = vWarehouseFk - AND st.order <= destinationOrder + AND st.order <= tc.destinationOrder GROUP BY t.id - ) dest ON dest.addressFk = origin.futureAddressFk + ) dest ON dest.addressFk = origin.addressFk WHERE origin.hasStock; - DROP TEMPORARY TABLE tStock; + DROP TEMPORARY TABLE IF EXISTS + tmp.itemList, + tmp.itemMinacum; END$$ DELIMITER ; diff --git a/db/versions/11221-chocolateSalal/00-firstScript.sql b/db/versions/11221-chocolateSalal/00-firstScript.sql index 680f0ee0e..bca742585 100644 --- a/db/versions/11221-chocolateSalal/00-firstScript.sql +++ b/db/versions/11221-chocolateSalal/00-firstScript.sql @@ -1,12 +1,9 @@ -- Place your SQL code here CREATE TABLE IF NOT EXISTS vn.ticketCanAdvanceConfig ( - id INT NOT NULL unsigned PRIMARY KEY, - destinationOrder INT NULL, - CONSTRAINT ticketCanAdvanceConfig_PK PRIMARY KEY (id) -) -ENGINE=InnoDB -DEFAULT CHARSET=utf8mb3 -COLLATE=utf8mb3_unicode_ci; + id int(10) unsigned NOT NULL, + destinationOrder INT NULL, + PRIMARY KEY (`id`), + CONSTRAINT `ticketCanAdvanceConfig_check` CHECK (`id` = 1) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -INSERT INTO vn.ticketCanAdvanceConfig - SET destinationOrder = 5; +INSERT INTO vn.ticketCanAdvanceConfig SET id =1, destinationOrder = 5; \ No newline at end of file From c21da8d258196466544549fadad1c7cd7b54c823 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 11 Sep 2024 10:31:43 +0200 Subject: [PATCH 51/62] fix: refs #7182 function name --- modules/worker/back/methods/worker-dms/filter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/worker/back/methods/worker-dms/filter.js b/modules/worker/back/methods/worker-dms/filter.js index ed0490f54..394988f9e 100644 --- a/modules/worker/back/methods/worker-dms/filter.js +++ b/modules/worker/back/methods/worker-dms/filter.js @@ -67,10 +67,10 @@ module.exports = Self => { const workerDms = await models.WorkerDms.find(allowedFilter); - const workerDocuware = filter.skip ? [] : await getDocuwareasync(ctx, id); + const workerDocuware = filter.skip ? [] : await getDocuware(ctx, id); return workerDms.concat(workerDocuware); - async function getDocuwareasync(ctx, id) { + async function getDocuware(ctx, id) { const {dmsTypeFk} = await models.Docuware.findOne({ fields: ['dmsTypeFk'], where: {code: 'hr', action: 'find'} From 011c16180da509df54fc2aec304c89f651a274ad Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 11 Sep 2024 12:31:16 +0200 Subject: [PATCH 52/62] fix: refs #7213 buyUltimate --- db/routines/vn/procedures/sale_getProblems.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index 133f3995a..da7c8d360 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -205,7 +205,7 @@ BEGIN ON DUPLICATE KEY UPDATE itemDelay = sub.problem, saleFk = sub.saleFk; -- Redondeo: cantidad incorrecta con respecto al grouping - CALL buyUltimate(vWarehouseFk, vDate); + CALL buy_getUltimate(NULL, vWarehouseFk, vDate); INSERT INTO tmp.sale_problems(ticketFk, hasRounding, saleFk) SELECT ticketFk, problem, saleFk FROM ( From d15be5100d8b58cfad3ee673f0008b30196582e6 Mon Sep 17 00:00:00 2001 From: ivanm Date: Wed, 11 Sep 2024 13:42:04 +0200 Subject: [PATCH 53/62] refactor: refs #7952 Deprecate creditInsurance.creditClassification --- db/routines/vn/procedures/creditInsurance_getRisk.sql | 2 +- .../vn/triggers/creditInsurance_afterInsert.sql | 2 +- .../vn/triggers/creditInsurance_beforeInsert.sql | 10 ---------- db/routines/vn/triggers/solunionCAP_afterInsert.sql | 2 +- db/routines/vn/triggers/solunionCAP_afterUpdate.sql | 4 ++-- db/routines/vn/triggers/solunionCAP_beforeDelete.sql | 2 +- db/versions/11224-whiteMastic/00-firstScript.sql | 2 ++ 7 files changed, 8 insertions(+), 16 deletions(-) delete mode 100644 db/routines/vn/triggers/creditInsurance_beforeInsert.sql create mode 100644 db/versions/11224-whiteMastic/00-firstScript.sql diff --git a/db/routines/vn/procedures/creditInsurance_getRisk.sql b/db/routines/vn/procedures/creditInsurance_getRisk.sql index ea19f8aef..5562c91d4 100644 --- a/db/routines/vn/procedures/creditInsurance_getRisk.sql +++ b/db/routines/vn/procedures/creditInsurance_getRisk.sql @@ -10,7 +10,7 @@ BEGIN SELECT * FROM ( SELECT cc.client clientFk, ci.grade FROM creditClassification cc - JOIN creditInsurance ci ON cc.id = ci.creditClassification + JOIN creditInsurance ci ON cc.id = ci.creditClassificationFk WHERE dateEnd IS NULL ORDER BY ci.creationDate DESC LIMIT 10000000000000000000) t1 diff --git a/db/routines/vn/triggers/creditInsurance_afterInsert.sql b/db/routines/vn/triggers/creditInsurance_afterInsert.sql index c865f31a4..f4857a730 100644 --- a/db/routines/vn/triggers/creditInsurance_afterInsert.sql +++ b/db/routines/vn/triggers/creditInsurance_afterInsert.sql @@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`creditInsurance_afterIn BEGIN UPDATE `client` c JOIN vn.creditClassification cc ON cc.client = c.id - SET creditInsurance = NEW.credit WHERE cc.id = NEW.creditClassification; + SET creditInsurance = NEW.credit WHERE cc.id = NEW.creditClassificationFk; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/creditInsurance_beforeInsert.sql b/db/routines/vn/triggers/creditInsurance_beforeInsert.sql deleted file mode 100644 index 8e036d373..000000000 --- a/db/routines/vn/triggers/creditInsurance_beforeInsert.sql +++ /dev/null @@ -1,10 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`creditInsurance_beforeInsert` - BEFORE INSERT ON `creditInsurance` - FOR EACH ROW -BEGIN - IF NEW.creditClassificationFk THEN - SET NEW.creditClassification = NEW.creditClassificationFk; - END IF; -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/solunionCAP_afterInsert.sql b/db/routines/vn/triggers/solunionCAP_afterInsert.sql index b4df7dc61..d09cadd95 100644 --- a/db/routines/vn/triggers/solunionCAP_afterInsert.sql +++ b/db/routines/vn/triggers/solunionCAP_afterInsert.sql @@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`solunionCAP_afterInsert BEGIN UPDATE client c JOIN creditClassification cc ON cc.client = c.id - JOIN creditInsurance ci ON ci.creditClassification = cc.id + JOIN creditInsurance ci ON ci.creditClassificationFk = cc.id SET creditInsurance = ci.credit * 2 WHERE ci.id = NEW.creditInsurance; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/solunionCAP_afterUpdate.sql b/db/routines/vn/triggers/solunionCAP_afterUpdate.sql index ccfba96f2..1199067bb 100644 --- a/db/routines/vn/triggers/solunionCAP_afterUpdate.sql +++ b/db/routines/vn/triggers/solunionCAP_afterUpdate.sql @@ -6,12 +6,12 @@ BEGIN IF NEW.dateLeaving IS NOT NULL THEN UPDATE client c JOIN creditClassification cc ON cc.client = c.id - JOIN creditInsurance ci ON ci.creditClassification = cc.id + JOIN creditInsurance ci ON ci.creditClassificationFk = cc.id SET creditInsurance = ci.credit WHERE ci.id = OLD.creditInsurance; ELSE UPDATE client c JOIN creditClassification cc ON cc.client = c.id - JOIN creditInsurance ci ON ci.creditClassification = cc.id + JOIN creditInsurance ci ON ci.creditClassificationFk = cc.id SET creditInsurance = ci.credit * 2 WHERE ci.id = OLD.creditInsurance; END IF; END$$ diff --git a/db/routines/vn/triggers/solunionCAP_beforeDelete.sql b/db/routines/vn/triggers/solunionCAP_beforeDelete.sql index a8b6732c1..7913a0d78 100644 --- a/db/routines/vn/triggers/solunionCAP_beforeDelete.sql +++ b/db/routines/vn/triggers/solunionCAP_beforeDelete.sql @@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`solunionCAP_beforeDelet BEGIN UPDATE client c JOIN creditClassification cc ON cc.client = c.id - JOIN creditInsurance ci ON ci.creditClassification = cc.id + JOIN creditInsurance ci ON ci.creditClassificationFk = cc.id SET creditInsurance = ci.credit WHERE ci.id = OLD.creditInsurance; END$$ DELIMITER ; diff --git a/db/versions/11224-whiteMastic/00-firstScript.sql b/db/versions/11224-whiteMastic/00-firstScript.sql new file mode 100644 index 000000000..52267cd91 --- /dev/null +++ b/db/versions/11224-whiteMastic/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.creditInsurance + CHANGE creditClassification creditClassification__ int(11) DEFAULT NULL COMMENT '@deprecated 2024-09-11'; From 889f3bdab4e9e3fae0e443bd193c5009d4d9771c Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 11 Sep 2024 14:12:07 +0200 Subject: [PATCH 54/62] fix: refs #7213 risk F11 --- db/routines/vn/procedures/ticket_getProblems.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/ticket_getProblems.sql b/db/routines/vn/procedures/ticket_getProblems.sql index f83351456..e91d62613 100644 --- a/db/routines/vn/procedures/ticket_getProblems.sql +++ b/db/routines/vn/procedures/ticket_getProblems.sql @@ -36,7 +36,7 @@ BEGIN UPDATE tmp.ticket_problems SET totalProblems = ( (isFreezed) + - (hasRisk) + + (hasHighRisk) + (hasTicketRequest) + (!isTaxDataChecked) + (hasComponentLack) + From 728c40916c4dc759afe2a0e56bb8ffb5e1acb7fd Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 11 Sep 2024 14:38:58 +0200 Subject: [PATCH 55/62] refactor: refs #7895 workerDocument to workerDms --- db/dump/fixtures.before.sql | 2 +- ...ent_afterDelete.sql => workerDms_afterDelete.sql} | 6 +++--- ...t_beforeInsert.sql => workerDms_beforeInsert.sql} | 4 ++-- ...t_beforeUpdate.sql => workerDms_beforeUpdate.sql} | 4 ++-- db/versions/11225-goldenLaurel/00-firstScript.sql | 1 + db/versions/11225-goldenLaurel/01-firstScript.sql | 1 + db/versions/11225-goldenLaurel/02-firstScript.sql | 1 + modules/worker/back/methods/worker-dms/filter.js | 7 ++++--- modules/worker/back/models/worker-dms.json | 12 +++--------- myt.config.yml | 2 +- 10 files changed, 19 insertions(+), 21 deletions(-) rename db/routines/vn/triggers/{workerDocument_afterDelete.sql => workerDms_afterDelete.sql} (71%) rename db/routines/vn/triggers/{workerDocument_beforeInsert.sql => workerDms_beforeInsert.sql} (73%) rename db/routines/vn/triggers/{workerDocument_beforeUpdate.sql => workerDms_beforeUpdate.sql} (73%) create mode 100644 db/versions/11225-goldenLaurel/00-firstScript.sql create mode 100644 db/versions/11225-goldenLaurel/01-firstScript.sql create mode 100644 db/versions/11225-goldenLaurel/02-firstScript.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index ea689c609..0a797f7ec 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2488,7 +2488,7 @@ INSERT INTO `vn`.`clientDms`(`clientFk`, `dmsFk`) (1104, 2), (1104, 3); -INSERT INTO `vn`.`workerDocument`(`id`, `worker`, `document`,`isReadableByWorker`) +INSERT INTO `vn`.`workerDms`(`id`, `workerFk`, `dmsFk`,`isReadableByWorker`) VALUES (1, 1106, 4, TRUE), (2, 1107, 3, FALSE); diff --git a/db/routines/vn/triggers/workerDocument_afterDelete.sql b/db/routines/vn/triggers/workerDms_afterDelete.sql similarity index 71% rename from db/routines/vn/triggers/workerDocument_afterDelete.sql rename to db/routines/vn/triggers/workerDms_afterDelete.sql index 8d4878248..bfb7d481e 100644 --- a/db/routines/vn/triggers/workerDocument_afterDelete.sql +++ b/db/routines/vn/triggers/workerDms_afterDelete.sql @@ -1,11 +1,11 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerDocument_afterDelete` - AFTER DELETE ON `workerDocument` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerDms_afterDelete` + AFTER DELETE ON `workerDms` FOR EACH ROW BEGIN INSERT INTO workerLog SET `action` = 'delete', - `changedModel` = 'WorkerDocument', + `changedModel` = 'WorkerDms', `changedModelId` = OLD.id, `userFk` = account.myUser_getId(); END$$ diff --git a/db/routines/vn/triggers/workerDocument_beforeInsert.sql b/db/routines/vn/triggers/workerDms_beforeInsert.sql similarity index 73% rename from db/routines/vn/triggers/workerDocument_beforeInsert.sql rename to db/routines/vn/triggers/workerDms_beforeInsert.sql index f0675e68f..a52c60961 100644 --- a/db/routines/vn/triggers/workerDocument_beforeInsert.sql +++ b/db/routines/vn/triggers/workerDms_beforeInsert.sql @@ -1,6 +1,6 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerDocument_beforeInsert` - BEFORE INSERT ON `workerDocument` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerDms_beforeInsert` + BEFORE INSERT ON `workerDms` FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); diff --git a/db/routines/vn/triggers/workerDocument_beforeUpdate.sql b/db/routines/vn/triggers/workerDms_beforeUpdate.sql similarity index 73% rename from db/routines/vn/triggers/workerDocument_beforeUpdate.sql rename to db/routines/vn/triggers/workerDms_beforeUpdate.sql index ffb6efd74..564064444 100644 --- a/db/routines/vn/triggers/workerDocument_beforeUpdate.sql +++ b/db/routines/vn/triggers/workerDms_beforeUpdate.sql @@ -1,6 +1,6 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerDocument_beforeUpdate` - BEFORE UPDATE ON `workerDocument` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerDms_beforeUpdate` + BEFORE UPDATE ON `workerDms` FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); diff --git a/db/versions/11225-goldenLaurel/00-firstScript.sql b/db/versions/11225-goldenLaurel/00-firstScript.sql new file mode 100644 index 000000000..87f521a03 --- /dev/null +++ b/db/versions/11225-goldenLaurel/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.workerDocument CHANGE worker workerFk int(10) unsigned DEFAULT NULL NULL; diff --git a/db/versions/11225-goldenLaurel/01-firstScript.sql b/db/versions/11225-goldenLaurel/01-firstScript.sql new file mode 100644 index 000000000..3aa3a1876 --- /dev/null +++ b/db/versions/11225-goldenLaurel/01-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.workerDocument CHANGE document dmsFk int(11) DEFAULT NULL NULL; diff --git a/db/versions/11225-goldenLaurel/02-firstScript.sql b/db/versions/11225-goldenLaurel/02-firstScript.sql new file mode 100644 index 000000000..d0e789534 --- /dev/null +++ b/db/versions/11225-goldenLaurel/02-firstScript.sql @@ -0,0 +1 @@ +RENAME TABLE vn.workerDocument TO vn.workerDms; diff --git a/modules/worker/back/methods/worker-dms/filter.js b/modules/worker/back/methods/worker-dms/filter.js index b7802a689..8feac3658 100644 --- a/modules/worker/back/methods/worker-dms/filter.js +++ b/modules/worker/back/methods/worker-dms/filter.js @@ -38,10 +38,11 @@ module.exports = Self => { const account = await models.VnUser.findById(userId); const stmt = new ParameterizedSQL( `SELECT d.id, d.id dmsFk - FROM workerDocument wd - JOIN dms d ON d.id = wd.document + FROM workerDms wd + JOIN dms d ON d.id = wd.dmsFk JOIN dmsType dt ON dt.id = d.dmsTypeFk - LEFT JOIN account.roleRole rr ON rr.inheritsFrom = dt.readRoleFk AND rr.role = ? + LEFT JOIN account.roleRole rr ON rr.inheritsFrom = dt.readRoleFk + AND rr.role = ? `, [account.roleFk] ); const yourOwnDms = {and: [{isReadableByWorker: true}, {worker: userId}]}; diff --git a/modules/worker/back/models/worker-dms.json b/modules/worker/back/models/worker-dms.json index a5c0f30b2..ef5684025 100644 --- a/modules/worker/back/models/worker-dms.json +++ b/modules/worker/back/models/worker-dms.json @@ -6,7 +6,7 @@ }, "options": { "mysql": { - "table": "workerDocument" + "table": "workerDms" } }, "properties": { @@ -16,17 +16,11 @@ }, "dmsFk": { "type": "number", - "required": true, - "mysql": { - "columnName": "document" - } + "required": true }, "workerFk": { "type": "number", - "required": true, - "mysql": { - "columnName": "worker" - } + "required": true }, "isReadableByWorker": { "type": "boolean" diff --git a/myt.config.yml b/myt.config.yml index ffa4188b2..1a0a138f0 100755 --- a/myt.config.yml +++ b/myt.config.yml @@ -375,7 +375,7 @@ localFixtures: - workerBosses - workerBusinessType - workerConfig - - workerDocument + - workerDms - workerLog - workerMana - workerManaExcluded From 6075ec6518d919ab7f31075b975d9431a94dac95 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 12 Sep 2024 09:06:03 +0200 Subject: [PATCH 56/62] feat: refs #7562 Requested changes --- .../11113-bronzeDendro/00-firstScript.sql | 36 +++++++------------ 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/db/versions/11113-bronzeDendro/00-firstScript.sql b/db/versions/11113-bronzeDendro/00-firstScript.sql index 98ac69966..63db65378 100644 --- a/db/versions/11113-bronzeDendro/00-firstScript.sql +++ b/db/versions/11113-bronzeDendro/00-firstScript.sql @@ -1,26 +1,16 @@ -ALTER TABLE util.config - ADD COLUMN dateRegex varchar(255) NULL COMMENT 'Expresión regular para obtener las fechas.', - ADD deprecatedMarkRegex varchar(255) NULL COMMENT 'Expresión regular para obtener los objetos deprecados.', - ADD daysKeepDeprecatedObjects int(11) unsigned NULL COMMENT 'Número de días que se mantendrán los objetos deprecados.'; - -UPDATE IGNORE util.config - SET dateRegex = '[0-9]{4}-[0-9]{2}-[0-9]{2}', - deprecatedMarkRegex = '__$', - daysKeepDeprecatedObjects = 60; - ALTER TABLE IF EXISTS `vn`.`payrollWorker` - MODIFY COLUMN IF EXISTS `nss__` varchar(23) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', - MODIFY COLUMN IF EXISTS `codpuesto__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', - MODIFY COLUMN IF EXISTS `codcontrato__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', - MODIFY COLUMN IF EXISTS `FAntiguedad__` date NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', - MODIFY COLUMN IF EXISTS `grupotarifa__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', - MODIFY COLUMN IF EXISTS `codcategoria__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', - MODIFY COLUMN IF EXISTS `ContratoTemporal__` tinyint(1) NOT NULL DEFAULT 0 COMMENT '@deprecated 2024-03-15 refs #6738'; + MODIFY COLUMN IF EXISTS `nss__` varchar(23) NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `codpuesto__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `codcontrato__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `FAntiguedad__` date NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `grupotarifa__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `codcategoria__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `ContratoTemporal__` tinyint(1) NOT NULL DEFAULT 0 COMMENT '@deprecated 2024-03-15'; ALTER TABLE IF EXISTS `vn`.`payrollWorkCenter` - MODIFY COLUMN IF EXISTS `Centro__` varchar(255) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', - MODIFY COLUMN IF EXISTS `nss_cotizacion__` varchar(15) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', - MODIFY COLUMN IF EXISTS `domicilio__` varchar(255) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', - MODIFY COLUMN IF EXISTS `poblacion__` varchar(45) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', - MODIFY COLUMN IF EXISTS `cp__` varchar(5) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738', - MODIFY COLUMN IF EXISTS `empresa_id__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15 refs #6738'; + MODIFY COLUMN IF EXISTS `Centro__` varchar(255) NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `nss_cotizacion__` varchar(15) NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `domicilio__` varchar(255) NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `poblacion__` varchar(45) NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `cp__` varchar(5) NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `empresa_id__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15'; From b6cba2325aeefa88e5c50fd271c0beecfae43950 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 12 Sep 2024 11:02:41 +0200 Subject: [PATCH 57/62] feat: refs #7562 myt version increased to 1.6.10 --- package.json | 2 +- pnpm-lock.yaml | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 1d3b9d253..d50631eb7 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@babel/register": "^7.7.7", "@commitlint/cli": "^19.2.1", "@commitlint/config-conventional": "^19.1.0", - "@verdnatura/myt": "^1.6.9", + "@verdnatura/myt": "^1.6.10", "angular-mocks": "^1.7.9", "babel-jest": "^26.0.1", "babel-loader": "^8.2.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b4030d779..458ce647c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -143,8 +143,8 @@ devDependencies: specifier: ^19.1.0 version: 19.1.0 '@verdnatura/myt': - specifier: ^1.6.9 - version: 1.6.9 + specifier: ^1.6.10 + version: 1.6.10 angular-mocks: specifier: ^1.7.9 version: 1.8.3 @@ -2846,8 +2846,8 @@ packages: dev: false optional: true - /@verdnatura/myt@1.6.9: - resolution: {integrity: sha512-29IauYra9igfdPWwV4+pVV/tBXvIg0fkVHEpSz8Zz3G3lRtzm286FN2Kv6hZkxmD/F1n52O37jN9WLiLHDTW1Q==} + /@verdnatura/myt@1.6.10: + resolution: {integrity: sha512-fih/TFll5Sn/SxxafUmYh6CW0Qwpck8PpQ63/CKm4ya8rz8gYPq0THM2B5N8yEJ3PiolMg0wrWWas9j+taAh6w==} hasBin: true dependencies: '@sqltools/formatter': 1.2.5 @@ -3306,6 +3306,7 @@ packages: /are-we-there-yet@1.1.7: resolution: {integrity: sha512-nxwy40TuMiUGqMyRHgCSWZ9FM4VAoRP4xUYSTv5ImRog+h9yISPbVH7H8fASCIzYn9wlEv4zvFL7uKDMCFQm3g==} + deprecated: This package is no longer supported. dependencies: delegates: 1.0.0 readable-stream: 2.3.8 @@ -6593,6 +6594,7 @@ packages: /gauge@2.7.4: resolution: {integrity: sha512-14x4kjc6lkD3ltw589k0NrPD6cCNTD6CWoVUNpB85+DrtONoZn+Rug6xZU5RvSC4+TZPxA5AnBibQYAvZn41Hg==} + deprecated: This package is no longer supported. dependencies: aproba: 1.2.0 console-control-strings: 1.1.0 @@ -10814,6 +10816,7 @@ packages: /npmlog@4.1.2: resolution: {integrity: sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==} + deprecated: This package is no longer supported. dependencies: are-we-there-yet: 1.1.7 console-control-strings: 1.1.0 @@ -11055,6 +11058,7 @@ packages: /osenv@0.1.5: resolution: {integrity: sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==} + deprecated: This package is no longer supported. dependencies: os-homedir: 1.0.2 os-tmpdir: 1.0.2 From 6b6eea78dadcc1d94d4ba3725ee5ba243d4ca599 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 12 Sep 2024 13:21:01 +0200 Subject: [PATCH 58/62] feat: refs #7562 myt version increased to 1.6.11 --- package.json | 2 +- pnpm-lock.yaml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index d50631eb7..2ae7c3764 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@babel/register": "^7.7.7", "@commitlint/cli": "^19.2.1", "@commitlint/config-conventional": "^19.1.0", - "@verdnatura/myt": "^1.6.10", + "@verdnatura/myt": "^1.6.11", "angular-mocks": "^1.7.9", "babel-jest": "^26.0.1", "babel-loader": "^8.2.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 458ce647c..e2480cf4a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -143,8 +143,8 @@ devDependencies: specifier: ^19.1.0 version: 19.1.0 '@verdnatura/myt': - specifier: ^1.6.10 - version: 1.6.10 + specifier: ^1.6.11 + version: 1.6.11 angular-mocks: specifier: ^1.7.9 version: 1.8.3 @@ -2846,8 +2846,8 @@ packages: dev: false optional: true - /@verdnatura/myt@1.6.10: - resolution: {integrity: sha512-fih/TFll5Sn/SxxafUmYh6CW0Qwpck8PpQ63/CKm4ya8rz8gYPq0THM2B5N8yEJ3PiolMg0wrWWas9j+taAh6w==} + /@verdnatura/myt@1.6.11: + resolution: {integrity: sha512-uqdbSJSznBBzAoRkvBt600nUMEPL1PJ2v73eWMZbaoGUMiZiNAehYjs4gIrObP1cxC85JOx97XoLpG0BzPsaig==} hasBin: true dependencies: '@sqltools/formatter': 1.2.5 From 1abf6a14f95be25297e3b52e1610cf916cf81eb9 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 12 Sep 2024 13:26:09 +0200 Subject: [PATCH 59/62] fix: workerDms filter workerFk --- modules/worker/back/methods/worker-dms/filter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/worker/back/methods/worker-dms/filter.js b/modules/worker/back/methods/worker-dms/filter.js index 0d13276b1..597084e60 100644 --- a/modules/worker/back/methods/worker-dms/filter.js +++ b/modules/worker/back/methods/worker-dms/filter.js @@ -50,7 +50,7 @@ module.exports = Self => { or: [ {and: [ {isReadableByWorker: true}, - {worker: userId} + {'wd.workerFk': userId} ]}, { role: { From b1027f454b3f056892f4111441be6ab2807acafa Mon Sep 17 00:00:00 2001 From: Pako Date: Thu, 12 Sep 2024 14:13:17 +0200 Subject: [PATCH 60/62] locallyTested --- db/routines/vn/procedures/collection_new.sql | 3 ++- .../vn/procedures/productionControl.sql | 21 +++++++++++++++---- .../11229-salmonAsparagus/00-firstScript.sql | 3 +++ 3 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 db/versions/11229-salmonAsparagus/00-firstScript.sql diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index a5a9a61c7..53f5500a0 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -167,7 +167,8 @@ BEGIN OR LENGTH(pb.problem) OR pb.lines > vLinesLimit OR pb.m3 > vVolumeLimit - OR sub.maxSize > vSizeLimit; + OR sub.maxSize > vSizeLimit + OR pb.hasPlantTray; END IF; -- Hay que excluir aquellos que no tengan la misma hora de preparacion, si procede diff --git a/db/routines/vn/procedures/productionControl.sql b/db/routines/vn/procedures/productionControl.sql index e5323e84e..101a0f058 100644 --- a/db/routines/vn/procedures/productionControl.sql +++ b/db/routines/vn/procedures/productionControl.sql @@ -211,8 +211,6 @@ proc: BEGIN salesInParkingCount INT DEFAULT 0) ENGINE = MEMORY; - -- Insertamos todos los tickets que tienen productos parkineados - -- en sectores de previa, segun el sector CREATE OR REPLACE TEMPORARY TABLE tItemShelvingStock (PRIMARY KEY(itemFk, sectorFk)) ENGINE = MEMORY @@ -245,7 +243,6 @@ proc: BEGIN AND s.quantity > 0 GROUP BY pb.ticketFk; - -- Se calcula la cantidad de productos que estan ya preparados porque su saleGroup está aparcado UPDATE tmp.ticketWithPrevia twp JOIN ( SELECT pb.ticketFk, COUNT(DISTINCT s.id) salesInParkingCount @@ -259,12 +256,28 @@ proc: BEGIN ) sub ON twp.ticketFk = sub.ticketFk SET twp.salesInParkingCount = sub.salesInParkingCount; - -- Marcamos como pendientes aquellos que no coinciden las cantidades UPDATE tmp.productionBuffer pb JOIN tmp.ticketWithPrevia twp ON twp.ticketFk = pb.ticketFk SET pb.previousWithoutParking = TRUE WHERE twp.salesCount > twp.salesInParkingCount; + -- hasPlantTray + ALTER TABLE tmp.productionBuffer + ADD hasPlantTray BOOL DEFAULT FALSE; + + UPDATE tmp.productionBuffer pb + JOIN sale s ON s.ticketFk = pb.ticketFk + JOIN item i ON i.id = s.itemFk + JOIN itemType it ON it.id = i.typeFk + JOIN itemCategory ic ON ic.id = it.categoryFk + JOIN 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 hasPlantTray = TRUE + WHERE ic.code = 'plant' + AND p.`depth` >= pc.minPlantTrayLength; + DROP TEMPORARY TABLE tmp.productionTicket, tmp.ticket, diff --git a/db/versions/11229-salmonAsparagus/00-firstScript.sql b/db/versions/11229-salmonAsparagus/00-firstScript.sql new file mode 100644 index 000000000..d590ed958 --- /dev/null +++ b/db/versions/11229-salmonAsparagus/00-firstScript.sql @@ -0,0 +1,3 @@ +-- Place your SQL code here +ALTER TABLE vn.productionConfig ADD minPlantTrayLength INT DEFAULT 53 NOT NULL +COMMENT 'minimum length for plant tray restriction. Avoid to make collection of the ticket with this kind of item'; From a0bfc2059530cee109a52d5a7e512af722b44ea8 Mon Sep 17 00:00:00 2001 From: Pako Date: Thu, 12 Sep 2024 14:34:19 +0200 Subject: [PATCH 61/62] revision --- db/routines/vn/procedures/productionControl.sql | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/db/routines/vn/procedures/productionControl.sql b/db/routines/vn/procedures/productionControl.sql index 101a0f058..842a306b4 100644 --- a/db/routines/vn/procedures/productionControl.sql +++ b/db/routines/vn/procedures/productionControl.sql @@ -266,14 +266,14 @@ proc: BEGIN ADD hasPlantTray BOOL DEFAULT FALSE; UPDATE tmp.productionBuffer pb - JOIN sale s ON s.ticketFk = pb.ticketFk - JOIN item i ON i.id = s.itemFk - JOIN itemType it ON it.id = i.typeFk - JOIN itemCategory ic ON ic.id = it.categoryFk - JOIN 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 + JOIN sale s ON s.ticketFk = pb.ticketFk + JOIN item i ON i.id = s.itemFk + JOIN itemType it ON it.id = i.typeFk + JOIN itemCategory ic ON ic.id = it.categoryFk + JOIN 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 hasPlantTray = TRUE WHERE ic.code = 'plant' AND p.`depth` >= pc.minPlantTrayLength; From 3d598a4ec4afcc57d5edd309f7479aa88e884f99 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 12 Sep 2024 14:57:19 +0200 Subject: [PATCH 62/62] fix: refs #7952 Version --- db/versions/11224-whiteMastic/00-firstScript.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/db/versions/11224-whiteMastic/00-firstScript.sql b/db/versions/11224-whiteMastic/00-firstScript.sql index 52267cd91..de74dfc55 100644 --- a/db/versions/11224-whiteMastic/00-firstScript.sql +++ b/db/versions/11224-whiteMastic/00-firstScript.sql @@ -1,2 +1,3 @@ +ALTER TABLE vn.creditInsurance DROP FOREIGN KEY CreditInsurance_Fk1; ALTER TABLE vn.creditInsurance CHANGE creditClassification creditClassification__ int(11) DEFAULT NULL COMMENT '@deprecated 2024-09-11';