diff --git a/back/models/docuware.json b/back/models/docuware.json index dec20eede..b1a6a8bce 100644 --- a/back/models/docuware.json +++ b/back/models/docuware.json @@ -28,5 +28,12 @@ "findById": { "type": "string" } + }, + "relations": { + "dmsType": { + "type": "belongsTo", + "model": "DmsType", + "foreignKey": "dmsTypeFk" + } } } diff --git a/modules/worker/back/methods/worker-dms/filter.js b/modules/worker/back/methods/worker-dms/filter.js index 1343038b7..e19010988 100644 --- a/modules/worker/back/methods/worker-dms/filter.js +++ b/modules/worker/back/methods/worker-dms/filter.js @@ -62,22 +62,25 @@ module.exports = Self => { where: {code: 'hr', action: 'find'} }); const docuwareDmsType = docuware.dmsTypeFk; + let workerDocuware; if (!(docuwareDmsType && !await models.DmsType.hasReadRole(ctx, docuwareDmsType))) { const worker = await models.Worker.findById(id, {fields: ['fi', 'firstName', 'lastName']}); const docuwareParse = { 'Filename': 'dmsFk', 'Tipo Documento': 'description', 'Stored on': 'created', + 'Document ID': 'id' }; - const workerDocuware = + workerDocuware = await models.Docuware.getById('hr', worker.lastName + worker.firstName, docuwareParse); for (document of workerDocuware) { const defaultData = { - file: document.dmsFk + '.png', + file: 'dw' + document.id + '.png', isDocuware: true, hardCopyNumber: null, hasFile: false, - reference: worker.fi + reference: worker.fi, + dmsFk: 'DW' + document.id }; document = Object.assign(document, defaultData);