#6274 workerTimeControl #1858
|
@ -8,6 +8,6 @@ INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalTyp
|
||||||
VALUES
|
VALUES
|
||||||
('WorkerTimeControl', 'login', 'READ', 'ALLOW', 'ROLE', 'timeControl'),
|
('WorkerTimeControl', 'login', 'READ', 'ALLOW', 'ROLE', 'timeControl'),
|
||||||
('WorkerTimeControl', 'getClockIn', 'READ', 'ALLOW', 'ROLE', 'timeControl'),
|
('WorkerTimeControl', 'getClockIn', 'READ', 'ALLOW', 'ROLE', 'timeControl'),
|
||||||
('WorkerTimeControl', 'addTimeEntry', 'WRITE', 'ALLOW', 'ROLE', 'timeControl');
|
('WorkerTimeControl', 'clockIn', 'WRITE', 'ALLOW', 'ROLE', 'timeControl');
|
||||||
|
|
||||||
CALL `account`.`role_sync`();
|
CALL `account`.`role_sync`();
|
||||||
|
|
|
@ -46,10 +46,7 @@ module.exports = Self => {
|
||||||
if (!isSubordinate || (isSubordinate && isHimself && !isTeamBoss))
|
if (!isSubordinate || (isSubordinate && isHimself && !isTeamBoss))
|
||||||
throw new UserError(`You don't have enough privileges`);
|
throw new UserError(`You don't have enough privileges`);
|
||||||
|
|
||||||
query = `CALL vn.workerTimeControl_clockIn(?,?,?)`;
|
const response = await Self.clockIn(workerId, args.timed, args.direction, myOptions);
|
||||||
const [response] = await Self.rawSql(query, [workerId, args.timed, args.direction], myOptions);
|
|
||||||
if (response[0] && response[0].error)
|
|
||||||
throw new UserError(response[0].error);
|
|
||||||
|
|
||||||
await models.WorkerTimeControl.resendWeeklyHourEmail(ctx, workerId, args.timed, myOptions);
|
await models.WorkerTimeControl.resendWeeklyHourEmail(ctx, workerId, args.timed, myOptions);
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
jorgep marked this conversation as resolved
Outdated
|
|||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethod('clockIn', {
|
Self.remoteMethod('clockIn', {
|
||||||
description: 'Check if the employee can clock in',
|
description: 'Check if the employee can clock in',
|
||||||
|
@ -8,6 +10,10 @@ module.exports = Self => {
|
||||||
type: 'integer',
|
type: 'integer',
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
arg: 'timed',
|
||||||
|
type: 'date'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
arg: 'direction',
|
arg: 'direction',
|
||||||
type: 'string'
|
type: 'string'
|
||||||
|
@ -24,12 +30,16 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.clockIn = async(workerFk, direction, options) => {
|
Self.clockIn = async(workerFk, timed, direction, options) => {
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
const query = 'CALL vn.workerTimeControl_clockIn(?, NULL, ?)';
|
const query = 'CALL vn.workerTimeControl_clockIn(?, ?, ?)';
|
||||||
return await Self.rawSql(query, [workerFk, direction], myOptions);
|
const [response] = await Self.rawSql(query, [workerFk, timed, direction], myOptions);
|
||||||
jorgep marked this conversation as resolved
Outdated
alexm
commented
Si es el caso puedes hacer:
Es decir, hacer Si es el caso puedes hacer:
```
const myArray = [[{}]]
const [[myNewArray]] = myArray
console.log(myNewArray) // Devuelve {}
```
Es decir, hacer `const [[response]] =` y te evitas luego hacer response[0]
|
|||||||
|
if (response[0] && response[0].error)
|
||||||
|
throw new UserError(response[0].error);
|
||||||
|
|
||||||
|
return response;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
veo que existe un archivo muy similar que llama al mismo procedimiento, lo has tenido en cuenta? conviene juntarlo en uno?
modules/worker/back/methods/worker-time-control/addTimeEntry.js
Ya se ha implementado, tenemos que mirarlo juntos conforme hemos hablado por rocket.
Refactor aplicado tras revisión en persona.