refs #6915 test_master24_8 #2067

Merged
alexm merged 561 commits from test_master24_8 into master 2024-02-22 07:31:34 +00:00
3 changed files with 15 additions and 18 deletions
Showing only changes of commit f11aa2605b - Show all commits

View File

@ -19,6 +19,10 @@ BEGIN
DECLARE vItemFk INT;
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

View File

@ -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
);
}
}

View File

@ -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;