Back end dependencies adjusted for #655

This commit is contained in:
Carlos Jimenez 2018-09-25 14:39:08 +02:00
parent e1131c2c93
commit 9bc8687a85
11 changed files with 30 additions and 17 deletions

View File

@ -1,6 +1,5 @@
module.exports = Self => {
// Validations
require('../methods/claim-beginning/importToNewRefundTicket')(Self);
Self.validatesUniquenessOf('saleFk', {
message: `A claim with that sale already exists`
});

View File

@ -31,6 +31,15 @@
},
"ticketFk": {
"type": "Number"
},
"claimStateFk": {
"type": "Number"
},
"clientFk": {
"type": "Number"
},
"workerFk": {
"type": "Number"
}
},
"relations": {
@ -48,6 +57,11 @@
"type": "belongsTo",
"model": "Worker",
"foreignKey": "workerFk"
},
"ticket": {
"type": "belongsTo",
"model": "Ticket",
"foreignKey": "ticketFk"
}
}
}

View File

@ -21,7 +21,7 @@ module.exports = Self => {
}
});
Self.new = async params => {
Self.new = async(params, transaction) => {
let existsAddress = await Self.app.models.Address.findOne({where: {id: params.addressFk, clientFk: params.clientFk}});
if (!existsAddress)
throw new UserError(`This address doesn't exist`);
@ -38,7 +38,7 @@ module.exports = Self => {
params.routeFk | null,
params.landed,
params.userId
]);
], transaction);
return result[1][0].newTicketId;
};

View File

@ -1,4 +1,4 @@
const UserError = require('vn-loopback/common/helpers').UserError;
const UserError = require(`../helpers`).UserError;
module.exports = Self => {
Self.rewriteDbError(function(err) {

View File

@ -1,5 +1,5 @@
module.exports = function(Self) {
require('../methods/ticket-tracking/changeState')(Self);
require('../../../ticket/common/methods/ticket-tracking/changeState')(Self);
Self.validatesPresenceOf('stateFk', {message: 'State cannot be blank'});
};

View File

@ -173,10 +173,10 @@ module.exports = function(Self) {
};
};
Self.rawSql = function(query, params, cb) {
Self.rawSql = function(query, params, options = {}, cb) {
var connector = this.dataSource.connector;
return new Promise(function(resolve, reject) {
connector.execute(query, params, function(error, response) {
connector.execute(query, params, options, function(error, response) {
if (cb)
cb(error, response);
if (error)

View File

@ -15,6 +15,15 @@
"ACL": {
"dataSource": "salix"
},
"ObservationType": {
"dataSource": "vn"
},
"TicketObservation": {
"dataSource": "vn"
},
"TicketTracking": {
"dataSource": "vn"
},
"RoleMapping": {
"dataSource": "salix"
},

View File

@ -1,13 +1,4 @@
{
"TicketObservation": {
"dataSource": "vn"
},
"ObservationType": {
"dataSource": "vn"
},
"TicketTracking": {
"dataSource": "vn"
},
"TicketPackaging": {
"dataSource": "vn"
},