Compare commits
No commits in common. "613327491bff2fb713af47853c4923d26eb70fb8" and "100936d40b935e0dac0f3f30e05c58ae0cced69f" have entirely different histories.
613327491b
...
100936d40b
|
@ -3,7 +3,7 @@
|
||||||
// Carácter predeterminado de final de línea.
|
// Carácter predeterminado de final de línea.
|
||||||
"files.eol": "\n",
|
"files.eol": "\n",
|
||||||
"editor.codeActionsOnSave": {
|
"editor.codeActionsOnSave": {
|
||||||
"source.fixAll.eslint": "explicit"
|
"source.fixAll.eslint": true
|
||||||
},
|
},
|
||||||
"search.useIgnoreFiles": false,
|
"search.useIgnoreFiles": false,
|
||||||
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
|
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
|
||||||
|
|
|
@ -24,40 +24,15 @@ describe('docuware upload()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should try upload file', async() => {
|
it('should try upload file', async() => {
|
||||||
const tx = await models.Docuware.beginTransaction({});
|
|
||||||
spyOn(ticketModel, 'deliveryNotePdf').and.returnValue(new Promise(resolve => resolve({})));
|
spyOn(ticketModel, 'deliveryNotePdf').and.returnValue(new Promise(resolve => resolve({})));
|
||||||
|
|
||||||
let error;
|
let error;
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
await models.Docuware.upload(ctx, ticketIds, fileCabinetName);
|
||||||
const user = await models.UserConfig.findById(userId, null, options);
|
|
||||||
await user.updateAttribute('tabletFk', 'Tablet1');
|
|
||||||
await models.Docuware.upload(ctx, ticketIds, fileCabinetName, options);
|
|
||||||
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error = e;
|
error = e.message;
|
||||||
await tx.rollback();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(error.message).toEqual('Action not allowed on the test environment');
|
expect(error).toEqual('Action not allowed on the test environment');
|
||||||
});
|
|
||||||
|
|
||||||
it('should throw error when not have tablet assigned', async() => {
|
|
||||||
const tx = await models.Docuware.beginTransaction({});
|
|
||||||
spyOn(ticketModel, 'deliveryNotePdf').and.returnValue(new Promise(resolve => resolve({})));
|
|
||||||
|
|
||||||
let error;
|
|
||||||
try {
|
|
||||||
const options = {transaction: tx};
|
|
||||||
await models.Docuware.upload(ctx, ticketIds, fileCabinetName, options);
|
|
||||||
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
|
||||||
error = e;
|
|
||||||
await tx.rollback();
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(error.message).toEqual('This user does not have an assigned tablet');
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -29,24 +29,12 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.upload = async function(ctx, ticketIds, fileCabinet, options) {
|
Self.upload = async function(ctx, ticketIds, fileCabinet) {
|
||||||
delete ctx.args.ticketIds;
|
delete ctx.args.ticketIds;
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const action = 'store';
|
const action = 'store';
|
||||||
|
|
||||||
const myOptions = {};
|
const options = await Self.getOptions();
|
||||||
|
|
||||||
if (typeof options == 'object')
|
|
||||||
Object.assign(myOptions, options);
|
|
||||||
|
|
||||||
const userConfig = await models.UserConfig.findById(ctx.req.accessToken.userId, {
|
|
||||||
fields: ['tabletFk']
|
|
||||||
}, myOptions);
|
|
||||||
|
|
||||||
if (!userConfig?.tabletFk)
|
|
||||||
throw new UserError('This user does not have an assigned tablet');
|
|
||||||
|
|
||||||
const docuwareOptions = await Self.getOptions();
|
|
||||||
const fileCabinetId = await Self.getFileCabinet(fileCabinet);
|
const fileCabinetId = await Self.getFileCabinet(fileCabinet);
|
||||||
const dialogId = await Self.getDialog(fileCabinet, action, fileCabinetId);
|
const dialogId = await Self.getDialog(fileCabinet, action, fileCabinetId);
|
||||||
|
|
||||||
|
@ -57,7 +45,7 @@ module.exports = Self => {
|
||||||
const deliveryNote = await models.Ticket.deliveryNotePdf(ctx, {
|
const deliveryNote = await models.Ticket.deliveryNotePdf(ctx, {
|
||||||
id,
|
id,
|
||||||
type: 'deliveryNote'
|
type: 'deliveryNote'
|
||||||
}, myOptions);
|
});
|
||||||
// get ticket data
|
// get ticket data
|
||||||
const ticket = await models.Ticket.findById(id, {
|
const ticket = await models.Ticket.findById(id, {
|
||||||
include: [{
|
include: [{
|
||||||
|
@ -66,7 +54,7 @@ module.exports = Self => {
|
||||||
fields: ['id', 'name', 'fi']
|
fields: ['id', 'name', 'fi']
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}, myOptions);
|
});
|
||||||
|
|
||||||
// upload file
|
// upload file
|
||||||
const templateJson = {
|
const templateJson = {
|
||||||
|
@ -114,7 +102,7 @@ module.exports = Self => {
|
||||||
{
|
{
|
||||||
'FieldName': 'FILTRO_TABLET',
|
'FieldName': 'FILTRO_TABLET',
|
||||||
'ItemElementName': 'string',
|
'ItemElementName': 'string',
|
||||||
'Item': userConfig.tabletFk,
|
'Item': 'Tablet1',
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
@ -128,11 +116,11 @@ module.exports = Self => {
|
||||||
const deleteJson = {
|
const deleteJson = {
|
||||||
'Field': [{'FieldName': 'ESTADO', 'Item': 'Pendiente eliminar', 'ItemElementName': 'String'}]
|
'Field': [{'FieldName': 'ESTADO', 'Item': 'Pendiente eliminar', 'ItemElementName': 'String'}]
|
||||||
};
|
};
|
||||||
const deleteUri = `${docuwareOptions.url}/FileCabinets/${fileCabinetId}/Documents/${docuwareFile.id}/Fields`;
|
const deleteUri = `${options.url}/FileCabinets/${fileCabinetId}/Documents/${docuwareFile.id}/Fields`;
|
||||||
await axios.put(deleteUri, deleteJson, docuwareOptions.headers);
|
await axios.put(deleteUri, deleteJson, options.headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
const uploadUri = `${docuwareOptions.url}/FileCabinets/${fileCabinetId}/Documents?StoreDialogId=${dialogId}`;
|
const uploadUri = `${options.url}/FileCabinets/${fileCabinetId}/Documents?StoreDialogId=${dialogId}`;
|
||||||
const FormData = require('form-data');
|
const FormData = require('form-data');
|
||||||
const data = new FormData();
|
const data = new FormData();
|
||||||
|
|
||||||
|
@ -142,7 +130,7 @@ module.exports = Self => {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'multipart/form-data',
|
'Content-Type': 'multipart/form-data',
|
||||||
'X-File-ModifiedDate': Date.vnNew(),
|
'X-File-ModifiedDate': Date.vnNew(),
|
||||||
'Cookie': docuwareOptions.headers.headers.Cookie,
|
'Cookie': options.headers.headers.Cookie,
|
||||||
...data.getHeaders()
|
...data.getHeaders()
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -153,11 +141,11 @@ module.exports = Self => {
|
||||||
const $t = ctx.req.__;
|
const $t = ctx.req.__;
|
||||||
const message = $t('Failed to upload delivery note', {id});
|
const message = $t('Failed to upload delivery note', {id});
|
||||||
if (uploaded.length)
|
if (uploaded.length)
|
||||||
await models.TicketTracking.setDelivered(ctx, uploaded, myOptions);
|
await models.TicketTracking.setDelivered(ctx, uploaded);
|
||||||
throw new UserError(message);
|
throw new UserError(message);
|
||||||
}
|
}
|
||||||
uploaded.push(id);
|
uploaded.push(id);
|
||||||
}
|
}
|
||||||
return models.TicketTracking.setDelivered(ctx, ticketIds, myOptions);
|
return models.TicketTracking.setDelivered(ctx, ticketIds);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
{
|
|
||||||
"name": "docuwareTablet",
|
|
||||||
"base": "VnModel",
|
|
||||||
"options": {
|
|
||||||
"mysql": {
|
|
||||||
"table": "docuwareTablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"properties": {
|
|
||||||
"tablet": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"description": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -26,9 +26,6 @@
|
||||||
},
|
},
|
||||||
"darkMode": {
|
"darkMode": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
|
||||||
"tabletFk": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
|
@ -46,11 +43,6 @@
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "VnUser",
|
"model": "VnUser",
|
||||||
"foreignKey": "userFk"
|
"foreignKey": "userFk"
|
||||||
},
|
}
|
||||||
"Tablet": {
|
|
||||||
"type": "belongsTo",
|
|
||||||
"model": "docuwareTablet",
|
|
||||||
"foreignKey": "tabletFk"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
-- vn.docuwareTablet definition
|
|
||||||
|
|
||||||
CREATE TABLE `vn`.`docuwareTablet` (
|
|
||||||
`tablet` varchar(100) NOT NULL PRIMARY KEY,
|
|
||||||
`description` varchar(255) DEFAULT NULL
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
|
||||||
|
|
||||||
ALTER TABLE `vn`.`userConfig`
|
|
||||||
ADD COLUMN tabletFk varchar(100) DEFAULT NULL,
|
|
||||||
ADD FOREIGN KEY (tabletFk) REFERENCES `vn`.`docuwareTablet`(tablet);
|
|
|
@ -3010,11 +3010,6 @@ INSERT INTO `vn`.`invoiceCorrectionType` (`id`, `description`)
|
||||||
(2, 'Error in sales details'),
|
(2, 'Error in sales details'),
|
||||||
(3, 'Error in customer data');
|
(3, 'Error in customer data');
|
||||||
|
|
||||||
INSERT INTO `vn`.`docuwareTablet` (`tablet`,`description`)
|
|
||||||
VALUES
|
|
||||||
('Tablet1','Jarvis tablet'),
|
|
||||||
('Tablet2','Avengers tablet');
|
|
||||||
|
|
||||||
|
|
||||||
UPDATE salix.ACL
|
UPDATE salix.ACL
|
||||||
SET principalId='employee'
|
SET principalId='employee'
|
||||||
|
|
|
@ -329,6 +329,5 @@
|
||||||
"The amount cannot be less than the minimum": "La cantidad no puede ser menor que la cantidad mínima",
|
"The amount cannot be less than the minimum": "La cantidad no puede ser menor que la cantidad mínima",
|
||||||
"quantityLessThanMin": "La cantidad no puede ser menor que la cantidad mínima",
|
"quantityLessThanMin": "La cantidad no puede ser menor que la cantidad mínima",
|
||||||
"Cannot past travels with entries": "No se pueden pasar envíos con entradas",
|
"Cannot past travels with entries": "No se pueden pasar envíos con entradas",
|
||||||
"It was not able to remove the next expeditions:": "No se pudo eliminar las siguientes expediciones: {{expeditions}}",
|
"It was not able to remove the next expeditions:": "No se pudo eliminar las siguientes expediciones: {{expeditions}}"
|
||||||
"This user does not have an assigned tablet": "Este usuario no tiene tablet asignada"
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue