fix: updateWorkCenter
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Alex Moreno 2023-01-25 15:29:01 +01:00
parent d77730dd47
commit 0a096bc96f
4 changed files with 6 additions and 5 deletions

View File

@ -7,7 +7,7 @@ CREATE FUNCTION `util`.`mockedDate`()
RETURNS DATETIME RETURNS DATETIME
DETERMINISTIC DETERMINISTIC
BEGIN BEGIN
RETURN '2022-06-15 11:00:00'; RETURN '2000-06-15 11:00:00';
END ;; END ;;
DELIMITER ; DELIMITER ;

View File

@ -2,7 +2,7 @@ module.exports = () => {
Date.vnUTC = () => { Date.vnUTC = () => {
const env = process.env.NODE_ENV; const env = process.env.NODE_ENV;
if (!env || env === 'development') 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()); return new Date(Date.UTC());
}; };

View File

@ -33,12 +33,13 @@ module.exports = Self => {
} }
try { try {
const date = Date.vnNew();
const [result] = await Self.rawSql(` const [result] = await Self.rawSql(`
SELECT IFNULL(wl.workCenterFk, r.defaultWorkCenterFk) AS commissionWorkCenter SELECT IFNULL(wl.workCenterFk, r.defaultWorkCenterFk) AS commissionWorkCenter
FROM vn.routeConfig r FROM vn.routeConfig r
LEFT JOIN vn.workerLabour wl ON wl.workerFk = ? LEFT JOIN vn.workerLabour wl ON wl.workerFk = ?
AND CURDATE() BETWEEN wl.started AND IFNULL(wl.ended, CURDATE()); AND ? BETWEEN wl.started AND IFNULL(wl.ended, ?);
`, [userId], myOptions); `, [userId, date, date], myOptions);
const route = await models.Route.findById(id, null, myOptions); const route = await models.Route.findById(id, null, myOptions);
await route.updateAttribute('commissionWorkCenterFk', result.commissionWorkCenter, myOptions); await route.updateAttribute('commissionWorkCenterFk', result.commissionWorkCenter, myOptions);

View File

@ -1,6 +1,6 @@
const models = require('vn-loopback/server/server').models; 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() => { it(`should return the expected hours and the worked hours of a given date`, async() => {
const workerID = 1106; const workerID = 1106;
const started = Date.vnNew(); const started = Date.vnNew();