feat: refs #6776 back & procedure modified
gitea/salix/pipeline/pr-dev This commit looks good
Details
gitea/salix/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
be7a570314
commit
f11aa2605b
|
@ -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
|
||||
|
||||
|
|
|
@ -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