salix/modules/ticket/back/methods/sale-tracking/new.js

54 lines
1.3 KiB
JavaScript

module.exports = Self => {
Self.remoteMethodCtx('new', {
description: 'Remplaza el registro o lo crea si no existe',
accessType: 'READ',
accepts: [
{
arg: 'saleFk',
type: 'number',
description: 'The sale id'
},
{
arg: 'isChecked',
type: 'boolean'
},
{
arg: 'quantity',
type: 'number'
},
{
arg: 'stateCode',
type: 'string'
}
],
returns: {
type: ['object'],
root: true
},
http: {
path: `/new`,
verb: 'POST'
}
});
Self.new = async(ctx, saleFk, isChecked, quantity, stateCode, options) => {
const myOptions = {};
const userId = ctx.req.accessToken.userId;
if (typeof options == 'object')
Object.assign(myOptions, options);
query = `CALL vn.saleTracking_new(?, ?, ?, ?, ?, ?, ?)`;
return Self.rawSql(query,
[
saleFk,
isChecked,
quantity,
userId,
stateCode,
null
], myOptions);
};
};