This commit is contained in:
parent
7947d6644e
commit
6b2533cfb1
|
@ -16,6 +16,7 @@ BEGIN
|
|||
*/
|
||||
DECLARE vCalculatedInventory INT;
|
||||
DECLARE vToday DATETIME DEFAULT util.VN_CURDATE();
|
||||
DECLARE vStartDate DATE DEFAULT '2001-01-01';
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tHistoricalPast
|
||||
ENGINE = MEMORY
|
||||
|
@ -33,46 +34,46 @@ BEGIN
|
|||
JOIN `entry` e ON e.id = b.entryFk
|
||||
JOIN travel tr ON tr.id = e.travelFk
|
||||
JOIN supplier s ON s.id = e.supplierFk
|
||||
WHERE tr.landed >= '2001-01-01'
|
||||
AND s.id <> 4
|
||||
WHERE tr.landed >= vStartDate
|
||||
AND s.id <> (SELECT supplierFk FROM inventoryConfig)
|
||||
AND vWarehouseFk IN (tr.warehouseInFk, 0)
|
||||
AND b.itemFk = vItemFk
|
||||
AND NOT e.isExcludedFromAvailable
|
||||
AND NOT e.isRaid
|
||||
UNION ALL
|
||||
SELECT tr.shipped `date`,
|
||||
NULL input,
|
||||
b.quantity `output`,
|
||||
tr.isDelivered ok,
|
||||
s.name alias,
|
||||
e.invoiceNumber reference,
|
||||
e.id id,
|
||||
tr.isDelivered f5
|
||||
SELECT tr.shipped,
|
||||
NULL,
|
||||
b.quantity,
|
||||
tr.isDelivered,
|
||||
s.name,
|
||||
e.invoiceNumber,
|
||||
e.id,
|
||||
tr.isDelivered
|
||||
FROM buy b
|
||||
JOIN `entry` e ON e.id = b.entryFk
|
||||
JOIN travel tr ON tr.id = e.travelFk
|
||||
JOIN supplier s ON s.id = e.supplierFk
|
||||
WHERE tr.shipped >= '2001-01-01'
|
||||
WHERE tr.shipped >= vStartDate
|
||||
AND vWarehouseFk = tr.warehouseOutFk
|
||||
AND s.id <> 4
|
||||
AND s.id <> (SELECT supplierFk FROM inventoryConfig)
|
||||
AND b.itemFk = vItemFk
|
||||
AND NOT e.isExcludedFromAvailable
|
||||
AND NOT e.isRaid
|
||||
UNION ALL
|
||||
SELECT t.shipped `date`,
|
||||
NULL input,
|
||||
m.quantity `output`,
|
||||
(m.isPicked OR t.isLabeled OR t.refFk IS NOT NULL) ok,
|
||||
t.nickname alias,
|
||||
t.refFk reference,
|
||||
SELECT t.shipped,
|
||||
NULL,
|
||||
m.quantity,
|
||||
(m.isPicked OR t.isLabeled OR t.refFk IS NOT NULL),
|
||||
t.nickname,
|
||||
t.refFk,
|
||||
t.id,
|
||||
t.isPrinted
|
||||
FROM sale m
|
||||
JOIN ticket t ON t.id = m.ticketFk
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
WHERE t.shipped >= '2001-01-01'
|
||||
WHERE t.shipped >= vStartDate
|
||||
AND m.itemFk = vItemFk
|
||||
AND vWarehouseFk IN (t.warehouseFk , 0)
|
||||
AND vWarehouseFk IN (t.warehouseFk, 0)
|
||||
) t1
|
||||
ORDER BY `date`, input DESC, ok DESC;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`multipleInventoryHistory`(
|
||||
vItemFk INT)
|
||||
vItemFk INT
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Calcula y proporciona un historial de inventario detallado
|
||||
|
@ -28,7 +29,7 @@ BEGIN
|
|||
SELECT tr.landed `date`,
|
||||
c.quantity input,
|
||||
NULL `output`,
|
||||
IF(warehouseInFk = 44, 1, warehouseInFk) warehouse,
|
||||
tr.warehouseInFk warehouse,
|
||||
tr.isReceived ok,
|
||||
e.invoiceNumber reference,
|
||||
e.id
|
||||
|
@ -40,12 +41,12 @@ BEGIN
|
|||
AND NOT e.isRaid
|
||||
AND c.quantity
|
||||
UNION ALL
|
||||
SELECT tr.shipped `date`,
|
||||
NULL input,
|
||||
c.quantity `output`,
|
||||
tr.warehouseOutFk warehouse,
|
||||
tr.isDelivered ok,
|
||||
e.invoiceNumber reference,
|
||||
SELECT tr.shipped,
|
||||
NULL,
|
||||
c.quantity,
|
||||
tr.warehouseOutFk,
|
||||
tr.isDelivered,
|
||||
e.invoiceNumber,
|
||||
e.id
|
||||
FROM buy c
|
||||
JOIN `entry` e ON e.id = c.entryFk
|
||||
|
@ -55,13 +56,13 @@ BEGIN
|
|||
AND NOT e.isRaid
|
||||
AND c.quantity
|
||||
UNION ALL
|
||||
SELECT t.shipped `date`,
|
||||
NULL input,
|
||||
m.quantity `output`,
|
||||
tr.warehouseInFk warehouse,
|
||||
(m.isPicked OR t.isLabeled OR t.refFk IS NOT NULL) ok,
|
||||
t.refFk reference,
|
||||
t.id id
|
||||
SELECT t.shipped,
|
||||
NULL,
|
||||
m.quantity,
|
||||
t.warehouseFk,
|
||||
(m.isPicked OR t.isLabeled OR t.refFk IS NOT NULL),
|
||||
t.refFk,
|
||||
t.id
|
||||
FROM sale m
|
||||
JOIN ticket t ON t.id = m.ticketFk
|
||||
WHERE t.shipped >= vDateInventory
|
||||
|
|
Loading…
Reference in New Issue