salix/modules/supplier/back/methods/supplier/updateFiscalData.js

99 lines
2.1 KiB
JavaScript
Raw Normal View History

2020-10-30 14:11:45 +00:00
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'
2020-10-30 14:11:45 +00:00
},
{
arg: 'sageTaxTypeFk',
type: 'any'
2020-10-30 14:11:45 +00:00
},
{
arg: 'sageWithholdingFk',
type: 'any'
2020-10-30 14:11:45 +00:00
},
{
arg: 'sageTransactionTypeFk',
type: 'any'
2020-10-30 14:11:45 +00:00
},
{
arg: 'postCode',
type: 'any'
2020-10-30 14:11:45 +00:00
},
{
arg: 'street',
type: 'any'
},
2020-10-30 14:11:45 +00:00
{
arg: 'city',
type: 'string'
},
{
arg: 'provinceFk',
type: 'any'
2020-10-30 14:11:45 +00:00
},
{
arg: 'countryFk',
type: 'any'
2022-04-25 10:23:03 +00:00
},
{
arg: 'supplierActivityFk',
type: 'string'
},
{
arg: 'healthRegister',
type: 'string'
2022-11-18 08:21:21 +00:00
},
{
arg: 'isVies',
type: 'boolean'
},
2023-02-28 13:39:01 +00:00
{
arg: 'isTrucker',
type: 'boolean'
2020-10-30 14:11:45 +00:00
}],
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);
};
};