diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index b4961771d..7ab8bb477 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -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');