This commit is contained in:
parent
37c1878602
commit
9ae255d747
|
@ -8,7 +8,7 @@ BEGIN
|
||||||
* Create a report with packaging balance
|
* Create a report with packaging balance
|
||||||
*
|
*
|
||||||
* @param vFromDated Starting date
|
* @param vFromDated Starting date
|
||||||
* @param vSupplierFk Supplier ID
|
* @param vNif number of nif/fi of supplier or client
|
||||||
*/
|
*/
|
||||||
DECLARE vEntityId INT;
|
DECLARE vEntityId INT;
|
||||||
|
|
||||||
|
@ -124,12 +124,12 @@ BEGIN
|
||||||
FROM (
|
FROM (
|
||||||
SELECT sp.itemFk,
|
SELECT sp.itemFk,
|
||||||
sp.longName,
|
sp.longName,
|
||||||
sp.supplier,
|
sp.supplier name,
|
||||||
CONCAT('E', sp.entryFk),
|
CONCAT('E', sp.entryFk) entryFk,
|
||||||
sp.landed,
|
sp.landed,
|
||||||
sp.`in`,
|
sp.`in`,
|
||||||
sp.`out`,
|
sp.`out`,
|
||||||
e.invoiceNumber,
|
e.invoiceNumber sref,
|
||||||
sp.buyingValue
|
sp.buyingValue
|
||||||
FROM supplierPackaging sp
|
FROM supplierPackaging sp
|
||||||
JOIN entry e ON e.id = sp.entryFk
|
JOIN entry e ON e.id = sp.entryFk
|
||||||
|
@ -142,8 +142,8 @@ BEGIN
|
||||||
supplier,
|
supplier,
|
||||||
'E previous',
|
'E previous',
|
||||||
vFromDated,
|
vFromDated,
|
||||||
IF(SUM(`in`) + SUM(-`out`)>0, SUM(`in`) + SUM(-`out`), 0) `in`,
|
GREATEST(SUM(`in`) - SUM(`out`), 0) AS `in`,
|
||||||
-IF(SUM(`in`) + SUM(-`out`)<0, SUM(`in`) + SUM(-`out`), 0) `out`,
|
LEAST(SUM(`in`) - SUM(`out`), 0) AS `out`,
|
||||||
NULL,
|
NULL,
|
||||||
AVG(buyingValue)
|
AVG(buyingValue)
|
||||||
FROM supplierPackaging sp
|
FROM supplierPackaging sp
|
||||||
|
|
Loading…
Reference in New Issue