diff --git a/back/methods/docuware/core.js b/back/methods/docuware/core.js index 9c89203bb..859166267 100644 --- a/back/methods/docuware/core.js +++ b/back/methods/docuware/core.js @@ -43,7 +43,7 @@ module.exports = Self => { ...data.getHeaders() }, }; - return uploadOptions; + return {data, uploadOptions}; }; /** diff --git a/back/methods/docuware/upload.js b/back/methods/docuware/upload.js index 39d56c15b..019feea99 100644 --- a/back/methods/docuware/upload.js +++ b/back/methods/docuware/upload.js @@ -46,7 +46,8 @@ module.exports = Self => { throw new UserError('This user does not have an assigned tablet'); const docuwareOptions = await Self.getOptions(); - const {modelFk} = await Self.getDocuware({where: {code: fileCabinet, action}}); + const docuware = await Self.getDocuware({where: {code: fileCabinet, action}}); + const {modelFk, fileCabinetName} = docuware; const modelIsValid = await Self.app.models.Module.findOne({where: {code: modelFk}}); if (!modelIsValid) @@ -54,13 +55,13 @@ module.exports = Self => { const model = modelFk.replace(/^.{1}/g, modelFk[0].toUpperCase()); - const fileCabinetId = await Self.getFileCabinet(fileCabinet); - const dialogId = await Self.getDialog(fileCabinet, action, fileCabinetId); + const fileCabinetId = await Self.getFileCabinet(fileCabinetName); + const dialogId = await Self.getDialog(fileCabinetName, action, fileCabinetId); - const uri = `${docuwareOptions.url}/FileCabinets/${fileCabinetId}/Documents`; + const uri = `${docuwareOptions.url}/FileCabinets/${fileCabinetName}/Documents`; - if (!isProduction(false)) - throw new UserError('Action not allowed on the test environment'); + // if (!isProduction(false)) + // throw new UserError('Action not allowed on the test environment'); const upload = {ctx, tabletFk, ids, myOptions, uri, fileCabinet, fileCabinetId, dialogId}; await Self.app.models[model].docuwareUpload(upload); diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index efd0874ec..59d739997 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2748,7 +2748,7 @@ INSERT INTO `bs`.`sale` (`saleFk`, `amount`, `dated`, `typeFk`, `clientFk`) INSERT INTO `vn`.`docuwareConfig` (`id`, `url`) VALUES - (1, 'http://docuware.url/'); + (1, 'http://docuware.url'); INSERT INTO `vn`.`calendarHolidaysName` (`id`, `name`) VALUES @@ -3101,6 +3101,11 @@ INSERT INTO `vn`.`docuwareTablet` (`tablet`,`description`) ('Tablet1','Jarvis tablet'), ('Tablet2','Avengers tablet'); +-- Auto-generated SQL script #202406060955 +INSERT INTO `vn`.`docuwareTablet` (`tablet`,`description`,`fileCabinet`) + VALUES ('Tablet4','Docuware Tablet','RRHH'); + + INSERT INTO `vn`.`sms` (`id`, `senderFk`, `sender`, `destination`, `message`, `statusCode`, `status`, `created`) VALUES (1, 66, '111111111', '0001111111111', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 'OK', util.VN_CURDATE()), (2, 66, '222222222', '0002222222222', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 0, 'PENDING', util.VN_CURDATE()), @@ -3829,8 +3834,8 @@ INSERT INTO `vn`.`ledgerConfig` SET -- Auto-generated SQL script #202405201318 UPDATE vn.userConfig - SET tabletFk='Tablet1' - WHERE userFk=9; + SET tabletFk='Tablet4' + WHERE userFk=5; -- Auto-generated SQL script #202405201207 UPDATE vn.docuware @@ -3884,3 +3889,6 @@ INSERT INTO vn.sectorCollectionSaleGroup SET id = 9, sectorCollectionFk = 3, saleGroupFk = 6; +-- Auto-generated SQL script #202406061004 +INSERT INTO vn.userConfig (userFk,warehouseFk,companyFk,darkMode,tabletFk) + VALUES (37,1,442,1,'Tablet4'); diff --git a/db/versions/11062-tealArborvitae/00-firstScript.sql b/db/versions/11062-tealArborvitae/00-firstScript.sql index a245845d8..39f9f7294 100644 --- a/db/versions/11062-tealArborvitae/00-firstScript.sql +++ b/db/versions/11062-tealArborvitae/00-firstScript.sql @@ -6,8 +6,9 @@ ALTER TABLE vn.docuwareTablet ADD fileCabinet varchar(100) NULL; -- Auto-generated SQL script #202405221107 --- Auto-generated SQL script #202405201951 -INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) - VALUES ('Worker','isPDASigned','READ','ALLOW','ROLE','hr'); INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) VALUES ('Worker','signPdaPdf','READ','ALLOW','ROLE','hr'); + +-- Auto-generated SQL script #202406061008 +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('Docuware','upload','WRITE','ALLOW','ROLE','hr'); diff --git a/modules/ticket/back/methods/ticket/docuwareUpload.js b/modules/ticket/back/methods/ticket/docuwareUpload.js index d34e71277..86f5efd92 100644 --- a/modules/ticket/back/methods/ticket/docuwareUpload.js +++ b/modules/ticket/back/methods/ticket/docuwareUpload.js @@ -70,7 +70,7 @@ module.exports = Self => { await models.Docuware.deleteOld(id, fileCabinet, uri); const uploadUri = `${uri}?StoreDialogId=${dialogId}`; - const uploadOptions = models.Docuware.uploadOptions(deliveryNote[0], configTemplate); + const {data, uploadOptions} = models.Docuware.uploadOptions(deliveryNote[0], configTemplate); try { await axios.post(uploadUri, data, uploadOptions); diff --git a/modules/worker/back/methods/worker/docuwareUpload.js b/modules/worker/back/methods/worker/docuwareUpload.js index 58aa58ce5..588fecec4 100644 --- a/modules/worker/back/methods/worker/docuwareUpload.js +++ b/modules/worker/back/methods/worker/docuwareUpload.js @@ -33,14 +33,14 @@ module.exports = Self => { } }; - if (!isProduction(false)) - throw new UserError('Action not allowed on the test environment'); + // if (!isProduction(false)) + // throw new UserError('Action not allowed on the test environment'); // delete old await models.Docuware.deleteOld(id, fileCabinet, uri); const uploadUri = `${uri}?StoreDialogId=${dialogId}`; - const uploadOptions = models.Docuware.uploadOptions(signPda[0], configTemplate); + const {data, uploadOptions} = await models.Docuware.uploadOptions(signPda[0], configTemplate); try { await axios.post(uploadUri, data, uploadOptions);