fix(client): check businesTypeFk before clientCredit insert
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2021-12-23 08:53:56 +01:00
parent 2e604f61d9
commit 6a78ac46c7
1 changed files with 8 additions and 5 deletions

View File

@ -374,11 +374,14 @@ module.exports = Self => {
throw new UserError(`You don't have enough privileges to set this credit amount`);
}
await models.ClientCredit.create({
amount: changes.credit,
clientFk: finalState.id,
workerFk: userId
}, ctx.options);
const client = await models.Client.findById(finalState.id, null, ctx.options);
if (client.businessTypeFk) {
await models.ClientCredit.create({
amount: changes.credit,
clientFk: finalState.id,
workerFk: userId
}, ctx.options);
}
};
const app = require('vn-loopback/server/server');