feat: refs #7709 change request
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Robert Ferrús 2025-01-08 08:41:49 +01:00
parent 37c1878602
commit 9ae255d747
1 changed files with 6 additions and 6 deletions

View File

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