Merge pull request '3449-client check businesTypeFk before clientCredit insert' (#832) from 3449-client_credit into dev
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #832
Reviewed-by: Carlos Jimenez Ruiz <carlosjr@verdnatura.es>
This commit is contained in:
Carlos Jimenez Ruiz 2021-12-24 10:53:56 +00:00
commit 48e22f7762
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');