Compare commits

...

11 Commits

Author SHA1 Message Date
Pako Natek eb3d0e837f Merge branch 'dev' into fixturesLocal
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-12 07:29:08 +00:00
Guillermo Bonet 5bbcf5005f Merge branch 'test' into dev
gitea/salix/pipeline/head This commit looks good Details
2024-11-12 08:04:30 +01:00
Guillermo Bonet 3158644032 fix: refs #7994 commented alter
gitea/salix/pipeline/head There was a failure building this commit Details
2024-11-12 07:59:07 +01:00
Alex Moreno 732dd02a19 Merge pull request '8179-testToMaster' (!3176) from 8179-testToMaster into master
gitea/salix/pipeline/head There was a failure building this commit Details
Reviewed-on: #3176
Reviewed-by: Guillermo Bonet <guillermo@verdnatura.es>
2024-11-12 06:41:51 +00:00
Pablo Natek 82bcb48101 Merge pull request 'test' (!3179) from test into dev
gitea/salix/pipeline/head This commit looks good Details
Reviewed-on: #3179
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
2024-11-12 06:37:16 +00:00
Pablo Natek ffe947c73d Merge pull request 'fix: refs #7404 remove volume from ticket sold on holland' (!3169) from 7404-fix-remove-tickets-volume into test
gitea/salix/pipeline/head This commit looks good Details
gitea/salix/pipeline/pr-dev This commit looks good Details
gitea/salix/pipeline/pr-master This commit looks good Details
Reviewed-on: #3169
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
2024-11-12 06:31:32 +00:00
Pablo Natek 3d3bc0dbaa Merge branch 'test' into 7404-fix-remove-tickets-volume
gitea/salix/pipeline/pr-test This commit looks good Details
2024-11-12 06:24:06 +00:00
Pablo Natek 395e6997dd Merge branch '7404-fix-remove-tickets-volume' of https://gitea.verdnatura.es/verdnatura/salix into 7404-fix-remove-tickets-volume
gitea/salix/pipeline/pr-test This commit looks good Details
2024-11-12 07:23:47 +01:00
Pablo Natek 2dd3ae1c75 fix: refs #7404 empty commit 2024-11-12 07:23:46 +01:00
Pablo Natek 82e62e8ee7 Merge branch 'test' into 7404-fix-remove-tickets-volume 2024-11-11 05:53:30 +00:00
Pablo Natek f8c3d69c5d fix: refs #7404 remove volume from ticket sold on holland
gitea/salix/pipeline/pr-test This commit looks good Details
2024-11-08 13:44:20 +01:00
2 changed files with 38 additions and 12 deletions

View File

@ -7,13 +7,13 @@ proc: BEGIN
* Calculate the stock of the auction warehouse from the inventory date to vDated
* without taking into account the outputs of the same day vDated
*
* @param vDated Date to calculate the stock.
* @param vDated Date to calculate the stock
*/
IF vDated < util.VN_CURDATE() THEN
LEAVE proc;
END IF;
CREATE OR REPLACE TEMPORARY TABLE tStockBought
CREATE OR REPLACE TEMPORARY TABLE tCurrentData
SELECT workerFk, reserve
FROM stockBought
WHERE dated = vDated
@ -21,15 +21,28 @@ proc: BEGIN
DELETE FROM stockBought WHERE dated = vDated;
CREATE OR REPLACE TEMPORARY TABLE tStockSold
SELECT it.workerFk,
SUM(ic.cm3 * ito.quantity / vc.palletM3 / 1000000) sold
FROM itemTicketOut ito
JOIN item i ON i.id = ito.itemFk
JOIN itemType it ON it.id = i.typeFk
JOIN ticket t ON t.id = ito.ticketFk
JOIN warehouse wh ON wh.id = t.warehouseFk
JOIN itemCost ic ON ic.itemFk = ito.itemFk
AND ic.warehouseFk = t.warehouseFk
JOIN volumeConfig vc
WHERE ito.shipped BETWEEN vDated AND util.dayEnd(vDated)
AND wh.code = 'VNH'
GROUP BY it.workerFk;
CALL item_calculateStock(vDated);
INSERT INTO stockBought(workerFk, bought, dated)
CREATE OR REPLACE TEMPORARY TABLE tStockBought
SELECT it.workerFk,
ROUND(SUM(
(ti.quantity / b.packing) *
buy_getVolume(b.id)
) / vc.palletM3 / 1000000, 1) bought,
vDated
SUM((ti.quantity / b.packing) *
buy_getVolume(b.id)
) / vc.palletM3 / 1000000 bought
FROM itemType it
JOIN item i ON i.typeFk = it.id
LEFT JOIN tmp.item ti ON ti.itemFk = i.id
@ -43,20 +56,33 @@ proc: BEGIN
GROUP BY it.workerFk
HAVING bought;
INSERT INTO stockBought(workerFk, bought, dated)
SELECT tb.workerFk,
ROUND(GREATEST(tb.bought - IFNULL(ts.sold, 0), 0), 1),
vDated
FROM tStockBought tb
LEFT JOIN tStockSold ts ON ts.workerFk = tb.workerFk;
UPDATE stockBought s
JOIN tStockBought ts ON ts.workerFk = s.workerFk
JOIN tCurrentData ts ON ts.workerFk = s.workerFk
SET s.reserve = ts.reserve
WHERE s.dated = vDated;
INSERT INTO stockBought (workerFk, reserve, dated)
SELECT ts.workerFk, ts.reserve, vDated
FROM tStockBought ts
FROM tCurrentData ts
WHERE ts.workerFk NOT IN (
SELECT workerFk
FROM stockBought
WHERE dated = vDated
);
DROP TEMPORARY TABLE tStockBought, tmp.item, tmp.buyUltimate;
UPDATE stockBought s
JOIN tStockSold ts ON ts.workerFk = s.workerFk
SET s.bought = IF(s.bought < ts.sold, ROUND(s.bought - ts.sold, 1), 0)
WHERE s.dated = vDated;
DROP TEMPORARY TABLE tCurrentData, tmp.item, tmp.buyUltimate, tStockSold;
END$$
DELIMITER ;

View File

@ -1 +1 @@
ALTER TABLE vn.sale MODIFY COLUMN originalQuantity decimal(10,2) DEFAULT 0.00 NOT NULL COMMENT 'Se utiliza para notificar a través de rocket los cambios de quantity';
-- ALTER TABLE vn.sale MODIFY COLUMN originalQuantity decimal(10,2) DEFAULT 0.00 NOT NULL COMMENT 'Se utiliza para notificar a través de rocket los cambios de quantity';