salix/services/loopback/common/methods/client/getDebt.js

29 lines
708 B
JavaScript
Raw Normal View History

module.exports = Self => {
Self.remoteMethod('getDebt', {
description: 'Returns the boolean debt of a client',
accessType: 'READ',
accepts: [{
arg: 'id',
type: 'number',
required: true,
description: 'client id',
http: {source: 'path'}
}],
returns: {
type: 'number',
root: true
},
http: {
path: `/:id/getDebt`,
verb: 'GET'
}
});
Self.getDebt = async clientFk => {
let query = `SELECT vn.clientGetDebt(?, CURDATE()) AS debt`;
2018-03-27 13:06:22 +00:00
let [debt] = await Self.rawSql(query, [clientFk]);
return debt;
};
};