feat: refs #7438 Added volume to item_valuateInventory
gitea/salix/pipeline/pr-dev This commit looks good
Details
gitea/salix/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
35a583d6d8
commit
35ce259e5a
|
@ -1,5 +1,7 @@
|
|||
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
|
||||
DECLARE vInventoried DATE;
|
||||
DECLARE vHasNotInventory BOOLEAN DEFAULT FALSE;
|
||||
|
@ -41,6 +43,7 @@ BEGIN
|
|||
warehouseFk SMALLINT,
|
||||
itemFk BIGINT,
|
||||
quantity INT,
|
||||
volume DECIMAL(10,2),
|
||||
cost DOUBLE DEFAULT 0,
|
||||
total DOUBLE DEFAULT 0,
|
||||
warehouseInventory VARCHAR(20),
|
||||
|
@ -183,7 +186,7 @@ BEGIN
|
|||
AND e.isConfirmed
|
||||
ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity);
|
||||
|
||||
CALL vn.buyUltimate(NULL, vDateDayEnd);
|
||||
CALL buyUltimate(NULL, vDateDayEnd);
|
||||
|
||||
UPDATE tInventory i
|
||||
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)
|
||||
WHERE i.quantity;
|
||||
|
||||
DELETE FROM tInventory
|
||||
WHERE quantity IS NULL OR NOT quantity;
|
||||
DELETE FROM tInventory WHERE quantity IS NULL OR NOT quantity;
|
||||
|
||||
UPDATE tInventory i
|
||||
JOIN itemCost ic ON ic.itemFk = i.itemFk
|
||||
AND ic.warehouseFk = i.warehouseFk
|
||||
SET i.volume = i.quantity * ic.cm3delivery / 1000000;
|
||||
|
||||
IF vIsDetailed THEN
|
||||
SELECT ti.warehouseFk,
|
||||
i.id itemFk,
|
||||
i.id,
|
||||
i.longName,
|
||||
i.size,
|
||||
ti.quantity,
|
||||
tp.name Tipo,
|
||||
ic.name Reino,
|
||||
ti.volume,
|
||||
tp.name itemTypeName,
|
||||
ic.name itemCategoryName,
|
||||
ti.cost,
|
||||
CAST(ti.total AS DECIMAL(10, 2)) total,
|
||||
ti.warehouseInventory almacen
|
||||
ti.total,
|
||||
ti.warehouseInventory
|
||||
FROM tInventory ti
|
||||
JOIN warehouse w ON w.id = warehouseFk
|
||||
JOIN item i ON i.id = ti.itemFk
|
||||
JOIN itemType tp ON tp.id = i.typeFk
|
||||
JOIN itemCategory ic ON ic.id = tp.categoryFk
|
||||
WHERE w.valuatedInventory
|
||||
AND ti.total > 0
|
||||
ORDER BY ti.total DESC;
|
||||
ELSE
|
||||
SELECT i.warehouseInventory Almacen,
|
||||
ic.name Reino,
|
||||
CAST(i.total AS DECIMAL(10, 2)) Euros,
|
||||
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;
|
||||
AND ti.total > 0;
|
||||
|
||||
DROP TEMPORARY TABLE
|
||||
tmp.buyUltimate,
|
||||
|
|
Loading…
Reference in New Issue