80 lines
2.3 KiB
JavaScript
80 lines
2.3 KiB
JavaScript
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'
|
|
}
|
|
});
|
|
|
|
Self.summary = async id => {
|
|
const filter = {
|
|
include: [
|
|
{
|
|
relation: 'company',
|
|
scope: {
|
|
fields: ['id', 'code']
|
|
}
|
|
},
|
|
{
|
|
relation: 'supplier',
|
|
scope: {
|
|
fields: ['id', 'name']
|
|
}
|
|
},
|
|
{
|
|
relation: 'sageWithholding',
|
|
scope: {
|
|
fields: ['withholding']
|
|
}
|
|
},
|
|
{
|
|
relation: 'invoiceInTax',
|
|
scope: {
|
|
fields: ['id', 'invoiceInFk', 'taxableBase', 'expenseFk', 'taxTypeSageFk', 'transactionTypeSageFk', 'foreignValue'],
|
|
include: [{
|
|
relation: 'transactionTypeSage',
|
|
scope: {
|
|
fields: ['transaction']
|
|
}
|
|
},
|
|
{
|
|
relation: 'taxTypeSage',
|
|
scope: {
|
|
fields: ['vat']
|
|
}
|
|
}]
|
|
}
|
|
},
|
|
{
|
|
relation: 'expenseDeductible',
|
|
scope: {
|
|
fields: ['id', 'name', 'taxTypeFk']
|
|
}
|
|
},
|
|
{
|
|
relation: 'currency',
|
|
scope: {
|
|
fields: ['id', 'name']
|
|
|
|
}
|
|
}
|
|
]
|
|
};
|
|
|
|
return Self.app.models.InvoiceIn.findById(id, filter);
|
|
};
|
|
};
|