8524-devToTest #3415

Merged
alexm merged 343 commits from 8524-devToTest into test 2025-02-04 13:42:16 +00:00
3 changed files with 41 additions and 15 deletions
Showing only changes of commit 04734ac55c - Show all commits

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}}};
fit('should Transfer buys not located', async() => {
const tx = await models.ItemShelving.beginTransaction({});
const options = {transaction: tx};
it('should Transfer buys not located', async() => {
try {
const id = 3;
const item = 8;
const buy = 6;
const originalEntry = 4;
const ctx = {req: {accessToken: {userId: 48}}};
const tx = await models.ItemShelving.beginTransaction({});
const options = {transaction: tx};
try {
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"
}
}
}