#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 12 additions and 12 deletions
Showing only changes of commit 854a9b62af - Show all commits

View File

@ -47,9 +47,10 @@ module.exports = Self => {
}
}, myOptions);
const {maxHours} = await models.MachineWorkerConfig.findOne({fields: ['maxHours']}, myOptions);
const hoursDifference = (Date.vnNow() - machineWorker.inTime.getTime()) / (60 * 60 * 1000);
if (machineWorker) {
jorgep marked this conversation as resolved Outdated

isHimself

isHimself
const {maxHours} = await models.MachineWorkerConfig.findOne({fields: ['maxHours']}, myOptions);
const hoursDifference = (Date.vnNow() - machineWorker.inTime.getTime()) / (60 * 60 * 1000);
const isHimself = userId == machineWorker.workerFk;
const isSameMachine = machine.id == machineWorker.machineFk;
@ -62,10 +63,9 @@ module.exports = Self => {
await machineWorker.updateAttributes({
outTime: Date.vnNew()
}, myOptions);
}
jorgep marked this conversation as resolved Outdated
Outdated
Review

Si en els dos casos fa el mateix, fica fora de les condicions

Si en els dos casos fa el mateix, fica fora de les condicions
if (hoursDifference >= maxHours)
await models.MachineWorker.create({machineFk: machine.id, workerFk: userId}, myOptions);
} else
if (!machineWorker || hoursDifference >= maxHours)
await models.MachineWorker.create({machineFk: machine.id, workerFk: userId}, myOptions);
if (tx) await tx.commit();

View File

@ -1,7 +1,7 @@
module.exports = Self => {
jorgep marked this conversation as resolved
Review

aqui no se puede usar el nativo desde front y no cremo el archivo?

aqui no se puede usar el nativo desde front y no cremo el archivo?
Review

@jgallego solo permite eliminar por id.

@jgallego solo permite eliminar por id.
Self.remoteMethod('delete', {
description: 'Delete an ItemBarcode by itemFk and code',
accessType: 'READ',
accessType: 'WRITE',
jorgep marked this conversation as resolved Outdated
Outdated
Review

Seria WRITE

Seria WRITE
accepts: [
{
arg: 'barcode',

View File

@ -47,7 +47,7 @@ module.exports = Self => {
return itemShelvings.map(itemShelving => {
const item = itemShelving.item();
const carros = alternatives.filter(alternative => alternative.itemFk == itemShelving.itemFk);
const shelvings = alternatives.filter(alternative => alternative.itemFk == itemShelving.itemFk);
jorgep marked this conversation as resolved Outdated
Outdated
Review

Mejor variable en ingles

Mejor variable en ingles
return {
id: itemShelving.id,
@ -56,7 +56,7 @@ module.exports = Self => {
size: item.size,
longName: item.longName,
quantity: itemShelving.visible,
carros
shelvings
};
});
}

View File

@ -13,7 +13,7 @@ describe('itemShelving getAlternative()', () => {
const shelvingFk = 'HEJ';
const itemShelvings = await models.ItemShelving.getAlternative(shelvingFk);
expect(itemShelvings[0].carros.length).toEqual(0);
expect(itemShelvings[0].shelvings.length).toEqual(0);
});
it('should return an empty list', async() => {

View File

@ -73,7 +73,7 @@ module.exports = Self => {
userFk: userId
}, myOptions);
const itemShelving = await models.ItemShelving.findById(itemShelvingFk, myOptions);
const itemShelving = await models.ItemShelving.findById(itemShelvingFk, null, myOptions);
await itemShelving.updateAttributes({visible: itemShelving.visible - quantity}, myOptions);
@ -86,8 +86,8 @@ module.exports = Self => {
await Self.updateTracking(ctx, saleFk, originalQuantity, code, isChecked, null, isScanned, myOptions);
try {
const buy = await models.Buy.findById(buyFk, myOptions);
if (buy.itemOriginalFk) await models.SaleBuy.create({saleFk, buyFk}, myOptions);
const {itemOriginalFk} = await models.Buy.findById(buyFk, {fields: ['itemOriginalFk']}, myOptions);
jorgep marked this conversation as resolved Outdated
Outdated
Review

const {itemOriginalFk}

const {itemOriginalFk}
if (itemOriginalFk) await models.SaleBuy.create({saleFk, buyFk}, myOptions);
} catch (e) {
throw new UserError('The sale cannot be tracked');
}