feat: refs #6822 test transfer
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Robert Ferrús 2025-01-07 08:59:47 +01:00
parent cbf72be299
commit 04734ac55c
3 changed files with 41 additions and 15 deletions

View File

@ -1,25 +1,41 @@
const transfer = require('../transfer');
// const transfer = require('../transfer');
const models = require('vn-loopback/server/server').models;
describe('Transfer merchandise from one entry to the next day()', () => {
const ctx = {req: {accessToken: {userId: 18}}};
it('should Transfer buys not located', async() => {
const id = 3;
const item = 8;
const buy = 6;
const originalEntry = 4;
fit('should Transfer buys not located', async() => {
const tx = await models.ItemShelving.beginTransaction({});
const options = {transaction: tx};
try {
const id = 3;
const item = 8;
const buy = 6;
const originalEntry = 4;
const ctx = {req: {accessToken: {userId: 48}}};
const currentItemShelving = await models.ItemShelving.findOne({where: {id}}, options);
await currentItemShelving.updateAttributes({itemFk: item, buyFk: buy}, options);
const result = await models.Entry.transfer(ctx, originalEntry, options);
const buys = await models.Buy.find({where: {entryFk: result[0].newEntryFk}}, options);
expect(buys.length).toEqual(3);
const result = await models.Entry.transfer(ctx, originalEntry, options);
const originalEntrybuys = await models.Buy.find({where: {entryFk: originalEntry}}, options);
const newEntrybuys = await models.Buy.find({where: {entryFk: result[0].newEntryFk}}, options);
const itemShelvingsWithBuys = await models.Buy.find({
include: {
relation: 'itemShelving',
scope: {
fields: ['id'],
},
},
where: {entryFk: originalEntry},
}, options);
const hasItemShelving = await itemShelvingsWithBuys.filter(buy => buy.itemShelving().length);
expect(newEntrybuys.length).toEqual(originalEntrybuys.length - hasItemShelving.length);
await tx.rollback();
} catch (e) {

View File

@ -114,6 +114,11 @@
"type": "belongsTo",
"model": "Delivery",
"foreignKey": "deliveryFk"
}
},
"itemShelving": {
"type": "hasMany",
"model": "ItemShelving",
"foreignKey": "buyFk"
}
}
}

View File

@ -61,6 +61,11 @@
"type": "belongsTo",
"model": "Shelving",
"foreignKey": "shelvingFk"
}
},
"buy": {
"type": "belongsTo",
"model": "Buy",
"foreignKey": "buyFk"
}
}
}
}