salix/modules/client/back/methods/client/canBeInvoiced.js

33 lines
895 B
JavaScript

module.exports = function(Self) {
Self.remoteMethodCtx('canBeInvoiced', {
description: 'Change property isEqualizated in all client addresses',
accessType: 'READ',
accepts: [
{
arg: 'id',
type: 'string',
required: true,
description: 'Client id',
http: {source: 'path'}
}
],
returns: {
arg: 'data',
type: 'boolean',
root: true
},
http: {
path: `/:id/canBeInvoiced`,
verb: 'get'
}
});
Self.canBeInvoiced = async id => {
let client = await Self.app.models.Client.findById(id, {fields: ['id', 'isTaxDataChecked', 'hasToInvoice']});
if (client.isTaxDataChecked && client.hasToInvoice)
return true;
return false;
};
};