Loggable errors
gitea/salix/1982-travel_add_thermograph There was a failure building this commit
Details
gitea/salix/1982-travel_add_thermograph There was a failure building this commit
Details
This commit is contained in:
parent
41e69a2e9d
commit
5e4ab8b128
|
@ -3,6 +3,9 @@
|
|||
"name": "Dms",
|
||||
"description": "Documental Managment system",
|
||||
"base": "VnModel",
|
||||
"log": {
|
||||
"showField": "reference"
|
||||
},
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "dms"
|
||||
|
|
|
@ -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;
|
|
@ -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);
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
};
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
"type": "Date"
|
||||
},
|
||||
"changedModelId": {
|
||||
"type": "Number"
|
||||
"type": "String"
|
||||
},
|
||||
"changedModelValue": {
|
||||
"type": "String"
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
"name": "Travel",
|
||||
"base": "Loggable",
|
||||
"log": {
|
||||
"model":"TravelLog"
|
||||
"model":"TravelLog",
|
||||
"showField": "ref"
|
||||
},
|
||||
"options": {
|
||||
"mysql": {
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue