refs #6915 test_master24_8 #2067
|
@ -17,7 +17,6 @@ BEGIN
|
||||||
|
|
||||||
CALL productionControl(vWarehouseFk, 0);
|
CALL productionControl(vWarehouseFk, 0);
|
||||||
|
|
||||||
-- Products with vn.item.isBoxPickingMode = TRUE, pay atention to vn.itemShelving.packing
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
||||||
(saleFk INT PRIMARY KEY)
|
(saleFk INT PRIMARY KEY)
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -52,8 +51,8 @@ BEGIN
|
||||||
LEFT JOIN ticketState ts ON ts.ticketFk = s.ticketFk
|
LEFT JOIN ticketState ts ON ts.ticketFk = s.ticketFk
|
||||||
LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = vWarehouseFk
|
LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = vWarehouseFk
|
||||||
LEFT JOIN buy b ON b.id = lb.buy_id
|
LEFT JOIN buy b ON b.id = lb.buy_id
|
||||||
WHERE s.quantity BETWEEN ish.packing AND (ish.visible - IFNULL(tISS.reserve,0))
|
WHERE IF(i.isBoxPickingMode, ish.packing, i.packingOut)
|
||||||
AND i.isBoxPickingMode
|
<= LEAST(s.quantity, ish.visible - IFNULL(tISS.reserve,0))
|
||||||
AND NOT pb.problem
|
AND NOT pb.problem
|
||||||
AND sgd.saleFk IS NULL
|
AND sgd.saleFk IS NULL
|
||||||
AND p.sectorFk = vSectorFk
|
AND p.sectorFk = vSectorFk
|
||||||
|
@ -64,47 +63,13 @@ BEGIN
|
||||||
GROUP BY s.id
|
GROUP BY s.id
|
||||||
ORDER BY etd;
|
ORDER BY etd;
|
||||||
|
|
||||||
-- Remaining products, vn.item.packingOut
|
SELECT *
|
||||||
INSERT IGNORE INTO tmp.sale
|
FROM tmp.sale
|
||||||
SELECT
|
WHERE stickers;
|
||||||
s.ticketFk,
|
|
||||||
s.id saleFk,
|
|
||||||
s.itemFk,
|
|
||||||
s.concept,
|
|
||||||
s.quantity,
|
|
||||||
MAKETIME(pb.HH,pb.mm,0) etd,
|
|
||||||
pb.routeFk,
|
|
||||||
s.quantity / i.packingOut stickers,
|
|
||||||
i.packingOut,
|
|
||||||
pc.defaultBigPackageFk
|
|
||||||
FROM sale s
|
|
||||||
JOIN item i ON i.id = s.itemFk
|
|
||||||
JOIN itemShelving ish ON ish.itemFk = s.itemFk
|
|
||||||
JOIN shelving sh ON sh.code = ish.shelvingFk
|
|
||||||
JOIN parking p ON p.id = sh.parkingFk
|
|
||||||
JOIN tmp.productionBuffer pb ON pb.ticketFk = s.ticketFk
|
|
||||||
JOIN agencyMode am ON am.id = pb.agencyModeFk
|
|
||||||
JOIN packagingConfig pc
|
|
||||||
LEFT JOIN routesMonitor rm ON rm.routeFk = pb.routeFk
|
|
||||||
LEFT JOIN itemShelvingStock iss ON iss.itemFk = s.itemFk AND iss.sectorFk = p.sectorFk
|
|
||||||
LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = s.id
|
|
||||||
LEFT JOIN ticketState ts ON ts.ticketFk = s.ticketFk
|
|
||||||
WHERE s.quantity >= i.packingOut
|
|
||||||
AND NOT pb.problem
|
|
||||||
AND s.quantity > 0
|
|
||||||
AND sgd.saleFk IS NULL
|
|
||||||
AND p.sectorFk = vSectorFk
|
|
||||||
AND ts.isPreviousPreparable
|
|
||||||
AND iss.visible >= s.quantity
|
|
||||||
AND ((rm.bufferFk AND rm.isPickingAllowed)
|
|
||||||
OR am.code = 'REC_ALG')
|
|
||||||
AND pb.shipped = vDated
|
|
||||||
GROUP BY s.id
|
|
||||||
ORDER BY etd;
|
|
||||||
|
|
||||||
SELECT * FROM tmp.sale;
|
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tmp.productionBuffer;
|
DROP TEMPORARY TABLE tmp.productionBuffer;
|
||||||
DROP TEMPORARY TABLE tmp.sale;
|
DROP TEMPORARY TABLE tmp.sale;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
||||||
|
CALL `vn`.`sale_getBoxPickingList`(1, curdate());
|
Loading…
Reference in New Issue