feat(salix): refs #5926 #5926 update docuwareUpload models
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Javier Segarra 2024-06-07 02:00:10 +02:00
parent ee2b03cabf
commit e3679c8b9a
3 changed files with 15 additions and 4 deletions

View File

@ -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');

View File

@ -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);

View File

@ -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);