diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index bfa56eb26..f82a01334 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1879,12 +1879,12 @@ INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `dated`) (8, 'day', DATE_ADD(CURDATE(), INTERVAL +5 DAY)), (8, 'day', DATE_ADD(CURDATE(), INTERVAL +6 DAY)); -INSERT INTO `vn`.`workerTimeControl`(`userFk`, `timed`, `order`, `manual`, `direction`) +INSERT INTO `vn`.`workerTimeControl`(`userFk`, `timed`, `manual`, `direction`) VALUES - (106, CONCAT(CURDATE(), ' 07:00'), 1, TRUE, 'in'), - (106, CONCAT(CURDATE(), ' 10:00'), 2, TRUE, 'middle'), - (106, CONCAT(CURDATE(), ' 10:10'), 3, TRUE, 'middle'), - (106, CONCAT(CURDATE(), ' 15:00'), 4, TRUE, 'out'); + (106, CONCAT(CURDATE(), ' 07:00'), TRUE, 'in'), + (106, CONCAT(CURDATE(), ' 10:00'), TRUE, 'middle'), + (106, CONCAT(CURDATE(), ' 10:10'), TRUE, 'middle'), + (106, CONCAT(CURDATE(), ' 15:00'), TRUE, 'out'); INSERT INTO `vn`.`dmsType`(`id`, `name`, `path`, `readRoleFk`, `writeRoleFk`, `code`) VALUES diff --git a/front/core/directives/specs/id.spec.js b/front/core/directives/specs/id.spec.js index 9d400701a..171f09556 100644 --- a/front/core/directives/specs/id.spec.js +++ b/front/core/directives/specs/id.spec.js @@ -23,13 +23,10 @@ describe('Directive vnId', () => { }).toThrow(new Error(`vnId: Attribute can't be null`)); }); - // FIXME: Sometimes fails with '$scope is undefined' - xit(`should set the controller into the $scope as there are no errors being thrown`, () => { - let html = `
`; - - expect($scope['1']).not.toBeDefined(); + it(`should set the controller into the $scope as there are no errors being thrown`, () => { + let html = `
`; compile(html); - expect($scope['1']).toBeDefined(); + expect($scope.myId).toBeDefined(); }); }); diff --git a/modules/worker/back/methods/worker/getWorkedHours.js b/modules/worker/back/methods/worker/getWorkedHours.js index e96d30f8d..d5019bde7 100644 --- a/modules/worker/back/methods/worker/getWorkedHours.js +++ b/modules/worker/back/methods/worker/getWorkedHours.js @@ -33,10 +33,11 @@ module.exports = Self => { } }); - Self.getWorkedHours = async(id, from, to) => { + Self.getWorkedHours = async(id, started, ended) => { const conn = Self.dataSource.connector; const stmts = []; - + const startedMinusOne = new Date(); + const endedPlusOne = new Date(); let worker = await Self.app.models.Worker.findById(id); let userId = worker.userFk; @@ -45,14 +46,16 @@ module.exports = Self => { tmp.timeControlCalculate, tmp.timeBusinessCalculate `); - - stmts.push(new ParameterizedSQL('CALL vn.timeControl_calculateByUser(?, ?, ?)', [userId, from, to])); - stmts.push(new ParameterizedSQL('CALL vn.timeBusiness_calculateByUser(?, ?, ?)', [userId, from, to])); - let resultIndex = stmts.push(` + startedMinusOne.setDate(started.getDate() - 1); + endedPlusOne.setDate(ended.getDate() + 1); + stmts.push(new ParameterizedSQL('CALL vn.timeControl_calculateByUser(?, ?, ?)', [userId, startedMinusOne, endedPlusOne])); + stmts.push(new ParameterizedSQL('CALL vn.timeBusiness_calculateByUser(?, ?, ?)', [userId, startedMinusOne, endedPlusOne])); + let resultIndex = stmts.push(new ParameterizedSQL(` SELECT tbc.dated, tbc.timeWorkSeconds expectedHours, tcc.timeWorkSeconds workedHours FROM tmp.timeBusinessCalculate tbc LEFT JOIN tmp.timeControlCalculate tcc ON tcc.dated = tbc.dated - `) - 1; + WHERE tbc.dated BETWEEN ? AND ? + `, [started, ended])) - 1; stmts.push(` DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate,