2021-04-15 08:44:25 +00:00
|
|
|
module.exports = Self => {
|
|
|
|
Self.remoteMethod('summary', {
|
|
|
|
description: 'The invoiceIn summary',
|
|
|
|
accessType: 'READ',
|
|
|
|
accepts: [{
|
|
|
|
arg: 'id',
|
|
|
|
type: 'number',
|
|
|
|
required: true,
|
|
|
|
description: 'The invoiceIn id',
|
|
|
|
http: {source: 'path'}
|
|
|
|
}],
|
|
|
|
returns: {
|
|
|
|
type: 'object',
|
|
|
|
root: true
|
|
|
|
},
|
|
|
|
http: {
|
|
|
|
path: `/:id/summary`,
|
|
|
|
verb: 'GET'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-06-28 08:15:54 +00:00
|
|
|
Self.summary = async(id, options) => {
|
|
|
|
let myOptions = {};
|
|
|
|
|
|
|
|
if (typeof options == 'object')
|
|
|
|
Object.assign(myOptions, options);
|
|
|
|
|
2021-04-15 08:44:25 +00:00
|
|
|
const filter = {
|
|
|
|
include: [
|
|
|
|
{
|
|
|
|
relation: 'company',
|
|
|
|
scope: {
|
|
|
|
fields: ['id', 'code']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
relation: 'supplier',
|
|
|
|
scope: {
|
|
|
|
fields: ['id', 'name']
|
|
|
|
}
|
2021-04-15 09:54:40 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
relation: 'sageWithholding',
|
|
|
|
scope: {
|
|
|
|
fields: ['withholding']
|
|
|
|
}
|
2021-06-10 15:08:21 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
relation: 'expenseDeductible',
|
|
|
|
scope: {
|
|
|
|
fields: ['id', 'name', 'taxTypeFk']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
relation: 'currency',
|
|
|
|
scope: {
|
|
|
|
fields: ['id', 'name']
|
|
|
|
}
|
2021-04-15 08:44:25 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
2021-06-28 08:15:54 +00:00
|
|
|
return Self.app.models.InvoiceIn.findById(id, filter, myOptions);
|
2021-04-15 08:44:25 +00:00
|
|
|
};
|
|
|
|
};
|