7152-devToTest_2414 #2228

Merged
alexm merged 636 commits from 7152-devToTest_2414 into test 2024-03-28 08:26:34 +00:00
2 changed files with 0 additions and 115 deletions
Showing only changes of commit 3dd4d48557 - Show all commits

View File

@ -1,50 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`supplier_getPackagingStock`(
vSelf INT
)
BEGIN
/**
* Obtiene el stock de los embalajes de un proveedor.
*
* @param vSelf Id del proveedor
*/
DECLARE vItemCategoryFk INT;
SELECT id INTO vItemCategoryFk
FROM itemCategory
WHERE code = 'others';
SELECT sub.itemFk,
i.name,
SUM(sub.quantity) quantity
FROM (
SELECT b.itemFk, b.quantity
FROM buy b
JOIN item i ON i.id = b.itemFk
JOIN itemType it ON it.id = i.typeFk
JOIN `entry` e ON e.id = b.entryFk
JOIN travel t ON t.id = e.travelFk
WHERE e.supplierFk = vSelf
AND t.landed >= '2010-01-01'
AND it.categoryFk = vItemCategoryFk
UNION ALL
SELECT s.itemFk, - s.quantity
FROM sale s
JOIN item i ON i.id = s.itemFk
JOIN itemType it ON it.id = i.typeFk
JOIN ticket t ON t.id = s.ticketFk
JOIN `address` a ON a.id = t.addressFk
JOIN (
SELECT c.id,
s.id supplierFk
FROM supplier s
JOIN client c ON c.fi = s.nif
) sub ON sub.id = a.clientFk
WHERE sub.supplierFk = vSelf
AND it.categoryFk = vItemCategoryFk
AND t.shipped > '2010-01-01'
) sub
JOIN item i ON i.id = sub.itemFk
GROUP BY i.id;
END$$
DELIMITER ;

View File

@ -1,65 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`supplier_getPackagingStockDetail`(
vSelf INT,
vItemFk INT
)
BEGIN
/**
* Obtiene el detalle del embalaje de un proveedor.
*
* @param vSelf Id del proveedor
* @param vItemFk Id del artículo
*/
SELECT sub.itemFk,
sub.`table`,
sub.registry,
sub.dated,
i.name item,
w.name warehouse,
sub.`in`,
sub.`out`,
s.name supplier,
CAST(sub.buyingValue AS DECIMAL(5,2)) price
FROM (
SELECT b.itemFk,
IF(b.quantity > 0, b.quantity, NULL) `in`,
IF(b.quantity > 0, NULL, - b.quantity) `out`,
'E' `table`,
b.entryFk registry,
t.landed dated,
t.warehouseInFk,
b.buyingValue
FROM buy b
JOIN `entry` e ON e.id = b.entryFk
JOIN travel t ON t.id = e.travelFk
WHERE e.supplierFk = vSelf
AND b.itemFk = vItemFk
AND t.landed >= '2010-01-01'
UNION ALL
SELECT s.itemFk,
IF(s.quantity < 0, - s.quantity, NULL),
IF(s.quantity < 0, NULL, s.quantity),
'T',
s.ticketFk,
t.shipped,
t.warehouseFk,
s.price
FROM sale s
JOIN ticket t ON t.id = s.ticketFk
JOIN address a ON a.id = t.addressFk
JOIN (
SELECT c.id,
s.id supplierFk
FROM supplier s
JOIN client c ON c.fi = s.nif
) sub ON sub.id = a.clientFk
WHERE sub.supplierFk = vSelf
AND s.itemFk = vItemFk
AND t.shipped > '2010-01-01'
) sub
JOIN item i ON i.id = sub.itemFk
JOIN supplier s ON s.id = vSelf
JOIN warehouse w on w.id = sub.warehouseInFk;
END$$
DELIMITER ;