refactor(client): added restriction to change the credit amount from zero set by a manager #731
|
@ -336,8 +336,8 @@ module.exports = Self => {
|
||||||
order: 'id DESC'
|
order: 'id DESC'
|
||||||
}, ctx.options);
|
}, ctx.options);
|
||||||
|
|
||||||
const lastAmount = lastCredit.amount;
|
const lastAmount = lastCredit && lastCredit.amount;
|
||||||
const lastWorkerId = lastCredit.workerFk;
|
const lastWorkerId = lastCredit && lastCredit.workerFk;
|
||||||
const lastWorkerIsManager = await models.Account.hasRole(lastWorkerId, 'manager', ctx.options);
|
const lastWorkerIsManager = await models.Account.hasRole(lastWorkerId, 'manager', ctx.options);
|
||||||
|
|
||||||
if (lastAmount == 0 && lastWorkerIsManager)
|
if (lastAmount == 0 && lastWorkerIsManager)
|
||||||
|
|
Loading…
Reference in New Issue