Fixed error for clients without a previous credit
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2021-09-09 16:44:15 +02:00
parent e8792d5686
commit b0d291e49c
1 changed files with 2 additions and 2 deletions

View File

@ -336,8 +336,8 @@ module.exports = Self => {
order: 'id DESC'
}, ctx.options);
const lastAmount = lastCredit.amount;
const lastWorkerId = lastCredit.workerFk;
const lastAmount = lastCredit && lastCredit.amount;
const lastWorkerId = lastCredit && lastCredit.workerFk;
const lastWorkerIsManager = await models.Account.hasRole(lastWorkerId, 'manager', ctx.options);
if (lastAmount == 0 && lastWorkerIsManager)