Alphabetize Operations nav buttons and fix Awaiting Shipment query
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>
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
-- Items with manufacturing complete but not yet shipped to vendor
|
||||
-- WOs that have an outside process material (EXTLAB) with no open PO
|
||||
-- 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
|
||||
fi.item_number AS finished_pn,
|
||||
fi.item_descrip1 AS finished_desc,
|
||||
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,
|
||||
to_char(COALESCE(mfg_wo.wo_duedate, parent_wo.wo_startdate), 'YYYY-MM-DD') AS date_in_stockroom,
|
||||
(CURRENT_DATE - COALESCE(mfg_wo.wo_duedate, parent_wo.wo_startdate)::date) AS days_waiting,
|
||||
formatwonumber(parent_wo.wo_id) AS wo_number,
|
||||
COALESCE(dv.vend_name, '') AS expected_vendor,
|
||||
COALESCE((
|
||||
SELECT SUM(w2.wo_qtyord - w2.wo_qtyrcv)
|
||||
@@ -30,10 +30,6 @@ JOIN womatl wm_mfg ON parent_wo.wo_id = wm_mfg.womatl_wo_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
|
||||
-- Find closed sub-WO for the manufactured part
|
||||
LEFT JOIN wo mfg_wo ON mfg_wo.wo_ordtype = 'W'
|
||||
AND mfg_wo.wo_itemsite_id = mis.itemsite_id
|
||||
AND mfg_wo.wo_status = 'C'
|
||||
-- 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
|
||||
@@ -44,12 +40,15 @@ WHERE cc.classcode_code = 'EXTLAB'
|
||||
AND parent_wo.wo_status IN ('R','E','I')
|
||||
-- Manufactured material has been issued (machining complete)
|
||||
AND wm_mfg.womatl_qtyiss > 0
|
||||
-- No open PO exists for the outside process item on this WO
|
||||
-- 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 days_waiting DESC, finished_pn;
|
||||
ORDER BY manufactured_pn, fi.item_number;
|
||||
|
||||
Reference in New Issue
Block a user