From 26d655075e79ece1998dff82c73a19735bb69e69 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 5 Oct 2022 13:28:08 +0200 Subject: [PATCH] fix: bad pull --- db/dump/fixtures.sql | 42 +- db/dump/structure.sql | 643 +++++++----------- modules/shelving/back/model-config.json | 2 +- .../packaging/specs/listPackaging.spec.js | 3 +- 4 files changed, 269 insertions(+), 421 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index c0fea4f81..73a6ef687 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -13,7 +13,11 @@ INSERT INTO `salix`.`AccessToken` (`id`, `ttl`, `created`, `userId`) VALUES ('DEFAULT_TOKEN', '1209600', util.VN_CURDATE(), 66); -INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`) +INSERT INTO `salix`.`printConfig` (`id`, `itRecipient`, `incidencesEmail`) + VALUES + (1, 'it@gotamcity.com', 'incidences@gotamcity.com'); + +INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`) VALUES ('1', '6'); @@ -151,7 +155,7 @@ INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPreparedByPacking`, `code`) - VALUES + VALUES (1, 'First sector', 1, 1, 'FIRST'), (2, 'Second sector', 2, 0, 'SECOND'); @@ -583,6 +587,7 @@ INSERT INTO `vn`.`expence`(`id`, `name`, `isWithheld`) (7001000000, 'Mercaderia', 0), (7050000000, 'Prestacion de servicios', 1); + INSERT INTO `vn`.`invoiceOutExpence`(`id`, `invoiceOutFk`, `amount`, `expenceFk`, `created`) VALUES (1, 1, 813.06, 2000000000, util.VN_CURDATE()), @@ -915,16 +920,19 @@ INSERT INTO `vn`.`expeditionStateType`(`id`, `description`, `code`) INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `isBox`, `created`, `itemFk`, `counter`, `workerFk`, `externalId`, `packagingFk`, `stateTypeFk`) VALUES - (1, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 15, 1, 18, 'UR9000006041', 94, 1), - (2, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 16, 2, 18, 'UR9000006041', 94, 1), - (3, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 3, 18, 'UR9000006041', 94, 2), - (4, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 4, 18, 'UR9000006041', 94, 2), - (5, 1, 2, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 1, 18, NULL, 94, 3), - (6, 7, 3, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL, 1, 18, NULL, 94, 3), - (7, 2, 4, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL, 1, 18, NULL, 94, NULL), - (8, 3, 5, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), NULL, 1, 18, NULL, 94, 1), - (9, 3, 6, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 1, 18, NULL, 94, 2), - (10, 7, 7, 71, NOW(), NULL, 1, 18, NULL, 94, 3); + (1, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 15, 1, 18, 'UR9000006041', 94, 1), + (2, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 16, 2, 18, 'UR9000006041', 94, 1), + (3, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 3, 18, 'UR9000006041', 94, 2), + (4, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 4, 18, 'UR9000006041', 94, 2), + (5, 1, 2, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 1, 18, NULL, 94, 3), + (6, 7, 3, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL, 1, 18, NULL, 94, 3), + (7, 2, 4, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL, 1, 18, NULL, 94, NULL), + (8, 3, 5, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), NULL, 1, 18, NULL, 94, 1), + (9, 3, 6, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 1, 18, NULL, 94, 2), + (10, 7, 7, 71, NOW(), NULL, 1, 18, NULL, 94, 3), + (11, 7, 8, 71, NOW(), NULL, 1, 18, NULL, 94, 3), + (12, 7, 9, 71, NOW(), NULL, 1, 18, NULL, 94, 3), + (13, 1, 10, 71, NOW(), NULL, 1, 18, NULL, 94, 3); INSERT INTO `vn`.`expeditionState`(`id`, `created`, `expeditionFk`, `typeFk`, `userFk`) @@ -1764,11 +1772,6 @@ INSERT INTO `vn`.`claimDestination`(`id`, `description`, `addressFk`) (4, 'Reclam.PRAG', 12), (5, 'Corregido', 11); -INSERT INTO `vn`.`claimResponsible`(`id`, `description`, `responsability`) - VALUES - (1, 'Buyers', 0), - (7, 'Quality', 0); - INSERT INTO `vn`.`claimDevelopment`(`id`, `claimFk`, `claimResponsibleFk`, `workerFk`, `claimReasonFk`, `claimResultFk`, `claimRedeliveryFk`, `claimDestinationFk`) VALUES (1, 1, 1, 21, 1, 1, 2, 5), @@ -1782,6 +1785,11 @@ INSERT INTO `vn`.`claimEnd`(`id`, `saleFk`, `claimFk`, `workerFk`, `claimDestina (1, 31, 4, 21, 2), (2, 32, 3, 21, 3); +INSERT INTO `vn`.`claimConfig`(`id`, `pickupContact`, `maxResponsibility`) + VALUES + (1, 'Contact description', 50), + (2, 'Contact description', 30); + INSERT INTO `hedera`.`tpvMerchant`(`id`, `description`, `companyFk`, `bankFk`, `secretKey`) VALUES (1, 'Arkham Bank', 442, 1, 'h12387193H10238'), diff --git a/db/dump/structure.sql b/db/dump/structure.sql index 315093046..402c8e695 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -27,7 +27,6 @@ USE `account`; -- Table structure for table `account` -- - DROP TABLE IF EXISTS `account`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -530,7 +529,7 @@ BEGIN IF !(NEW.`password` <=> OLD.`password`) THEN SET NEW.bcryptPassword = NULL; - SET NEW.lastPassChange = NOW(); + SET NEW.lastPassChange = util.VN_NOW(); END IF; END */;; DELIMITER ; @@ -3288,8 +3287,8 @@ BEGIN * @param vStartingDate Fecha desde la cual se recalculan la tabla bs.bancos_evolution */ DECLARE vCurrentDate DATE; - DECLARE vMaxDate DATE DEFAULT TIMESTAMPADD(MONTH, 7, CURDATE()); - IF IFNULL(vStartingDate,0) < TIMESTAMPADD(YEAR, -5, CURDATE()) THEN + DECLARE vMaxDate DATE DEFAULT TIMESTAMPADD(MONTH, 7, util.VN_CURDATE()); + IF IFNULL(vStartingDate,0) < TIMESTAMPADD(YEAR, -5, util.VN_CURDATE()) THEN CALL util.throw('invalid date'); END IF; DELETE FROM bs.bancos_evolution WHERE Fecha >= vStartingDate; @@ -3344,8 +3343,8 @@ BEGIN SELECT t.dated, p.id_banco, - importe FROM vn.time t join vn2008.pago p ON p.fecha <= t.dated - WHERE t.dated BETWEEN CURDATE() AND vMaxDate - AND p.fecha BETWEEN CURDATE() AND vMaxDate + WHERE t.dated BETWEEN util.VN_CURDATE() AND vMaxDate + AND p.fecha BETWEEN util.VN_CURDATE() AND vMaxDate AND NOT conciliado ON DUPLICATE KEY UPDATE saldo = saldo + VALUES(saldo); @@ -3354,8 +3353,8 @@ BEGIN SELECT t.dated, r.Id_Banco, SUM(Entregado) FROM vn.time t JOIN vn2008.Recibos r ON r.Fechacobro <= t.dated - WHERE r.Fechacobro > CURDATE() AND r.Fechacobro <= vMaxDate - AND t.dated BETWEEN CURDATE() AND vMaxDate + WHERE r.Fechacobro > util.VN_CURDATE() AND r.Fechacobro <= vMaxDate + AND t.dated BETWEEN util.VN_CURDATE() AND vMaxDate GROUP BY t.dated, r.Id_Banco ON DUPLICATE KEY UPDATE saldo = saldo + VALUES(saldo); @@ -3466,7 +3465,7 @@ BEGIN * Inserta en @bs.carteras. */ DELETE FROM bs.carteras - WHERE Año >= YEAR(CURDATE()) - 1; + WHERE Año >= YEAR(util.VN_CURDATE()) - 1; INSERT INTO bs.carteras(Año,Mes,CodigoTrabajador,Peso) SELECT t.year AS Año, t.month AS Mes, w.code AS CodigoTrabajador, SUM(v.importe) AS Peso @@ -3500,10 +3499,10 @@ BEGIN DECLARE vThreeYearAgo DATETIME; - SET vOneYearAgo = TIMESTAMPADD(YEAR, -1,CURDATE()); - SET vTwoYearAgo = TIMESTAMPADD(YEAR, -2,CURDATE()); - SET vThreeYearAgo = TIMESTAMPADD(YEAR, -3,CURDATE()); - SET vFourYearsAgo = TIMESTAMPADD(YEAR, -4,CURDATE()); + SET vOneYearAgo = TIMESTAMPADD(YEAR, -1,util.VN_CURDATE()); + SET vTwoYearAgo = TIMESTAMPADD(YEAR, -2,util.VN_CURDATE()); + SET vThreeYearAgo = TIMESTAMPADD(YEAR, -3,util.VN_CURDATE()); + SET vFourYearsAgo = TIMESTAMPADD(YEAR, -4,util.VN_CURDATE()); DELETE FROM bs.clientNewBorn WHERE lastShipped < vOneYearAgo; @@ -3543,9 +3542,9 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `clientDied_recalc`() BEGIN - SET @primerAviso := TIMESTAMPADD(MONTH,-1,CURDATE()); - SET @segundoAviso := TIMESTAMPADD(MONTH,-2,CURDATE()); - SET @tercerAviso := TIMESTAMPADD(MONTH,-3,CURDATE()); + SET @primerAviso := TIMESTAMPADD(MONTH,-1,util.VN_CURDATE()); + SET @segundoAviso := TIMESTAMPADD(MONTH,-2,util.VN_CURDATE()); + SET @tercerAviso := TIMESTAMPADD(MONTH,-3,util.VN_CURDATE()); TRUNCATE TABLE bs.clientDied; @@ -3571,7 +3570,7 @@ BEGIN DELETE cd.* FROM bs.clientDied cd JOIN vn.ticket t ON t.clientFk = cd.id WHERE t.refFk IS NULL - AND t.shipped >=TIMESTAMPADD(MONTH,-1,CURDATE()); + AND t.shipped >=TIMESTAMPADD(MONTH,-1,util.VN_CURDATE()); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -3610,7 +3609,7 @@ BLOCK1: BEGIN FROM vn.client c JOIN vn.ticket t on t.clientFk = c.id LEFT JOIN clientNewBorn cb on cb.clientFk = c.id - WHERE t.shipped BETWEEN TIMESTAMPADD(YEAR, -1, CURDATE()) AND CURDATE() AND cb.isModified is null + WHERE t.shipped BETWEEN TIMESTAMPADD(YEAR, -1, util.VN_CURDATE()) AND util.VN_CURDATE() AND cb.isModified is null GROUP BY c.id; OPEN cur; @@ -4435,7 +4434,7 @@ BEGIN INTO vFromDated FROM vn.clientManaCache; - WHILE timestampadd(DAY,30,vFromDated) < CURDATE() DO + WHILE timestampadd(DAY,30,vFromDated) < util.VN_CURDATE() DO SELECT timestampadd(DAY,30,vFromDated), @@ -4513,7 +4512,7 @@ BEGIN JOIN (SELECT Id_Trabajador workerFk, FLOOR(SUM(importe)/12) pesoCarteraMensual FROM bs.vendedores - WHERE año * 100 + mes >= (YEAR(CURDATE()) -1) * 100 + MONTH(CURDATE()) + WHERE año * 100 + mes >= (YEAR(util.VN_CURDATE()) -1) * 100 + MONTH(util.VN_CURDATE()) GROUP BY workerFk ) lastYearSales USING(workerFk) SET pricesModifierRate = GREATEST(minRate, LEAST(maxRate, ROUND(- amount/lastYearSales.pesoCarteraMensual,3))); @@ -4570,7 +4569,7 @@ BEGIN END IF; UPDATE nightTask - SET `started` = NOW(), + SET `started` = util.VN_NOW(), `finished` = NULL, `error` = NULL, `errorCode` = NULL @@ -4593,8 +4592,8 @@ BEGIN WHERE id = vId; ELSE UPDATE nightTask - SET finished = NOW(), - lastFinished = NOW() + SET finished = util.VN_NOW(), + lastFinished = util.VN_NOW() WHERE id = vId; END IF; END LOOP; @@ -4716,8 +4715,8 @@ BEGIN SET vItemFk = IFNULL(vItemFk,0); SET vTypeFk = IFNULL(vTypeFk, 0); SET vCategoryFk = IFNULL(vCategoryFk,0); - SET vFromDate = IFNULL(vFromDate,CURDATE()); - SET vToDate = IFNULL(vToDate,CURDATE()); + SET vFromDate = IFNULL(vFromDate,util.VN_CURDATE()); + SET vToDate = IFNULL(vToDate,util.VN_CURDATE()); SET vProducerFk = IFNULL(vProducerFk,0); SET vFromDateLastYear = TIMESTAMPADD(YEAR,-1,vFromDate); @@ -4793,7 +4792,7 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `salesByclientSalesPerson_add`(vDate BEGIN IF vDatedFrom IS NULL THEN - SELECT CURDATE() - INTERVAL DAY(CURDATE())-1 DAY - INTERVAL 1 MONTH INTO vDatedFrom; + SELECT util.VN_CURDATE() - INTERVAL DAY(util.VN_CURDATE())-1 DAY - INTERVAL 1 MONTH INTO vDatedFrom; END IF; INSERT INTO salesByclientSalesPerson( dated, salesPersonFk, clientFk, amount, equalizationTax) @@ -5062,7 +5061,7 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `salesByItemTypeDay_addLauncher`() BEGIN DECLARE vDateStart,vDateEnd INT; - SELECT DATE_SUB(CURDATE(), INTERVAL 30 DAY), CURDATE() INTO vDateStart,vDateEnd; + SELECT DATE_SUB(util.VN_CURDATE(), INTERVAL 30 DAY), util.VN_CURDATE() INTO vDateStart,vDateEnd; CALL bs.salesByItemTypeDay_add(vDateStart, vDateEnd); END ;; DELIMITER ; @@ -5090,13 +5089,13 @@ BEGIN DECLARE vMaxWorkersWithPlusNewClient INT; DECLARE vRowCount INT DEFAULT 1; DECLARE vMaxRow INT; - DECLARE vPreviusMonth DATETIME DEFAULT CURDATE(); + DECLARE vPreviusMonth DATETIME DEFAULT util.VN_CURDATE(); SELECT executionDay, maxPlusNewClient, plusDifference, maxScoreNewClient, scoreDifference, salesPersonWithPlusNewClient INTO vExecutionDay, vPlusNewClient, vPlusDifference, vScoreNewClient, vScoreDifference, vMaxWorkersWithPlusNewClient FROM vn.commissionConfig; - IF(DAY(CURDATE()) = vExecutionDay) THEN + IF(DAY(util.VN_CURDATE()) = vExecutionDay) THEN -- COMERCIAL Y EQUIPO DROP TEMPORARY TABLE IF EXISTS tmp.salesPersons; CREATE TEMPORARY TABLE tmp.salesPersons @@ -5477,7 +5476,7 @@ BEGIN CALL bs.vendedores_add(YEAR(util.VN_CURDATE()),QUARTER(util.VN_CURDATE())); CALL bs.vendedores_evolution_add; - SELECT util.firstDayOfMonth(CURDATE())- INTERVAL 1 MONTH INTO vDatedFrom; + SELECT util.firstDayOfMonth(util.VN_CURDATE())- INTERVAL 1 MONTH INTO vDatedFrom; CALL bs.salesByclientSalesPerson_add(vDatedFrom); END ;; @@ -5507,8 +5506,8 @@ Inserta en la tabla compradores_evolution las ventas acumuladas en el ultimo mes DECLARE vDateFrom DATE; DECLARE vDateTo DATE; - SET vCurYear = year(CURDATE()); - SET vCurMonth = month(CURDATE()); + SET vCurYear = year(util.VN_CURDATE()); + SET vCurMonth = month(util.VN_CURDATE()); SELECT IFNULL(max(year),vCurYear-1), IFNULL(max(month),1) INTO vYear, vMonth @@ -5659,7 +5658,7 @@ BEGIN * **/ - CALL bs.ventas_add(timestampadd(week,-1,curdate()),curdate()); + CALL bs.ventas_add(timestampadd(week,-1,util.VN_CURDATE()),util.VN_CURDATE()); END ;; DELIMITER ; @@ -6505,8 +6504,8 @@ BEGIN SELECT t.routeFk, t.zoneFk, t.addressFk addressFk1, t2.addressFk addressFk2 FROM vn.ticket t JOIN vn.ticket t2 USING(routeFk, zoneFk) - WHERE t.shipped >= TIMESTAMPADD(MONTH,-3,CURDATE()) - AND t2.shipped >= TIMESTAMPADD(MONTH,-3,CURDATE()) + WHERE t.shipped >= TIMESTAMPADD(MONTH,-3,util.VN_CURDATE()) + AND t2.shipped >= TIMESTAMPADD(MONTH,-3,util.VN_CURDATE()) AND t.addressFk != t2.addressFk) sub GROUP BY addressFk1, addressFk2; @@ -6514,7 +6513,7 @@ BEGIN SELECT r.agencyModeFk, t.zoneFk, count(*) friendship FROM vn.route r JOIN vn.ticket t ON t.routeFk = r.id - WHERE t.shipped >= TIMESTAMPADD(MONTH,-3,CURDATE()) + WHERE t.shipped >= TIMESTAMPADD(MONTH,-3,util.VN_CURDATE()) AND r.agencyModeFk AND t.routeFk AND t.zoneFk @@ -6549,7 +6548,7 @@ proc: BEGIN RESIGNAL; END; - IF vDate < CURDATE() THEN + IF vDate < util.VN_CURDATE() THEN LEAVE proc; END IF; @@ -6569,7 +6568,7 @@ proc: BEGIN SELECT inventoried INTO vInventoryDate FROM vn.config; - SELECT SUBTIME(NOW(), reserveTime) INTO vReserveDate + SELECT SUBTIME(util.VN_NOW(), reserveTime) INTO vReserveDate FROM hedera.orderConfig; -- Calcula el ultimo dia de vida para cada producto @@ -6742,7 +6741,7 @@ proc: BEGIN RESIGNAL; END; - IF vDate < CURDATE() THEN + IF vDate < util.VN_CURDATE() THEN LEAVE proc; END IF; @@ -6773,7 +6772,7 @@ proc: BEGIN SELECT inventoried INTO vInventoryDate FROM vn.config; - SELECT SUBTIME(NOW(), reserveTime) INTO vReserveDate + SELECT SUBTIME(util.VN_NOW(), reserveTime) INTO vReserveDate FROM hedera.orderConfig; -- Calcula el ultimo dia de vida para cada producto @@ -6900,7 +6899,7 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `cacheCalc_clean`() BEGIN - DECLARE vCleanTime DATETIME DEFAULT TIMESTAMPADD(MINUTE, -5, NOW()); + DECLARE vCleanTime DATETIME DEFAULT TIMESTAMPADD(MINUTE, -5, util.VN_NOW()); DELETE FROM cache_calc WHERE expires < vCleanTime; END ;; DELIMITER ; @@ -6927,8 +6926,8 @@ BEGIN UPDATE cache_calc cc JOIN cache c ON c.id = cc.cache_id SET - cc.last_refresh = NOW(), - cc.expires = LEAST(ADDTIME(NOW(), c.lifetime), util.midNight()), + cc.last_refresh = util.VN_NOW(), + cc.expires = LEAST(ADDTIME(util.VN_NOW(), c.lifetime), util.midNight()), cc.connection_id = NULL WHERE cc.id = v_calc; @@ -7007,7 +7006,7 @@ proc: BEGIN -- Si existe una calculo valido libera el bloqueo y devuelve su identificador. - IF !v_refresh AND NOW() < v_expires + IF !v_refresh AND util.VN_NOW() < v_expires THEN DO RELEASE_LOCK(v_lock_id); SET v_refresh = FALSE; @@ -7116,7 +7115,7 @@ BEGIN DECLARE vDateShort DATETIME; - SET vDateShort = TIMESTAMPADD(MONTH, -1, CURDATE()); + SET vDateShort = TIMESTAMPADD(MONTH, -1, util.VN_CURDATE()); DELETE FROM cache.departure_limit WHERE Fecha < vDateShort; END ;; @@ -7153,11 +7152,11 @@ DECLARE vLoadingDelay DECIMAL(5) DEFAULT 2; DECLARE rs CURSOR FOR SELECT Departure , Sum(pb.m3)/(GREATEST(IFNULL(lhp.m3,0),IFNULL(dp.minSpeed,0))) AS Horas - , curDate()+(Departure + vLoadingDelay -(Sum(pb.m3)/(GREATEST(IFNULL(lhp.m3,0),IFNULL(minSpeed,0))))/24) AS InicioPreparacion + , util.VN_CURDATE()+(Departure + vLoadingDelay -(Sum(pb.m3)/(GREATEST(IFNULL(lhp.m3,0),IFNULL(minSpeed,0))))/24) AS InicioPreparacion FROM tmp.production_buffer pb LEFT JOIN vn.lastHourProduction lhp ON lhp.warehouseFk = pb.warehouse_id - LEFT JOIN cache.departure_limit dp ON dp.warehouse_id = pb.warehouse_id AND dp.fecha = CURDATE() - WHERE pb.Fecha = CURDATE() + LEFT JOIN cache.departure_limit dp ON dp.warehouse_id = pb.warehouse_id AND dp.fecha = util.VN_CURDATE() + WHERE pb.Fecha = util.VN_CURDATE() AND pb.graphCategory > 1 AND IFNULL(Departure,0) > 0 GROUP BY Departure @@ -7199,10 +7198,10 @@ DECLARE rs CURSOR FOR SELECT minSpeed INTO myMinSpeed FROM cache.departure_limit WHERE warehouse_id = vWarehouseId - AND fecha = CURDATE(); + AND fecha = util.VN_CURDATE(); REPLACE cache.departure_limit(warehouse_id, fecha, hora, minSpeed) - VALUES (vWarehouseId, CURDATE(), departureLimit, IFNULL(myMinSpeed,0)); + VALUES (vWarehouseId, util.VN_CURDATE(), departureLimit, IFNULL(myMinSpeed,0)); CLOSE rs; @@ -7251,7 +7250,7 @@ proc: BEGIN -- TODO: ¿Se puede usar la fecha del ultimo inventario? SELECT inventoried INTO started FROM vn.config LIMIT 1; - SET ended = CURDATE(); -- TIMESTAMPADD(DAY, -1, CURDATE()); + SET ended = util.VN_CURDATE(); -- TIMESTAMPADD(DAY, -1, util.VN_CURDATE()); CALL vn.buyUltimateFromInterval(NULL, started, ended); @@ -7307,7 +7306,7 @@ proc: BEGIN pb.Agencia FROM tmp.production_buffer pb JOIN vn.state st ON st.id = pb.state - WHERE Fecha = CURDATE() + WHERE Fecha = util.VN_CURDATE() GROUP BY wh_id, graphCategory ; @@ -8425,7 +8424,7 @@ BEGIN JOIN vn.ticket t ON s.ticketFk = t.id JOIN vn.item i ON i.id = s.itemFk JOIN deliveryInformation di ON di.ID = NEW.deliveryInformationID - WHERE t.clientFk = NEW.EndUserPartyGLN AND t.shipped >= CURDATE() + WHERE t.clientFk = NEW.EndUserPartyGLN AND t.shipped >= util.VN_CURDATE() AND i.supplyResponseFk = NEW.supplyResponseID LIMIT 1; @@ -8434,7 +8433,7 @@ BEGIN JOIN vn.item i ON i.id = s.itemFk JOIN deliveryInformation di ON di.ID = NEW.deliveryInformationID SET s.quantity = 0 - WHERE t.clientFk = NEW.EndUserPartyGLN AND t.shipped >= CURDATE() + WHERE t.clientFk = NEW.EndUserPartyGLN AND t.shipped >= util.VN_CURDATE() AND i.supplyResponseFk = NEW.supplyResponseID; INSERT INTO vn.mail (sender, `subject`, body) @@ -8730,23 +8729,6 @@ CREATE TABLE `tableConfig` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `tableConfig` --- - -DROP TABLE IF EXISTS `tableConfig`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `tableConfig` ( - `fileName` varchar(2) COLLATE utf8_unicode_ci NOT NULL, - `toTable` varchar(15) COLLATE utf8_unicode_ci NOT NULL, - `file` varchar(30) COLLATE utf8_unicode_ci NOT NULL, - `updated` date DEFAULT NULL, - PRIMARY KEY (`fileName`), - UNIQUE KEY `to_table` (`toTable`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `type` -- @@ -8878,8 +8860,8 @@ DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `clean`() BEGIN - DECLARE vFourYearsAgo DATE DEFAULT TIMESTAMPADD(YEAR,-4,CURDATE()); - DECLARE vOneWeekAgo DATE DEFAULT TIMESTAMPADD(WEEK,-1,CURDATE()); + DECLARE vFourYearsAgo DATE DEFAULT TIMESTAMPADD(YEAR,-4,util.VN_CURDATE()); + DECLARE vOneWeekAgo DATE DEFAULT TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); DELETE FROM ekt WHERE fec < vFourYearsAgo; @@ -8976,7 +8958,7 @@ BEGIN putOrderFk, `ref`, kop) - SELECT year(curdate()) entryYear, + SELECT year(util.VN_CURDATE()) entryYear, p.id deliveryNumber , DATE(di.LatestDeliveryDateTime) fec, HOUR(di.LatestDeliveryDateTime) hor, @@ -12458,7 +12440,7 @@ BEGIN FROM vn.buy b JOIN vn.entry e ON e.id = b.entryFk JOIN vn.travel t ON t.id = e.travelFk - WHERE t.shipped BETWEEN vDateInv AND CURDATE() + WHERE t.shipped BETWEEN vDateInv AND util.VN_CURDATE() AND t.warehouseOutFk = vWarehouse AND NOT e.isRaid AND t.isDelivered @@ -12467,7 +12449,7 @@ BEGIN FROM vn.sale m JOIN vn.ticket t ON t.id = m.ticketFk JOIN vn.ticketState s ON s.ticket = t.id - WHERE t.shipped BETWEEN vDateInv AND CURDATE() + WHERE t.shipped BETWEEN vDateInv AND util.VN_CURDATE() AND t.warehouseFk = vWarehouse AND s.alertLevel = 3 ) t @@ -13297,8 +13279,8 @@ BEGIN * @param vTo To date, if %NULL current date * @select The tickets list */ - SET vFrom = IFNULL(vFrom, DATE_FORMAT(TIMESTAMPADD(MONTH, -3, CURDATE()), '%Y-%m-01')); - SET vTo = IFNULL(vTo, TIMESTAMPADD(YEAR, 1, CURDATE())); + SET vFrom = IFNULL(vFrom, DATE_FORMAT(TIMESTAMPADD(MONTH, -3, util.VN_CURDATE()), '%Y-%m-01')); + SET vTo = IFNULL(vTo, TIMESTAMPADD(YEAR, 1, util.VN_CURDATE())); DROP TEMPORARY TABLE IF EXISTS tmp.ticket; CREATE TEMPORARY TABLE tmp.ticket @@ -13964,7 +13946,7 @@ BEGIN IF vTicket IS NULL THEN - SET vShipment = IFNULL(vShipment, CURDATE()); + SET vShipment = IFNULL(vShipment, util.VN_CURDATE()); CALL vn.ticket_add( vClientId, @@ -14093,7 +14075,7 @@ BEGIN JOIN edi.floraHollandConfig fhc JOIN hedera.`order` o ON o.id = vOrder WHERE i.id = vItem - AND di.LatestOrderDateTime > NOW() + AND di.LatestOrderDateTime > util.VN_NOW() AND vAmount > @available LIMIT 1; @@ -14127,7 +14109,7 @@ BEGIN DELETE FROM basketOrder WHERE orderFk = vOrder; - UPDATE `order` SET confirmed = TRUE, confirm_date = NOW() + UPDATE `order` SET confirmed = TRUE, confirm_date = util.VN_NOW() WHERE id = vOrder; COMMIT; @@ -14505,7 +14487,7 @@ proc: BEGIN CALL vn.ticketCalculatePurge; END IF; - UPDATE `order` SET date_make = NOW() + UPDATE `order` SET date_make = util.VN_NOW() WHERE id = vSelf; COMMIT; @@ -14886,7 +14868,7 @@ BEGIN WHERE ssid = vSsid; DELETE FROM userSession - WHERE lastUpdate < TIMESTAMPADD(HOUR, -1, NOW()); + WHERE lastUpdate < TIMESTAMPADD(HOUR, -1, util.VN_NOW()); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -19892,7 +19874,7 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `log_refreshOrder`( `vTableId` INT) BEGIN DECLARE vExpireTime INT DEFAULT 20; - DECLARE vExpired DATETIME DEFAULT TIMESTAMPADD(MINUTE, -vExpireTime, NOW()); + DECLARE vExpired DATETIME DEFAULT TIMESTAMPADD(MINUTE, -vExpireTime, util.VN_NOW()); DROP TEMPORARY TABLE IF EXISTS tValues; CREATE TEMPORARY TABLE tValues @@ -20096,7 +20078,7 @@ proc: BEGIN -- Deletes expired outbounds - DELETE FROM outbound WHERE expired <= NOW(); + DELETE FROM outbound WHERE expired <= util.VN_NOW(); -- Attaches desync inbounds @@ -21088,12 +21070,12 @@ CREATE DEFINER=`root`@`localhost` FUNCTION `today`() RETURNS date BEGIN /** * Devuelve la fecha actual. Usar en lugar de la función nativa - * CURDATE() en aquellos que se necesite rendimiento ya que la + * util.VN_CURDATE() en aquellos que se necesite rendimiento ya que la * la última no es determinista. * * @return La fecha actual */ - RETURN CURDATE(); + RETURN util.VN_CURDATE(); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -21118,7 +21100,7 @@ BEGIN * * @return La fecha de mañana */ - RETURN TIMESTAMPADD(DAY, 1, CURDATE()); + RETURN TIMESTAMPADD(DAY, 1, util.VN_CURDATE()); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -21143,7 +21125,7 @@ BEGIN * * @return La fecha de antes de ayer */ - RETURN TIMESTAMPADD(DAY, -2, CURDATE()); + RETURN TIMESTAMPADD(DAY, -2, util.VN_CURDATE()); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -21230,7 +21212,7 @@ BEGIN * @param vYear Año a evaluar * @return La posicion relativa del año */ - DECLARE vCurYear INT DEFAULT YEAR(CURDATE()); + DECLARE vCurYear INT DEFAULT YEAR(util.VN_CURDATE()); IF vYear = vCurYear THEN RETURN 'curYear'; @@ -21269,7 +21251,7 @@ BEGIN * * @return La fecha de ayer */ - RETURN TIMESTAMPADD(DAY, -1, CURDATE()); + RETURN TIMESTAMPADD(DAY, -1, util.VN_CURDATE()); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -21671,7 +21653,7 @@ BEGIN RENAME TABLE `mysql`.`slow_log` TO `mysql`.`slow_log_temp`; DELETE FROM `mysql`.`slow_log_temp` - WHERE start_time < TIMESTAMPADD(WEEK, -1, NOW()); + WHERE start_time < TIMESTAMPADD(WEEK, -1, util.VN_NOW()); RENAME TABLE `mysql`.`slow_log_temp` TO `mysql`.`slow_log`; @@ -22011,21 +21993,6 @@ CREATE TABLE `accountingConfig` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `accountingConfig` --- - -DROP TABLE IF EXISTS `accountingConfig`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `accountingConfig` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `minDate` date NOT NULL, - `maxDate` date NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `accountingType` -- @@ -23660,8 +23627,6 @@ trig: BEGIN CALL stock.log_add('buy', NULL, OLD.id); - CALL util.debugAdd('buy_deleted', CONCAT(OLD.id,' ', OLD.itemFk,' ', vn.getWorkerCode())); - /*IF entry_isInventoryOrPrevious(OLD.entryFk) THEN SET vValues = CONCAT_WS(',', OLD.entryFk, @@ -23874,29 +23839,6 @@ CREATE TABLE `chat` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `chat` --- - -DROP TABLE IF EXISTS `chat`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `chat` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `senderFk` int(10) unsigned DEFAULT NULL, - `recipient` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `dated` datetime DEFAULT NULL, - `checkUserStatus` tinyint(1) DEFAULT NULL, - `message` text COLLATE utf8_unicode_ci, - `status` tinyint(1) DEFAULT NULL, - `attempts` int(1) DEFAULT NULL, - `error` text COLLATE utf8_unicode_ci, - PRIMARY KEY (`id`), - KEY `chat_FK` (`senderFk`), - CONSTRAINT `chat_FK` FOREIGN KEY (`senderFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `chatConfig` -- @@ -25302,21 +25244,6 @@ CREATE TABLE `comparativeFilterType` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `comparativeFilterType` --- - -DROP TABLE IF EXISTS `comparativeFilterType`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `comparativeFilterType` ( - `comparativeFilterFk` int(11) NOT NULL, - `itemTypeFk` int(11) NOT NULL, - PRIMARY KEY (`comparativeFilterFk`,`itemTypeFk`), - CONSTRAINT `comparativeFilterType_FK` FOREIGN KEY (`comparativeFilterFk`) REFERENCES `comparativeFilter` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `component` -- @@ -28544,7 +28471,7 @@ DELIMITER ;; BEFORE UPDATE ON `greuge` FOR EACH ROW BEGIN - DECLARE vMaxDate DATETIME DEFAULT TIMESTAMPADD(YEAR,1,CURDATE()); + DECLARE vMaxDate DATETIME DEFAULT TIMESTAMPADD(YEAR,1,util.VN_CURDATE()); IF NEW.shipped > vMaxDate THEN SET NEW.shipped = vMaxDate; @@ -28637,7 +28564,7 @@ DELIMITER ;; BEFORE UPDATE ON `host` FOR EACH ROW BEGIN - SET new.updated = NOW(); + SET new.updated = util.VN_NOW(); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -30173,7 +30100,7 @@ BEGIN JOIN vn.route r ON r.id = t.routeFk WHERE r.isOk = FALSE AND ic.itemFk = NEW.itemFk - AND r.created >= CURDATE() + AND r.created >= util.VN_CURDATE() GROUP BY r.id; IF NEW.cm3Delivery = 0 AND NEW.warehouseFk = 60 THEN CALL mail_insert( @@ -32064,39 +31991,6 @@ CREATE TABLE `mrwServiceWeekday` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Configuración de los servicios en relación con el día de la semana para MRW'; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `mrwService` --- - -DROP TABLE IF EXISTS `mrwService`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `mrwService` ( - `agencyModeCodeFk` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `clientType` int(11) unsigned NOT NULL, - `serviceType` int(11) unsigned DEFAULT NULL, - PRIMARY KEY (`agencyModeCodeFk`), - CONSTRAINT `mrwService_agencyModeCodeFk` FOREIGN KEY (`agencyModeCodeFk`) REFERENCES `agencyMode` (`code`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Configuración de los servicios de MRW'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `mrwServiceWeekday` --- - -DROP TABLE IF EXISTS `mrwServiceWeekday`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `mrwServiceWeekday` ( - `agencyModeCodeFk` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `weekdays` set('mon','tue','wed','thu','fri','sat','sun') COLLATE utf8_unicode_ci NOT NULL, - `serviceType` int(11) unsigned NOT NULL, - `params` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - PRIMARY KEY (`agencyModeCodeFk`), - CONSTRAINT `mrwServiceWeekday_agencyModeCodeFk` FOREIGN KEY (`agencyModeCodeFk`) REFERENCES `agencyMode` (`code`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Configuración de los servicios en relación con el día de la semana para MRW'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `newBornSales` -- @@ -33382,20 +33276,6 @@ CREATE TABLE `ppeLocation` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `ppeLocation` --- - -DROP TABLE IF EXISTS `ppeLocation`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `ppeLocation` ( - `code` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `description` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, - PRIMARY KEY (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `ppePlan` -- @@ -34419,22 +34299,6 @@ CREATE TABLE `returnBuckets` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Temporary table structure for view `returnBuckets` --- - -DROP TABLE IF EXISTS `returnBuckets`; -/*!50001 DROP VIEW IF EXISTS `returnBuckets`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `returnBuckets` ( - `id` tinyint NOT NULL, - `freightContainerType` tinyint NOT NULL, - `freightPackagingEmpty` tinyint NOT NULL, - `freightPackagingFull` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - -- -- Temporary table structure for view `role` -- @@ -34534,6 +34398,7 @@ DELIMITER ;; FOR EACH ROW BEGIN DECLARE vKmMax INT; + IF NEW.isOk <> FALSE AND OLD.isOk = FALSE THEN SET NEW.m3 = ( SELECT SUM(litros)/1000 FROM vn.saleVolume s @@ -34642,32 +34507,6 @@ CREATE TABLE `routeCommission` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `routeCommission` --- - -DROP TABLE IF EXISTS `routeCommission`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `routeCommission` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `routeFk` int(10) unsigned NOT NULL, - `workCenterFk` int(11) DEFAULT NULL, - `km` decimal(5,2) DEFAULT NULL, - `m3` decimal(5,2) DEFAULT NULL, - `yearlyKm` decimal(5,2) DEFAULT NULL, - `yearlyM3` decimal(5,2) DEFAULT NULL, - `cat4m3` decimal(5,2) DEFAULT NULL, - `cat5m3` decimal(5,2) DEFAULT NULL, - `freelanceYearlyM3` decimal(5,2) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `routeCommission_routeFk_idx` (`routeFk`), - KEY `routeCommission_workCenterFk_idx` (`workCenterFk`), - CONSTRAINT `routeCommission_routeFk` FOREIGN KEY (`routeFk`) REFERENCES `route` (`id`) ON UPDATE CASCADE, - CONSTRAINT `routeCommission_workCenterFk` FOREIGN KEY (`workCenterFk`) REFERENCES `workCenter` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `routeComplement` -- @@ -34999,7 +34838,7 @@ BEGIN JOIN vn.route r ON r.id = t.routeFk WHERE r.isOk = FALSE AND s.id = NEW.id - AND r.created >= CURDATE() + AND r.created >= util.VN_CURDATE() GROUP BY r.id; END IF; @@ -35126,7 +34965,7 @@ BEGIN JOIN vn.route r ON r.id = t.routeFk WHERE r.isOk = FALSE AND s.id = NEW.id - AND r.created >= CURDATE() + AND r.created >= util.VN_CURDATE() GROUP BY r.id; END IF; @@ -35172,7 +35011,7 @@ BEGIN JOIN vn.route r ON r.id = t.routeFk WHERE r.isOk = FALSE AND s.id = OLD.id - AND r.created >= CURDATE() + AND r.created >= util.VN_CURDATE() GROUP BY r.id; END IF; END */;; @@ -36078,8 +35917,8 @@ DELIMITER ;; BEFORE INSERT ON `sharingClient` FOR EACH ROW BEGIN - SET NEW.ended = GREATEST(CURDATE(),NEW.ended); - SET NEW.started = GREATEST(CURDATE(),NEW.started); + SET NEW.ended = GREATEST(util.VN_CURDATE(),NEW.ended); + SET NEW.started = GREATEST(util.VN_CURDATE(),NEW.started); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -36099,8 +35938,8 @@ DELIMITER ;; BEFORE UPDATE ON `sharingClient` FOR EACH ROW BEGIN - SET NEW.ended = GREATEST(CURDATE(),NEW.ended); - SET NEW.started = GREATEST(CURDATE(),NEW.started); + SET NEW.ended = GREATEST(util.VN_CURDATE(),NEW.ended); + SET NEW.started = GREATEST(util.VN_CURDATE(),NEW.started); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -37415,7 +37254,7 @@ BEGIN FROM vn.route r WHERE r.isOk = FALSE AND r.id IN (OLD.routeFk,NEW.routeFk) - AND r.created >= CURDATE() + AND r.created >= util.VN_CURDATE() GROUP BY r.id; call util.debugAdd(NEW.id,CONCAT(OLD.routeFk,' ',NEW.routeFk)); END IF; @@ -37439,7 +37278,7 @@ BEGIN JOIN vn.route r ON r.id = t.routeFk WHERE r.isOk = FALSE AND t.id = NEW.id - AND r.created >= CURDATE() + AND r.created >= util.VN_CURDATE() GROUP BY r.id; SET NEW.shipped = DATE_FORMAT(NEW.shipped, '2000-%m-%d %T'); SET NEW.landed = DATE_FORMAT(NEW.landed, '2000-%m-%d %T'); @@ -37548,7 +37387,7 @@ BEGIN FROM vn.route r WHERE r.isOk = FALSE AND r.id = OLD.routeFk - AND r.created >= CURDATE() + AND r.created >= util.VN_CURDATE() GROUP BY r.id; DELETE FROM sale WHERE ticketFk = OLD.id; @@ -40531,7 +40370,7 @@ DELIMITER ;; BEFORE INSERT ON `workingHours` FOR EACH ROW BEGIN - IF (SELECT COUNT(*) FROM workingHours WHERE userId = NEW.userId AND DATE(timeIn) = CURDATE()) > 0 THEN + IF (SELECT COUNT(*) FROM workingHours WHERE userId = NEW.userId AND DATE(timeIn) = util.VN_CURDATE()) > 0 THEN CALL util.throw ('ALREADY_LOGGED'); END IF; END */;; @@ -41158,7 +40997,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `sale_checkWithoutComponents` ON SCHEDULE EVERY 10 MINUTE STARTS '2020-05-04 11:56:23' ON COMPLETION PRESERVE DISABLE DO call sale_checkNoComponents(DATE_ADD(NOW(), INTERVAL -10 MINUTE),DATE_ADD(NOW(), INTERVAL -1 MINUTE)) */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `sale_checkWithoutComponents` ON SCHEDULE EVERY 10 MINUTE STARTS '2020-05-04 11:56:23' ON COMPLETION PRESERVE DISABLE DO call sale_checkNoComponents(DATE_ADD(util.VN_NOW(), INTERVAL -10 MINUTE),DATE_ADD(util.VN_NOW(), INTERVAL -1 MINUTE)) */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -41176,7 +41015,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `ticketClosure` ON SCHEDULE EVERY 1 DAY STARTS '2017-09-18 00:30:00' ON COMPLETION NOT PRESERVE DISABLE COMMENT 'Realiza el cierre de todos los almacenes del dia actual' DO CALL ticketClosureMultiWarehouse(DATE_ADD(CURDATE(), INTERVAL -1 DAY)) */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `ticketClosure` ON SCHEDULE EVERY 1 DAY STARTS '2017-09-18 00:30:00' ON COMPLETION NOT PRESERVE DISABLE COMMENT 'Realiza el cierre de todos los almacenes del dia actual' DO CALL ticketClosureMultiWarehouse(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 DAY)) */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -41322,7 +41161,7 @@ BEGIN tmp.addressCompany, tmp.addressTaxArea; - RETURN vTaxArea; + RETURN vTaxArea; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -41580,7 +41419,7 @@ BEGIN INSERT INTO tmp.catalog_component (warehouseFk, itemFk, componentFk, cost) SELECT vWarehouse, vItem, vComponentCost, vCost FROM vn.rate - WHERE dated <= CURDATE() + WHERE dated <= util.VN_CURDATE() AND warehouseFk = vWarehouse ORDER BY dated DESC LIMIT 1; @@ -41590,7 +41429,7 @@ BEGIN /* INSERT INTO tmp.catalog_component (warehouseFk, itemFk, componentFk, cost) SELECT vWarehouse, vItem, vComponentMargin, (vCost / ((100 - rate2) / 100)) - vCost FROM vn.rate - WHERE dated <= CURDATE() + WHERE dated <= util.VN_CURDATE() AND warehouseFk = vWarehouse ORDER BY dated DESC LIMIT 1; @@ -41766,7 +41605,7 @@ BEGIN JOIN `client` c ON c.id = r.clientFk WHERE r.bankFk = vManaBank AND r.payed > vFromDated - AND r.payed <= CURDATE() + AND r.payed <= util.VN_CURDATE() AND c.id = vClient UNION ALL SELECT g.amount @@ -41774,7 +41613,7 @@ BEGIN JOIN `client` c ON c.id = g.clientFk WHERE g.greugeTypeFk = vManaGreugeType AND g.shipped > vFromDated - AND g.shipped <= CURDATE() + AND g.shipped <= util.VN_CURDATE() AND c.id = vClient ) sub; RETURN IFNULL(vMana,0); @@ -43030,10 +42869,10 @@ BEGIN FROM vn.sale s JOIN vn.saleTracking st ON st.saleFk = s.id JOIN vn.ticketStateToday tst ON tst.ticket = s.ticketFk - WHERE st.created > CURDATE() + WHERE st.created > util.VN_CURDATE() -- AND tst.`code` = 'ON_PREPARATION' ) sub ON sub.ticketFk = i.Id_Ticket - WHERE odbc_date > CURDATE() + WHERE odbc_date > util.VN_CURDATE() AND s.`code` = 'ON_PREPARATION' AND i.Id_Trabajador = vWorker AND sub.ticketFk IS NULL @@ -44062,7 +43901,7 @@ BEGIN DECLARE vCount INT; DECLARE vUuid VARCHAR(255); - DECLARE vSendDate DATETIME DEFAULT NOW(); + DECLARE vSendDate DATETIME DEFAULT util.VN_NOW(); DECLARE vSender VARCHAR(255) CHARSET utf8; SELECT `name` INTO vSender @@ -45041,7 +44880,7 @@ proc:BEGIN JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id JOIN vn.saleGroup sg ON sg.id = sgd.saleGroupFk WHERE sg.id = vParamFk - AND sg.created > TIMESTAMPADD(WEEK,-1, CURDATE()) + AND sg.created > TIMESTAMPADD(WEEK,-1, util.VN_CURDATE()) LIMIT 1; IF vValidFk THEN @@ -45200,7 +45039,7 @@ BEGIN IF vTicket IS NULL THEN CALL vn.ticket_add( vClientFk, - IFNULL(vShipped, CURDATE()), + IFNULL(vShipped, util.VN_CURDATE()), vWarehouseFk, vCompanyFk, vAddressFk, @@ -46090,7 +45929,7 @@ BEGIN */ DECLARE vAgency INT; DECLARE vShipped DATE; -DECLARE vLanded DATE DEFAULT CURDATE(); +DECLARE vLanded DATE DEFAULT util.VN_CURDATE(); SELECT agencyFk INTO vAgency FROM agencyMode WHERE id= vAgencyMode; l: LOOP @@ -46233,8 +46072,8 @@ BEGIN AND (ah.provinceFk = a.provinceFk OR ah.provinceFk IS NULL OR vAddress IS NULL) - AND TIMESTAMPADD(DAY, -ah.substractDay, vDate) >= CURDATE() - AND IF(TIMESTAMPADD(DAY, -ah.substractDay, vDate) = CURDATE(), ah.maxHour > HOUR(NOW()), TRUE) + AND TIMESTAMPADD(DAY, -ah.substractDay, vDate) >= util.VN_CURDATE() + AND IF(TIMESTAMPADD(DAY, -ah.substractDay, vDate) = util.VN_CURDATE(), ah.maxHour > HOUR(util.VN_NOW()), TRUE) ORDER BY ( (ah.weekDay IS NOT NULL) + (ah.agencyFk IS NOT NULL) + @@ -46412,7 +46251,7 @@ BEGIN ON s.id = bp.supplierFk LEFT JOIN vn.bank b ON b.id = bp.bankFk - WHERE bp.insuranceExpired = CURDATE(); + WHERE bp.insuranceExpired = util.VN_CURDATE(); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -46449,7 +46288,7 @@ BEGIN FROM cache.last_buy WHERE warehouse_id = vWarehouseFk OR vWarehouseFk IS NULL; - CALL buyUltimateFromInterval(vWarehouseFk, CURDATE(), vDated); + CALL buyUltimateFromInterval(vWarehouseFk, util.VN_CURDATE(), vDated); REPLACE INTO tmp.buyUltimate SELECT itemFk, buyFk, warehouseFk, landed landing @@ -47225,7 +47064,7 @@ BEGIN * @param vItemFk id del item * @param vPacking packing a actualizar */ - CALL buyUltimate(vWarehouseFk, CURDATE()); + CALL buyUltimate(vWarehouseFk, util.VN_CURDATE()); UPDATE buy b JOIN tmp.buyUltimate bu ON b.id = bu.buyFk @@ -47902,7 +47741,7 @@ proc: BEGIN * @return tmp.ticketComponentPrice * @return tmp.zoneGetShipped */ - DECLARE vLanded DATE DEFAULT DATE_ADD(CURDATE(),INTERVAL 2 DAY); + DECLARE vLanded DATE DEFAULT DATE_ADD(util.VN_CURDATE(),INTERVAL 2 DAY); DECLARE vAddressFk INT DEFAULT 24526; DECLARE vAgencyModeFk INT DEFAULT 639; DECLARE vAvailableCalc INT; @@ -48060,12 +47899,12 @@ BEGIN DECLARE v3Month DATE; DECLARE vTrashId varchar(15); - SET vDateShort = TIMESTAMPADD(MONTH, -2, CURDATE()); - SET vOneYearAgo = TIMESTAMPADD(YEAR,-1,CURDATE()); - SET vFourYearsAgo = TIMESTAMPADD(YEAR,-4,CURDATE()); - SET v18Month = TIMESTAMPADD(MONTH, -18,CURDATE()); - SET v26Month = TIMESTAMPADD(MONTH, -26,CURDATE()); - SET v3Month = TIMESTAMPADD(MONTH, -3, CURDATE()); + SET vDateShort = TIMESTAMPADD(MONTH, -2, util.VN_CURDATE()); + SET vOneYearAgo = TIMESTAMPADD(YEAR,-1,util.VN_CURDATE()); + SET vFourYearsAgo = TIMESTAMPADD(YEAR,-4,util.VN_CURDATE()); + SET v18Month = TIMESTAMPADD(MONTH, -18,util.VN_CURDATE()); + SET v26Month = TIMESTAMPADD(MONTH, -26,util.VN_CURDATE()); + SET v3Month = TIMESTAMPADD(MONTH, -3, util.VN_CURDATE()); DELETE FROM ticketParking WHERE created < vDateShort; DELETE FROM routesMonitor WHERE dated < vDateShort; @@ -48074,8 +47913,8 @@ BEGIN DELETE FROM messageInbox WHERE sendDate < vDateShort; DELETE FROM messageInbox WHERE sendDate < vDateShort; DELETE FROM workerTimeControl WHERE timed < vFourYearsAgo; - DELETE FROM itemShelving WHERE created < CURDATE() AND visible = 0; - DELETE FROM ticketDown WHERE created < TIMESTAMPADD(DAY,-1,CURDATE()); + DELETE FROM itemShelving WHERE created < util.VN_CURDATE() AND visible = 0; + DELETE FROM ticketDown WHERE created < TIMESTAMPADD(DAY,-1,util.VN_CURDATE()); DELETE FROM entryLog WHERE creationDate < vDateShort; DELETE IGNORE FROM expedition WHERE created < v26Month; DELETE FROM sms WHERE created < v18Month; @@ -48137,7 +47976,7 @@ BEGIN FROM vn.travel t LEFT JOIN vn.entry e ON e.travelFk = t.id JOIN vn.travelThermograph th ON th.travelFk = t.id - WHERE t.shipped < TIMESTAMPADD(MONTH, -3, CURDATE()) AND e.travelFk IS NULL; + WHERE t.shipped < TIMESTAMPADD(MONTH, -3, util.VN_CURDATE()) AND e.travelFk IS NULL; SELECT dt.id into vTrashId FROM vn.dmsType dt @@ -48168,7 +48007,7 @@ BEGIN FROM vn.entry e LEFT JOIN vn.buy b ON b.entryFk = e.id JOIN vn.entryConfig ec ON e.id != ec.defaultEntry - WHERE e.dated < TIMESTAMPADD(MONTH, -3, CURDATE()) AND b.entryFK IS NULL; + WHERE e.dated < TIMESTAMPADD(MONTH, -3, util.VN_CURDATE()) AND b.entryFK IS NULL; DELETE e FROM vn.entry e @@ -48458,7 +48297,7 @@ BEGIN CALL vn.clientGreugeSpray(vClientFk, TRUE, '', TRUE); INSERT INTO vn.greuge(clientFk, description, amount, shipped, greugeTypeFk) - SELECT vClientFk, 'Liquidación cliente', sum(amount), CURDATE(), 5 + SELECT vClientFk, 'Liquidación cliente', sum(amount), util.VN_CURDATE(), 5 FROM vn.greuge WHERE clientFk = vClientFk; @@ -48548,10 +48387,10 @@ BEGIN * @param vDate Fecha maxima de los registros * @return tmp.risk */ - DECLARE vStarted DATETIME DEFAULT TIMESTAMPADD(DAY, -35, CURDATE()); + DECLARE vStarted DATETIME DEFAULT TIMESTAMPADD(DAY, -35, util.VN_CURDATE()); DECLARE vEnded DATETIME; - SET vEnded = TIMESTAMP(IFNULL(vDate, CURDATE()), '23:59:59'); + SET vEnded = TIMESTAMP(IFNULL(vDate, util.VN_CURDATE()), '23:59:59'); DROP TEMPORARY TABLE IF EXISTS tClientRisk; CREATE TEMPORARY TABLE tClientRisk @@ -48761,7 +48600,7 @@ BEGIN VALUES( vClientFk, 'Desasignación', -1 * vMana, - CURDATE(), + util.VN_CURDATE(), vGreugeTypeMana); END IF; @@ -48794,7 +48633,7 @@ BEGIN JOIN vn.workerMana wm ON wm.workerFk = c.salesPersonFk JOIN vn.claimRatio cr ON cr.clientFk = c.id WHERE wm.workerFk = IF(onlyForHisOwner, vOwner, wm.workerFk) - AND t.shipped >= TIMESTAMPADD(MONTH,-1,CURDATE()) + AND t.shipped >= TIMESTAMPADD(MONTH,-1,util.VN_CURDATE()) AND c.id != vClientFk HAVING monthSale > 100; @@ -48802,10 +48641,10 @@ BEGIN FROM tmp.clientList; INSERT INTO vn.greuge(clientFk, description, amount, shipped, greugeTypeFk) - SELECT clientFk, CONCAT('Cliente: ',vClientFk), vGreuge * monthSale / vTotalSale, CURDATE(), vGreugeTypeFk + SELECT clientFk, CONCAT('Cliente: ',vClientFk), vGreuge * monthSale / vTotalSale, util.VN_CURDATE(), vGreugeTypeFk FROM tmp.clientList UNION ALL - SELECT vClientFk, 'Reparto greuge', -vGreuge, CURDATE(), vGreugeTypeFk; + SELECT vClientFk, 'Reparto greuge', -vGreuge, util.VN_CURDATE(), vGreugeTypeFk; END IF; @@ -48896,7 +48735,7 @@ BEGIN IFNULL(pe.equivalentFk, p.itemFk) itemFk, NULL, NULL, - IF(tp.quantity > 0 AND t.shipped <= TIMESTAMPADD(DAY, - vGraceDays, CURDATE()), tp.quantity, NULL) SenttoClient, + IF(tp.quantity > 0 AND t.shipped <= TIMESTAMPADD(DAY, - vGraceDays, util.VN_CURDATE()), tp.quantity, NULL) SenttoClient, IF(tp.quantity < 0, -tp.quantity, NULL) GotfromClient, NULL AS refFk, NULL, @@ -48946,13 +48785,13 @@ BEGIN CALL vn.ticket_add( vClientFk - ,CURDATE() + ,util.VN_CURDATE() ,vWarehouseFk -- Algemesi ,442 -- Verdnatura ,NULL -- address ,NULL -- agencia ,NULL -- route - ,CURDATE() + ,util.VN_CURDATE() ,account.myUser_getId() ,TRUE ,vNewTicket); @@ -49248,7 +49087,7 @@ BEGIN */ SET SESSION group_concat_max_len = 1000000; --- IF (DAY(CURDATE()) = 5) THEN +-- IF (DAY(util.VN_CURDATE()) = 5) THEN INSERT INTO vn.mail (receiver, replyTo, @@ -49265,7 +49104,7 @@ BEGIN Estimado cliente,
- A continuación le enviamos el resumen menual de CMR ',UPPER(MONTHNAME(CURDATE() - INTERVAL 1 MONTH)),' ', YEAR(CURDATE() - INTERVAL 1 MONTH), '.

+ A continuación le enviamos el resumen menual de CMR ',UPPER(MONTHNAME(util.VN_CURDATE() - INTERVAL 1 MONTH)),' ', YEAR(util.VN_CURDATE() - INTERVAL 1 MONTH), '.

Le rogamos que nos devuelva el resumen firmado a cmr@verdnatura.es


@@ -49284,8 +49123,8 @@ BEGIN JOIN vn.address a ON c.addressToFk = a.id JOIN vn.client c2 ON a.clientFk = c2.id WHERE c.state = 'Pending' - AND MONTH(c.created) = MONTH(CURDATE() - INTERVAL 1 MONTH) - AND YEAR(c.created) = YEAR(CURDATE() - INTERVAL 1 MONTH) + AND MONTH(c.created) = MONTH(util.VN_CURDATE() - INTERVAL 1 MONTH) + AND YEAR(c.created) = YEAR(util.VN_CURDATE() - INTERVAL 1 MONTH) AND c2.email IS NOT NULL -- No cogemos los CMRs dirigidos a 'Verdnatura' GROUP BY c2.id; @@ -52104,13 +51943,13 @@ DECLARE done INT DEFAULT FALSE; DECLARE vEntryFk INT; DECLARE vTravelFk INT; DECLARE vId INT; -DECLARE vLanded DATE DEFAULT CURDATE(); +DECLARE vLanded DATE DEFAULT util.VN_CURDATE(); DECLARE cur1 CURSOR FOR SELECT id FROM vn.ektEntryAssign; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; - IF HOUR(NOW()) > 12 THEN + IF HOUR(util.VN_NOW()) > 12 THEN SET vLanded = TIMESTAMPADD(DAY,1,vLanded); @@ -52168,6 +52007,7 @@ OPEN cur1; AND tr.landed = vLanded; IF NOT vTravelFk THEN + INSERT INTO vn.travel(landed, shipped, warehouseInFk, warehouseOutFk, agencyModeFk) SELECT vLanded, vLanded, warehouseInFk, warehouseOutFk, agencyModeFk FROM vn.ektEntryAssign @@ -52269,6 +52109,7 @@ BEGIN WHERE id = vTravelFk; ELSE + INSERT INTO vn.travel(shipped, landed, warehouseInFk, warehouseOutFk, agencyModeFk, ref, isDelivered, isReceived) SELECT LEAST(shipped, vDated), vDated, warehouseInFk, warehouseOutFk, agencyModeFk, CONCAT(account.myUser_getName(),' ', vEntryFk), TRUE, TRUE FROM vn.travel WHERE id = vTravelFk; @@ -52793,6 +52634,7 @@ BEGIN SELECT SUM(IFNULL(b.buyingValue * b.quantity, 0)) INTO vInvoiceAmountOldEntryFk FROM vn.buy b WHERE b.entryFk = vSelf; + UPDATE vn.entry e JOIN vn.buy b ON b.entryFk = e.id SET e.ref = CONCAT(e.ref,'(1)'), @@ -53841,7 +53683,7 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionTruck_Add`(vHour VARCHAR( BEGIN INSERT INTO vn.expeditionTruck(ETD,description) - VALUES(CONCAT(CURDATE(), ' ', vHour), vDescription); + VALUES(CONCAT(util.VN_CURDATE(), ' ', vHour), vDescription); END ;; DELIMITER ; @@ -53866,7 +53708,7 @@ BEGIN ETD, description Destino FROM vn.expeditionTruck - WHERE ETD BETWEEN CURDATE() AND util.dayend(CURDATE()) + WHERE ETD BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) ORDER BY ETD; END ;; DELIMITER ; @@ -54128,7 +53970,7 @@ BEGIN JOIN vn.client c ON c.id = t.clientFk WHERE c.typeFk = 'loses' COLLATE utf8_unicode_ci AND s.isPicked = FALSE - AND date(t.shipped) = CURDATE() + AND date(t.shipped) = util.VN_CURDATE() AND t.warehouseFk = vWarehouseFk ) sub ON sub.itemFk = ishr.itemFk ; @@ -54158,7 +54000,7 @@ BEGIN JOIN vn.client c ON c.id = t.clientFk SET s.isPicked = TRUE WHERE c.typeFk = 'loses' COLLATE utf8_unicode_ci - AND date(t.shipped) = CURDATE() + AND date(t.shipped) = util.VN_CURDATE() AND t.warehouseFk = vWarehouseFk AND s.itemFk = vItemFk; @@ -54470,7 +54312,7 @@ BEGIN t.routeFk as routeFk FROM vn2008.expeditions e INNER JOIN vn.ticket t ON t.id = e.ticket_id - WHERE DATE(odbc_date) = CURDATE(); + WHERE DATE(odbc_date) = util.VN_CURDATE(); END ;; DELIMITER ; @@ -54881,7 +54723,7 @@ proc: BEGIN -- Actualizamos el campo lastUsed de vn.item UPDATE vn.item i JOIN tmp.inventory i2 ON i2.itemFk = i.id - SET i.lastUsed = NOW() + SET i.lastUsed = util.VN_NOW() WHERE i2.quantity; -- DROP TEMPORARY TABLE tmp.inventory; @@ -54933,7 +54775,7 @@ BEGIN * Recalcula los inventarios de todos los almacenes. */ - call vn.inventoryMake(TIMESTAMPADD(DAY, -10, CURDATE()), 0); + call vn.inventoryMake(TIMESTAMPADD(DAY, -10, util.VN_CURDATE()), 0); END ;; DELIMITER ; @@ -55026,7 +54868,7 @@ BEGIN LEFT JOIN origin o ON o.id = i.originFk ) ON it.id = i.typeFk LEFT JOIN edi.ekt ek ON b.ektFk = ek.id - WHERE b.packageFk != "--" AND b.price2 != 0 AND b.packing != 0 AND b.buyingValue > 0 AND tr.landed > util.firstDayOfMonth(TIMESTAMPADD(MONTH,-2,CURDATE())) + WHERE b.packageFk != "--" AND b.price2 != 0 AND b.packing != 0 AND b.buyingValue > 0 AND tr.landed > util.firstDayOfMonth(TIMESTAMPADD(MONTH,-2,util.VN_CURDATE())) ORDER BY tr.landed DESC; DROP TEMPORARY TABLE IF EXISTS tmp.lastEntryOkGroup; @@ -55152,7 +54994,7 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceFromClient`(IN vMaxTicketDate datetime, IN vClientFk INT, IN vCompanyFk INT) BEGIN - DECLARE vMinTicketDate DATE DEFAULT TIMESTAMPADD(YEAR, -3, CURDATE()); + DECLARE vMinTicketDate DATE DEFAULT TIMESTAMPADD(YEAR, -3, util.VN_CURDATE()); SET vMaxTicketDate = util.dayend(vMaxTicketDate); DROP TEMPORARY TABLE IF EXISTS `ticketToInvoice`; @@ -56014,7 +55856,7 @@ BEGIN WHERE iot.invoiceOutFk = vInvoice; UPDATE invoiceOut - SET booked = CURDATE() + SET booked = util.VN_CURDATE() WHERE id = vInvoice; END ;; DELIMITER ; @@ -56559,7 +56401,7 @@ BEGIN END IF; CALL invoiceFromClient(vMaxShipped, vClientFk, vCompanyFk); - CALL invoiceOut_new(vSerial, CURDATE(), vTaxArea, vInvoiceId); + CALL invoiceOut_new(vSerial, util.VN_CURDATE(), vTaxArea, vInvoiceId); UPDATE invoiceOut SET `ref` = vRef @@ -56598,7 +56440,7 @@ BEGIN */ DECLARE vIsRefEditable BOOLEAN; CALL invoiceFromTicket(vTicketFk); - CALL invoiceOut_new(vSerial, CURDATE(), vTaxArea, vInvoiceId); + CALL invoiceOut_new(vSerial, util.VN_CURDATE(), vTaxArea, vInvoiceId); IF vRef IS NOT NULL THEN SELECT isRefEditable INTO vIsRefEditable @@ -56806,14 +56648,14 @@ BEGIN LEFT JOIN ( SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as venta FROM vn2008.item_out - WHERE dat BETWEEN CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(curdate())) + WHERE dat BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(util.VN_CURDATE())) AND warehouse_id = vWarehouseFk GROUP BY item_id ) sale ON sale.item_id = i.id LEFT JOIN ( SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as compra FROM vn2008.item_entry_in - WHERE dat BETWEEN CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(curdate())) + WHERE dat BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(util.VN_CURDATE())) AND warehouse_id = vWarehouseFk AND isVirtualStock = FALSE GROUP BY item_id @@ -56821,7 +56663,7 @@ BEGIN LEFT JOIN ( SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as traslado FROM vn2008.item_entry_out - WHERE dat BETWEEN CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(curdate())) + WHERE dat BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(util.VN_CURDATE())) AND warehouse_id = vWarehouseFk GROUP BY item_id ) mov ON mov.item_id = i.id @@ -57990,7 +57832,7 @@ BEGIN JOIN tmp.item2 ti ON ti.itemFk = s.itemFk JOIN vn.ticket t ON t.id = s.ticketFk LEFT JOIN vn.ticketState tst ON tst.ticketFk = t.id - WHERE t.shipped BETWEEN CURDATE() AND vTodayDayEnd + WHERE t.shipped BETWEEN util.VN_CURDATE() AND vTodayDayEnd AND t.warehouseFk = vWarehouseFk AND IFNULL(tst.productionOrder,0) < 5 GROUP BY s.itemFK @@ -58110,7 +57952,7 @@ BEGIN LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk JOIN client c on c.id = t.clientFk JOIN clientType ct ON ct.id = c.clientTypeFk - WHERE t.shipped BETWEEN CURDATE() AND util.dayend(CURDATE()) + WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) AND ISNULL(st.saleFk) AND ct.code IN ('normal', 'trust') GROUP BY s.itemFk @@ -58137,7 +57979,7 @@ BEGIN LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk JOIN client c on c.id = t.clientFk JOIN clientType ct ON ct.id = c.clientTypeFk - WHERE t.shipped BETWEEN CURDATE() AND util.dayend(CURDATE()) + WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) AND ISNULL(st.saleFk) AND ct.code IN ('normal', 'trust') GROUP BY s.itemFk @@ -58325,7 +58167,7 @@ BEGIN JOIN ticket t ON t.id = c.ticketFk WHERE c.id = vClaimFk; - CALL buyUltimate (vWarehouseFk, CURDATE()); + CALL buyUltimate (vWarehouseFk, util.VN_CURDATE()); INSERT INTO itemShelving (itemFk, shelvingFk, packing, `grouping`, visible) SELECT s.itemFk, vShelvingFk, b.packing, b.`grouping`, cb.quantity AS visible @@ -58462,7 +58304,7 @@ proc:BEGIN JOIN ticket t ON t.id = s.ticketFk JOIN client c on c.id = t.clientFk JOIN clientType ct ON ct.id = c.clientTypeFk - WHERE t.shipped BETWEEN CURDATE() AND util.dayend(CURDATE()) + WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) AND ISNULL(st.saleFk) AND ct.code IN ('normal', 'trust') GROUP BY s.itemFk @@ -58487,7 +58329,7 @@ proc:BEGIN JOIN ticket t ON t.id = s.ticketFk JOIN client c on c.id = t.clientFk JOIN clientType ct ON ct.id = c.clientTypeFk - WHERE t.shipped BETWEEN CURDATE() AND util.dayend(CURDATE()) + WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) AND ISNULL(st.saleFk) AND ct.code IN ('normal', 'trust') GROUP BY s.itemFk @@ -58683,7 +58525,7 @@ BEGIN UNION ALL SELECT item_id, sum(iei.amount), dat FROM vn2008.item_entry_in iei - WHERE dat >= CURDATE() + WHERE dat >= util.VN_CURDATE() AND warehouse_id = vWarehouseFk AND isVirtualStock = FALSE GROUP BY item_id, dat @@ -58697,7 +58539,7 @@ BEGIN SELECT i.itemFk, sum(io.amount), dat FROM vn2008.item_out io JOIN tmp.item i ON i.itemFk = io.item_id - WHERE io.dat >= CURDATE() + WHERE io.dat >= util.VN_CURDATE() AND io.warehouse_id = vWarehouseFk GROUP BY io.item_id, io.dat ) t2 @@ -58866,7 +58708,7 @@ BEGIN SELECT itemFk, SUM(quantity) stock, SUM(quantity) visible, SUM(quantity) available FROM ( SELECT itemFk, quantity FROM itemTicketOut - WHERE shipped >= CURDATE() AND shipped < vDated + WHERE shipped >= util.VN_CURDATE() AND shipped < vDated AND warehouseFk = vWarehouseFk AND (vItemFk IS NULL OR itemFk = vItemFk) UNION ALL @@ -58880,7 +58722,7 @@ BEGIN UNION ALL SELECT itemFk, quantity FROM itemEntryOut - WHERE shipped >= CURDATE() AND shipped < vDated + WHERE shipped >= util.VN_CURDATE() AND shipped < vDated AND warehouseOutFk = vWarehouseFk AND (vItemFk IS NULL OR itemFk = vItemFk) ) t @@ -59128,7 +58970,7 @@ BEGIN SELECT s.itemFk, SUM(s.quantity) AS total, v.tipo_id typeFk FROM vn.sale s INNER JOIN bs.ventas v ON v.Id_Movimiento = s.id - WHERE v.fecha BETWEEN TIMESTAMPADD(DAY, - 7, CURDATE()) AND CURDATE() + WHERE v.fecha BETWEEN TIMESTAMPADD(DAY, - 7, util.VN_CURDATE()) AND util.VN_CURDATE() GROUP BY s.itemFk; DROP TABLE IF EXISTS tmp.topSeller; @@ -59206,7 +59048,7 @@ BEGIN JOIN address a ON a.id=t.addressFk WHERE t.warehouseFk = vWarehouseFk AND t.clientFk = vClientFk - AND DATE(t.shipped) = CURDATE() + AND DATE(t.shipped) = util.VN_CURDATE() AND a.isDefaultAddress LIMIT 1; @@ -59577,7 +59419,7 @@ DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getBalance`(IN vItemId int, IN vWarehouse int) BEGIN DECLARE vDateInventory DATETIME; - DECLARE vCurdate DATE DEFAULT CURDATE(); + DECLARE vCurdate DATE DEFAULT util.VN_CURDATE(); DECLARE vDayEnd DATETIME DEFAULT util.dayEnd(vCurdate); SELECT inventoried INTO vDateInventory FROM config; @@ -59625,8 +59467,8 @@ BEGIN JOIN supplier s ON s.id = e.supplierFk JOIN alertLevel al ON al.id = CASE - WHEN tr.landed < CURDATE() THEN 3 - WHEN tr.landed = CURDATE() AND tr.isReceived = TRUE THEN 3 + WHEN tr.landed < util.VN_CURDATE() THEN 3 + WHEN tr.landed = util.VN_CURDATE() AND tr.isReceived = TRUE THEN 3 ELSE 0 END JOIN state st ON st.code = al.code @@ -59659,8 +59501,8 @@ BEGIN JOIN supplier s ON s.id = e.supplierFk JOIN alertLevel al ON al.id = CASE - WHEN tr.shipped < CURDATE() THEN 3 - WHEN tr.shipped = CURDATE() AND tr.isReceived = TRUE THEN 3 + WHEN tr.shipped < util.VN_CURDATE() THEN 3 + WHEN tr.shipped = util.VN_CURDATE() AND tr.isReceived = TRUE THEN 3 ELSE 0 END JOIN state st ON st.code = al.code @@ -59696,8 +59538,8 @@ BEGIN JOIN clientType ct ON ct.id = c.clientTypeFk JOIN alertLevel al ON al.id = CASE - WHEN t.shipped < curdate() THEN 3 - WHEN t.shipped > util.dayEnd(curdate()) THEN 0 + WHEN t.shipped < util.VN_CURDATE() THEN 3 + WHEN t.shipped > util.dayEnd(util.VN_CURDATE()) THEN 0 ELSE IFNULL(ts.alertLevel, 0) END LEFT JOIN state stPrep ON stPrep.`code` = 'PREPARED' @@ -59819,7 +59661,7 @@ BEGIN **/ CALL `cache`.stock_refresh(vForce); - CALL item_getMinacum(NULL, CURDATE(), vDays, NULL); + CALL item_getMinacum(NULL, util.VN_CURDATE(), vDays, NULL); CALL item_getMinETD(); SELECT i.id itemFk, @@ -60115,7 +59957,7 @@ BEGIN WHERE i.warehouseFk = vWarehouse AND (vItem IS NULL OR i.itemFk = vItem) AND (s.isPicked OR i.reserved OR stPrevious.saleFk ) - AND i.shipped >= CURDATE() AND i.shipped < vTomorrow + AND i.shipped >= util.VN_CURDATE() AND i.shipped < vTomorrow UNION ALL SELECT iei.itemFk, quantity FROM itemEntryIn iei @@ -60128,7 +59970,7 @@ BEGIN SELECT itemFk, quantity FROM itemEntryOut WHERE isDelivered != FALSE - AND shipped >= CURDATE() AND shipped < vTomorrow + AND shipped >= util.VN_CURDATE() AND shipped < vTomorrow AND warehouseOutFk = vWarehouse AND (vItem IS NULL OR itemFk = vItem) ) t @@ -60667,7 +60509,7 @@ BEGIN JOIN itemType t ON t.id = i.typeFk JOIN warehouse w ON w.id = tr.warehouseInFk WHERE tr.landed BETWEEN vInventoried AND vDateDayEnd - AND IF(tr.landed = CURDATE(), tr.isReceived, trUE) + AND IF(tr.landed = util.VN_CURDATE(), tr.isReceived, trUE) AND NOT e.isRaid AND w.valuatedInventory AND t.isInventory @@ -60700,7 +60542,7 @@ BEGIN AND it.isInventory ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + s.quantity * IF(vHasNotInventory,1,-1); - IF vDated = CURDATE() THEN -- volver a poner lo que esta aun en las estanterias + IF vDated = util.VN_CURDATE() THEN -- volver a poner lo que esta aun en las estanterias INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen) SELECT w.id, s.itemFk, s.quantity * IF(vHasNotInventory,0,1), w.`name` @@ -61249,7 +61091,7 @@ BEGIN SELECT COUNT(*) INTO vIsRepeated FROM vn.mail - WHERE creationDate >= CURDATE() + WHERE creationDate >= util.VN_CURDATE() AND `receiver` = vReceiver AND `replyTo` = vReplyTo AND `subject` = vSubject @@ -61371,7 +61213,7 @@ BEGIN */ DECLARE vWorkerIsExcluded BOOLEAN; DECLARE vFromDated DATE; - DECLARE vToDated DATE DEFAULT TIMESTAMPADD(DAY,1,CURDATE()); + DECLARE vToDated DATE DEFAULT TIMESTAMPADD(DAY,1,util.VN_CURDATE()); DECLARE vMana INT; DECLARE vAutoMana INT; DECLARE vClaimMana INT; @@ -62302,7 +62144,7 @@ BEGIN DECLARE vCalcFk INT; DECLARE vWarehouseFk INT; DECLARE vWarehouseAliasFk INT; - DECLARE vCurrentYear INT DEFAULT YEAR(NOW()); + DECLARE vCurrentYear INT DEFAULT YEAR(util.VN_NOW()); DROP TEMPORARY TABLE IF EXISTS tmp.sale; CREATE TEMPORARY TABLE tmp.sale @@ -62385,7 +62227,7 @@ BEGIN ish.visible, IF(ts.isStowaway, - 100000, IF(ish.visible > 0 OR iss.id, 1, 100000)) * p.pickingOrder as `order`, IFNULL(IF(sc.isPreviousPreparedByPacking, ish.packing, g.`grouping`),1) as `grouping`, - IF(iss.id, TO_SECONDS(TIMESTAMPADD(YEAR,-vCurrentYear,iss.created)), TO_SECONDS(TIMESTAMPADD(YEAR,- year(ish.created),ish.created)) + TO_SECONDS(TIMESTAMPADD(YEAR,-vCurrentYear,NOW()))) as priority, + IF(iss.id, TO_SECONDS(TIMESTAMPADD(YEAR,-vCurrentYear,iss.created)), TO_SECONDS(TIMESTAMPADD(YEAR,- year(ish.created),ish.created)) + TO_SECONDS(TIMESTAMPADD(YEAR,-vCurrentYear,util.VN_NOW()))) as priority, 0 as saleOrder, sc.isPreviousPrepared, iss.id as itemShelvingSaleFk, @@ -62506,11 +62348,11 @@ BEGIN JOIN vn.client c ON c.id = t.clientFk WHERE c.typeFk IN ('normal','handMaking','internalUse') AND ( - t.shipped BETWEEN CURDATE() AND vEndingDate + t.shipped BETWEEN util.VN_CURDATE() AND vEndingDate OR ( ts.alertLevel < 3 AND t.shipped >= vStartingDate - AND t.shipped < CURDATE() + AND t.shipped < util.VN_CURDATE() ) ); END ;; @@ -62856,7 +62698,7 @@ BEGIN FROM vn.sale s JOIN vn.item i ON i.id = s.itemFk JOIN vn.ticket t ON t.id = s.ticketFk - WHERE t.shipped BETWEEN CURDATE() AND TIMESTAMPADD(HOUR, 23, CURDATE()) + WHERE t.shipped BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(HOUR, 23, util.VN_CURDATE()) GROUP BY s.ticketFk HAVING saleNum = iptNull; @@ -62868,7 +62710,7 @@ BEGIN JOIN vn.item i ON i.id = s.itemFk JOIN vn.ticket t ON t.id = s.ticketFk JOIN vn.sector sc ON sc.id = vSectorFk - WHERE t.shipped BETWEEN CURDATE() AND TIMESTAMPADD(HOUR, 23, CURDATE()) + WHERE t.shipped BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(HOUR, 23, util.VN_CURDATE()) GROUP BY s.ticketFk HAVING iptSector; @@ -63408,13 +63250,13 @@ BEGIN ) SELECT vCustomer, - CURDATE(), + util.VN_CURDATE(), vAddress, vRefundAgencyMode, a.nickname, vWarehouse, vCompany, - CURDATE(), + util.VN_CURDATE(), vZoneFk FROM address a WHERE a.id = vAddress; @@ -63614,7 +63456,7 @@ UPDATE ticket mt SELECT tt.addressFk, ROUND(IFNULL(AVG(t.priority),0),0) AS priority FROM ticket t JOIN ticket tt ON tt.addressFk = t.addressFk - WHERE t.shipped > TIMESTAMPADD(YEAR,-1,CURDATE()) + WHERE t.shipped > TIMESTAMPADD(YEAR,-1,util.VN_CURDATE()) AND tt.routeFk = vRuta GROUP BY addressFk ) sub ON sub.addressFk = mt.addressFk @@ -64330,7 +64172,7 @@ proc: BEGIN UPDATE vn.saleGroup sg SET sg.parkingFk = vParkingFk WHERE sg.id = vSaleGroupFk - AND sg.created >= TIMESTAMPADD(WEEK,-1,CURDATE()); + AND sg.created >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); CALL vn.ticket_setNextState(vn.ticket_get(vSaleGroupFk)); END ;; @@ -65163,10 +65005,10 @@ BEGIN DECLARE vComponentCount INT; DECLARE vCursor CURSOR FOR - SELECT DISTINCT tt.warehouseFk, IF(vIsTodayRelative, CURDATE(), date(tt.shipped)) + SELECT DISTINCT tt.warehouseFk, IF(vIsTodayRelative, util.VN_CURDATE(), date(tt.shipped)) FROM tmp.sale_getProblems tt - WHERE DATE(tt.shipped) BETWEEN CURDATE() - AND TIMESTAMPADD(DAY, IF(vIsTodayRelative, 9.9, 1.9), CURDATE()); + WHERE DATE(tt.shipped) BETWEEN util.VN_CURDATE() + AND TIMESTAMPADD(DAY, IF(vIsTodayRelative, 9.9, 1.9), util.VN_CURDATE()); DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = 1; @@ -65215,12 +65057,12 @@ BEGIN FROM tmp.ticket_list tl JOIN vn.saleVolume sv ON sv.ticketFk = tl.ticketFk JOIN vn.ticket t ON t.id = tl.ticketFk - JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk AND zc.dated = CURDATE() + JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk AND zc.dated = util.VN_CURDATE() JOIN vn.agencyMode am ON am.id = t.agencyModeFk JOIN vn.deliveryMethod dm ON dm.id = am.deliveryMethodFk - WHERE NOW() < TIMESTAMPADD(MINUTE,MINUTE(zc.`hour`) ,TIMESTAMPADD(HOUR,HOUR(zc.`hour`),CURDATE())) + WHERE util.VN_NOW() < TIMESTAMPADD(MINUTE,MINUTE(zc.`hour`) ,TIMESTAMPADD(HOUR,HOUR(zc.`hour`),util.VN_CURDATE())) AND dm.code IN('AGENCY','DELIVERY','PICKUP') - AND t.shipped BETWEEN CURDATE() AND util.midnight() + AND t.shipped BETWEEN util.VN_CURDATE() AND util.midnight() GROUP BY t.addressFk) sub ON sub.addressFk = t.addressFk JOIN vn.volumeConfig vc WHERE sub.litros < vc.minTicketVolume @@ -65255,7 +65097,7 @@ BEGIN SELECT DISTINCT clientFk FROM tmp.ticket_list; - CALL clientGetDebt(CURDATE()); + CALL clientGetDebt(util.VN_CURDATE()); INSERT INTO tmp.sale_problems(ticketFk, risk, hasHighRisk) SELECT DISTINCT tl.ticketFk, r.risk, ((r.risk - cc.riskTolerance) > c.credit + 10) @@ -65332,7 +65174,7 @@ BEGIN AND ic.merchandise = TRUE AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate) AND NOT i.generic - AND CURDATE() = vDate + AND util.VN_CURDATE() = vDate AND t.warehouseFk = vWarehouseFk GROUP BY tl.ticketFk) sub ON DUPLICATE KEY UPDATE itemShortage = sub.problem, saleFk = sub.saleFk; @@ -65358,7 +65200,7 @@ BEGIN AND ic.merchandise = TRUE AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate) AND NOT i.generic - AND CURDATE() = vDate + AND util.VN_CURDATE() = vDate AND t.warehouseFk = vWarehouseFk GROUP BY tl.ticketFk) sub ON DUPLICATE KEY UPDATE itemDelay = sub.problem, saleFk = sub.saleFk; @@ -65386,7 +65228,7 @@ BEGIN AND ic.merchandise = TRUE AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate) AND NOT i.generic - AND CURDATE() = vDate + AND util.VN_CURDATE() = vDate AND t.warehouseFk = vWarehouseFk GROUP BY tl.ticketFk) sub ON DUPLICATE KEY UPDATE itemDelay = sub.problem, saleFk = sub.saleFk; @@ -65872,7 +65714,7 @@ BEGIN WHERE ISNULL(scsg.id) AND sc.userFk = vUserFk AND sc.sectorFk = vSectorFk - AND sc.created >= CURDATE(); + AND sc.created >= util.VN_CURDATE(); IF NOT hasEmptyCollections THEN INSERT INTO vn.sectorCollection(userFk, sectorFk) @@ -66068,7 +65910,7 @@ proc: BEGIN SELECT COUNT(*) INTO vIsTicket FROM vn.ticket t WHERE t.id = vParam - AND t.shipped >= TIMESTAMPADD(WEEK,-1,CURDATE()); + AND t.shipped >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); IF vIsTicket THEN CALL vn.ticket_setParking(vParam, vParkingFk); @@ -66224,7 +66066,7 @@ proc: BEGIN SELECT COUNT(*) INTO vIsTicket FROM vn.ticket t WHERE t.id = vParam - AND t.shipped >= TIMESTAMPADD(WEEK,-1,CURDATE()); + AND t.shipped >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); IF vIsTicket THEN @@ -66280,7 +66122,7 @@ proc: BEGIN WHERE s.code = vParam COLLATE utf8_unicode_ci; UPDATE vn.shelving - SET parkingFk = vParkingFk, parked = NOW(), isPrinted = TRUE + SET parkingFk = vParkingFk, parked = util.VN_NOW(), isPrinted = TRUE WHERE `code` = vParam COLLATE utf8_unicode_ci; END ;; @@ -66365,13 +66207,13 @@ BEGIN DELETE FROM vn.itemShelving WHERE visible <= 0 - AND created < TIMESTAMPADD(MONTH,-1,CURDATE()); + AND created < TIMESTAMPADD(MONTH,-1,util.VN_CURDATE()); DELETE ish.* FROM vn.itemShelving ish JOIN vn.shelving sh ON sh.code = ish.shelvingFk WHERE sh.parkingFk IS NULL - AND ish.created < TIMESTAMPADD(WEEK,-1,CURDATE()); + AND ish.created < TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); UPDATE vn.shelving sh LEFT JOIN vn.itemShelving its ON its.shelvingFk = sh.`code` @@ -66438,14 +66280,14 @@ BEGIN LEFT JOIN ( SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as venta FROM vn2008.item_out - WHERE dat BETWEEN CURDATE() AND util.dayend(vDated) + WHERE dat BETWEEN util.VN_CURDATE() AND util.dayend(vDated) AND warehouse_id = vWarehouseFk GROUP BY item_id ) sale ON sale.item_id = i.id LEFT JOIN ( SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as compra FROM vn2008.item_entry_in - WHERE dat BETWEEN CURDATE() AND util.dayend(vDated) + WHERE dat BETWEEN util.VN_CURDATE() AND util.dayend(vDated) AND warehouse_id = vWarehouseFk AND isVirtualStock = FALSE GROUP BY item_id @@ -66453,7 +66295,7 @@ BEGIN LEFT JOIN ( SELECT item_id, CAST(sum(amount)AS DECIMAL(10,0)) as traslado FROM vn2008.item_entry_out - WHERE dat BETWEEN CURDATE() AND util.dayend(vDated) + WHERE dat BETWEEN util.VN_CURDATE() AND util.dayend(vDated) AND warehouse_id = vWarehouseFk GROUP BY item_id ) mov ON mov.item_id = i.id @@ -66514,7 +66356,7 @@ proc: BEGIN WHERE s.code = vShelvingCode COLLATE utf8_unicode_ci; UPDATE vn.shelving - SET parkingFk = vParkingFk, parked = NOW(), isPrinted = TRUE + SET parkingFk = vParkingFk, parked = util.VN_NOW(), isPrinted = TRUE WHERE code = vShelvingCode COLLATE utf8_unicode_ci; END ;; DELIMITER ; @@ -67166,7 +67008,7 @@ BEGIN FROM vn.payment p LEFT JOIN vn.supplier s ON s.id = p.supplierFk LEFT JOIN vn.payMethod pm ON pm.id = s.payMethodFk - WHERE p.created < (CURDATE() - INTERVAL pm.graceMonthsDisableChecked MONTH) + WHERE p.created < (util.VN_CURDATE() - INTERVAL pm.graceMonthsDisableChecked MONTH) AND pm.graceMonthsDisableChecked AND s.isPayMethodChecked GROUP BY p.supplierFk) sdpmc ON sdpmc.supplierFk = s.id @@ -68163,10 +68005,10 @@ BEGIN WHERE t.id = vTicket; IF vAlertLevel IS NULL OR vAlertLevel = 0 THEN - IF vShipped >= CURDATE() THEN + IF vShipped >= util.VN_CURDATE() THEN CALL cache.available_refresh(vAvailableCalc, FALSE, vWarehouse, vShipped); END IF; - IF vShipped = CURDATE() THEN + IF vShipped = util.VN_CURDATE() THEN CALL cache.visible_refresh(vVisibleCalc, FALSE, vWarehouse); END IF; END IF; @@ -69133,11 +68975,11 @@ BEGIN LEFT JOIN (SELECT tc.collectionFk FROM ticketCollection tc WHERE ticketFk = vTicketFk - AND tc.created >= CURDATE() + AND tc.created >= util.VN_CURDATE() )sub ON sub.collectionFk = tc.collectionFk WHERE ts.workerFk = vWorkerFk AND sub.collectionFk IS NULL - AND tc.created >= CURDATE() + AND tc.created >= util.VN_CURDATE() GROUP BY tc.collectionFk )sub ON sub.collectionFk = tc.collectionFk JOIN ticketState ts ON ts.ticketFk = t.id @@ -69863,7 +69705,7 @@ BEGIN CREATE TEMPORARY TABLE tmp.ticket SELECT ticketFk FROM tmp.productionBuffer - WHERE shipped = curdate() + WHERE shipped = util.VN_CURDATE() AND problem LIKE '%I:%' AND (HH <= vHour OR HH = vHour AND mm < vMinute) AND alertLevel = 0; @@ -70472,7 +70314,7 @@ BEGIN DECLARE vAvailableCache INT; DECLARE vVisibleCache INT; - CALL cache.available_refresh(vAvailableCache, FALSE, vWarehouseFk, CURDATE()); + CALL cache.available_refresh(vAvailableCache, FALSE, vWarehouseFk, util.VN_CURDATE()); CALL cache.visible_refresh(vVisibleCache, FALSE, vWarehouseFk); CALL `vn`.`zoneClosure_recalc`(); @@ -70499,7 +70341,7 @@ BEGIN AND s.isPicked = FALSE AND s.reserved = FALSE AND ic.merchandise = TRUE - AND t.shipped BETWEEN CURDATE() AND util.dayend(CURDATE()) + AND t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) AND NOT i.generic AND t.warehouseFk = vWarehouseFk; @@ -70518,7 +70360,7 @@ BEGIN AND s.isPicked = FALSE AND s.reserved = FALSE AND ic.merchandise = TRUE - AND t.shipped BETWEEN CURDATE() AND util.dayend(CURDATE()) + AND t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) AND NOT i.generic AND t.warehouseFk = vWarehouseFk; @@ -70539,7 +70381,7 @@ BEGIN AND s.isPicked = FALSE AND s.reserved = FALSE AND ic.merchandise = TRUE - AND t.shipped BETWEEN CURDATE() AND util.dayend(CURDATE()) + AND t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) AND NOT i.generic AND t.warehouseFk = vWarehouseFk; @@ -71247,7 +71089,7 @@ proc:BEGIN UPDATE vn.ticket SET landed = vDated + 1, shipped = vDated, - nickname = CONCAT('(',DAY(curdate()),') ', nickname ) + nickname = CONCAT('(',DAY(util.VN_CURDATE()),') ', nickname ) WHERE id = vTicketFk; SELECT CONCAT("Se ha cambiado el ticket ", vTicketFk, " al dia ", vDated); @@ -72250,7 +72092,7 @@ BEGIN FROM hedera.tpvTransaction t WHERE t.receiptFk IS NULL AND t.status = 'ok' - AND t.created < DATE_ADD(NOW(),INTERVAL - 2 DAY) + AND t.created < DATE_ADD(util.VN_NOW(),INTERVAL - 2 DAY) GROUP BY t.clientFk; END ;; @@ -72777,7 +72619,7 @@ BEGIN DECLARE vDone BOOLEAN DEFAULT FALSE; DECLARE vRsTravel CURSOR FOR SELECT travelFk, - @a := TIMESTAMPADD(DAY,vCounter * 7 - WEEKDAY(CURDATE()) - 1 + weekDay,CURDATE()), + @a := TIMESTAMPADD(DAY,vCounter * 7 - WEEKDAY(util.VN_CURDATE()) - 1 + weekDay,util.VN_CURDATE()), @a := TIMESTAMPADD(DAY,duration,@a), warehouseOutFk, warehouseInFk, @@ -73351,7 +73193,7 @@ DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workerDisable`(vUserId int) mainLabel:BEGIN - IF (SELECT COUNT(*) FROM workerDisableExcluded WHERE workerFk = vUserId AND (dated > CURDATE() OR dated IS NULL)) > 0 THEN + IF (SELECT COUNT(*) FROM workerDisableExcluded WHERE workerFk = vUserId AND (dated > util.VN_CURDATE() OR dated IS NULL)) > 0 THEN LEAVE mainLabel; END IF; DELETE FROM account.account @@ -73708,7 +73550,6 @@ BEGIN AND NOT isUpdated AND night.NigthlyHours <> 0; - -- Horas téoricas y precio de la hora ordinaria UPDATE workerJourney wj JOIN business b ON b.id = wj.businessFk @@ -74145,7 +73986,7 @@ BEGIN @cont cont, @lastUserFk := userFk FROM workerTimeControl wtc - WHERE wtc.timed BETWEEN TIMESTAMPADD(YEAR,-1,CURDATE()) AND util.dayEnd(CURDATE()) + WHERE wtc.timed BETWEEN TIMESTAMPADD(YEAR,-1,util.VN_CURDATE()) AND util.dayEnd(util.VN_CURDATE()) ORDER BY userFk, timed LIMIT 10000000000000000000)sub GROUP BY cont @@ -75034,7 +74875,7 @@ BEGIN * @return (name, surname, userFk, departmentFk, button1, button2) * Los valores posibles para button son ('in', 'inMiddle', 'outMiddle', 'out') */ - CALL vn.workerTimeControl_direction(vWorkerFk, NOW()); + CALL vn.workerTimeControl_direction(vWorkerFk, util.VN_NOW()); SELECT wi.name, wi.surname, @@ -75764,7 +75605,7 @@ BEGIN FROM workerTimeControl WHERE timed >= vDated AND userFk = vUserFk; SET @day := 0; - SET @lastTimed := NOW(); + SET @lastTimed := util.VN_NOW(); SELECT SUM(IF(interval_in_minutes >= v12hoursInMinutes,1,0)), SUM(FLOOR(interval_in_minutes/ v36hoursInMinutes)) , SUM(jornadas) INTO vDescansos12h, vDescansos36h, vJornadas @@ -76388,7 +76229,7 @@ DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workingHoursTimeIn`(vUserId INT(11)) BEGIN INSERT INTO vn.workingHours (timeIn, userId) - VALUES (NOW(),vUserId); + VALUES (util.VN_NOW(),vUserId); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -76408,9 +76249,9 @@ DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `workingHoursTimeOut`(vUserId INT(11)) BEGIN UPDATE vn.workingHours - SET timeOut = NOW() + SET timeOut = util.VN_NOW() WHERE userId = vUserId - AND DATE(timeIn) = CURDATE(); + AND DATE(timeIn) = util.VN_CURDATE(); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -76474,7 +76315,7 @@ proc: BEGIN */ DECLARE vScope INT; DECLARE vCounter INT DEFAULT 0; - DECLARE vShipped DATE DEFAULT CURDATE(); + DECLARE vShipped DATE DEFAULT util.VN_CURDATE(); DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN @@ -76927,7 +76768,7 @@ proc:BEGIN JOIN vn.productionConfig pc WHERE a.isOwn AND pc.isZoneClosedByExpeditionActivated - AND e.created >= CURDATE() + AND e.created >= util.VN_CURDATE() GROUP BY t.zoneFk, t.warehouseFk HAVING numTickets >= minTicketsToCloseZone) sub; END ;; @@ -76969,7 +76810,7 @@ BEGIN JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk WHERE dm.code IN ('AGENCY','DELIVERY'); - CALL zone_getOptionsForShipment(CURDATE(),FALSE); + CALL zone_getOptionsForShipment(util.VN_CURDATE(),FALSE); DROP TEMPORARY TABLE IF EXISTS tmp.zoneNodes; CREATE TEMPORARY TABLE tmp.zoneNodes ( @@ -77037,7 +76878,7 @@ BEGIN INSERT INTO mail (receiver,replyTo,subject,body) SELECT 'pepe@verdnatura.es' receiver, 'noreply@verdnatura.es' replyTo, - CONCAT('Colisiones en zonas ', CURDATE()) subject, + CONCAT('Colisiones en zonas ', util.VN_CURDATE()) subject, CONCAT(vTableCollisions, GROUP_CONCAT(sub.td SEPARATOR ''), '') body @@ -77263,7 +77104,7 @@ BEGIN LEFT JOIN tmp.closedZones cz ON cz.warehouseFk = zw.warehouseFk AND cz.zoneFk = zw.zoneFk - AND zo.shipped = CURDATE() + AND zo.shipped = util.VN_CURDATE() WHERE z.agencyModeFk = vAgencyModeFk AND zw.warehouseFk = vWarehouseFk AND (ISNULL(cz.zoneFk) OR vShowExpiredZones); @@ -77572,8 +77413,8 @@ BEGIN IF NOT vShowExpiredZones THEN DELETE FROM tmp.zoneOption - WHERE shipped < CURDATE() - OR (shipped = CURDATE() AND CURTIME() > `hour`); + WHERE shipped < util.VN_CURDATE() + OR (shipped = util.VN_CURDATE() AND util.VN_CURTIME() > `hour`); END IF; END ;; DELIMITER ; @@ -77660,8 +77501,8 @@ BEGIN IF NOT vShowExpiredZones THEN DELETE FROM tmp.zoneOption - WHERE vShipped < CURDATE() - OR (vShipped = CURDATE() AND CURTIME() > `hour`); + WHERE vShipped < util.VN_CURDATE() + OR (vShipped = util.VN_CURDATE() AND util.VN_CURTIME() > `hour`); END IF; END ;; DELIMITER ; @@ -77716,7 +77557,7 @@ BEGIN LEFT JOIN tmp.closedZones cz ON cz.warehouseFk = zw.warehouseFk AND cz.zoneFk = zw.zoneFk - AND zo.shipped = CURDATE() + AND zo.shipped = util.VN_CURDATE() WHERE z.agencyModeFk = vAgencyModeFk AND (ISNULL(cz.zoneFk) OR vShowExpiredZones) ORDER BY shipped @@ -77766,7 +77607,7 @@ BEGIN SELECT zo.zoneFk, zo.`hour`etd, - (zo.`hour` <= TIME(now())) isLate, + (zo.`hour` <= TIME(util.VN_NOW())) isLate, !ISNULL(cz.zoneFk) isFull, zw.warehouseFk, zo.landed @@ -77854,7 +77695,7 @@ BEGIN DECLARE vForwardDays INT; SELECT forwardDays INTO vForwardDays FROM zoneConfig; - CALL util.time_createTable(CURDATE(), DATE_ADD(CURDATE(), INTERVAL vForwardDays DAY)); + CALL util.time_createTable(util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL vForwardDays DAY)); DROP TEMPORARY TABLE IF EXISTS tLandings; CREATE TEMPORARY TABLE tLandings @@ -77866,7 +77707,7 @@ BEGIN ti.dated shipped FROM zone z JOIN zoneEvent e ON e.zoneFk = z.id - JOIN tmp.time ti ON ti.dated BETWEEN curdate() AND TIMESTAMPADD(DAY, vForwardDays, curdate()); + JOIN tmp.time ti ON ti.dated BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(DAY, vForwardDays, util.VN_CURDATE()); DROP TEMPORARY TABLE IF EXISTS tmp.zoneOption; CREATE TEMPORARY TABLE tmp.zoneOption @@ -78164,7 +78005,7 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `clean`() BEGIN - DECLARE vDate DATETIME DEFAULT TIMESTAMPADD(MONTH, -2, CURDATE()); + DECLARE vDate DATETIME DEFAULT TIMESTAMPADD(MONTH, -2, util.VN_CURDATE()); DELETE i FROM inter i JOIN vn.ticket t ON i.Id_Ticket = t.id WHERE t.shipped <= vDate; END ;; diff --git a/modules/shelving/back/model-config.json b/modules/shelving/back/model-config.json index 742eae70a..c26c39d38 100644 --- a/modules/shelving/back/model-config.json +++ b/modules/shelving/back/model-config.json @@ -11,4 +11,4 @@ "Sector": { "dataSource": "vn" } -} +} \ No newline at end of file diff --git a/modules/ticket/back/methods/packaging/specs/listPackaging.spec.js b/modules/ticket/back/methods/packaging/specs/listPackaging.spec.js index e1fdeb0c5..1b5892e04 100644 --- a/modules/ticket/back/methods/packaging/specs/listPackaging.spec.js +++ b/modules/ticket/back/methods/packaging/specs/listPackaging.spec.js @@ -1,7 +1,6 @@ const models = require('vn-loopback/server/server').models; -// 4376 -xdescribe('ticket listPackaging()', () => { +describe('ticket listPackaging()', () => { it('should return the packaging', async() => { const tx = await models.Packaging.beginTransaction({});