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 => { module.exports = Self => {
// Validations require('../methods/claim-beginning/importToNewRefundTicket')(Self);
Self.validatesUniquenessOf('saleFk', { Self.validatesUniquenessOf('saleFk', {
message: `A claim with that sale already exists` message: `A claim with that sale already exists`
}); });

View File

@ -31,6 +31,15 @@
}, },
"ticketFk": { "ticketFk": {
"type": "Number" "type": "Number"
},
"claimStateFk": {
"type": "Number"
},
"clientFk": {
"type": "Number"
},
"workerFk": {
"type": "Number"
} }
}, },
"relations": { "relations": {
@ -48,6 +57,11 @@
"type": "belongsTo", "type": "belongsTo",
"model": "Worker", "model": "Worker",
"foreignKey": "workerFk" "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}}); let existsAddress = await Self.app.models.Address.findOne({where: {id: params.addressFk, clientFk: params.clientFk}});
if (!existsAddress) if (!existsAddress)
throw new UserError(`This address doesn't exist`); throw new UserError(`This address doesn't exist`);
@ -38,7 +38,7 @@ module.exports = Self => {
params.routeFk | null, params.routeFk | null,
params.landed, params.landed,
params.userId params.userId
]); ], transaction);
return result[1][0].newTicketId; 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 => { module.exports = Self => {
Self.rewriteDbError(function(err) { Self.rewriteDbError(function(err) {

View File

@ -1,5 +1,5 @@
module.exports = function(Self) { 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'}); 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; var connector = this.dataSource.connector;
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
connector.execute(query, params, function(error, response) { connector.execute(query, params, options, function(error, response) {
if (cb) if (cb)
cb(error, response); cb(error, response);
if (error) if (error)

View File

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

View File

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