fix: refs #6501 entry_getTransferFix #2106
|
@ -13,15 +13,15 @@ BEGIN
|
||||||
DECLARE vWarehouseIn INT;
|
DECLARE vWarehouseIn INT;
|
||||||
DECLARE vWarehouseOut INT;
|
DECLARE vWarehouseOut INT;
|
||||||
DECLARE vCalcVisible INT;
|
DECLARE vCalcVisible INT;
|
||||||
DECLARE vInventoryDate DATE DEFAULT vn.getInventoryDate();
|
DECLARE vInventoryDate DATE DEFAULT getInventoryDate();
|
||||||
|
|
||||||
SELECT shipped, landed, warehouseInFk, warehouseOutFk
|
SELECT shipped, landed, warehouseInFk, warehouseOutFk
|
||||||
INTO vDateShipped, vDateLanded, vWarehouseIn, vWarehouseOut
|
INTO vDateShipped, vDateLanded, vWarehouseIn, vWarehouseOut
|
||||||
FROM vn.travel t
|
FROM travel t
|
||||||
JOIN vn.entry e ON e.travelFk = t.id
|
JOIN entry e ON e.travelFk = t.id
|
||||||
WHERE e.id = vSelf;
|
WHERE e.id = vSelf;
|
||||||
|
|
||||||
CALL vn.rate_getPrices(vDateShipped, vWarehouseIn);
|
CALL rate_getPrices(vDateShipped, vWarehouseIn);
|
||||||
|
|
||||||
-- Traslado en almacen origen
|
-- Traslado en almacen origen
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tBuy
|
CREATE OR REPLACE TEMPORARY TABLE tBuy
|
||||||
|
@ -84,7 +84,7 @@ BEGIN
|
||||||
WHERE a.available
|
WHERE a.available
|
||||||
ON DUPLICATE KEY UPDATE availableLanding = a.available;
|
ON DUPLICATE KEY UPDATE availableLanding = a.available;
|
||||||
ELSE
|
ELSE
|
||||||
CALL vn.item_getStock(vWarehouseOut, vDateShipped, NULL);
|
CALL item_getStock(vWarehouseOut, vDateShipped, NULL);
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tItem
|
CREATE OR REPLACE TEMPORARY TABLE tItem
|
||||||
(UNIQUE INDEX i USING HASH (itemFk))
|
(UNIQUE INDEX i USING HASH (itemFk))
|
||||||
|
@ -97,7 +97,7 @@ BEGIN
|
||||||
FROM tmp.itemList;
|
FROM tmp.itemList;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
CALL vn.buyUltimateFromInterval(vWarehouseIn,vInventoryDate, vDateLanded);
|
CALL buyUltimateFromInterval(vWarehouseIn,vInventoryDate, vDateLanded);
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tTransfer
|
CREATE OR REPLACE TEMPORARY TABLE tTransfer
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
|
@ -145,26 +145,26 @@ BEGIN
|
||||||
b.id buyFkOrigin,
|
b.id buyFkOrigin,
|
||||||
pa.returnCost,
|
pa.returnCost,
|
||||||
b.weight
|
b.weight
|
||||||
FROM vn.item i
|
FROM item i
|
||||||
JOIN tItem ti ON ti.itemFk = i.id
|
JOIN tItem ti ON ti.itemFk = i.id
|
||||||
LEFT JOIN vn.producer p ON p.id = i.producerFk
|
LEFT JOIN producer p ON p.id = i.producerFk
|
||||||
LEFT JOIN vn.itemType it ON it.id = i.typeFk
|
LEFT JOIN itemType it ON it.id = i.typeFk
|
||||||
JOIN vn.itemCategory ic ON ic.id = it.categoryFk
|
JOIN itemCategory ic ON ic.id = it.categoryFk
|
||||||
LEFT JOIN vn.origin o ON o.id = i.originFk
|
LEFT JOIN origin o ON o.id = i.originFk
|
||||||
LEFT JOIN tBuy lb ON lb.itemFk = i.id
|
LEFT JOIN tBuy lb ON lb.itemFk = i.id
|
||||||
LEFT JOIN vn.buy b ON b.id = lb.buyFk
|
LEFT JOIN buy b ON b.id = lb.buyFk
|
||||||
LEFT JOIN vn.packaging pa ON pa.id = b.packagingFk
|
LEFT JOIN packaging pa ON pa.id = b.packagingFk
|
||||||
LEFT JOIN vn.entry e2 ON e2.id = b.entryFk
|
LEFT JOIN entry e2 ON e2.id = b.entryFk
|
||||||
LEFT JOIN vn.supplier s ON s.id = e2.supplierFk
|
LEFT JOIN supplier s ON s.id = e2.supplierFk
|
||||||
LEFT JOIN vn.entry e ON e.id = vSelf
|
LEFT JOIN entry e ON e.id = vSelf
|
||||||
LEFT JOIN vn.travel tr ON tr.id = e.travelFk
|
LEFT JOIN travel tr ON tr.id = e.travelFk
|
||||||
LEFT JOIN vn.agencyMode am ON am.id = tr.agencyModeFk
|
LEFT JOIN agencyMode am ON am.id = tr.agencyModeFk
|
||||||
LEFT JOIN vn.buy b2 ON b2.itemFk = i.id
|
LEFT JOIN buy b2 ON b2.itemFk = i.id
|
||||||
AND b2.entryFk = vSelf
|
AND b2.entryFk = vSelf
|
||||||
LEFT JOIN vn.packaging pa2 ON pa2.id = b.packagingFk
|
LEFT JOIN packaging pa2 ON pa2.id = b.packagingFk
|
||||||
LEFT JOIN tmp.rate r ON TRUE
|
LEFT JOIN tmp.rate r ON TRUE
|
||||||
LEFT JOIN tmp.buyUltimateFromInterval bufi ON bufi.itemFk = i.id
|
LEFT JOIN tmp.buyUltimateFromInterval bufi ON bufi.itemFk = i.id
|
||||||
LEFT JOIN vn.buy b3 ON b3.id = bufi.buyFk
|
LEFT JOIN buy b3 ON b3.id = bufi.buyFk
|
||||||
WHERE ic.display
|
WHERE ic.display
|
||||||
AND NOT e.isRaid
|
AND NOT e.isRaid
|
||||||
AND (ti.visible OR ti.available)
|
AND (ti.visible OR ti.available)
|
||||||
|
@ -172,11 +172,6 @@ BEGIN
|
||||||
|
|
||||||
CREATE INDEX tIndex USING HASH ON tTransfer (itemFk);
|
CREATE INDEX tIndex USING HASH ON tTransfer (itemFk);
|
||||||
|
|
||||||
SET @carriage := 0;
|
|
||||||
SET @comission := 0;
|
|
||||||
SET @packaging := 0;
|
|
||||||
SET @rate3 := 0;
|
|
||||||
SET @cost := 0;
|
|
||||||
SELECT *,
|
SELECT *,
|
||||||
quantity - MOD(quantity , `grouping`) subQuantity,
|
quantity - MOD(quantity , `grouping`) subQuantity,
|
||||||
MOD(quantity, `grouping`) soll,
|
MOD(quantity, `grouping`) soll,
|
||||||
|
|
Loading…
Reference in New Issue