diff --git a/db/dump/mockDate.sql b/db/dump/mockDate.sql index e9a81eb86..937da071c 100644 --- a/db/dump/mockDate.sql +++ b/db/dump/mockDate.sql @@ -7,7 +7,7 @@ CREATE FUNCTION `util`.`mockedDate`() RETURNS DATETIME DETERMINISTIC BEGIN - RETURN '2001-01-01 11:00:00'; + RETURN CONVERT_TZ('2001-01-01 11:00:00', 'utc', 'Europe/Madrid'); END ;; DELIMITER ; diff --git a/modules/route/back/methods/route/updateWorkCenter.js b/modules/route/back/methods/route/updateWorkCenter.js index 7796fba41..75169ce7e 100644 --- a/modules/route/back/methods/route/updateWorkCenter.js +++ b/modules/route/back/methods/route/updateWorkCenter.js @@ -33,12 +33,13 @@ module.exports = Self => { } try { + const date = Date.vnNew(); const [result] = await Self.rawSql(` SELECT IFNULL(wl.workCenterFk, r.defaultWorkCenterFk) AS commissionWorkCenter FROM vn.routeConfig r LEFT JOIN vn.workerLabour wl ON wl.workerFk = ? - AND CURDATE() BETWEEN wl.started AND IFNULL(wl.ended, CURDATE()); - `, [userId], myOptions); + AND ? BETWEEN wl.started AND IFNULL(wl.ended, ?); + `, [userId, date, date], myOptions); const route = await models.Route.findById(id, null, myOptions); await route.updateAttribute('commissionWorkCenterFk', result.commissionWorkCenter, myOptions);