From 354ecfaa1684d1f17db20d092ce9821a849219d9 Mon Sep 17 00:00:00 2001 From: ivanm Date: Wed, 6 Mar 2024 09:00:21 +0100 Subject: [PATCH] refs #6498 Arreglar grant y tabs --- .../procedures/absoluteInventoryHistory.sql | 4 +- .../procedures/multipleInventoryHistory.sql | 206 +++++++++--------- .../10932-azureEucalyptus/00-firstScript.sql | 20 ++ 3 files changed, 125 insertions(+), 105 deletions(-) diff --git a/db/routines/vn/procedures/absoluteInventoryHistory.sql b/db/routines/vn/procedures/absoluteInventoryHistory.sql index f1a317598..a1e143185 100644 --- a/db/routines/vn/procedures/absoluteInventoryHistory.sql +++ b/db/routines/vn/procedures/absoluteInventoryHistory.sql @@ -1,6 +1,6 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`absoluteInventoryHistory`( - vItemFk INT, vWarehouse INT, vDate DATETIME) + vItemFk INT, vWarehouse INT, vDate DATETIME) BEGIN /** * Calcula y proporciona un historial de inventario absoluto @@ -72,7 +72,7 @@ BEGIN WHERE t.shipped >= '2001-01-01' AND m.itemFk = vItemFk AND vWarehouse IN (t.warehouseFk , 0) - ) t1 + ) t1 ORDER BY `date`, input DESC, ok DESC; SELECT sum(input) - sum(`output`) INTO vCalculatedInventory diff --git a/db/routines/vn/procedures/multipleInventoryHistory.sql b/db/routines/vn/procedures/multipleInventoryHistory.sql index bd399e889..b15cab549 100644 --- a/db/routines/vn/procedures/multipleInventoryHistory.sql +++ b/db/routines/vn/procedures/multipleInventoryHistory.sql @@ -1,6 +1,6 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`multipleInventoryHistory`( - vItemFk INT) + vItemFk INT) BEGIN /** * Calcula y proporciona un historial de inventario detallado @@ -17,58 +17,58 @@ BEGIN CREATE TEMPORARY TABLE tMultipleHistory1 SELECT DATE(`date`) `date`, - input, + input, `output`, ok, reference, history.id, warehouse, `name` warehouseName - FROM ( - SELECT tr.landed `date`, + FROM ( + SELECT tr.landed `date`, c.quantity input, NULL `output`, IF(warehouseInFk = 44, 1, warehouseInFk) warehouse, (tr.isReceived <> FALSE) ok, e.invoiceNumber reference, - e.id id - FROM buy c - JOIN `entry` e ON e.id = c.entryFk - JOIN travel tr ON tr.id = e.travelFk - WHERE tr.landed >= vDateInventory - AND c.itemFk = vItemFk - AND NOT e.isRaid - AND c.quantity <> 0 - UNION ALL - SELECT tr.shipped `date`, + e.id id + FROM buy c + JOIN `entry` e ON e.id = c.entryFk + JOIN travel tr ON tr.id = e.travelFk + WHERE tr.landed >= vDateInventory + AND c.itemFk = vItemFk + AND NOT e.isRaid + AND c.quantity <> 0 + UNION ALL + SELECT tr.shipped `date`, NULL input, c.quantity `output`, - warehouseOutFk warehouse, + tr.warehouseOutFk warehouse, tr.isDelivered ok, e.invoiceNumber reference, e.id id - FROM buy c - JOIN `entry` e ON e.id = c.entryFk - JOIN travel tr ON tr.id = e.travelFk - WHERE tr.shipped >= vDateInventory - AND c.itemFk = vItemFk - AND NOT e.isRaid - AND c.quantity <> 0 - UNION ALL - SELECT t.shipped `date`, + FROM buy c + JOIN `entry` e ON e.id = c.entryFk + JOIN travel tr ON tr.id = e.travelFk + WHERE tr.shipped >= vDateInventory + AND c.itemFk = vItemFk + AND NOT e.isRaid + AND c.quantity <> 0 + UNION ALL + SELECT t.shipped `date`, NULL input, m.quantity `output`, - warehouseInFk warehouse, + tr.warehouseInFk warehouse, (m.isPicked <> 0 OR t.isLabeled <> 0 OR t.refFk IS NOT NULL) ok, t.refFk reference, t.id id - FROM sale m - JOIN ticket t ON t.id = m.ticketFk - WHERE t.shipped >= vDateInventory - AND m.itemFk = vItemFk - ) history - JOIN warehouse ON warehouse.id = history.warehouse - ORDER BY `date`, input DESC, ok DESC; + FROM sale m + JOIN ticket t ON t.id = m.ticketFk + WHERE t.shipped >= vDateInventory + AND m.itemFk = vItemFk + ) history + JOIN warehouse ON warehouse.id = history.warehouse + ORDER BY `date`, input DESC, ok DESC; DROP TEMPORARY TABLE IF EXISTS tMultipleHistory2; DROP TEMPORARY TABLE IF EXISTS tMultipleHistory3; @@ -86,76 +86,76 @@ BEGIN CREATE TEMPORARY TABLE tMultipleHistory8 SELECT * FROM tMultipleHistory1 WHERE warehouse = 55; SELECT * - FROM ( - SELECT `date`, input BOGinput, `output` BOGoutput, ok BOGok, reference BOGreference, id BOGid, - NULL VNHinput, NULL VNHoutput, NULL VNHok, NULL VNHreference, NULL VNHid, - NULL ALGinput, NULL ALGoutput, NULL ALGok, NULL ALGreference, NULL ALGid, - NULL MADinput, NULL MADoutput, NULL MADok, NULL MADreference, NULL MADid, - NULL MCFinput, NULL MCFoutput, NULL MCFok, NULL MCFreference, NULL MCFid, - NULL VILinput, NULL VILoutput, NULL VILok, NULL VILreference, NULL VILid, - NULL BARinput, NULL BARoutput, NULL BARok, NULL BARreference, NULL BARid - FROM tMultipleHistory2 - UNION ALL - SELECT `date`, - NULL, NULL, NULL, NULL, NULL, - 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 - FROM tMultipleHistory3 - UNION ALL - SELECT `date`, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - 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 tMultipleHistory4 - UNION ALL - SELECT `date`, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - input, `output`, ok, reference, id, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL - FROM tMultipleHistory5 - UNION ALL - 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, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL - FROM tMultipleHistory6 - UNION ALL - 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, - input, `output`, ok, reference, id, - NULL, NULL, NULL, NULL, NULL - FROM tMultipleHistory7 - UNION ALL - 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 - FROM tMultipleHistory8 - ) 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; + FROM ( + SELECT `date`, input BOGinput, `output` BOGoutput, ok BOGok, reference BOGreference, id BOGid, + NULL VNHinput, NULL VNHoutput, NULL VNHok, NULL VNHreference, NULL VNHid, + NULL ALGinput, NULL ALGoutput, NULL ALGok, NULL ALGreference, NULL ALGid, + NULL MADinput, NULL MADoutput, NULL MADok, NULL MADreference, NULL MADid, + NULL MCFinput, NULL MCFoutput, NULL MCFok, NULL MCFreference, NULL MCFid, + NULL VILinput, NULL VILoutput, NULL VILok, NULL VILreference, NULL VILid, + NULL BARinput, NULL BARoutput, NULL BARok, NULL BARreference, NULL BARid + FROM tMultipleHistory2 + UNION ALL + SELECT `date`, + NULL, NULL, NULL, NULL, NULL, + 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 + FROM tMultipleHistory3 + UNION ALL + SELECT `date`, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + 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 tMultipleHistory4 + UNION ALL + SELECT `date`, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + input, `output`, ok, reference, id, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL + FROM tMultipleHistory5 + UNION ALL + 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, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL + FROM tMultipleHistory6 + UNION ALL + 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, + input, `output`, ok, reference, id, + NULL, NULL, NULL, NULL, NULL + FROM tMultipleHistory7 + UNION ALL + 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 + FROM tMultipleHistory8 + ) 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; END$$ DELIMITER ; \ No newline at end of file diff --git a/db/versions/10932-azureEucalyptus/00-firstScript.sql b/db/versions/10932-azureEucalyptus/00-firstScript.sql index 55eea3211..399819cc4 100644 --- a/db/versions/10932-azureEucalyptus/00-firstScript.sql +++ b/db/versions/10932-azureEucalyptus/00-firstScript.sql @@ -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.multipleInventoryHistory TO buyer;