7729-devToTest_2430 #2739

Merged
alexm merged 339 commits from 7729-devToTest_2430 into test 2024-07-16 07:11:37 +00:00
2 changed files with 15 additions and 15 deletions
Showing only changes of commit 7bdc242fc7 - Show all commits

View File

@ -136,7 +136,7 @@ BEGIN
CALL vn.catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk);
INSERT INTO tmp.ticketCalculateItem (
INSERT INTO tmp.ticketCalculateItem(
itemFk,
available,
producer,
@ -149,7 +149,8 @@ BEGIN
origin,
price,
priceKg,
`grouping`)
`grouping`,
minQuantity)
SELECT
tl.itemFk,
SUM(tl.available) available,
@ -163,7 +164,8 @@ BEGIN
o.code origin,
bl.price,
bl.priceKg,
bl.`grouping`
bl.`grouping`,
mq.quantity
FROM tmp.ticketLot tl
JOIN item i ON tl.itemFk = i.id
LEFT JOIN producer p ON p.id = i.producerFk AND p.isVisible
@ -179,6 +181,15 @@ BEGIN
) sub
GROUP BY itemFk
) bl ON bl.itemFk = tl.itemFk
LEFT JOIN (
SELECT itemFk, quantity, warehouseFk
FROM vn.itemMinimumQuantity
WHERE `started` <= util.VN_CURDATE()
AND (`ended` >= util.VN_CURDATE() OR `ended` IS NULL)
GROUP BY itemFk, warehouseFk
ORDER BY warehouseFk DESC
) mq ON mq.itemFk = tl.itemFk
AND (mq.warehouseFk = tl.warehouseFk OR mq.warehouseFk IS NULL)
WHERE tl.zoneFk = vZoneFk AND tl.warehouseFk = vWarehouseFk
GROUP BY tl.itemFk
ON DUPLICATE KEY UPDATE available = available + VALUES(available);

View File

@ -101,14 +101,6 @@ module.exports = Self => {
));
stmt = new ParameterizedSQL(`
WITH minQuantity AS (
SELECT itemFk, quantity, warehouseFk
FROM vn.itemMinimumQuantity
WHERE started <= util.VN_CURDATE()
AND (ended >= util.VN_CURDATE() OR ended IS NULL)
GROUP BY itemFk, warehouseFk
ORDER BY warehouseFk DESC
)
SELECT i.id,
i.name,
i.subName,
@ -127,15 +119,12 @@ module.exports = Self => {
w.firstName,
tci.priceKg,
ink.hex,
mq.quantity minQuantity
tci.minQuantity
FROM tmp.ticketCalculateItem tci
JOIN vn.item i ON i.id = tci.itemFk
JOIN vn.itemType it ON it.id = i.typeFk
JOIN vn.worker w on w.id = it.workerFk
LEFT JOIN vn.ink ON ink.id = i.inkFk
LEFT JOIN tmp.ticketLot tl ON tl.itemFk = i.id
LEFT JOIN minQuantity mq ON mq.itemFk = i.id
AND (mq.warehouseFk = tl.warehouseFk OR mq.warehouseFk IS NULL)
`);
// Apply order by tag