3928-worker.time-control_sendMail #1129
|
@ -2715,7 +2715,6 @@ UPDATE `account`.`user`
|
||||||
SET `hasGrant` = 1
|
SET `hasGrant` = 1
|
||||||
WHERE `id` = 66;
|
WHERE `id` = 66;
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO `vn`.`osTicketConfig` (`id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `day`, `comment`, `hostDb`, `userDb`, `passwordDb`, `portDb`, `responseType`, `fromEmailId`, `replyTo`)
|
INSERT INTO `vn`.`osTicketConfig` (`id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `day`, `comment`, `hostDb`, `userDb`, `passwordDb`, `portDb`, `responseType`, `fromEmailId`, `replyTo`)
|
||||||
VALUES
|
VALUES
|
||||||
(0, 'http://localhost:56596/scp', 'ostadmin', 'Admin1', 'open', 3, 60, 'Este CAU se ha cerrado automáticamente. Si el problema persiste responda a este mensaje.', 'localhost', 'osticket', 'osticket', 40003, 'reply', 1, 'all');
|
(0, 'http://localhost:56596/scp', 'ostadmin', 'Admin1', 'open', 3, 60, 'Este CAU se ha cerrado automáticamente. Si el problema persiste responda a este mensaje.', 'localhost', 'osticket', 'osticket', 40003, 'reply', 1, 'all');
|
||||||
|
|
|
@ -162,6 +162,8 @@ module.exports = Self => {
|
||||||
let previousWorkerFk = days[index][0].workerFk;
|
let previousWorkerFk = days[index][0].workerFk;
|
||||||
let previousReceiver = days[index][0].receiver;
|
let previousReceiver = days[index][0].receiver;
|
||||||
|
|
||||||
|
const workerTimeControlConfig = await models.WorkerTimeControlConfig.findOne(null, myOptions);
|
||||||
|
|
||||||
for (let day of days[index]) {
|
for (let day of days[index]) {
|
||||||
workerFk = day.workerFk;
|
workerFk = day.workerFk;
|
||||||
if (day.timeWorkDecimal > 0 && day.timeWorkedDecimal == null
|
if (day.timeWorkDecimal > 0 && day.timeWorkedDecimal == null
|
||||||
|
@ -176,7 +178,7 @@ module.exports = Self => {
|
||||||
isSendMail: true
|
isSendMail: true
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
if (day.timeWorkDecimal >= 5) {
|
if (day.timeWorkDecimal >= workerTimeControlConfig.timeToBreakTime / 3600) {
|
||||||
await models.WorkerTimeControl.create({
|
await models.WorkerTimeControl.create({
|
||||||
userFk: day.workerFk,
|
userFk: day.workerFk,
|
||||||
timed: timed.setHours(9),
|
timed: timed.setHours(9),
|
||||||
|
@ -227,7 +229,6 @@ module.exports = Self => {
|
||||||
|
|
||||||
for (let journey of journeys) {
|
for (let journey of journeys) {
|
||||||
const timeTableDecimal = timeTableDecimalInSeconds / 3600;
|
const timeTableDecimal = timeTableDecimalInSeconds / 3600;
|
||||||
console.log(timeTableDecimal);
|
|
||||||
if (day.timeWorkDecimal == timeTableDecimal) {
|
if (day.timeWorkDecimal == timeTableDecimal) {
|
||||||
const timed = new Date(day.dated);
|
const timed = new Date(day.dated);
|
||||||
const [startHours, startMinutes, startSeconds] = getTime(journey.start);
|
const [startHours, startMinutes, startSeconds] = getTime(journey.start);
|
||||||
|
@ -273,7 +274,7 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (day.timeWorkDecimal >= 5) {
|
if (day.timeWorkDecimal >= workerTimeControlConfig.timeToBreakTime / 3600) {
|
||||||
const minStart = journeys.reduce(function(prev, curr) {
|
const minStart = journeys.reduce(function(prev, curr) {
|
||||||
return curr.start < prev.start ? curr : prev;
|
return curr.start < prev.start ? curr : prev;
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/* eslint max-len: ["error", { "code": 150 }]*/
|
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
fdescribe('workerTimeControl sendMail()', () => {
|
fdescribe('workerTimeControl sendMail()', () => {
|
||||||
|
@ -18,7 +17,7 @@ fdescribe('workerTimeControl sendMail()', () => {
|
||||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fill time control of a worker...', async() => {
|
it('should fill time control of a worker without records in Journey and and with rest', async() => {
|
||||||
const tx = await models.WorkerTimeControl.beginTransaction({});
|
const tx = await models.WorkerTimeControl.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -42,7 +41,7 @@ fdescribe('workerTimeControl sendMail()', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fill time control of a worker2...', async() => {
|
it('should fill time control of a worker without records in Journey and and without rest', async() => {
|
||||||
const workdayOf20Hours = 3;
|
const workdayOf20Hours = 3;
|
||||||
const tx = await models.WorkerTimeControl.beginTransaction({});
|
const tx = await models.WorkerTimeControl.beginTransaction({});
|
||||||
|
|
||||||
|
@ -69,8 +68,7 @@ fdescribe('workerTimeControl sendMail()', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fill time control of a worker3...', async() => {
|
it('should fill time control of a worker with records in Journey', async() => {
|
||||||
const workdayOf20Hours = 3;
|
|
||||||
const tx = await models.WorkerTimeControl.beginTransaction({});
|
const tx = await models.WorkerTimeControl.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -87,46 +85,6 @@ fdescribe('workerTimeControl sendMail()', () => {
|
||||||
const workerTimeControl = await models.WorkerTimeControl.find({
|
const workerTimeControl = await models.WorkerTimeControl.find({
|
||||||
where: {userFk: workerId}
|
where: {userFk: workerId}
|
||||||
}, options);
|
}, options);
|
||||||
console.log(workerTimeControl);
|
|
||||||
|
|
||||||
expect(workerTimeControl[0].timed.getHours()).toEqual(9);
|
|
||||||
expect(workerTimeControl[2].timed.getHours()).toEqual(10);
|
|
||||||
expect(`${workerTimeControl[3].timed.getHours()}:${workerTimeControl[3].timed.getMinutes()}`).toEqual('10:20');
|
|
||||||
expect(workerTimeControl[1].timed.getHours()).toEqual(13);
|
|
||||||
expect(workerTimeControl[4].timed.getHours()).toEqual(14);
|
|
||||||
expect(workerTimeControl[5].timed.getHours()).toEqual(19);
|
|
||||||
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
|
||||||
await tx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should fill time control of a worker4...', async() => {
|
|
||||||
const workdayOf20Hours = 3;
|
|
||||||
const tx = await models.WorkerTimeControl.beginTransaction({});
|
|
||||||
|
|
||||||
try {
|
|
||||||
const options = {transaction: tx};
|
|
||||||
query = `UPDATE business b
|
|
||||||
SET b.calendarTypeFk = ?
|
|
||||||
WHERE b.workerFk = ?; `;
|
|
||||||
await models.WorkerTimeControl.rawSql(query, [workdayOf20Hours, workerId], options);
|
|
||||||
|
|
||||||
query = `INSERT INTO postgresql.journey(journey_id, day_id, start, end, business_id)
|
|
||||||
VALUES
|
|
||||||
(1, 1, '09:00:00', '13:00:00', ?),
|
|
||||||
(2, 1, '14:00:00', '19:00:00', ?),
|
|
||||||
(3, 2, '12:30:00', '19:00:00', ?);`;
|
|
||||||
await models.WorkerTimeControl.rawSql(query, [workerId, workerId, workerId], options);
|
|
||||||
|
|
||||||
await models.WorkerTimeControl.sendMail(ctx, options);
|
|
||||||
|
|
||||||
const workerTimeControl = await models.WorkerTimeControl.find({
|
|
||||||
where: {userFk: workerId}
|
|
||||||
}, options);
|
|
||||||
console.log(workerTimeControl);
|
|
||||||
|
|
||||||
expect(workerTimeControl[0].timed.getHours()).toEqual(9);
|
expect(workerTimeControl[0].timed.getHours()).toEqual(9);
|
||||||
expect(workerTimeControl[2].timed.getHours()).toEqual(10);
|
expect(workerTimeControl[2].timed.getHours()).toEqual(10);
|
||||||
|
|
|
@ -65,6 +65,9 @@
|
||||||
"WorkerLog": {
|
"WorkerLog": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
"WorkerTimeControlConfig": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
"WorkerTimeControlParams": {
|
"WorkerTimeControlParams": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"name": "WorkerTimeControlConfig",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "workerTimeControlConfig"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"id": true,
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"timeToBreakTime": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue