5638-ticket.summary_states #1538

Merged
vicent merged 9 commits from 5638-ticket.summary_states into dev 2023-05-19 11:35:32 +00:00
1 changed files with 6 additions and 9 deletions
Showing only changes of commit 404acdab6f - Show all commits

View File

@ -24,20 +24,17 @@ module.exports = Self => {
if (typeof options == 'object')
Object.assign(myOptions, options);
let statesList = await models.State.find(filter, myOptions);
const isProduction = await models.VnUser.hasRole(userId, 'production', myOptions);
const isSalesPerson = await models.VnUser.hasRole(userId, 'salesPerson', myOptions);
vicent marked this conversation as resolved Outdated
Outdated
Review

Refactor, ho tens en rocket

Refactor, ho tens en rocket
const isAdministrative = await models.VnUser.hasRole(userId, 'administrative', myOptions);
if (isProduction || isAdministrative)
return statesList;
filter.where = {alertLevel: 0};
if (isSalesPerson) {
return statesList = statesList.filter(stateList =>
stateList.alertLevel === 0 || stateList.code === 'PICKER_DESIGNED'
);
}
if (isSalesPerson)
filter.where = {or: [{alertLevel: 0}, {code: 'PICKER_DESIGNED'}]};
return statesList.filter(stateList => stateList.alertLevel === 0);
if (isProduction || isAdministrative) delete filter.where;
return models.State.find(filter, myOptions);
};
};