correciones varias

This commit is contained in:
Daniel Herrero 2017-10-19 09:12:27 +02:00
parent 070cd764b6
commit 9159af69f4
5 changed files with 24 additions and 25 deletions

View File

@ -134,10 +134,10 @@ module.exports = function(Client) {
JOIN RoleMapping rm ON (rm.principalId = ac.id) JOIN RoleMapping rm ON (rm.principalId = ac.id)
JOIN Role r on (r.id = rm.roleId) JOIN Role r on (r.id = rm.roleId)
WHERE rm.principalType = 'USER' WHERE rm.principalType = 'USER'
AND cc.employeeFk = ${instances[0].employeeFk} AND cc.employeeFk = ?
AND r.\`name\` = 'manager'`; AND r.\`name\` = 'manager'`;
Client.dataSource.connector.execute(sql, [], (_, res) => clientCreditCb(_, res)); Client.dataSource.connector.execute(sql, [instances[0].employeeFk], (_, res) => clientCreditCb(_, res));
} }
function clientCreditCb(_, instance) { function clientCreditCb(_, instance) {

View File

@ -33,7 +33,7 @@ module.exports = (Client) => {
ORDER BY em.name ASC ORDER BY em.name ASC
LIMIT ? OFFSET ?`; LIMIT ? OFFSET ?`;
Client.rawSql(query, [where.value, limit, skip], callback) Client.rawSql(query, [where.value, parseInt(limit, 10), parseInt(skip, 10)], callback)
.then(response => { .then(response => {
callback(null, formatSalesPerson(response)); callback(null, formatSalesPerson(response));
}) })

View File

@ -36,7 +36,7 @@ module.exports = function(Self) {
}); });
function getAddress(ctx, newData, next) { function getAddress(ctx, newData, next) {
Self.findOne( {where: { id: newData.id}}, function (err, oldData){ Self.findOne({where: {id: newData.id}}, (_, oldData) => {
if (oldData) if (oldData)
callbackGetAddress(ctx, newData, oldData, next); callbackGetAddress(ctx, newData, oldData, next);
}); });
@ -45,10 +45,9 @@ module.exports = function(Self) {
function callbackGetAddress(ctx, newData, oldData, next) { function callbackGetAddress(ctx, newData, oldData, next) {
if (newData.isDefaultAddress) { if (newData.isDefaultAddress) {
removeAllDefault(oldData.client, next); removeAllDefault(oldData.client, next);
} } else if (oldData.isDefaultAddress && newData.hasOwnProperty('isDefaultAddress') && !newData.isDefaultAddress) {
else if (oldData.isDefaultAddress && newData.hasOwnProperty('isDefaultAddress') && !newData.isDefaultAddress)
next(generateErrorDefaultAddress()); next(generateErrorDefaultAddress());
else } else
next(); next();
} }