fix(discount): handle error for a worker without business contract
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2022-12-23 08:27:03 +01:00
parent c27ecf42bb
commit 93c98e05fc
1 changed files with 2 additions and 0 deletions

View File

@ -24,6 +24,8 @@ module.exports = Self => {
const salesDepartment = await models.Department.findOne({where: {code: 'VT'}, fields: 'id'}, myOptions);
const departments = await models.Department.getLeaves(salesDepartment.id, null, myOptions);
const workerDepartment = await models.WorkerDepartment.findById(userId, null, myOptions);
if (!workerDepartment) return false;
const usesMana = departments.find(department => department.id == workerDepartment.departmentFk);
return usesMana ? true : false;