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`); throw new UserError(`You don't have enough privileges to set this credit amount`);
} }
await models.ClientCredit.create({ const client = await models.Client.findById(finalState.id, null, ctx.options);
amount: changes.credit, if (client.businessTypeFk) {
clientFk: finalState.id, await models.ClientCredit.create({
workerFk: userId amount: changes.credit,
}, ctx.options); clientFk: finalState.id,
workerFk: userId
}, ctx.options);
}
}; };
const app = require('vn-loopback/server/server'); const app = require('vn-loopback/server/server');