validation client credit - refact

This commit is contained in:
Dani Herrero 2017-10-04 08:33:51 +02:00
parent 2aed5d088c
commit 8e5eca5629
1 changed files with 7 additions and 2 deletions

View File

@ -121,7 +121,12 @@ module.exports = function(Client) {
function maxCb(_, instances) {
//console.log('maxCb', instances);
if (instances && (instances.length !== 1 || instances[0].employeeFk == userId || instances[0].amount > 0)) {
if(!instances){
err();
return;
}
if (instances.length !== 1 || instances[0].employeeFk == userId || instances[0].amount > 0) {
done();
return;
}
@ -141,7 +146,7 @@ module.exports = function(Client) {
}
function clientCreditCb(_, instance) {
if (instance.length && instance[0].hasManagerRole > 0 )
if (!instance || (instance.length && instance[0].hasManagerRole > 0 ))
err();
done();
}