4358-financialBoss #1054

Merged
joan merged 4 commits from 4358-financialBoss into dev 2022-09-21 06:49:47 +00:00
3 changed files with 11 additions and 8 deletions
Showing only changes of commit 8c984b5ebe - Show all commits

View File

@ -0,0 +1,3 @@
DELETE FROM `account`.`roleInherit`
WHERE `role` = 30
AND `inheritsFrom` = 20;

View File

@ -402,8 +402,8 @@ module.exports = Self => {
const models = Self.app.models;
const userId = ctx.options.accessToken.userId;
const isManager = await models.Account.hasRole(userId, 'manager', ctx.options);
if (!isManager) {
const isFinancialBoss = await models.Account.hasRole(userId, 'financialBoss', ctx.options);
if (!isFinancialBoss) {
const lastCredit = await models.ClientCredit.findOne({
where: {
clientFk: finalState.id
@ -413,10 +413,10 @@ module.exports = Self => {
const lastAmount = lastCredit && lastCredit.amount;
const lastWorkerId = lastCredit && lastCredit.workerFk;
const lastWorkerIsManager = await models.Account.hasRole(lastWorkerId, 'manager', ctx.options);
const lastWorkerIsFinancialBoss = await models.Account.hasRole(lastWorkerId, 'financialBoss', ctx.options);
if (lastAmount == 0 && lastWorkerIsManager)
throw new UserError(`You can't change the credit set to zero from a manager`);
if (lastAmount == 0 && lastWorkerIsFinancialBoss)
throw new UserError(`You can't change the credit set to zero from a financialBoss`);
const creditLimits = await models.ClientCreditLimit.find({
fields: ['roleFk'],

View File

@ -53,7 +53,7 @@ describe('Client Model', () => {
});
describe('changeCredit()', () => {
it('should fail to change the credit as a salesAssistant set to zero by a manager', async() => {
it('should fail to change the credit as a salesAssistant set to zero by a financialBoss', async() => {
const tx = await models.Client.beginTransaction({});
let error;
@ -62,7 +62,7 @@ describe('Client Model', () => {
const options = {transaction: tx};
const context = {options};
// Set credit to zero by a manager
// Set credit to zero by a financialBoss
const financialBoss = await models.Account.findOne({
where: {name: 'financialBoss'}
}, options);
@ -83,7 +83,7 @@ describe('Client Model', () => {
await tx.rollback();
}
expect(error.message).toEqual(`You can't change the credit set to zero from a manager`);
expect(error.message).toEqual(`You can't change the credit set to zero from a financialBoss`);
});
it('should fail to change to a high credit amount as a salesAssistant', async() => {