#6276 createNewWarehouse methods migrated from silex to salix #1850
|
@ -18,5 +18,6 @@
|
|||
"salix",
|
||||
"fdescribe",
|
||||
"Loggable"
|
||||
]
|
||||
],
|
||||
"CodeGPT.apiKey": "CodeGPT Plus Beta"
|
||||
jorgep marked this conversation as resolved
Outdated
|
||||
}
|
||||
|
|
|
@ -210,6 +210,8 @@
|
|||
"We do not have availability for the selected item": "We do not have availability for the selected item",
|
||||
"You are already using a machine": "You are already using a machine",
|
||||
"This worker does not exist": "This worker does not exist",
|
||||
"this state does not exist": "This state does not exist"
|
||||
"this state does not exist": "This state does not exist",
|
||||
"The line could not be marked": "The line could not be marked"
|
||||
|
||||
|
||||
}
|
|
@ -331,7 +331,6 @@
|
|||
"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}}",
|
||||
"The line could not be marked": "The line could not be marked",
|
||||
"This claim has been updated": "La reclamación con Id: {{claimId}}, ha sido actualizada",
|
||||
"This user does not have an assigned tablet": "Este usuario no tiene tablet asignada",
|
||||
"Incorrect pin": "Pin incorrecto.",
|
||||
|
@ -347,5 +346,7 @@
|
|||
"You are already using a machine": "Ya estás usando una máquina.",
|
||||
"This worker does not exist": "Este trabajador no existe",
|
||||
"this state does not exist": "Este estado no existe",
|
||||
"Este estado no existe": "Este estado no existe"
|
||||
"Este estado no existe": "Este estado no existe",
|
||||
"The line could not be marked": "No se ha podido marcar la línea",
|
||||
"No se ha podido marcar la línea": "No se ha podido marcar la línea"
|
||||
}
|
|
@ -268,14 +268,8 @@ class VnMySQL extends MySQL {
|
|||
arguments, model, ctx, opts, cb);
|
||||
}
|
||||
|
||||
isLoggable(model) {
|
||||
jorgep marked this conversation as resolved
Outdated
alexm
commented
Esto te lo ha dicho Juan? Esto te lo ha dicho Juan?
Esto cambia el como se loggean todos los cambios
jorgep
commented
Sí @alexm , @jgallego . Me hacía falta para poder utilizar la función account.getMyuserId (o parecido) dentro de los procedimientos. Si no, coge el usuario del sistema. En caso de duda, habría que hablarlo con @juan Sí @alexm , @jgallego . Me hacía falta para poder utilizar la función account.getMyuserId (o parecido) dentro de los procedimientos. Si no, coge el usuario del sistema. En caso de duda, habría que hablarlo con @juan
jorgep
commented
De momento he puesto que el modelo SaleBuy sea loggable, tal cual hemos hablado @alexm y yo. Le he preguntado por rocket a @juan a ver que opina... @sergiodt @jgallego . De momento he puesto que el modelo SaleBuy sea loggable, tal cual hemos hablado @alexm y yo. Le he preguntado por rocket a @juan a ver que opina... @sergiodt @jgallego .
jorgep
commented
Cambios realizados para que todos tengan acceso acceso a userId, no solo loggable. Revisado con @juan Cambios realizados para que todos tengan acceso acceso a userId, no solo loggable. Revisado con @juan
|
||||
const Model = this.getModelDefinition(model).model;
|
||||
const {settings} = Model.definition;
|
||||
return settings?.mixins?.Loggable;
|
||||
}
|
||||
|
||||
invokeMethod(method, args, model, ctx, opts, cb) {
|
||||
if (!this.isLoggable(model))
|
||||
if (!opts?.httpCtx)
|
||||
return super[method].apply(this, args);
|
||||
|
||||
this.invokeMethodP(method, [...args], model, ctx, opts)
|
||||
|
|
|
@ -54,6 +54,7 @@ module.exports = Self => {
|
|||
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 $t = ctx.req.__;
|
||||
const myOptions = {};
|
||||
let tx;
|
||||
|
||||
|
@ -73,15 +74,9 @@ module.exports = Self => {
|
|||
userFk: userId
|
||||
}, myOptions);
|
||||
|
||||
const itemShelving = await models.ItemShelving.findOne({
|
||||
where: {
|
||||
id: itemShelvingFk
|
||||
}
|
||||
}, myOptions);
|
||||
const itemShelving = await models.ItemShelving.findById(itemShelvingFk, myOptions);
|
||||
|
||||
await itemShelving.updateAttributes({
|
||||
visible: itemShelving.visible - quantity}
|
||||
, myOptions);
|
||||
await itemShelving.updateAttributes({visible: itemShelving.visible - quantity}, myOptions);
|
||||
|
||||
await Self.updateAll(
|
||||
{saleFk},
|
||||
|
@ -89,12 +84,21 @@ module.exports = Self => {
|
|||
myOptions
|
||||
);
|
||||
|
||||
await Self.updateTracking(ctx, saleFk, originalQuantity, code, isChecked, buyFk, isScanned, myOptions);
|
||||
await Self.updateTracking(ctx, saleFk, originalQuantity, code, isChecked, null, isScanned, myOptions);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw new UserError('The line could not be marked');
|
||||
throw new UserError($t('The line could not be marked'));
|
||||
}
|
||||
jorgep marked this conversation as resolved
Outdated
alexm
commented
No hace falta usar $t, UserError traduce por defecto. No hace falta usar $t, UserError traduce por defecto.
|
||||
|
||||
const buy = await models.Buy.findOne({
|
||||
where: {
|
||||
id: buyFk,
|
||||
itemOriginalFk: {neq: null}
|
||||
jorgep marked this conversation as resolved
Outdated
jgallego
commented
cannot cannot
|
||||
}
|
||||
});
|
||||
|
||||
if (buy) await models.SaleBuy.create({saleFk, buyFk});
|
||||
};
|
||||
};
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
fdescribe('saleTracking mark()', () => {
|
||||
const saleFk = 1;
|
||||
const originalQuantity = 10;
|
||||
const code = 'PREPARED';
|
||||
const isChecked = true;
|
||||
const buyFk = 1;
|
||||
const isScanned = false;
|
||||
const quantity = 1;
|
||||
const itemShelvingFk = 1;
|
||||
|
||||
beforeAll(async() => {
|
||||
ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 104},
|
||||
headers: {origin: 'http://localhost'},
|
||||
__: value => value
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
it('should throw an error if the line was not able to be marked', async() => {
|
||||
const tx = await models.SaleTracking.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
const code = 'FAKESTATE';
|
||||
try {
|
||||
await models.SaleTracking.mark(
|
||||
ctx,
|
||||
saleFk,
|
||||
originalQuantity,
|
||||
code,
|
||||
isChecked,
|
||||
buyFk,
|
||||
isScanned,
|
||||
quantity,
|
||||
itemShelvingFk,
|
||||
options
|
||||
);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
const error = e;
|
||||
|
||||
expect(error.message).toEqual('The line could not be marked');
|
||||
await tx.rollback();
|
||||
}
|
||||
});
|
||||
|
||||
it('should add an itemShelvingSale and Modify a saleTracking', async() => {
|
||||
const tx = await models.SaleTracking.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
try {
|
||||
const itemShelvingSaleBefore = await models.ItemShelvingSale.find({}, options);
|
||||
await models.SaleTracking.mark(
|
||||
ctx,
|
||||
saleFk,
|
||||
originalQuantity,
|
||||
code,
|
||||
isChecked,
|
||||
buyFk,
|
||||
isScanned,
|
||||
quantity,
|
||||
itemShelvingFk,
|
||||
options
|
||||
);
|
||||
const itemShelvingSaleAfter = await models.ItemShelvingSale.find({}, options);
|
||||
const saleTracking = await models.SaleTracking.findOne({where: {saleFk, isChecked: false}}, options);
|
||||
|
||||
expect(itemShelvingSaleAfter.length).toEqual(itemShelvingSaleBefore.length + 1);
|
||||
expect(saleTracking.isChecked).toBeFalse();
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
}
|
||||
});
|
||||
});
|
|
@ -18,7 +18,7 @@ describe('saleTracking updateTracking()', () => {
|
|||
};
|
||||
});
|
||||
|
||||
it('should add a new saleTracking and saleBuy', async() => {
|
||||
it('should throw an error if the state does not exist', async() => {
|
||||
const tx = await models.SaleTracking.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
const code = 'FAKESTATE';
|
||||
|
|
Loading…
Reference in New Issue
esto a nivel equipo lo subimos @alexm ?
Lo voy a quitar, yo lo plantearía con @jsegarra en un reunión de salix.
Este archivo sólo sube en caso de añadir palabras para la extensión de Code Spell Checker.
Yo tengo la misma que tu y no me ha cambiado nada.
Descartaría los cambios d este fichero si no aporta valor