Nav buttons in Operations section now in alphabetical order across all 11 pages: Engineering Holds, External Process, Job Drawing Status, Unused Items, WO Shortages. Fixed Awaiting Shipment query: - Primary focus on manufactured part (the item in stockroom), not finished part - Added wm_op.womatl_qtyiss < wm_op.womatl_qtyreq filter to exclude completed external process cycles (was showing 10-year-old data) - Removed unreliable date_in_stockroom/days_waiting columns - Added WO number and manufactured part description columns Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
55 lines
2.4 KiB
Plaintext
55 lines
2.4 KiB
Plaintext
-- Manufactured parts awaiting shipment to external vendor
|
|
-- The manufactured part has been produced (womatl issued) but the
|
|
-- outside process (EXTLAB) has not been completed yet and no open PO exists.
|
|
SELECT
|
|
mi.item_number AS manufactured_pn,
|
|
mi.item_descrip1 AS manufactured_desc,
|
|
fi.item_number AS finished_pn,
|
|
opi.item_number AS ext_labor_pn,
|
|
wm_mfg.womatl_qtyiss AS qty_ready,
|
|
formatwonumber(parent_wo.wo_id) AS wo_number,
|
|
COALESCE(dv.vend_name, '') AS expected_vendor,
|
|
COALESCE((
|
|
SELECT SUM(w2.wo_qtyord - w2.wo_qtyrcv)
|
|
FROM wo w2
|
|
JOIN itemsite is2 ON w2.wo_itemsite_id = is2.itemsite_id
|
|
WHERE is2.itemsite_item_id = fi.item_id
|
|
AND w2.wo_status IN ('R','E','I')
|
|
), 0) AS wo_demand
|
|
FROM wo parent_wo
|
|
JOIN itemsite fis ON parent_wo.wo_itemsite_id = fis.itemsite_id
|
|
JOIN item fi ON fis.itemsite_item_id = fi.item_id
|
|
-- Find the outside process material on this WO
|
|
JOIN womatl wm_op ON parent_wo.wo_id = wm_op.womatl_wo_id
|
|
JOIN itemsite opis ON wm_op.womatl_itemsite_id = opis.itemsite_id
|
|
JOIN item opi ON opis.itemsite_item_id = opi.item_id
|
|
JOIN classcode cc ON opi.item_classcode_id = cc.classcode_id
|
|
-- Find the manufactured part material on this WO
|
|
JOIN womatl wm_mfg ON parent_wo.wo_id = wm_mfg.womatl_wo_id
|
|
AND wm_mfg.womatl_id != wm_op.womatl_id
|
|
JOIN itemsite mis ON wm_mfg.womatl_itemsite_id = mis.itemsite_id
|
|
JOIN item mi ON mis.itemsite_item_id = mi.item_id
|
|
JOIN classcode cc_mfg ON mi.item_classcode_id = cc_mfg.classcode_id
|
|
-- Default vendor for the outside process item
|
|
LEFT JOIN itemsrc isrc ON isrc.itemsrc_item_id = opi.item_id AND isrc.itemsrc_active
|
|
LEFT JOIN vendinfo dv ON isrc.itemsrc_vend_id = dv.vend_id
|
|
WHERE cc.classcode_code = 'EXTLAB'
|
|
AND opi.item_type = 'O'
|
|
AND cc_mfg.classcode_code != 'EXTLAB'
|
|
AND mi.item_type != 'O'
|
|
AND parent_wo.wo_status IN ('R','E','I')
|
|
-- Manufactured material has been issued (machining complete)
|
|
AND wm_mfg.womatl_qtyiss > 0
|
|
-- Outside process NOT yet completed (material not fully issued/received)
|
|
AND wm_op.womatl_qtyiss < wm_op.womatl_qtyreq
|
|
-- No open PO exists for the outside process item
|
|
AND NOT EXISTS (
|
|
SELECT 1 FROM poitem pi2
|
|
JOIN pohead ph2 ON pi2.poitem_pohead_id = ph2.pohead_id
|
|
WHERE pi2.poitem_itemsite_id = opis.itemsite_id
|
|
AND ph2.pohead_status = 'O'
|
|
AND pi2.poitem_status = 'O'
|
|
AND pi2.poitem_qty_received < pi2.poitem_qty_ordered
|
|
)
|
|
ORDER BY manufactured_pn, fi.item_number;
|