Merge branch '1891-worker_time_control_tests' of verdnatura/salix into dev
gitea/salix/dev This commit looks good
Details
gitea/salix/dev This commit looks good
Details
Joan: LGTM
This commit is contained in:
commit
0733ef8949
|
@ -0,0 +1,73 @@
|
||||||
|
DROP function IF EXISTS `vn`.`workerTimeControl_add`;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE DEFINER=`root`@`%` FUNCTION `vn`.`workerTimeControl_add`( vUserFk INT, vWarehouseFk INT, vTimed DATETIME, vIsManual BOOL) RETURNS int(11)
|
||||||
|
DETERMINISTIC
|
||||||
|
BEGIN
|
||||||
|
DECLARE vDirection VARCHAR(6);
|
||||||
|
DECLARE vLastIn DATETIME;
|
||||||
|
DECLARE vDayStayMax INT;
|
||||||
|
DECLARE vHasDirectionOut INT;
|
||||||
|
DECLARE vLastInsertedId INT;
|
||||||
|
|
||||||
|
SELECT dayStayMax INTO vDayStayMax
|
||||||
|
FROM workerTimeControlParams;
|
||||||
|
|
||||||
|
SELECT timeWorkerControl_getDirection(vUserFk,vTimed) INTO vDirection;
|
||||||
|
|
||||||
|
IF vDirection = 'out' THEN
|
||||||
|
|
||||||
|
SELECT MAX(timed) INTO vLastIn
|
||||||
|
FROM workerTimeControl
|
||||||
|
WHERE userFk = vUserFk
|
||||||
|
AND direction = 'in'
|
||||||
|
AND timed < vTimed;
|
||||||
|
|
||||||
|
UPDATE workerTimeControl wtc
|
||||||
|
SET wtc.direction = 'middle'
|
||||||
|
WHERE userFk = vUserFk
|
||||||
|
AND direction = 'out'
|
||||||
|
AND timed BETWEEN vLastIn AND vTimed;
|
||||||
|
|
||||||
|
ELSE IF vDirection = 'in' THEN
|
||||||
|
|
||||||
|
SELECT COUNT(*) INTO vHasDirectionOut
|
||||||
|
FROM workerTimeControl wtc
|
||||||
|
WHERE userFk = vUserFk
|
||||||
|
AND direction = 'out'
|
||||||
|
AND timed BETWEEN vTimed AND TIMESTAMPADD(SECOND, 50400, vTimed);
|
||||||
|
|
||||||
|
UPDATE workerTimeControl wtc
|
||||||
|
SET wtc.direction = IF (vHasDirectionOut,'middle','out')
|
||||||
|
WHERE userFk = vUserFk
|
||||||
|
AND direction = 'in'
|
||||||
|
AND timed BETWEEN vTimed AND TIMESTAMPADD(SECOND, 50400, vTimed);
|
||||||
|
|
||||||
|
END IF;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
INSERT INTO workerTimeControl(userFk, timed, warehouseFk, direction, manual)
|
||||||
|
VALUES(vUserFk, vTimed, vWarehouseFk, vDirection, vIsManual);
|
||||||
|
|
||||||
|
SET vLastInsertedId = LAST_INSERT_ID();
|
||||||
|
|
||||||
|
CALL workerTimeControlSOWP(vUserFk, vTimed);
|
||||||
|
|
||||||
|
RETURN vLastInsertedId;
|
||||||
|
END$$
|
||||||
|
|
||||||
|
DELIMITER ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
DROP procedure IF EXISTS `vn`.`workerTimeControl_add`;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`workerTimeControl_add`(IN vUserFk INT, IN vWarehouseFk INT, IN vTimed DATETIME, IN vIsManual BOOL)
|
||||||
|
BEGIN
|
||||||
|
|
||||||
|
|
||||||
|
SELECT workerTimeControl_add(vUserFk,vWarehouseFk,vTimed,vIsManual);
|
||||||
|
END$$
|
||||||
|
|
||||||
|
DELIMITER ;
|
|
@ -1835,12 +1835,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`,`manual`, `direction`)
|
INSERT INTO `vn`.`workerTimeControl`(`userFk`, `timed`, `order`, `manual`, `direction`)
|
||||||
VALUES
|
VALUES
|
||||||
(106, CONCAT(CURDATE(), ' 07:00'), TRUE, 'in'),
|
(106, CONCAT(CURDATE(), ' 07:00'), 1, TRUE, 'in'),
|
||||||
(106, CONCAT(CURDATE(), ' 10:00'), TRUE, 'middle'),
|
(106, CONCAT(CURDATE(), ' 10:00'), 2, TRUE, 'middle'),
|
||||||
(106, CONCAT(CURDATE(), ' 10:10'), TRUE, 'middle'),
|
(106, CONCAT(CURDATE(), ' 10:10'), 3, TRUE, 'middle'),
|
||||||
(106, CONCAT(CURDATE(), ' 15:00'), TRUE, 'out');
|
(106, CONCAT(CURDATE(), ' 15:00'), 4, TRUE, 'out');
|
||||||
|
|
||||||
INSERT INTO `vn`.`dmsType`(`id`, `name`, `path`, `readRoleFk`, `writeRoleFk`, `code`)
|
INSERT INTO `vn`.`dmsType`(`id`, `name`, `path`, `readRoleFk`, `writeRoleFk`, `code`)
|
||||||
VALUES
|
VALUES
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import './tooltip';
|
import './tooltip';
|
||||||
|
|
||||||
// #1615 migrar karma a jest
|
describe('Component vnTooltip', () => {
|
||||||
xdescribe('Component vnTooltip', () => {
|
|
||||||
let $element;
|
let $element;
|
||||||
let controller;
|
let controller;
|
||||||
let $parent;
|
let $parent;
|
||||||
|
@ -21,8 +20,8 @@ xdescribe('Component vnTooltip', () => {
|
||||||
$parent.css({
|
$parent.css({
|
||||||
backgroundColor: 'red',
|
backgroundColor: 'red',
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
width: '10px',
|
width: '100px',
|
||||||
height: '10px',
|
height: '100px',
|
||||||
top: '0',
|
top: '0',
|
||||||
left: '0'
|
left: '0'
|
||||||
});
|
});
|
||||||
|
@ -36,13 +35,13 @@ xdescribe('Component vnTooltip', () => {
|
||||||
|
|
||||||
describe('show()', () => {
|
describe('show()', () => {
|
||||||
it(`should check that tooltip is visible into the screen`, () => {
|
it(`should check that tooltip is visible into the screen`, () => {
|
||||||
|
expect(element.classList).not.toContain('show');
|
||||||
|
|
||||||
controller.show($parent[0]);
|
controller.show($parent[0]);
|
||||||
|
|
||||||
let rect = element.getBoundingClientRect();
|
let rect = element.getBoundingClientRect();
|
||||||
let style = window.getComputedStyle(element);
|
|
||||||
|
|
||||||
expect(style.visibility).toEqual('visible');
|
expect(element.classList).toContain('show');
|
||||||
expect(style.display).not.toEqual('none');
|
|
||||||
|
|
||||||
expect(0).toBeLessThanOrEqual(rect.top);
|
expect(0).toBeLessThanOrEqual(rect.top);
|
||||||
expect(0).toBeLessThanOrEqual(rect.left);
|
expect(0).toBeLessThanOrEqual(rect.left);
|
||||||
|
@ -54,14 +53,16 @@ xdescribe('Component vnTooltip', () => {
|
||||||
describe('hide()', () => {
|
describe('hide()', () => {
|
||||||
it(`should check that tooltip is not visible`, () => {
|
it(`should check that tooltip is not visible`, () => {
|
||||||
controller.show($parent[0]);
|
controller.show($parent[0]);
|
||||||
controller.hide();
|
|
||||||
let style = window.getComputedStyle(element);
|
|
||||||
|
|
||||||
expect(style.display).toEqual('none');
|
expect(element.classList).toContain('show');
|
||||||
|
controller.hide();
|
||||||
|
|
||||||
|
expect(element.classList).not.toContain('show');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('relocate()', () => {
|
// #1892 reparar unitarios front tooltip.js
|
||||||
|
xdescribe('relocate()', () => {
|
||||||
it(`should reallocate tooltip on top-left`, () => {
|
it(`should reallocate tooltip on top-left`, () => {
|
||||||
controller.show($parent[0]);
|
controller.show($parent[0]);
|
||||||
let rect = element.getBoundingClientRect();
|
let rect = element.getBoundingClientRect();
|
||||||
|
|
|
@ -34,7 +34,9 @@ module.exports = Self => {
|
||||||
const subordinate = await Worker.findById(data.workerFk);
|
const subordinate = await Worker.findById(data.workerFk);
|
||||||
const timed = new Date(data.timed);
|
const timed = new Date(data.timed);
|
||||||
|
|
||||||
return Self.rawSql('CALL vn.workerTimeControl_add(?, ?, ?, ?)', [
|
let [result] = await Self.rawSql('SELECT vn.workerTimeControl_add(?, ?, ?, ?) AS id', [
|
||||||
subordinate.userFk, null, timed, true]);
|
subordinate.userFk, null, timed, true]);
|
||||||
|
|
||||||
|
return result;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
const app = require('vn-loopback/server/server');
|
const app = require('vn-loopback/server/server');
|
||||||
|
|
||||||
describe('workerTimeControl addTimeEntry()', () => {
|
describe('workerTimeControl addTimeEntry()', () => {
|
||||||
let insertedTime;
|
let timeEntry;
|
||||||
|
let createdTimeEntry;
|
||||||
|
|
||||||
it('should fail to add a time entry if the target user is not a subordinate', async() => {
|
it('should fail to add a time entry if the target user is not a subordinate', async() => {
|
||||||
let error;
|
let error;
|
||||||
|
@ -52,11 +53,9 @@ describe('workerTimeControl addTimeEntry()', () => {
|
||||||
timed: todayAtSix
|
timed: todayAtSix
|
||||||
};
|
};
|
||||||
|
|
||||||
await app.models.WorkerTimeControl.addTimeEntry(ctx, data);
|
timeEntry = await app.models.WorkerTimeControl.addTimeEntry(ctx, data);
|
||||||
|
|
||||||
insertedTime = await app.models.WorkerTimeControl.findOne({where: {timed: data.timed}});
|
createdTimeEntry = await app.models.WorkerTimeControl.findById(timeEntry.id);
|
||||||
|
|
||||||
let createdTimeEntry = await app.models.WorkerTimeControl.findById(insertedTime.id);
|
|
||||||
|
|
||||||
expect(createdTimeEntry).toBeDefined();
|
expect(createdTimeEntry).toBeDefined();
|
||||||
});
|
});
|
||||||
|
@ -66,10 +65,6 @@ describe('workerTimeControl addTimeEntry()', () => {
|
||||||
let teamBossId = 13;
|
let teamBossId = 13;
|
||||||
let ctx = {req: {accessToken: {userId: teamBossId}}};
|
let ctx = {req: {accessToken: {userId: teamBossId}}};
|
||||||
|
|
||||||
let createdTimeEntry = await app.models.WorkerTimeControl.findById(insertedTime.id);
|
|
||||||
|
|
||||||
expect(createdTimeEntry).toBeDefined();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await app.models.WorkerTimeControl.deleteTimeEntry(ctx, createdTimeEntry.id);
|
await app.models.WorkerTimeControl.deleteTimeEntry(ctx, createdTimeEntry.id);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -85,14 +80,12 @@ describe('workerTimeControl addTimeEntry()', () => {
|
||||||
let HHRRId = 37;
|
let HHRRId = 37;
|
||||||
let ctx = {req: {accessToken: {userId: HHRRId}}};
|
let ctx = {req: {accessToken: {userId: HHRRId}}};
|
||||||
|
|
||||||
let createdTimeEntry = await app.models.WorkerTimeControl.findById(insertedTime.id);
|
|
||||||
|
|
||||||
expect(createdTimeEntry).toBeDefined();
|
expect(createdTimeEntry).toBeDefined();
|
||||||
|
|
||||||
ctx.req.accessToken.userId = HHRRId;
|
ctx.req.accessToken.userId = HHRRId;
|
||||||
await app.models.WorkerTimeControl.deleteTimeEntry(ctx, insertedTime.id);
|
await app.models.WorkerTimeControl.deleteTimeEntry(ctx, timeEntry.id);
|
||||||
|
|
||||||
createdTimeEntry = await app.models.WorkerTimeControl.findById(insertedTime.id);
|
createdTimeEntry = await app.models.WorkerTimeControl.findById(timeEntry.id);
|
||||||
|
|
||||||
expect(createdTimeEntry).toBeNull();
|
expect(createdTimeEntry).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
filter="::$ctrl.filter"
|
filter="::$ctrl.filter"
|
||||||
data="$ctrl.hours">
|
data="$ctrl.hours">
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
<vn-card class="vn-pa-lg vn-w-md">
|
<vn-card class="vn-pa-lg vn-w-lg">
|
||||||
<vn-table model="model" auto-load="false">
|
<vn-table model="model" auto-load="false">
|
||||||
<vn-thead>
|
<vn-thead>
|
||||||
<vn-tr>
|
<vn-tr>
|
||||||
|
@ -31,8 +31,8 @@
|
||||||
</vn-thead>
|
</vn-thead>
|
||||||
<vn-tbody>
|
<vn-tbody>
|
||||||
<vn-tr>
|
<vn-tr>
|
||||||
<vn-td ng-repeat="weekday in $ctrl.weekDays" class="hours vn-pa-none" expand center>
|
<vn-td ng-repeat="weekday in $ctrl.weekDays" class="hours vn-pa-none" expand>
|
||||||
<section ng-repeat="hour in weekday.hours" center>
|
<section ng-repeat="hour in weekday.hours">
|
||||||
<vn-icon
|
<vn-icon
|
||||||
icon="{{
|
icon="{{
|
||||||
::hour.direction == 'in' ? 'arrow_forward' : 'arrow_back'
|
::hour.direction == 'in' ? 'arrow_forward' : 'arrow_back'
|
||||||
|
@ -45,7 +45,6 @@
|
||||||
<vn-chip
|
<vn-chip
|
||||||
ng-class="::{'colored': hour.manual}"
|
ng-class="::{'colored': hour.manual}"
|
||||||
removable="::hour.manual"
|
removable="::hour.manual"
|
||||||
translate-attr="{title: 'Category'}"
|
|
||||||
on-remove="$ctrl.showDeleteDialog(hour)">
|
on-remove="$ctrl.showDeleteDialog(hour)">
|
||||||
{{::hour.timed | date: 'HH:mm'}}
|
{{::hour.timed | date: 'HH:mm'}}
|
||||||
</vn-chip>
|
</vn-chip>
|
||||||
|
|
|
@ -12,6 +12,7 @@ vn-worker-time-control {
|
||||||
& > section {
|
& > section {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
padding: .3em 0;
|
padding: .3em 0;
|
||||||
|
|
||||||
& > vn-icon {
|
& > vn-icon {
|
||||||
|
|
|
@ -19,7 +19,6 @@ module.exports = app => {
|
||||||
require('./core/database').init();
|
require('./core/database').init();
|
||||||
// Init SMTP Instance
|
// Init SMTP Instance
|
||||||
require('./core/smtp').init();
|
require('./core/smtp').init();
|
||||||
//
|
|
||||||
require('./core/mixins');
|
require('./core/mixins');
|
||||||
require('./core/filters');
|
require('./core/filters');
|
||||||
require('./core/directives');
|
require('./core/directives');
|
||||||
|
|
|
@ -29,7 +29,7 @@ module.exports = {
|
||||||
LEFT JOIN worker w ON w.id = c.salesPersonFk
|
LEFT JOIN worker w ON w.id = c.salesPersonFk
|
||||||
LEFT JOIN account.user wu ON wu.id = w.userFk
|
LEFT JOIN account.user wu ON wu.id = w.userFk
|
||||||
WHERE c.id = ?`, [clientId]);
|
WHERE c.id = ?`, [clientId]);
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
'email-header': emailHeader.build(),
|
'email-header': emailHeader.build(),
|
||||||
|
|
Loading…
Reference in New Issue