Remove manager restriction to edit client credits
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
2e49e1e772
commit
7b3128d646
|
@ -339,28 +339,5 @@ module.exports = Self => {
|
||||||
|
|
||||||
if (count <= 0)
|
if (count <= 0)
|
||||||
throw new UserError('The role cannot set this credit amount');
|
throw new UserError('The role cannot set this credit amount');
|
||||||
|
|
||||||
// Si se puso a 0 por gerencia, solo gerencia puede aumentarlo
|
|
||||||
|
|
||||||
let query = 'SELECT * FROM clientCredit WHERE clientFk = ? ORDER BY created DESC LIMIT 1';
|
|
||||||
let instances = await Self.rawSql(query, [finalState.id]);
|
|
||||||
|
|
||||||
if (instances.length !== 1 || instances[0].amount > 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
query = `
|
|
||||||
SELECT COUNT(*) AS hasRoleManager
|
|
||||||
FROM worker em
|
|
||||||
JOIN account.user ac ON ac.id = em.userFk
|
|
||||||
JOIN salix.RoleMapping rm ON rm.principalId = ac.id
|
|
||||||
JOIN account.role r on r.id = rm.roleId
|
|
||||||
WHERE em.id = ?
|
|
||||||
AND rm.principalType = 'USER'
|
|
||||||
AND r.name = 'manager'`;
|
|
||||||
|
|
||||||
let instance = await Self.rawSql(query, [instances[0].workerFk]);
|
|
||||||
|
|
||||||
if (instance[0].hasRoleManager)
|
|
||||||
throw new UserError('Only manager can change the credit');
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue