This commit is contained in:
parent
f215ce5f05
commit
354ecfaa16
|
@ -1,6 +1,6 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`absoluteInventoryHistory`(
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`absoluteInventoryHistory`(
|
||||||
vItemFk INT, vWarehouse INT, vDate DATETIME)
|
vItemFk INT, vWarehouse INT, vDate DATETIME)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Calcula y proporciona un historial de inventario absoluto
|
* Calcula y proporciona un historial de inventario absoluto
|
||||||
|
@ -72,7 +72,7 @@ BEGIN
|
||||||
WHERE t.shipped >= '2001-01-01'
|
WHERE t.shipped >= '2001-01-01'
|
||||||
AND m.itemFk = vItemFk
|
AND m.itemFk = vItemFk
|
||||||
AND vWarehouse IN (t.warehouseFk , 0)
|
AND vWarehouse IN (t.warehouseFk , 0)
|
||||||
) t1
|
) t1
|
||||||
ORDER BY `date`, input DESC, ok DESC;
|
ORDER BY `date`, input DESC, ok DESC;
|
||||||
|
|
||||||
SELECT sum(input) - sum(`output`) INTO vCalculatedInventory
|
SELECT sum(input) - sum(`output`) INTO vCalculatedInventory
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
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
|
||||||
|
@ -17,58 +17,58 @@ BEGIN
|
||||||
|
|
||||||
CREATE TEMPORARY TABLE tMultipleHistory1
|
CREATE TEMPORARY TABLE tMultipleHistory1
|
||||||
SELECT DATE(`date`) `date`,
|
SELECT DATE(`date`) `date`,
|
||||||
input,
|
input,
|
||||||
`output`,
|
`output`,
|
||||||
ok,
|
ok,
|
||||||
reference,
|
reference,
|
||||||
history.id,
|
history.id,
|
||||||
warehouse,
|
warehouse,
|
||||||
`name` warehouseName
|
`name` warehouseName
|
||||||
FROM (
|
FROM (
|
||||||
SELECT tr.landed `date`,
|
SELECT tr.landed `date`,
|
||||||
c.quantity input,
|
c.quantity input,
|
||||||
NULL `output`,
|
NULL `output`,
|
||||||
IF(warehouseInFk = 44, 1, warehouseInFk) warehouse,
|
IF(warehouseInFk = 44, 1, warehouseInFk) warehouse,
|
||||||
(tr.isReceived <> FALSE) ok,
|
(tr.isReceived <> FALSE) ok,
|
||||||
e.invoiceNumber reference,
|
e.invoiceNumber reference,
|
||||||
e.id id
|
e.id id
|
||||||
FROM buy c
|
FROM buy c
|
||||||
JOIN `entry` e ON e.id = c.entryFk
|
JOIN `entry` e ON e.id = c.entryFk
|
||||||
JOIN travel tr ON tr.id = e.travelFk
|
JOIN travel tr ON tr.id = e.travelFk
|
||||||
WHERE tr.landed >= vDateInventory
|
WHERE tr.landed >= vDateInventory
|
||||||
AND c.itemFk = vItemFk
|
AND c.itemFk = vItemFk
|
||||||
AND NOT e.isRaid
|
AND NOT e.isRaid
|
||||||
AND c.quantity <> 0
|
AND c.quantity <> 0
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT tr.shipped `date`,
|
SELECT tr.shipped `date`,
|
||||||
NULL input,
|
NULL input,
|
||||||
c.quantity `output`,
|
c.quantity `output`,
|
||||||
warehouseOutFk warehouse,
|
tr.warehouseOutFk warehouse,
|
||||||
tr.isDelivered ok,
|
tr.isDelivered ok,
|
||||||
e.invoiceNumber reference,
|
e.invoiceNumber reference,
|
||||||
e.id id
|
e.id id
|
||||||
FROM buy c
|
FROM buy c
|
||||||
JOIN `entry` e ON e.id = c.entryFk
|
JOIN `entry` e ON e.id = c.entryFk
|
||||||
JOIN travel tr ON tr.id = e.travelFk
|
JOIN travel tr ON tr.id = e.travelFk
|
||||||
WHERE tr.shipped >= vDateInventory
|
WHERE tr.shipped >= vDateInventory
|
||||||
AND c.itemFk = vItemFk
|
AND c.itemFk = vItemFk
|
||||||
AND NOT e.isRaid
|
AND NOT e.isRaid
|
||||||
AND c.quantity <> 0
|
AND c.quantity <> 0
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT t.shipped `date`,
|
SELECT t.shipped `date`,
|
||||||
NULL input,
|
NULL input,
|
||||||
m.quantity `output`,
|
m.quantity `output`,
|
||||||
warehouseInFk warehouse,
|
tr.warehouseInFk warehouse,
|
||||||
(m.isPicked <> 0 OR t.isLabeled <> 0 OR t.refFk IS NOT NULL) ok,
|
(m.isPicked <> 0 OR t.isLabeled <> 0 OR t.refFk IS NOT NULL) ok,
|
||||||
t.refFk reference,
|
t.refFk reference,
|
||||||
t.id id
|
t.id 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
|
||||||
AND m.itemFk = vItemFk
|
AND m.itemFk = vItemFk
|
||||||
) history
|
) history
|
||||||
JOIN warehouse ON warehouse.id = history.warehouse
|
JOIN warehouse ON warehouse.id = history.warehouse
|
||||||
ORDER BY `date`, input DESC, ok DESC;
|
ORDER BY `date`, input DESC, ok DESC;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tMultipleHistory2;
|
DROP TEMPORARY TABLE IF EXISTS tMultipleHistory2;
|
||||||
DROP TEMPORARY TABLE IF EXISTS tMultipleHistory3;
|
DROP TEMPORARY TABLE IF EXISTS tMultipleHistory3;
|
||||||
|
@ -86,76 +86,76 @@ BEGIN
|
||||||
CREATE TEMPORARY TABLE tMultipleHistory8 SELECT * FROM tMultipleHistory1 WHERE warehouse = 55;
|
CREATE TEMPORARY TABLE tMultipleHistory8 SELECT * FROM tMultipleHistory1 WHERE warehouse = 55;
|
||||||
|
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM (
|
FROM (
|
||||||
SELECT `date`, input BOGinput, `output` BOGoutput, ok BOGok, reference BOGreference, id BOGid,
|
SELECT `date`, input BOGinput, `output` BOGoutput, ok BOGok, reference BOGreference, id BOGid,
|
||||||
NULL VNHinput, NULL VNHoutput, NULL VNHok, NULL VNHreference, NULL VNHid,
|
NULL VNHinput, NULL VNHoutput, NULL VNHok, NULL VNHreference, NULL VNHid,
|
||||||
NULL ALGinput, NULL ALGoutput, NULL ALGok, NULL ALGreference, NULL ALGid,
|
NULL ALGinput, NULL ALGoutput, NULL ALGok, NULL ALGreference, NULL ALGid,
|
||||||
NULL MADinput, NULL MADoutput, NULL MADok, NULL MADreference, NULL MADid,
|
NULL MADinput, NULL MADoutput, NULL MADok, NULL MADreference, NULL MADid,
|
||||||
NULL MCFinput, NULL MCFoutput, NULL MCFok, NULL MCFreference, NULL MCFid,
|
NULL MCFinput, NULL MCFoutput, NULL MCFok, NULL MCFreference, NULL MCFid,
|
||||||
NULL VILinput, NULL VILoutput, NULL VILok, NULL VILreference, NULL VILid,
|
NULL VILinput, NULL VILoutput, NULL VILok, NULL VILreference, NULL VILid,
|
||||||
NULL BARinput, NULL BARoutput, NULL BARok, NULL BARreference, NULL BARid
|
NULL BARinput, NULL BARoutput, NULL BARok, NULL BARreference, NULL BARid
|
||||||
FROM tMultipleHistory2
|
FROM tMultipleHistory2
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT `date`,
|
SELECT `date`,
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
input, `output`, ok, reference, id,
|
input, `output`, ok, reference, id,
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL, NULL, NULL
|
NULL, NULL, NULL, NULL, NULL
|
||||||
FROM tMultipleHistory3
|
FROM tMultipleHistory3
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT `date`,
|
SELECT `date`,
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
input, `output`, ok, reference, id,
|
input, `output`, ok, reference, id,
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL, NULL, NULL
|
NULL, NULL, NULL, NULL, NULL
|
||||||
FROM tMultipleHistory4
|
FROM tMultipleHistory4
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT `date`,
|
SELECT `date`,
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
input, `output`, ok, reference, id,
|
input, `output`, ok, reference, id,
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL, NULL, NULL
|
NULL, NULL, NULL, NULL, NULL
|
||||||
FROM tMultipleHistory5
|
FROM tMultipleHistory5
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT `date`,
|
SELECT `date`,
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
input, `output`, ok, reference, id,
|
input, `output`, ok, reference, id,
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL, NULL, NULL
|
NULL, NULL, NULL, NULL, NULL
|
||||||
FROM tMultipleHistory6
|
FROM tMultipleHistory6
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT `date`,
|
SELECT `date`,
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
input, `output`, ok, reference, id,
|
input, `output`, ok, reference, id,
|
||||||
NULL, NULL, NULL, NULL, NULL
|
NULL, NULL, NULL, NULL, NULL
|
||||||
FROM tMultipleHistory7
|
FROM tMultipleHistory7
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT `date`,
|
SELECT `date`,
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
input, `output`, ok, reference, id
|
input, `output`, ok, reference, id
|
||||||
FROM tMultipleHistory8
|
FROM tMultipleHistory8
|
||||||
) sub
|
) sub
|
||||||
ORDER BY `date`, BOGinput IS NULL, VNHinput IS NULL, ALGinput IS NULL, MADinput IS NULL, MCFinput IS NULL, VILinput IS NULL, BARinput IS NULL;
|
ORDER BY `date`, BOGinput IS NULL, VNHinput IS NULL, ALGinput IS NULL, MADinput IS NULL, MCFinput IS NULL, VILinput IS NULL, BARinput IS NULL;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
|
@ -1,2 +1,22 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`multipleInventoryHistory`(
|
||||||
|
vItemFk INT)
|
||||||
|
BEGIN
|
||||||
|
DECLARE vDateInventory DATETIME;
|
||||||
|
SELECT inventoried INTO vDateInventory FROM config;
|
||||||
|
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`absoluteInventoryHistory`(
|
||||||
|
vItemFk INT, vWarehouse INT, vDate DATETIME)
|
||||||
|
BEGIN
|
||||||
|
DECLARE vCalculatedInventory INT;
|
||||||
|
SET vCalculatedInventory = 0;
|
||||||
|
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
||||||
|
|
||||||
GRANT EXECUTE ON PROCEDURE vn.absoluteInventoryHistory TO buyer;
|
GRANT EXECUTE ON PROCEDURE vn.absoluteInventoryHistory TO buyer;
|
||||||
GRANT EXECUTE ON PROCEDURE vn.multipleInventoryHistory TO buyer;
|
GRANT EXECUTE ON PROCEDURE vn.multipleInventoryHistory TO buyer;
|
||||||
|
|
Loading…
Reference in New Issue