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

54 lines
1.3 KiB
JavaScript
Raw Normal View History

2023-06-01 13:01:38 +00:00
module.exports = Self => {
2023-06-02 11:31:41 +00:00
Self.remoteMethodCtx('new', {
2023-06-01 13:01:38 +00:00
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: {
2023-06-02 11:31:41 +00:00
path: `/new`,
2023-06-01 13:01:38 +00:00
verb: 'POST'
}
});
2023-06-02 11:31:41 +00:00
Self.new = async(ctx, saleFk, isChecked, quantity, stateCode, options) => {
2023-06-01 13:01:38 +00:00
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);
2023-06-01 13:01:38 +00:00
};
};