Warehouse name #2610

Merged
pako merged 5 commits from 7420-supplierPackaging_reportSource_update into dev 2024-06-21 07:02:32 +00:00
1 changed files with 18 additions and 17 deletions

View File

@ -22,7 +22,7 @@ BEGIN
landed, landed,
`in`, `in`,
`out`, `out`,
warehouse, sref,
buyingValue, buyingValue,
IF ( IF (
NOT (@vItemFk <=> sub.itemFk), NOT (@vItemFk <=> sub.itemFk),
@ -31,19 +31,20 @@ BEGIN
) balance, ) balance,
@vItemFk := sub.itemFk previousItemFk @vItemFk := sub.itemFk previousItemFk
FROM ( FROM (
SELECT supplierFk, SELECT sp.supplierFk,
itemFk, sp.itemFk,
longName, sp.longName,
supplier, sp.supplier,
CONCAT('E',entryFk) entryFk, CONCAT('E',sp.entryFk) entryFk,
landed, sp.landed,
`in`, sp.`in`,
`out`, sp.`out`,
warehouse, e.invoiceNumber sref,
buyingValue sp.buyingValue
FROM supplierPackaging FROM supplierPackaging sp
WHERE supplierFk = vSupplierFk JOIN entry e ON e.id = sp.entryFk
AND landed >= vFromDated WHERE sp.supplierFk = vSupplierFk
AND sp.landed >= vFromDated
UNION ALL UNION ALL
SELECT vSupplierFk, SELECT vSupplierFk,
itemFk, itemFk,
@ -68,7 +69,7 @@ BEGIN
DATE(t.shipped), DATE(t.shipped),
-LEAST(s.quantity,0) `in`, -LEAST(s.quantity,0) `in`,
GREATEST(s.quantity,0) `out`, GREATEST(s.quantity,0) `out`,
t.warehouseFk, t.cmrFk,
s.price * (100 - s.discount) / 100 s.price * (100 - s.discount) / 100
FROM sale s FROM sale s
JOIN item i ON i.id = s.itemFk JOIN item i ON i.id = s.itemFk
@ -110,7 +111,7 @@ BEGIN
DATE(t.shipped), DATE(t.shipped),
-LEAST(tp.quantity,0) `in`, -LEAST(tp.quantity,0) `in`,
GREATEST(tp.quantity,0) `out`, GREATEST(tp.quantity,0) `out`,
t.warehouseFk, t.cmrFk,
0 0
FROM ticketPackaging tp FROM ticketPackaging tp
JOIN packaging p ON p.id = tp.packagingFk JOIN packaging p ON p.id = tp.packagingFk
@ -155,7 +156,7 @@ BEGIN
landed, landed,
CAST(`in` AS DECIMAL(10,0)) `in`, CAST(`in` AS DECIMAL(10,0)) `in`,
CAST(`out` AS DECIMAL(10,0)) `out`, CAST(`out` AS DECIMAL(10,0)) `out`,
warehouse, sref,
buyingValue, buyingValue,
balance balance
FROM tSupplierPackaging FROM tSupplierPackaging