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