Two-tab dashboard tracking external labor workflows (e.g., tin plating): - Tab 1 "At Vendor": Open POs for outside process items (EXTLAB classcode), showing vendor, PO#, finished/manufactured/ext labor PNs, qty, ship date, expected return (7-day default), days out, and WO demand - Tab 2 "Awaiting Shipment": WOs with manufactured material issued but no open PO for the outside process item, showing days waiting in stockroom Nav button added to all 11 pages in Operations section (rows 56-60). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
56 lines
2.5 KiB
Plaintext
56 lines
2.5 KiB
Plaintext
-- Items with manufacturing complete but not yet shipped to vendor
|
|
-- WOs that have an outside process material (EXTLAB) with no open PO
|
|
SELECT
|
|
fi.item_number AS finished_pn,
|
|
fi.item_descrip1 AS finished_desc,
|
|
mi.item_number AS manufactured_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,
|
|
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
|
|
-- 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
|
|
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
|
|
-- No open PO exists for the outside process item on this WO
|
|
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'
|
|
)
|
|
ORDER BY days_waiting DESC, finished_pn;
|