refs #6276 getItemPackingType
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Jorge Penadés 2023-12-01 13:54:09 +01:00
parent 660e77be55
commit 4690dca4f9
4 changed files with 36 additions and 1 deletions

View File

@ -1,6 +1,6 @@
module.exports = Self => {
Self.remoteMethod('updateFromSale', {
description: 'Returns a list of items and possible alternative locations',
description: 'Update the visible items',
accessType: 'WRITE',
accepts: [{
arg: 'saleFk',

View File

@ -0,0 +1,28 @@
module.exports = Self => {
Self.remoteMethodCtx('getItemPackingType', {
description: 'Retrieve the operator items',
accessType: 'READ',
returns: {
type: 'string',
},
http: {
path: `/getItemPackingType`,
verb: 'GET'
},
});
Self.getItemPackingType = async ctx => {
const userId = 9 ?? ctx.req.accessToken.userId;
const result = await Self.findOne({
where: {
workerFk: userId
},
include: {
relation: 'itemPackingType',
}
});
const itemPackingType = result.itemPackingType();
return itemPackingType?.description;
};
};

View File

@ -2,6 +2,7 @@ module.exports = Self => {
require('../methods/operator/add')(Self);
require('../methods/operator/getPrinter')(Self);
require('../methods/operator/getAvailablePrinters')(Self);
require('../methods/operator/getItemPackingType')(Self);
Self.observe('after save', async function(ctx) {
const instance = ctx.data || ctx.instance;

View File

@ -43,6 +43,12 @@
"type": "belongsTo",
"model": "Printer",
"foreignKey": "labelerFk"
},
"itemPackingType": {
"type": "belongsTo",
"model": "ItemPackingType",
"foreignKey": "itemPackingTypeFk",
"primaryKey": "code"
}
}
}