feat: refs #7438 Added volume to item_valuateInventory
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Guillermo Bonet 2024-05-23 14:26:11 +02:00
parent 35a583d6d8
commit 35ce259e5a
1 changed files with 36 additions and 45 deletions

View File

@ -1,5 +1,7 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_ValuateInventory`(vDated DATE, vIsDetailed BOOLEAN) CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_valuateInventory`(
vDated DATE
)
BEGIN BEGIN
DECLARE vInventoried DATE; DECLARE vInventoried DATE;
DECLARE vHasNotInventory BOOLEAN DEFAULT FALSE; DECLARE vHasNotInventory BOOLEAN DEFAULT FALSE;
@ -38,13 +40,14 @@ BEGIN
END IF; END IF;
CREATE OR REPLACE TEMPORARY TABLE tInventory( CREATE OR REPLACE TEMPORARY TABLE tInventory(
warehouseFk SMALLINT, warehouseFk SMALLINT,
itemFk BIGINT, itemFk BIGINT,
quantity INT, quantity INT,
cost DOUBLE DEFAULT 0, volume DECIMAL(10,2),
total DOUBLE DEFAULT 0, cost DOUBLE DEFAULT 0,
warehouseInventory VARCHAR(20), total DOUBLE DEFAULT 0,
PRIMARY KEY (warehouseInventory, itemFk) USING HASH warehouseInventory VARCHAR(20),
PRIMARY KEY (warehouseInventory, itemFk) USING HASH
) )
ENGINE = MEMORY; ENGINE = MEMORY;
@ -183,7 +186,7 @@ BEGIN
AND e.isConfirmed AND e.isConfirmed
ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity); ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity);
CALL vn.buyUltimate(NULL, vDateDayEnd); CALL buyUltimate(NULL, vDateDayEnd);
UPDATE tInventory i UPDATE tInventory i
JOIN tmp.buyUltimate bu ON i.warehouseFk = bu.warehouseFk AND i.itemFk = bu.itemFk JOIN tmp.buyUltimate bu ON i.warehouseFk = bu.warehouseFk AND i.itemFk = bu.itemFk
@ -192,43 +195,31 @@ BEGIN
cost = IFNULL(b.buyingValue, 0) + IFNULL(b.packageValue, 0) + IFNULL(b.freightValue, 0) + IFNULL(b.comissionValue, 0) cost = IFNULL(b.buyingValue, 0) + IFNULL(b.packageValue, 0) + IFNULL(b.freightValue, 0) + IFNULL(b.comissionValue, 0)
WHERE i.quantity; WHERE i.quantity;
DELETE FROM tInventory DELETE FROM tInventory WHERE quantity IS NULL OR NOT quantity;
WHERE quantity IS NULL OR NOT quantity;
IF vIsDetailed THEN UPDATE tInventory i
SELECT ti.warehouseFk, JOIN itemCost ic ON ic.itemFk = i.itemFk
i.id itemFk, AND ic.warehouseFk = i.warehouseFk
i.longName, SET i.volume = i.quantity * ic.cm3delivery / 1000000;
i.size,
ti.quantity, SELECT ti.warehouseFk,
tp.name Tipo, i.id,
ic.name Reino, i.longName,
ti.cost, i.size,
CAST(ti.total AS DECIMAL(10, 2)) total, ti.quantity,
ti.warehouseInventory almacen ti.volume,
FROM tInventory ti tp.name itemTypeName,
JOIN warehouse w ON w.id = warehouseFk ic.name itemCategoryName,
JOIN item i ON i.id = ti.itemFk ti.cost,
JOIN itemType tp ON tp.id = i.typeFk ti.total,
JOIN itemCategory ic ON ic.id = tp.categoryFk ti.warehouseInventory
WHERE w.valuatedInventory FROM tInventory ti
AND ti.total > 0 JOIN warehouse w ON w.id = warehouseFk
ORDER BY ti.total DESC; JOIN item i ON i.id = ti.itemFk
ELSE JOIN itemType tp ON tp.id = i.typeFk
SELECT i.warehouseInventory Almacen, JOIN itemCategory ic ON ic.id = tp.categoryFk
ic.name Reino, WHERE w.valuatedInventory
CAST(i.total AS DECIMAL(10, 2)) Euros, AND ti.total > 0;
w.code Comprador,
it.id
FROM tInventory i
JOIN warehouse wh ON wh.id = warehouseFk
JOIN item it ON it.id = i.itemFk
JOIN itemType itp ON itp.id = it.typeFk
LEFT JOIN worker w ON w.id = itp.workerFk
JOIN itemCategory ic ON ic.id = itp.categoryFk
WHERE wh.valuatedInventory
AND i.total > 0;
END IF;
DROP TEMPORARY TABLE DROP TEMPORARY TABLE
tmp.buyUltimate, tmp.buyUltimate,