Merge pull request 'Warehouse name' (!2610) from 7420-supplierPackaging_reportSource_update into dev
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #2610
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
This commit is contained in:
Pako Natek 2024-06-21 07:02:31 +00:00
commit fc0c03f01a
1 changed files with 18 additions and 17 deletions

View File

@ -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
@ -110,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
@ -155,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