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 10 additions and 10 deletions

View File

@ -208,7 +208,7 @@
"Wasn't able to invoice the following clients": "No se han podido facturar los siguientes clientes", "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", "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 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", "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 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", "The type of business must be filled in basic data": "El tipo de negocio debe estar rellenado en datos básicos",
@ -233,4 +233,4 @@
"Descanso diario 12h.": "Descanso diario 12h.", "Descanso diario 12h.": "Descanso diario 12h.",
"Descanso semanal 36h. / 72h.": "Descanso semanal 36h. / 72h.", "Descanso semanal 36h. / 72h.": "Descanso semanal 36h. / 72h.",
"Dirección incorrecta": "Dirección incorrecta" "Dirección incorrecta": "Dirección incorrecta"
} }

View File

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

View File

@ -53,7 +53,7 @@ describe('Client Model', () => {
}); });
describe('changeCredit()', () => { 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({}); const tx = await models.Client.beginTransaction({});
let error; let error;
@ -62,7 +62,7 @@ describe('Client Model', () => {
const options = {transaction: tx}; const options = {transaction: tx};
const context = {options}; const context = {options};
// Set credit to zero by a manager // Set credit to zero by a financialBoss
const financialBoss = await models.Account.findOne({ const financialBoss = await models.Account.findOne({
where: {name: 'financialBoss'} where: {name: 'financialBoss'}
}, options); }, options);
@ -83,7 +83,7 @@ describe('Client Model', () => {
await tx.rollback(); 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() => { it('should fail to change to a high credit amount as a salesAssistant', async() => {