Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5216-expeditionStateAdd
This commit is contained in:
commit
083f19fd41
|
@ -0,0 +1,32 @@
|
|||
INSERT INTO `account`.`role` (`id`, `name`, `description`, `hasLogin`)
|
||||
VALUES ('claimViewer','Trabajadores que consulta las reclamaciones ',1);
|
||||
|
||||
INSERT INTO `account`.`roleInherit` (`role`,`inheritsFrom`)
|
||||
SELECT `r`.`id`, `r2`.`id`
|
||||
FROM `account`.`role` `r`
|
||||
JOIN `account`.`role` `r2` ON `r2`.`name` = 'claimViewer'
|
||||
WHERE `r`.`name` IN (
|
||||
'salesPerson',
|
||||
'buyer',
|
||||
'deliveryBoss',
|
||||
'handmadeBoss'
|
||||
)
|
||||
|
||||
DELETE FROM `salix`.`ACL`
|
||||
WHERE `model`= 'claim'
|
||||
AND `property` IN (
|
||||
'filter',
|
||||
'find',
|
||||
'findById',
|
||||
'getSummary'
|
||||
);
|
||||
|
||||
INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalType`,`principalid`)
|
||||
VALUES ('Claim','filter','READ','ALLOW','ROLE','claimViewer');
|
||||
INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalType`,`principalid`)
|
||||
VALUES ('Claim','find','READ','ALLOW','ROLE','claimViewer');
|
||||
INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalType`,`principalid`)
|
||||
VALUES ('Claim','findById','READ','ALLOW','ROLE','claimViewer');
|
||||
INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalType`,`principalid`)
|
||||
VALUES ('Claim','getSummary','READ','ALLOW','ROLE','claimViewer');
|
||||
|
|
@ -121,15 +121,18 @@ module.exports = Self => {
|
|||
`, [started, ended]);
|
||||
stmts.push(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)))
|
||||
FROM tmp.timeControlError tce
|
||||
JOIN vn.workerTimeControl wtc ON wtc.id = tce.id
|
||||
JOIN worker w ON w.id = wtc.userFK
|
||||
JOIN account.user u ON u.id = w.bossFk
|
||||
GROUP BY w.bossFk`, [args.week, args.year]);
|
||||
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)))
|
||||
FROM tmp.timeControlError tce
|
||||
JOIN vn.workerTimeControl wtc ON wtc.id = tce.id
|
||||
JOIN worker w ON w.id = wtc.userFK
|
||||
JOIN account.user u ON u.id = w.bossFk
|
||||
GROUP BY w.bossFk
|
||||
`, [args.week, args.year]);
|
||||
stmts.push(stmt);
|
||||
|
||||
stmt = new ParameterizedSQL(`
|
||||
|
@ -177,10 +180,8 @@ module.exports = Self => {
|
|||
const workerTimeControlConfig = await models.WorkerTimeControlConfig.findOne(null, myOptions);
|
||||
|
||||
for (let day of days[index]) {
|
||||
if (!myOptions.transaction) {
|
||||
tx = await Self.beginTransaction({});
|
||||
myOptions.transaction = tx;
|
||||
}
|
||||
tx = await Self.beginTransaction({});
|
||||
myOptions.transaction = tx;
|
||||
try {
|
||||
workerFk = day.workerFk;
|
||||
if (day.timeWorkDecimal > 0 && day.timeWorkedDecimal == null
|
||||
|
@ -365,13 +366,31 @@ module.exports = Self => {
|
|||
previousReceiver = day.receiver;
|
||||
}
|
||||
|
||||
if (tx) {
|
||||
await tx.commit();
|
||||
delete myOptions.transaction;
|
||||
}
|
||||
if (tx) await tx.commit();
|
||||
} catch (e) {
|
||||
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: ',
|
||||
w.id, ' ', w.firstName, ' ', w.lastName, ' por el motivo: ', ?)
|
||||
FROM worker w
|
||||
JOIN account.user u ON u.id = w.bossFk
|
||||
WHERE w.id = ?
|
||||
`, [args.week, args.year, e.message, day.workerFk]);
|
||||
stmts.push(stmt);
|
||||
|
||||
const sql = ParameterizedSQL.join(stmts, ';');
|
||||
await conn.executeStmt(sql);
|
||||
|
||||
previousWorkerFk = day.workerFk;
|
||||
previousReceiver = day.receiver;
|
||||
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ module.exports = Self => {
|
|||
const salix = await models.Url.findOne({
|
||||
where: {
|
||||
appName: 'salix',
|
||||
environment: process.env.NODE_ENV || 'dev'
|
||||
environment: process.env.NODE_ENV || 'development'
|
||||
}
|
||||
}, myOptions);
|
||||
|
||||
|
@ -61,7 +61,7 @@ module.exports = Self => {
|
|||
const url = `${salix.url}worker/${args.workerId}/time-control?timestamp=${timestamp}`;
|
||||
ctx.args.url = url;
|
||||
|
||||
Self.sendTemplate(ctx, 'weekly-hour-record');
|
||||
await Self.sendTemplate(ctx, 'weekly-hour-record');
|
||||
|
||||
return models.WorkerTimeControl.updateWorkerTimeControlMail(ctx, myOptions);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue