#7211 check if there's available clockIn #2368
|
@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## [24.20.01] - 2024-05-14
|
||||
|
||||
### Fixed
|
||||
- (Worker -> time-control) Corrección de errores
|
||||
|
||||
## [24.18.01] - 2024-05-07
|
||||
|
||||
## [24.16.01] - 2024-04-18
|
||||
|
|
|
@ -121,15 +121,17 @@ BEGIN
|
|||
CALL util.throw(vErrorCode);
|
||||
END IF;
|
||||
|
||||
|
||||
-- DIRECCION CORRECTA
|
||||
CALL workerTimeControl_direction(vWorkerFk, vTimed);
|
||||
IF (SELECT
|
||||
IF(IF(option1 IN ('inMiddle', 'outMiddle'),
|
||||
IF((IF(option1 IN ('inMiddle', 'outMiddle'),
|
||||
'middle',
|
||||
option1) <> vDirection
|
||||
AND IF(option2 IN ('inMiddle', 'outMiddle'),
|
||||
'middle',
|
||||
IFNULL(option2, '')) <> vDirection,
|
||||
IFNULL(option2, '')) <> vDirection)
|
||||
OR (option1 IS NULL AND option2 IS NULL),
|
||||
TRUE ,
|
||||
FALSE)
|
||||
FROM tmp.workerTimeControlDirection
|
||||
|
@ -137,12 +139,17 @@ BEGIN
|
|||
SET vIsError = TRUE;
|
||||
END IF;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.workerTimeControlDirection;
|
||||
|
||||
IF vIsError THEN
|
||||
SET vErrorCode = 'WRONG_DIRECTION';
|
||||
IF(SELECT option1 IS NULL AND option2 IS NULL
|
||||
FROM tmp.workerTimeControlDirection) THEN
|
||||
|
||||
SET vErrorCode = 'DAY_MAX_TIME';
|
||||
END IF;
|
||||
CALL util.throw(vErrorCode);
|
||||
END IF;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.workerTimeControlDirection;
|
||||
-- FICHADAS IMPARES
|
||||
SELECT timed INTO vLastIn
|
||||
FROM workerTimeControl
|
||||
|
|
|
@ -45,7 +45,7 @@ describe('workerTimeControl clockIn()', () => {
|
|||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
it('should throw an error trying to change a middle hour to out not resting 12h', async() => {
|
||||
activeCtx.accessToken.userId = HHRRId;
|
||||
const workerId = teamBossId;
|
||||
|
@ -99,6 +99,32 @@ describe('workerTimeControl clockIn()', () => {
|
|||
}
|
||||
});
|
||||
|
||||
it('should throw an error trying to add an "in" entry if the last clockIn is not out', async() => {
|
||||
activeCtx.accessToken.userId = HHRRId;
|
||||
const workerId = teamBossId;
|
||||
const tx = await models.WorkerTimeControl.beginTransaction({});
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
ctx.args = {timed: "2000-12-25T21:00:00.000Z", direction: 'in'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
ctx.args = {timed: "2000-12-25T22:00:00.000Z", direction: 'middle'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
ctx.args = {timed: "2000-12-25T22:30:00.000Z", direction: 'middle'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
ctx.args = {timed: "2000-12-26T01:00:00.000Z", direction: 'in'};
|
||||
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
expect(e.message).toBe('Dirección incorrecta');
|
||||
await tx.rollback();
|
||||
}
|
||||
});
|
||||
|
||||
describe('as Role errors', () => {
|
||||
it('should add if the current user is team boss and the target user is himself', async() => {
|
||||
activeCtx.accessToken.userId = teamBossId;
|
||||
|
|
Loading…
Reference in New Issue