refs #6915 test_master24_8 #2067
|
@ -20,6 +20,10 @@ BEGIN
|
|||
|
||||
SELECT barcodeToItem(vBarcode) INTO vItemFk;
|
||||
|
||||
SET vPacking = COALESCE(vPacking, GREATEST(vn.itemPacking(vBarcode,vWarehouseFk), 1));
|
||||
|
||||
SET vQuantity = vQuantity * vPacking;
|
||||
|
||||
IF (SELECT COUNT(*) FROM shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN
|
||||
|
||||
INSERT IGNORE INTO parking(code) VALUES(vShelvingFk);
|
||||
|
|
|
@ -37,27 +37,20 @@ module.exports = Self => {
|
|||
myOptions.transaction = tx;
|
||||
}
|
||||
|
||||
const discardItems = [];
|
||||
const discardItems = new Set();
|
||||
const itemCounts = items.reduce((acc, item) => {
|
||||
acc[item] = (acc[item] || 0) + 1;
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
try {
|
||||
for (let item of items) {
|
||||
if (!discardItems.includes(item)) {
|
||||
let quantity = items.reduce((acc, cur) => {
|
||||
return acc + (cur === item ? 1 : 0);
|
||||
}, 0);
|
||||
discardItems.push(item);
|
||||
if (!discardItems.has(item)) {
|
||||
let quantity = itemCounts[item];
|
||||
discardItems.add(item);
|
||||
|
||||
const [result] = await Self.rawSql('SELECT vn.itemPacking(?, ?) itemPacking',
|
||||
[item, warehouseFk], myOptions);
|
||||
let packing;
|
||||
|
||||
if (result) packing = result.itemPacking;
|
||||
if (!packing) packing = 1;
|
||||
|
||||
quantity = quantity * packing;
|
||||
|
||||
await Self.rawSql('CALL vn.itemShelving_add(?, ?, ?, NULL, NULL, ?, ?)',
|
||||
[shelvingFk, item, quantity, packing, warehouseFk], myOptions
|
||||
await Self.rawSql('CALL vn.itemShelving_add(?, ?, ?, NULL, NULL, NULL, ?)',
|
||||
[shelvingFk, item, quantity, warehouseFk], myOptions
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
fdescribe('ItemShelving makeMulti()', () => {
|
||||
describe('ItemShelving makeMulti()', () => {
|
||||
const warehouseFk = 1;
|
||||
let ctx;
|
||||
let options;
|
||||
|
|
Loading…
Reference in New Issue