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 * 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