diff --git a/back/methods/docuware/specs/core.spec.js b/back/methods/docuware/specs/core.spec.js index 0063c9a9e..60d1253ad 100644 --- a/back/methods/docuware/specs/core.spec.js +++ b/back/methods/docuware/specs/core.spec.js @@ -106,7 +106,7 @@ describe('Docuware core', () => { 'N__DOCUMENTO': { type: 'string', value: '12345' - }}); + }}, 'test.pdf'); expect(result.headers.Cookie).toEqual(null); expect(result.headers['Content-Type']).toEqual('multipart/form-data'); diff --git a/modules/ticket/back/methods/ticket/docuwareUpload.js b/modules/ticket/back/methods/ticket/docuwareUpload.js index 86f5efd92..7c722c17d 100644 --- a/modules/ticket/back/methods/ticket/docuwareUpload.js +++ b/modules/ticket/back/methods/ticket/docuwareUpload.js @@ -4,12 +4,13 @@ const UserError = require('vn-loopback/util/user-error'); const isProduction = require('vn-loopback/server/boot/isProduction'); module.exports = Self => { Self.docuwareUpload = async({ctx, tabletFk, ids: ticketIds, myOptions, uri, dialogId}) => { + const type = 'deliveryNote'; for (id of ticketIds) { // get delivery note ctx.args.id = id; const deliveryNote = await models.Ticket.deliveryNotePdf(ctx, { id, - type: 'deliveryNote' + type }, myOptions); // get ticket data @@ -70,7 +71,7 @@ module.exports = Self => { await models.Docuware.deleteOld(id, fileCabinet, uri); const uploadUri = `${uri}?StoreDialogId=${dialogId}`; - const {data, uploadOptions} = models.Docuware.uploadOptions(deliveryNote[0], configTemplate); + const {data, uploadOptions} = models.Docuware.uploadOptions(deliveryNote[0], configTemplate, `${type}.pdf`); 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 dc1a7c778..8ae9c89ed 100644 --- a/modules/worker/back/methods/worker/docuwareUpload.js +++ b/modules/worker/back/methods/worker/docuwareUpload.js @@ -10,6 +10,15 @@ module.exports = Self => { delete ctx.args.ids; // upload file + const workerFk = await models.DeviceProductionUser.findOne( + { + fields: ['userFk'], + where: {deviceProductionFk: pdaId} + } + , myOptions); + // const worker = await models.Worker.findById( + // workerFk + // , myOptions); const signPda = await models.Worker.signPdaPdf(ctx, pdaId, workerFk , myOptions); @@ -40,7 +49,8 @@ module.exports = Self => { await models.Docuware.deleteOld(id, fileCabinet, uri); const uploadUri = `${uri}?StoreDialogId=${dialogId}`; - const {data, uploadOptions} = await models.Docuware.uploadOptions(signPda[0], configTemplate); + const fileName = `assign${pdaId}Pda${workerFk}.pdf`; + const {data, uploadOptions} = await models.Docuware.uploadOptions(signPda[0], configTemplate, fileName); try { await axios.post(uploadUri, data, uploadOptions);