8032-devToTest_2440 #3009

Merged
alexm merged 262 commits from 8032-devToTest_2440 into test 2024-09-24 09:34:49 +00:00
1 changed files with 54 additions and 3 deletions
Showing only changes of commit 8dc83e2444 - Show all commits

View File

@ -57,15 +57,66 @@ module.exports = Self => {
}
}]
};
const where = mergeWhere(filter.where, yourOwnDms);
stmt.merge(conn.makeSuffix({where}));
const dmsIds = await conn.executeStmt(stmt);
const allowedIds = dmsIds.map(dms => dms.id);
const allowedFilter = mergeFilters(filter, {where: {dmsFk: {inq: allowedIds}}});
const allowedFilter = mergeFilters(filter, {where: {dmsFk: {inq: allowedIds}, workerFk: id}});
const find = await models.WorkerDms.find(allowedFilter);
const workerDms = await models.WorkerDms.find(allowedFilter);
return find;
const workerDocuware = filter.skip ? [] : await getDocuwareasync(ctx, id);
return workerDms.concat(workerDocuware);
async function getDocuwareasync(ctx, id) {
const {dmsTypeFk} = await models.Docuware.findOne({
fields: ['dmsTypeFk'],
where: {code: 'hr', action: 'find'}
});
if (!await models.DmsType.hasReadRole(ctx, dmsTypeFk)) return [];
let workerDocuware = [];
const worker = await models.Worker.findById(id, {fields: ['fi', 'firstName', 'lastName']});
const docuwareParse = {
'Filename': 'dmsFk',
'Tipo Documento': 'description',
'Stored on': 'created',
'Document ID': 'id',
'URL': 'download',
'Stored by': 'name',
'Estado': 'state'
};
workerDocuware =
await models.Docuware.getById('hr', worker.lastName + ' ' + worker.firstName, docuwareParse) ?? [];
const url = (await Self.app.models.Url.getUrl('docuware')) + 'WebClient';
for (document of workerDocuware) {
const docuwareId = document.id;
const defaultData = {
id: docuwareId,
workerFk: id,
dmsFk: docuwareId,
dms: {
id: docuwareId,
file: docuwareId + '.pdf',
isDocuware: true,
hasFile: false,
reference: worker.fi,
dmsFk: docuwareId,
url,
description: document.description + ' - ' + document.state,
download: document.download,
created: document.created,
dmsType: {name: 'Docuware'},
worker: {id: null, user: {name: document.name}},
}
};
Object.assign(document, defaultData);
}
return workerDocuware;
}
};
};