Add QOH column to Unused Items page

Sum itemsite_qtyonhand across all itemsites per item.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-31 06:55:14 -04:00
parent a8b9a45a5d
commit c851e06086
3 changed files with 44 additions and 5 deletions

View File

@@ -14,6 +14,7 @@ SELECT
END AS "Item Type",
clc.classcode_code AS "Class Code",
COALESCE(bom_count.num_boms, 0) AS "BOMs Used In",
COALESCE(qoh.qty_on_hand, 0) AS "QOH",
cc.comment_user AS "Created By",
COALESCE(i.item_created, cc.comment_date)::date AS "Date Created",
last_txn.last_transaction_date::date AS "Last Transaction",
@@ -25,6 +26,11 @@ LEFT JOIN (
FROM bomitem
GROUP BY bomitem_item_id
) bom_count ON bom_count.bomitem_item_id = i.item_id
LEFT JOIN (
SELECT itemsite_item_id, SUM(itemsite_qtyonhand) AS qty_on_hand
FROM itemsite
GROUP BY itemsite_item_id
) qoh ON qoh.itemsite_item_id = i.item_id
LEFT JOIN comment cc
ON cc.comment_source_id = i.item_id
AND cc.comment_source = 'I'