diff --git a/db/dump/mockDate.sql b/db/dump/mockDate.sql index 5334bbe81..6452b38da 100644 --- a/db/dump/mockDate.sql +++ b/db/dump/mockDate.sql @@ -7,7 +7,7 @@ CREATE FUNCTION `util`.`mockedDate`() RETURNS DATETIME DETERMINISTIC BEGIN - RETURN '2022-06-15 11:00:00'; + RETURN '2000-06-15 11:00:00'; END ;; DELIMITER ; diff --git a/loopback/server/boot/date.js b/loopback/server/boot/date.js index 27fbbd589..e56393437 100644 --- a/loopback/server/boot/date.js +++ b/loopback/server/boot/date.js @@ -2,7 +2,7 @@ module.exports = () => { Date.vnUTC = () => { const env = process.env.NODE_ENV; if (!env || env === 'development') - return new Date(Date.UTC(2022, 5, 15, 11)); + return new Date(Date.UTC(2000, 5, 15, 11)); return new Date(Date.UTC()); }; 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); diff --git a/modules/worker/back/methods/worker/specs/getWorkedHours.spec.js b/modules/worker/back/methods/worker/specs/getWorkedHours.spec.js index f5b06cc9e..a6117e68a 100644 --- a/modules/worker/back/methods/worker/specs/getWorkedHours.spec.js +++ b/modules/worker/back/methods/worker/specs/getWorkedHours.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -describe('Worker getWorkedHours()', () => { +fdescribe('Worker getWorkedHours()', () => { it(`should return the expected hours and the worked hours of a given date`, async() => { const workerID = 1106; const started = Date.vnNew();