From 49e01218e9d9dfffb71c9715339e482db6bf2759 Mon Sep 17 00:00:00 2001 From: Pako Date: Wed, 19 Jun 2024 10:45:37 +0200 Subject: [PATCH 1/2] Warehouse name --- .../vn/procedures/supplierPackaging_ReportSource.sql | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/supplierPackaging_ReportSource.sql b/db/routines/vn/procedures/supplierPackaging_ReportSource.sql index 7cc72848f..a8e506244 100644 --- a/db/routines/vn/procedures/supplierPackaging_ReportSource.sql +++ b/db/routines/vn/procedures/supplierPackaging_ReportSource.sql @@ -68,7 +68,7 @@ BEGIN DATE(t.shipped), -LEAST(s.quantity,0) `in`, GREATEST(s.quantity,0) `out`, - t.warehouseFk, + w.name, s.price * (100 - s.discount) / 100 FROM sale s JOIN item i ON i.id = s.itemFk @@ -76,6 +76,7 @@ BEGIN JOIN ticket t ON t.id = s.ticketFk JOIN client c ON c.id = t.clientFk JOIN supplier su ON su.nif = c.fi + JOIN warehouse w ON w.id = t.warehouseFk WHERE su.id = vSupplierFk AND t.shipped >= vFromDated AND p.isPackageReturnable @@ -110,7 +111,7 @@ BEGIN DATE(t.shipped), -LEAST(tp.quantity,0) `in`, GREATEST(tp.quantity,0) `out`, - t.warehouseFk, + w.name, 0 FROM ticketPackaging tp JOIN packaging p ON p.id = tp.packagingFk @@ -118,6 +119,7 @@ BEGIN JOIN ticket t ON t.id = tp.ticketFk JOIN client c ON c.id = t.clientFk JOIN supplier su ON su.nif = c.fi + JOIN warehouse w ON w.id = t.warehouseFk WHERE su.id = vSupplierFk AND t.shipped >= vFromDated AND p.isPackageReturnable From fe154b9ee84f9db7c5e4edaa0ffd25b9156a7e4b Mon Sep 17 00:00:00 2001 From: Pako Date: Fri, 21 Jun 2024 08:32:22 +0200 Subject: [PATCH 2/2] sref --- .../supplierPackaging_ReportSource.sql | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/db/routines/vn/procedures/supplierPackaging_ReportSource.sql b/db/routines/vn/procedures/supplierPackaging_ReportSource.sql index a8e506244..63285203b 100644 --- a/db/routines/vn/procedures/supplierPackaging_ReportSource.sql +++ b/db/routines/vn/procedures/supplierPackaging_ReportSource.sql @@ -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`, - w.name, + t.cmrFk, s.price * (100 - s.discount) / 100 FROM sale s JOIN item i ON i.id = s.itemFk @@ -76,7 +77,6 @@ BEGIN JOIN ticket t ON t.id = s.ticketFk JOIN client c ON c.id = t.clientFk JOIN supplier su ON su.nif = c.fi - JOIN warehouse w ON w.id = t.warehouseFk WHERE su.id = vSupplierFk AND t.shipped >= vFromDated AND p.isPackageReturnable @@ -111,7 +111,7 @@ BEGIN DATE(t.shipped), -LEAST(tp.quantity,0) `in`, GREATEST(tp.quantity,0) `out`, - w.name, + t.cmrFk, 0 FROM ticketPackaging tp JOIN packaging p ON p.id = tp.packagingFk @@ -119,7 +119,6 @@ BEGIN JOIN ticket t ON t.id = tp.ticketFk JOIN client c ON c.id = t.clientFk JOIN supplier su ON su.nif = c.fi - JOIN warehouse w ON w.id = t.warehouseFk WHERE su.id = vSupplierFk AND t.shipped >= vFromDated AND p.isPackageReturnable @@ -157,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