29 lines
708 B
JavaScript
29 lines
708 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 [debt] = await Self.rawSql(query, [clientFk]);
|
|
|
|
return debt;
|
|
};
|
|
};
|