2023-06-01 13:01:38 +00:00
|
|
|
|
|
|
|
module.exports = Self => {
|
|
|
|
Self.remoteMethod('delete', {
|
|
|
|
description: 'Elimina el registro (si se cumple la condición) y inserta uno nuevo',
|
|
|
|
accessType: 'READ',
|
|
|
|
accepts: [
|
|
|
|
{
|
|
|
|
arg: 'saleFk',
|
|
|
|
type: 'number',
|
|
|
|
description: 'The sale id'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
arg: 'stateCode',
|
|
|
|
type: 'string'
|
|
|
|
}
|
|
|
|
],
|
|
|
|
returns: {
|
|
|
|
type: ['object'],
|
|
|
|
root: true
|
|
|
|
},
|
|
|
|
http: {
|
|
|
|
path: `/delete`,
|
|
|
|
verb: 'POST'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Self.delete = async(saleFk, stateCode, options) => {
|
|
|
|
const myOptions = {};
|
|
|
|
|
|
|
|
if (typeof options == 'object')
|
|
|
|
Object.assign(myOptions, options);
|
|
|
|
|
2023-06-02 08:57:28 +00:00
|
|
|
query = `CALL vn.saleTracking_del(?, ?)`;
|
|
|
|
return Self.rawSql(query,
|
|
|
|
[
|
|
|
|
saleFk,
|
|
|
|
stateCode,
|
|
|
|
], myOptions);
|
2023-06-01 13:01:38 +00:00
|
|
|
};
|
|
|
|
};
|