#6276 createNewWarehouse methods migrated from silex to salix #1850

Merged
jorgep merged 158 commits from 6276-createNewWarehouse into dev 2024-03-06 11:32:11 +00:00
5 changed files with 109 additions and 3 deletions
Showing only changes of commit 3109f7722e - Show all commits

View File

@ -6,4 +6,5 @@ INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalTyp
('MachineWorker','add','READ','ALLOW','ROLE','employee'),
('MobileAppVersionControl','getVersion','READ','ALLOW','ROLE','employee'),
('SaleTracking','deleteTracking','WRITE','ALLOW','ROLE','employee'),
('SaleTracking','updateTracking','WRITE','ALLOW','ROLE','employee');
('SaleTracking','updateTracking','WRITE','ALLOW','ROLE','employee'),
('SaleTracking','mark','WRITE','ALLOW','ROLE','employee');

View File

@ -200,5 +200,6 @@
"Try again": "Try again",
"keepPrice": "keepPrice",
"Cannot past travels with entries": "Cannot past travels with entries",
"It was not able to remove the next expeditions:": "It was not able to remove the next expeditions: {{expeditions}}"
"It was not able to remove the next expeditions:": "It was not able to remove the next expeditions: {{expeditions}}",
"The notification subscription of this worker cant be modified": "The notification subscription of this worker cant be modified"
}

View File

@ -329,5 +329,6 @@
"The amount cannot be less than the minimum": "La cantidad no puede ser menor que la cantidad mínima",
"quantityLessThanMin": "La cantidad no puede ser menor que la cantidad mínima",
"Cannot past travels with entries": "No se pueden pasar envíos con entradas",
"It was not able to remove the next expeditions:": "No se pudo eliminar las siguientes expediciones: {{expeditions}}"
"It was not able to remove the next expeditions:": "No se pudo eliminar las siguientes expediciones: {{expeditions}}",
"The line could not be marked": "The line could not be marked"
}

View File

@ -0,0 +1,102 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethodCtx('mark', {
jorgep marked this conversation as resolved Outdated

mark es poco descriptivo, buscad un nombre que diga algo mas sobre el cometido del método.

mark es poco descriptivo, buscad un nombre que diga algo mas sobre el cometido del método.

@jgallego saleMarked bien?

@jgallego saleMarked bien?

aqui se hacen cambios en varias tablas, imagino que es fruto de una acción muy concreta. Cual es? porque tal vez ese sea el nombre mas descriptivo @sergiodt ? ej setPicked?

aqui se hacen cambios en varias tablas, imagino que es fruto de una acción muy concreta. Cual es? porque tal vez ese sea el nombre mas descriptivo @sergiodt ? ej setPicked?
description: 'Insert an itemShelvingSale and Modify a saleTracking record',
accessType: 'WRITE',
accepts: [
{
arg: 'saleFk',
type: 'number',
required: true
},
{
arg: 'originalQuantity',
type: 'number',
required: true
},
{
arg: 'code',
type: 'string',
required: true
},
{
arg: 'isChecked',
type: 'number',
required: true
},
{
arg: 'buyFk',
type: 'number',
required: true
},
{
arg: 'isScanned',
type: 'number',
},
{
arg: 'quantity',
type: 'number',
required: true
},
{
arg: 'itemShelvingFk',
type: 'number',
required: true
}
],
http: {
path: `/mark`,
verb: 'POST'
}
});
Self.mark = async(ctx, saleFk, originalQuantity, code, isChecked, buyFk, isScanned, quantity, itemShelvingFk, options) => {
const userId = ctx.req.accessToken.userId;
const models = Self.app.models;
const myOptions = {};
let tx;
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
try {
await models.ItemShelvingSale.create({
itemShelvingFk,
saleFk,
quantity,
userFk: userId
}, myOptions);
const itemShelving = await models.ItemShelving.findOne({
where: {
id: itemShelvingFk
}
}, myOptions);
if (itemShelving.visible) {
await itemShelving.updateAttributes({
visible: itemShelving.visible - quantity}
, myOptions);
}
await Self.updateAll(
{saleFk},
{isChecked: 1},
myOptions
);
jorgep marked this conversation as resolved Outdated
Outdated
Review

No hace falta usar $t, UserError traduce por defecto.

No hace falta usar $t, UserError traduce por defecto.
await Self.updateTracking(ctx, saleFk, originalQuantity, code, isChecked, buyFk, isScanned, myOptions);
if (tx) await tx.commit();
} catch (e) {
if (tx) await tx.rollback();
jorgep marked this conversation as resolved Outdated

cannot

cannot
throw new UserError('The line could not be marked');
}
};
};

View File

@ -4,4 +4,5 @@ module.exports = Self => {
require('../methods/sale-tracking/new')(Self);
require('../methods/sale-tracking/delete')(Self);
require('../methods/sale-tracking/updateTracking')(Self);
require('../methods/sale-tracking/mark')(Self);
};