fix(updateWorkCenter): use vnNew()
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2023-02-02 14:52:40 +01:00
parent 6c772643a8
commit 8a50c56284
2 changed files with 4 additions and 3 deletions

View File

@ -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 ;

View File

@ -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);