Inventory Valuation Report Query

Ray Lee ✓ Verified SQL Production 2026-03-02

Comprehensive SQL query for generating an inventory valuation report. Calculates on-hand quantity, reserved quantity, and total value per product and warehouse. Essential for financial period-end reporting and inventory audit in iDempiere.

Code
-- Inventory Valuation by Warehouse and Product
SELECT
    w.Name                  AS Warehouse,
    p.Value                 AS ProductCode,
    p.Name                  AS ProductName,
    uom.Name                AS UOM,
    COALESCE(s.QtyOnHand, 0)    AS QtyOnHand,
    COALESCE(s.QtyReserved, 0)  AS QtyReserved,
    COALESCE(s.QtyOrdered, 0)   AS QtyOrdered,
    mc.CurrentCostPrice         AS UnitCost,
    COALESCE(s.QtyOnHand, 0) * mc.CurrentCostPrice AS TotalValue
FROM M_Product p
JOIN M_Storage s       ON p.M_Product_ID = s.M_Product_ID
JOIN M_Locator l       ON s.M_Locator_ID = l.M_Locator_ID
JOIN M_Warehouse w     ON l.M_Warehouse_ID = w.M_Warehouse_ID
JOIN C_UOM uom         ON p.C_UOM_ID = uom.C_UOM_ID
LEFT JOIN M_Cost mc    ON p.M_Product_ID = mc.M_Product_ID
                      AND mc.AD_Client_ID = p.AD_Client_ID
                      AND mc.M_CostElement_ID = (
                          SELECT M_CostElement_ID FROM M_CostElement
                          WHERE CostingMethod = 'A'
                            AND AD_Client_ID = p.AD_Client_ID
                            AND ROWNUM = 1
                      )
WHERE p.IsActive = 'Y'
  AND p.ProductType = 'I'
  AND s.QtyOnHand <> 0
ORDER BY w.Name, p.Value;

You Missed