7631_testToMaster_2426 #2634

Merged
alexm merged 147 commits from 7631_testToMaster_2426 into master 2024-06-25 06:36:59 +00:00
1 changed files with 25 additions and 22 deletions
Showing only changes of commit 8c5f468087 - Show all commits

View File

@ -1,14 +1,14 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`supplierPackaging_ReportSource`(
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`supplierPackaging_ReportSource`(
vFromDated DATE,
vSupplierFk INT
)
BEGIN
/**
* Selecciona los embalajes de un proveedor a partir de una fecha
* Create a report with packaging balance
*
* @param vFromDated Fecha de la que partir
* @param vSupplierFk Id del proveedor
* @param vFromDated Starting date
* @param vSupplierFk Supplier ID
*/
SET @vBalance = 0;
SET @vItemFk = NULL;
@ -22,7 +22,7 @@ BEGIN
landed,
`in`,
`out`,
warehouse,
sref,
buyingValue,
IF (
NOT (@vItemFk <=> sub.itemFk),
@ -31,19 +31,20 @@ BEGIN
) balance,
@vItemFk := sub.itemFk previousItemFk
FROM (
SELECT supplierFk,
itemFk,
longName,
supplier,
CONCAT('E',entryFk) entryFk,
landed,
`in`,
`out`,
warehouse,
buyingValue
FROM supplierPackaging
WHERE supplierFk = vSupplierFk
AND landed >= vFromDated
SELECT sp.supplierFk,
sp.itemFk,
sp.longName,
sp.supplier,
CONCAT('E',sp.entryFk) entryFk,
sp.landed,
sp.`in`,
sp.`out`,
e.invoiceNumber sref,
sp.buyingValue
FROM supplierPackaging sp
JOIN entry e ON e.id = sp.entryFk
WHERE sp.supplierFk = vSupplierFk
AND sp.landed >= vFromDated
UNION ALL
SELECT vSupplierFk,
itemFk,
@ -68,7 +69,7 @@ BEGIN
DATE(t.shipped),
-LEAST(s.quantity,0) `in`,
GREATEST(s.quantity,0) `out`,
t.warehouseFk,
t.cmrFk,
s.price * (100 - s.discount) / 100
FROM sale s
JOIN item i ON i.id = s.itemFk
@ -99,6 +100,7 @@ BEGIN
WHERE su.id = vSupplierFk
AND t.shipped < vFromDated
AND p.isPackageReturnable
AND NOT t.isDeleted
GROUP BY s.itemFk
UNION ALL
SELECT vSupplierFk,
@ -109,7 +111,7 @@ BEGIN
DATE(t.shipped),
-LEAST(tp.quantity,0) `in`,
GREATEST(tp.quantity,0) `out`,
t.warehouseFk,
t.cmrFk,
0
FROM ticketPackaging tp
JOIN packaging p ON p.id = tp.packagingFk
@ -138,8 +140,9 @@ BEGIN
JOIN client c ON c.id = t.clientFk
JOIN supplier su ON su.nif = c.fi
WHERE su.id = vSupplierFk
AND t.shipped >= vFromDated
AND t.shipped < vFromDated
AND p.isPackageReturnable
AND NOT t.isDeleted
GROUP BY p.itemFk
ORDER BY itemFk, landed, entryFk
) sub
@ -153,7 +156,7 @@ BEGIN
landed,
CAST(`in` AS DECIMAL(10,0)) `in`,
CAST(`out` AS DECIMAL(10,0)) `out`,
warehouse,
sref,
buyingValue,
balance
FROM tSupplierPackaging