99 lines
2.1 KiB
JavaScript
99 lines
2.1 KiB
JavaScript
module.exports = Self => {
|
|
Self.remoteMethod('updateFiscalData', {
|
|
description: 'Updates fiscal data of a supplier',
|
|
accessType: 'WRITE',
|
|
accepts: [{
|
|
arg: 'ctx',
|
|
type: 'Object',
|
|
http: {source: 'context'}
|
|
},
|
|
{
|
|
arg: 'id',
|
|
type: 'Number',
|
|
description: 'The supplier id',
|
|
http: {source: 'path'}
|
|
},
|
|
{
|
|
arg: 'name',
|
|
type: 'string'
|
|
},
|
|
{
|
|
arg: 'nif',
|
|
type: 'string'
|
|
},
|
|
{
|
|
arg: 'account',
|
|
type: 'any'
|
|
},
|
|
{
|
|
arg: 'sageTaxTypeFk',
|
|
type: 'any'
|
|
},
|
|
{
|
|
arg: 'sageWithholdingFk',
|
|
type: 'any'
|
|
},
|
|
{
|
|
arg: 'sageTransactionTypeFk',
|
|
type: 'any'
|
|
},
|
|
{
|
|
arg: 'postCode',
|
|
type: 'any'
|
|
},
|
|
{
|
|
arg: 'street',
|
|
type: 'any'
|
|
},
|
|
{
|
|
arg: 'city',
|
|
type: 'string'
|
|
},
|
|
{
|
|
arg: 'provinceFk',
|
|
type: 'any'
|
|
},
|
|
{
|
|
arg: 'countryFk',
|
|
type: 'any'
|
|
},
|
|
{
|
|
arg: 'supplierActivityFk',
|
|
type: 'string'
|
|
},
|
|
{
|
|
arg: 'healthRegister',
|
|
type: 'string'
|
|
},
|
|
{
|
|
arg: 'isVies',
|
|
type: 'boolean'
|
|
},
|
|
{
|
|
arg: 'isTrucker',
|
|
type: 'boolean'
|
|
}],
|
|
returns: {
|
|
arg: 'res',
|
|
type: 'string',
|
|
root: true
|
|
},
|
|
http: {
|
|
path: `/:id/updateFiscalData`,
|
|
verb: 'PATCH'
|
|
}
|
|
});
|
|
|
|
Self.updateFiscalData = async(ctx, supplierId) => {
|
|
const models = Self.app.models;
|
|
const args = ctx.args;
|
|
const supplier = await models.Supplier.findById(supplierId);
|
|
|
|
// Remove unwanted properties
|
|
delete args.ctx;
|
|
delete args.id;
|
|
|
|
return supplier.updateAttributes(args);
|
|
};
|
|
};
|