7729-devToTest_2430 #2739
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue