refs #6498 Arreglar grant y tabs
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Ivan Mas 2024-03-06 09:00:21 +01:00
parent f215ce5f05
commit 354ecfaa16
3 changed files with 125 additions and 105 deletions

View File

@ -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

View File

@ -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 ;

View File

@ -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;