#6276 createNewWarehouse methods migrated from silex to salix #1850
|
@ -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
|
||||
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
alexm
commented
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();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module.exports = Self => {
|
||||
jorgep marked this conversation as resolved
jgallego
commented
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?
jorgep
commented
@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
alexm
commented
Seria WRITE Seria WRITE
|
||||
accepts: [
|
||||
{
|
||||
arg: 'barcode',
|
||||
|
|
|
@ -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
alexm
commented
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
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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() => {
|
||||
|
|
|
@ -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
alexm
commented
const {itemOriginalFk} const {itemOriginalFk}
|
||||
if (itemOriginalFk) await models.SaleBuy.create({saleFk, buyFk}, myOptions);
|
||||
} catch (e) {
|
||||
throw new UserError('The sale cannot be tracked');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
isHimself