28 lines
716 B
JavaScript
28 lines
716 B
JavaScript
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`;
|
|
let response = await Self.rawSql(query, [clientFk]);
|
|
return response[0];
|
|
};
|
|
};
|