diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 47cba44b5..058c5cd2a 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -767,7 +767,7 @@ INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeF (35, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Somewhere in Philippines', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL), (36, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Ant-Man Adventure', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL), (37, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1110, 'Deadpool swords', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL); - + INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`) VALUES (1, 11, 1, 'ready'), @@ -3848,7 +3848,7 @@ INSERT INTO `vn`.`ledgerConfig` SET INSERT INTO vn.sectorCollection SET id = 2, userFk = 18, - sectorFk = 1; + sectorFk = 1; INSERT INTO vn.sectorCollectionSaleGroup SET id = 8, @@ -3862,9 +3862,23 @@ INSERT INTO vn.saleGroup (userFk, parkingFk, sectorFk, ticketFk) INSERT INTO vn.sectorCollection SET id = 3, userFk = 18, - sectorFk = 1; + sectorFk = 1; INSERT INTO vn.sectorCollectionSaleGroup SET id = 9, sectorCollectionFk = 3, - saleGroupFk = 6; \ No newline at end of file + saleGroupFk = 6; + + +INSERT INTO `vn`.`calendarHolidays` (calendarHolidaysTypeFk, dated, calendarHolidaysNameFk, workCenterFk) + VALUES + (1, '2001-05-08', 1, 1), + (1, '2001-05-09', 1, 1), + (1, '2001-05-10', 1, 1), + (1, '2001-05-11', 1, 1), + (1, '2001-05-14', 1, 5), + (1, '2001-05-15', 1, 5), + (1, '2001-05-16', 1, 5), + (1, '2001-05-17', 1, 5), + (1, '2001-05-18', 1, 5); + diff --git a/db/routines/util/procedures/debugAdd.sql b/db/routines/util/procedures/debugAdd.sql index 8c690376e..a8f7b3aa2 100644 --- a/db/routines/util/procedures/debugAdd.sql +++ b/db/routines/util/procedures/debugAdd.sql @@ -1,5 +1,8 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`debugAdd`(vVariable VARCHAR(255), vValue VARCHAR(255)) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`debugAdd`( + vVariable VARCHAR(255), + vValue TEXT +) MODIFIES SQL DATA BEGIN /** diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index fa947ddef..b022d8dcc 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -28,6 +28,8 @@ BEGIN DECLARE vLockName VARCHAR(215); DECLARE vLockTime INT DEFAULT 30; DECLARE vFreeWagonFk INT; + DECLARE vErrorNumber INT; + DECLARE vErrorMsg TEXT; DECLARE c1 CURSOR FOR SELECT ticketFk, `lines`, m3 @@ -47,12 +49,18 @@ BEGIN DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN + GET DIAGNOSTICS CONDITION 1 + vErrorNumber = MYSQL_ERRNO, + vErrorMsg = MESSAGE_TEXT; + IF vLockName IS NOT NULL THEN DO RELEASE_LOCK(vLockName); - CALL util.debugAdd(JSON_OBJECT( - 'type', 'releaseLock', - 'userFk', vUserFk - ), vLockName); -- Tmp + CALL util.debugAdd('collection_new', JSON_OBJECT( + 'errorNumber', vErrorNumber, + 'errorMsg', vErrorMsg, + 'lockName', vLockName, + 'userFk', vUserFk + )); -- Tmp END IF; RESIGNAL; diff --git a/db/routines/vn/procedures/itemShelving_add.sql b/db/routines/vn/procedures/itemShelving_add.sql index 9395f5d80..c308304ef 100644 --- a/db/routines/vn/procedures/itemShelving_add.sql +++ b/db/routines/vn/procedures/itemShelving_add.sql @@ -1,7 +1,14 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_add`(IN vShelvingFk VARCHAR(8), IN vBarcode VARCHAR(22), IN vQuantity INT, IN vPackagingFk VARCHAR(10), IN vGrouping INT, IN vPacking INT, IN vWarehouseFk INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_add`( + vShelvingFk VARCHAR(8), + vBarcode VARCHAR(22), + vQuantity INT, + vPackagingFk VARCHAR(10), + vGrouping INT, + vPacking INT, + vWarehouseFk INT +) BEGIN - /** * Añade registro o lo actualiza si ya existe. * @@ -23,12 +30,7 @@ BEGIN SELECT barcodeToItem(vBarcode) INTO vItemFk; IF vBuyFk IS NULL THEN - CALL cache.last_buy_refresh(FALSE); - - SELECT buy_id INTO vBuyFk - FROM cache.last_buy - WHERE item_id = vItemFk - AND warehouse_id = vWarehouseFk; + CALL util.throw('The buy is required'); END IF; IF vPacking IS NULL diff --git a/db/routines/vn/procedures/item_getAtp.sql b/db/routines/vn/procedures/item_getAtp.sql index bbf13d396..255e38867 100644 --- a/db/routines/vn/procedures/item_getAtp.sql +++ b/db/routines/vn/procedures/item_getAtp.sql @@ -1,5 +1,5 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getAtp`(vDated DATE) +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getAtp`(vDated DATE) BEGIN /** * Calcula el valor mínimo acumulado para cada artículo ordenado por fecha y @@ -44,5 +44,5 @@ BEGIN GROUP BY itemFk, wareHouseFk; DROP TEMPORARY TABLE tItemOrdered; -END$$ -DELIMITER ; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/item_getMinacum.sql b/db/routines/vn/procedures/item_getMinacum.sql index ed987637c..7573759f7 100644 --- a/db/routines/vn/procedures/item_getMinacum.sql +++ b/db/routines/vn/procedures/item_getMinacum.sql @@ -30,6 +30,7 @@ BEGIN FROM sale s JOIN ticket t ON t.id = s.ticketFk WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo + AND t.warehouseFk AND s.quantity != 0 AND (vItemFk IS NULL OR s.itemFk = vItemFk) AND (vWarehouseFk IS NULL OR t.warehouseFk = vWarehouseFk) @@ -40,7 +41,7 @@ BEGIN t.warehouseInFk FROM buy b JOIN entry e ON e.id = b.entryFk - LEFT JOIN travel t ON t.id = e.travelFk + JOIN travel t ON t.id = e.travelFk WHERE t.landed BETWEEN vDatedFrom AND vDatedTo AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) AND !e.isExcludedFromAvailable @@ -53,7 +54,7 @@ BEGIN t.warehouseOutFk FROM buy b JOIN entry e ON e.id = b.entryFk - LEFT JOIN travel t ON t.id = e.travelFk + JOIN travel t ON t.id = e.travelFk WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo AND (vWarehouseFk IS NULL OR t.warehouseOutFk = vWarehouseFk) AND !e.isExcludedFromAvailable diff --git a/db/routines/vn/procedures/item_getSimilar.sql b/db/routines/vn/procedures/item_getSimilar.sql index 762c25342..0bc84f8c0 100644 --- a/db/routines/vn/procedures/item_getSimilar.sql +++ b/db/routines/vn/procedures/item_getSimilar.sql @@ -21,9 +21,6 @@ BEGIN CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vDated); - -- Añadido temporalmente para que no se cuelgue la db - SET vShowType = TRUE; - WITH itemTags AS ( SELECT i.id, typeFk, @@ -38,7 +35,7 @@ BEGIN t.name, it.value FROM vn.item i - LEFT JOIN vn.itemTag it ON it.itemFk = i.id + LEFT JOIN vn.itemTag it FORCE INDEX(itemTagItemPriority) ON it.itemFk = i.id AND it.priority = vPriority LEFT JOIN vn.tag t ON t.id = it.tagFk WHERE i.id = vSelf @@ -68,7 +65,7 @@ BEGIN iss.visible located, b.price2 FROM vn.item i - JOIN cache.available a ON a.item_id = i.id + JOIN cache.available a FORCE INDEX (calc_id_4) ON a.item_id = i.id AND a.calc_id = vCalcFk LEFT JOIN vn.itemProposal ip ON ip.mateFk = i.id AND ip.itemFk = vSelf diff --git a/db/routines/vn/triggers/deviceProductionConfig_afterUpdate.sql b/db/routines/vn/triggers/deviceProductionConfig_afterUpdate.sql deleted file mode 100644 index 98e4f844f..000000000 --- a/db/routines/vn/triggers/deviceProductionConfig_afterUpdate.sql +++ /dev/null @@ -1,13 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`deviceProductionConfig_afterUpdate` - AFTER UPDATE ON `deviceProductionConfig` - FOR EACH ROW -BEGIN - IF NEW.isAllUsersAllowed = 1 OR NEW.isAllUsersAllowed = -1 THEN - SET @username := (SELECT account.myUser_getName()); - INSERT INTO vn.mail (receiver, subject, body) - VALUES ('cau@verdnatura.es', 'Se ha activado la autenticación sin restricciones en la app', - CONCAT('El usuario ', @username,' ha habilitado la opción para que todos los usuarios puedan acceder a la app sin restricciones')); - END IF; -END$$ -DELIMITER ; diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 740b50bcd..a2332fdca 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -229,8 +229,8 @@ "InvoiceIn is already booked": "InvoiceIn is already booked", "This workCenter is already assigned to this agency": "This workCenter is already assigned to this agency", "You can only have one PDA": "You can only have one PDA", - "Incoterms and Customs agent are required for a non UEE member": "Incoterms and Customs agent are required for a non UEE member", + "Incoterms and Customs agent are required for a non UEE member": "Incoterms and Customs agent are required for a non UEE member", "It has been invoiced but the PDF could not be generated": "It has been invoiced but the PDF could not be generated", - "It has been invoiced but the PDF of refund not be generated": "It has been invoiced but the PDF of refund not be generated" - -} + "It has been invoiced but the PDF of refund not be generated": "It has been invoiced but the PDF of refund not be generated", + "Cannot add holidays on this day": "Cannot add holidays on this day" +} \ No newline at end of file diff --git a/modules/route/back/methods/route/downloadCmrsZip.js b/modules/route/back/methods/route/downloadCmrsZip.js index c6934edca..895ff7a16 100644 --- a/modules/route/back/methods/route/downloadCmrsZip.js +++ b/modules/route/back/methods/route/downloadCmrsZip.js @@ -41,14 +41,16 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - ids = ids.split(','); - - for (const id of ids) { + const downloadAddZip = async id => { ctx.args = ctx.args || {}; ctx.args.id = Number(id); const [data] = await models.Route.cmr(ctx, myOptions); zip.file(`${id}.pdf`, data, {binary: true}); - } + }; + + ids = ids.split(','); + const promises = ids.map(id => downloadAddZip(id)); + await Promise.all(promises); const zipStream = zip.generateNodeStream({streamFiles: true}); return [zipStream, 'application/zip', `filename="cmrs.zip"`]; }; diff --git a/modules/route/back/models/routesMonitor.json b/modules/route/back/models/routesMonitor.json index a14680b5c..c5fe4c1ce 100644 --- a/modules/route/back/models/routesMonitor.json +++ b/modules/route/back/models/routesMonitor.json @@ -48,6 +48,9 @@ "priority": { "type": "number" }, + "roadmapStopFk": { + "type": "number" + }, "m3boxes": { "type": "number" }, diff --git a/modules/supplier/front/search-panel/index.html b/modules/supplier/front/search-panel/index.html index 161c8a98c..e67fa9083 100644 --- a/modules/supplier/front/search-panel/index.html +++ b/modules/supplier/front/search-panel/index.html @@ -35,7 +35,7 @@ label="Country" ng-model="filter.countryFk" url="countries" - show-field="country" + show-field="name" value-field="id"> diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js index 2de1d6e4d..0397886cf 100644 --- a/modules/worker/back/methods/worker/createAbsence.js +++ b/modules/worker/back/methods/worker/createAbsence.js @@ -110,8 +110,7 @@ module.exports = Self => { workCenterFk: workCenter.workCenterFk } }); - - if (holiday && isFestive) + if ((holiday && isFestive) && (workCenter.workcenterFk === holiday.workCenterFk)) throw new UserError(`Cannot add holidays on this day`); const absence = await models.Calendar.create({