refs #6276 hotFix:itemShelving_add #2270
|
@ -21,7 +21,6 @@ BEGIN
|
||||||
SELECT barcodeToItem(vBarcode) INTO vItemFk;
|
SELECT barcodeToItem(vBarcode) INTO vItemFk;
|
||||||
|
|
||||||
SET vPacking = COALESCE(vPacking, GREATEST(vn.itemPacking(vBarcode,vWarehouseFk), 1));
|
SET vPacking = COALESCE(vPacking, GREATEST(vn.itemPacking(vBarcode,vWarehouseFk), 1));
|
||||||
|
|
||||||
SET vQuantity = vQuantity * vPacking;
|
SET vQuantity = vQuantity * vPacking;
|
||||||
|
|
||||||
IF (SELECT COUNT(*) FROM shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN
|
IF (SELECT COUNT(*) FROM shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const {models} = require('vn-loopback/server/server');
|
const { models } = require('vn-loopback/server/server');
|
||||||
const LoopBackContext = require('loopback-context');
|
const LoopBackContext = require('loopback-context');
|
||||||
|
|
||||||
// #6276
|
// #6276
|
||||||
|
@ -8,11 +8,11 @@ describe('ItemShelving upsertItem()', () => {
|
||||||
let options;
|
let options;
|
||||||
let tx;
|
let tx;
|
||||||
|
|
||||||
beforeEach(async() => {
|
beforeEach(async () => {
|
||||||
ctx = {
|
ctx = {
|
||||||
req: {
|
req: {
|
||||||
accessToken: {userId: 9},
|
accessToken: { userId: 9 },
|
||||||
headers: {origin: 'http://localhost'}
|
headers: { origin: 'http://localhost' }
|
||||||
},
|
},
|
||||||
args: {}
|
args: {}
|
||||||
};
|
};
|
||||||
|
@ -21,36 +21,37 @@ describe('ItemShelving upsertItem()', () => {
|
||||||
active: ctx.req
|
active: ctx.req
|
||||||
});
|
});
|
||||||
|
|
||||||
options = {transaction: tx};
|
options = { transaction: tx };
|
||||||
tx = await models.ItemShelving.beginTransaction({});
|
tx = await models.ItemShelving.beginTransaction({});
|
||||||
options.transaction = tx;
|
options.transaction = tx;
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(async() => {
|
afterEach(async () => {
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
});
|
});
|
||||||
|
|
||||||
xit('should add two new records', async() => {
|
it('should add two new records', async () => {
|
||||||
const shelvingFk = 'ZPP';
|
const shelvingFk = 'ZPP';
|
||||||
const items = [1, 1, 1, 2];
|
const items = [1, 1, 1, 2];
|
||||||
|
|
||||||
await models.ItemShelving.upsertItem(ctx, shelvingFk, items, warehouseFk, options);
|
await models.ItemShelving.upsertItem(ctx, shelvingFk, items, warehouseFk, options);
|
||||||
const itemShelvings = await models.ItemShelving.find({where: {shelvingFk}}, options);
|
const itemShelvings = await models.ItemShelving.find({ where: { shelvingFk } }, options);
|
||||||
|
|
||||||
expect(itemShelvings.length).toEqual(2);
|
expect(itemShelvings.length).toEqual(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
xit('should update the visible items', async() => {
|
it('should update the visible items', async () => {
|
||||||
const shelvingFk = 'GVC';
|
const shelvingFk = 'GVC';
|
||||||
const items = [2, 2];
|
const items = [2, 2];
|
||||||
const {visible: itemsBefore} = await models.ItemShelving.findOne({
|
const { visible: visibleItemsBefore } = await models.ItemShelving.findOne({
|
||||||
where: {shelvingFk, itemFk: items[0]}
|
where: { shelvingFk, itemFk: items[0] }
|
||||||
}, options);
|
}, options);
|
||||||
await models.ItemShelving.upsertItem(ctx, shelvingFk, items, warehouseFk, options);
|
await models.ItemShelving.upsertItem(ctx, shelvingFk, items, warehouseFk, options);
|
||||||
const {visible: itemsAfter} = await models.ItemShelving.findOne({
|
|
||||||
where: {shelvingFk, itemFk: items[0]}
|
const { visible: visibleItemsAfter } = await models.ItemShelving.findOne({
|
||||||
|
where: { shelvingFk, itemFk: items[0] }
|
||||||
}, options);
|
}, options);
|
||||||
|
|
||||||
expect(itemsAfter).toEqual(itemsBefore + 2);
|
expect(visibleItemsAfter).toEqual(visibleItemsBefore + 2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue