Loggable errors
gitea/salix/1982-travel_add_thermograph There was a failure building this commit Details

This commit is contained in:
Joan Sanchez 2020-01-21 09:00:42 +01:00
parent 41e69a2e9d
commit 5e4ab8b128
10 changed files with 86 additions and 12 deletions

View File

@ -3,6 +3,9 @@
"name": "Dms",
"description": "Documental Managment system",
"base": "VnModel",
"log": {
"showField": "reference"
},
"options": {
"mysql": {
"table": "dms"

View File

@ -0,0 +1,7 @@
ALTER TABLE `vn`.`travelThermograph`
ADD COLUMN `id` INT NOT NULL AUTO_INCREMENT FIRST,
DROP PRIMARY KEY,
ADD PRIMARY KEY (`id`);
ALTER TABLE `vn`.`travelThermograph`
ADD UNIQUE INDEX `thermograph_created` (`thermographFk` ASC, `created` ASC) VISIBLE;

View File

@ -1959,4 +1959,5 @@ INSERT INTO `vn`.`travelThermograph`(`thermographFk`, `created`, `warehouseFk`,
('TL.BBA85422', DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2, 2, 'COOL', 'Ok', NULL),
('TL.BBA85422', CURDATE(), 2, 1, 'COOL', 'can not read the temperature', NULL),
('TZ1905012010', CURDATE(), 1, 1, 'WARM', 'Temperature in range', 5),
('138350-0', CURDATE(), 1, NULL, 'WARM', NULL, 5);
('138350-0', DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, NULL, 'WARM', NULL, 5),
('138350-0', CURDATE(), 1, 1, 'WARM', 'Ok', 5);

View File

@ -219,7 +219,7 @@ module.exports = function(Self) {
userFk: userFk,
action: action,
changedModel: ctx.Model.definition.name,
changedModelId: changedModelId,
changedModelId: changedModelId, // Model property with an different data type will throw a NaN error
changedModelValue: where,
oldInstance: oldInstance,
newInstance: newInstance

View File

@ -0,0 +1,61 @@
module.exports = Self => {
Self.remoteMethod('delete', {
description: 'Delete a invoiceOut',
accessType: 'WRITE',
accepts: {
arg: 'id',
type: 'string',
required: true,
description: 'The invoiceOut id',
http: {source: 'path'}
},
returns: {
type: 'object',
root: true
},
http: {
path: '/:id/delete',
verb: 'POST'
}
});
Self.delete = async id => {
const models = Self.app.models;
const targetClaimDms = await models.ClaimDms.findById(id);
const targetDms = await models.Dms.findById(targetClaimDms.dmsFk);
const trashDmsType = await models.DmsType.findOne({
where: {code: 'trash'}
});
await models.Dms.removeFile(ctx, targetClaimDms.dmsFk);
await targetClaimDms.destroy();
return targetDms.updateAttribute('dmsTypeFk', trashDmsType.id);
const transaction = await Self.beginTransaction({});
try {
let options = {transaction: transaction};
let invoiceOut = await Self.findById(id);
let tickets = await Self.app.models.Ticket.find({where: {refFk: invoiceOut.ref}});
const promises = [];
tickets.forEach(ticket => {
promises.push(ticket.updateAttribute('refFk', null, options));
});
await Promise.all(promises);
await invoiceOut.destroy(options);
await transaction.commit();
return tickets;
} catch (e) {
await transaction.rollback();
throw e;
}
};
};

View File

@ -46,7 +46,7 @@ module.exports = Self => {
}
});
Self.uploadFile = async(ctx, thermograpId, travelId) => {
Self.uploadFile = async(ctx, thermographId, travelId) => {
const models = Self.app.models;
const tx = await Self.beginTransaction({});
@ -57,7 +57,7 @@ module.exports = Self => {
const travelThermograph = await models.TravelThermograph.findOne({
where: {
thermographFk: thermograpId,
thermographFk: thermographId,
travelFk: null
}
}, options);
@ -65,7 +65,7 @@ module.exports = Self => {
await travelThermograph.updateAttributes({
dmsFk: firstDms.id,
travelFk: travelId
});
}, options);
await tx.commit();

View File

@ -36,7 +36,7 @@
"type": "Date"
},
"changedModelId": {
"type": "Number"
"type": "String"
},
"changedModelValue": {
"type": "String"

View File

@ -2,7 +2,9 @@
"name": "TravelThermograph",
"base": "Loggable",
"log": {
"model":"TravelLog"
"model":"TravelLog",
"relation": "travel",
"showField": "ref"
},
"options": {
"mysql": {
@ -12,12 +14,11 @@
"properties": {
"thermographFk": {
"type": "String",
"id": 1,
"description": "Identifier"
"description": "Identifier",
"id": true
},
"created": {
"type": "Date",
"id": 2,
"description": "Identifier"
},
"temperature": {

View File

@ -2,7 +2,8 @@
"name": "Travel",
"base": "Loggable",
"log": {
"model":"TravelLog"
"model":"TravelLog",
"showField": "ref"
},
"options": {
"mysql": {

View File

@ -8,7 +8,7 @@ Upload file: Subir fichero
Edit file: Editar fichero
Upload: Subir
File: Fichero
FileDescription: Travel id {{ticketId}}
FileDescription: Travel id {{travelId}}
ContentTypesInfo: 'Tipos de archivo permitidos: {{allowedContentTypes}}'
Are you sure you want to continue?: ¿Seguro que quieres continuar?
Add thermograph: Añadir termógrafo