dev #1731

Merged
jgallego merged 105 commits from dev into test 2023-08-31 09:13:29 +00:00
1 changed files with 6 additions and 8 deletions
Showing only changes of commit 251ed36eca - Show all commits

View File

@ -179,7 +179,6 @@ module.exports = Self => {
const workerTimeControlConfig = await models.WorkerTimeControlConfig.findOne(null, myOptions);
console.log(days[index]);
for (let day of days[index]) {
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
@ -374,22 +373,18 @@ module.exports = Self => {
delete myOptions.transaction;
}
} catch (e) {
if (tx) await tx.rollback();
delete myOptions.transaction;
const stmts = [];
let stmt;
stmt = new ParameterizedSQL(`
INSERT INTO mail (receiver, subject, body)
SELECT CONCAT(u.name, '@verdnatura.es'),
CONCAT('Error registro de horas semana ', ?, ' año ', ?) ,
CONCAT('No se ha podido enviar el registro de horas al empleado/s: ',
GROUP_CONCAT(DISTINCT CONCAT('<br>', w.id, ' ', w.firstName, ' ', w.lastName)))
CONCAT('No se ha podido enviar el registro de horas al empleado: ',
w.id, ' ', w.firstName, ' ', w.lastName, ' por el motivo: ', ?)
FROM worker w
JOIN account.user u ON u.id = w.bossFk
WHERE w.id = ?
GROUP BY w.bossFk
`, [args.week, args.year, day.workerFk]);
`, [args.week, args.year, e.message, day.workerFk]);
stmts.push(stmt);
const sql = ParameterizedSQL.join(stmts, ';');
@ -398,6 +393,9 @@ module.exports = Self => {
previousWorkerFk = day.workerFk;
previousReceiver = day.receiver;
if (tx) await tx.rollback();
delete myOptions.transaction;
continue;
}
}