Merge pull request '4358-financialBoss' (#1054) from 4358-financialBoss into dev
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #1054
Reviewed-by: Joan Sanchez <joan@verdnatura.es>
This commit is contained in:
Joan Sanchez 2022-09-21 06:49:44 +00:00
commit 284524e3fa
3 changed files with 9 additions and 9 deletions

View File

@ -208,7 +208,7 @@
"Wasn't able to invoice the following clients": "No se han podido facturar los siguientes clientes",
"Can't verify data unless the client has a business type": "No se puede verificar datos de un cliente que no tiene tipo de negocio",
"You don't have enough privileges to set this credit amount": "No tienes suficientes privilegios para establecer esta cantidad de crédito",
"You can't change the credit set to zero from a manager": "No puedes cambiar el cŕedito establecido a cero por un gerente",
"You can't change the credit set to zero from a financialBoss": "No puedes cambiar el cŕedito establecido a cero por un jefe de finanzas",
"Amounts do not match": "Las cantidades no coinciden",
"The PDF document does not exists": "El documento PDF no existe. Prueba a regenerarlo desde la opción 'Regenerar PDF factura'",
"The type of business must be filled in basic data": "El tipo de negocio debe estar rellenado en datos básicos",

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() => {