Merge branch '#2037-worked-hours' of verdnatura/salix into dev
gitea/salix/dev This commit looks good
Details
gitea/salix/dev This commit looks good
Details
This commit is contained in:
commit
9fd28bd0ca
|
@ -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 +5 DAY)),
|
||||||
(8, 'day', DATE_ADD(CURDATE(), INTERVAL +6 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
|
VALUES
|
||||||
(106, CONCAT(CURDATE(), ' 07:00'), 1, TRUE, 'in'),
|
(106, CONCAT(CURDATE(), ' 07:00'), TRUE, 'in'),
|
||||||
(106, CONCAT(CURDATE(), ' 10:00'), 2, TRUE, 'middle'),
|
(106, CONCAT(CURDATE(), ' 10:00'), TRUE, 'middle'),
|
||||||
(106, CONCAT(CURDATE(), ' 10:10'), 3, TRUE, 'middle'),
|
(106, CONCAT(CURDATE(), ' 10:10'), TRUE, 'middle'),
|
||||||
(106, CONCAT(CURDATE(), ' 15:00'), 4, TRUE, 'out');
|
(106, CONCAT(CURDATE(), ' 15:00'), TRUE, 'out');
|
||||||
|
|
||||||
INSERT INTO `vn`.`dmsType`(`id`, `name`, `path`, `readRoleFk`, `writeRoleFk`, `code`)
|
INSERT INTO `vn`.`dmsType`(`id`, `name`, `path`, `readRoleFk`, `writeRoleFk`, `code`)
|
||||||
VALUES
|
VALUES
|
||||||
|
|
|
@ -23,13 +23,10 @@ describe('Directive vnId', () => {
|
||||||
}).toThrow(new Error(`vnId: Attribute can't be null`));
|
}).toThrow(new Error(`vnId: Attribute can't be null`));
|
||||||
});
|
});
|
||||||
|
|
||||||
// FIXME: Sometimes fails with '$scope is undefined'
|
it(`should set the controller into the $scope as there are no errors being thrown`, () => {
|
||||||
xit(`should set the controller into the $scope as there are no errors being thrown`, () => {
|
let html = `<form vn-id="myId"></form>`;
|
||||||
let html = `<form vn-id="1"></form>`;
|
|
||||||
|
|
||||||
expect($scope['1']).not.toBeDefined();
|
|
||||||
compile(html);
|
compile(html);
|
||||||
|
|
||||||
expect($scope['1']).toBeDefined();
|
expect($scope.myId).toBeDefined();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -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 conn = Self.dataSource.connector;
|
||||||
const stmts = [];
|
const stmts = [];
|
||||||
|
const startedMinusOne = new Date();
|
||||||
|
const endedPlusOne = new Date();
|
||||||
let worker = await Self.app.models.Worker.findById(id);
|
let worker = await Self.app.models.Worker.findById(id);
|
||||||
let userId = worker.userFk;
|
let userId = worker.userFk;
|
||||||
|
|
||||||
|
@ -45,14 +46,16 @@ module.exports = Self => {
|
||||||
tmp.timeControlCalculate,
|
tmp.timeControlCalculate,
|
||||||
tmp.timeBusinessCalculate
|
tmp.timeBusinessCalculate
|
||||||
`);
|
`);
|
||||||
|
startedMinusOne.setDate(started.getDate() - 1);
|
||||||
stmts.push(new ParameterizedSQL('CALL vn.timeControl_calculateByUser(?, ?, ?)', [userId, from, to]));
|
endedPlusOne.setDate(ended.getDate() + 1);
|
||||||
stmts.push(new ParameterizedSQL('CALL vn.timeBusiness_calculateByUser(?, ?, ?)', [userId, from, to]));
|
stmts.push(new ParameterizedSQL('CALL vn.timeControl_calculateByUser(?, ?, ?)', [userId, startedMinusOne, endedPlusOne]));
|
||||||
let resultIndex = stmts.push(`
|
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
|
SELECT tbc.dated, tbc.timeWorkSeconds expectedHours, tcc.timeWorkSeconds workedHours
|
||||||
FROM tmp.timeBusinessCalculate tbc
|
FROM tmp.timeBusinessCalculate tbc
|
||||||
LEFT JOIN tmp.timeControlCalculate tcc ON tcc.dated = tbc.dated
|
LEFT JOIN tmp.timeControlCalculate tcc ON tcc.dated = tbc.dated
|
||||||
`) - 1;
|
WHERE tbc.dated BETWEEN ? AND ?
|
||||||
|
`, [started, ended])) - 1;
|
||||||
stmts.push(`
|
stmts.push(`
|
||||||
DROP TEMPORARY TABLE IF EXISTS
|
DROP TEMPORARY TABLE IF EXISTS
|
||||||
tmp.timeControlCalculate,
|
tmp.timeControlCalculate,
|
||||||
|
|
Loading…
Reference in New Issue