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 +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
|
||||
|
|
|
@ -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 = `<form vn-id="1"></form>`;
|
||||
|
||||
expect($scope['1']).not.toBeDefined();
|
||||
it(`should set the controller into the $scope as there are no errors being thrown`, () => {
|
||||
let html = `<form vn-id="myId"></form>`;
|
||||
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 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,
|
||||
|
|
Loading…
Reference in New Issue