{ "gitSyncId": "8f96c44ddc5247178794ffac_2883aec1-7d30-4336-8621-14ed7f85caf8", "id": "Operations - External Process_at_vendor", "pluginId": "postgres-plugin", "pluginType": "DB", "unpublishedAction": { "actionConfiguration": { "body": "-- Items currently at an external vendor (PO open, not fully received)\n-- Outside process items identified by item_type='O' and classcode_code='EXTLAB'\nSELECT\n v.vend_name AS vendor,\n ph.pohead_number AS po_number,\n fi.item_number AS finished_pn,\n fi.item_descrip1 AS finished_desc,\n COALESCE(mi.item_number, '') AS manufactured_pn,\n opi.item_number AS ext_labor_pn,\n pi.poitem_qty_ordered AS qty_ordered,\n pi.poitem_qty_received AS qty_received,\n to_char(ph.pohead_orderdate, 'YYYY-MM-DD') AS date_shipped,\n to_char(ph.pohead_orderdate + interval '7 days', 'YYYY-MM-DD') AS expected_return,\n (CURRENT_DATE - ph.pohead_orderdate::date) AS days_out,\n COALESCE((\n SELECT SUM(w2.wo_qtyord - w2.wo_qtyrcv)\n FROM wo w2\n JOIN itemsite is2 ON w2.wo_itemsite_id = is2.itemsite_id\n WHERE is2.itemsite_item_id = fi.item_id\n AND w2.wo_status IN ('R','E','I')\n ), 0) AS wo_demand\nFROM poitem pi\nJOIN pohead ph ON pi.poitem_pohead_id = ph.pohead_id\nJOIN vendinfo v ON ph.pohead_vend_id = v.vend_id\nJOIN itemsite opis ON pi.poitem_itemsite_id = opis.itemsite_id\nJOIN item opi ON opis.itemsite_item_id = opi.item_id\nJOIN classcode cc ON opi.item_classcode_id = cc.classcode_id\n-- Link PO outside process item back to the WO that needs it\nJOIN womatl wm ON wm.womatl_itemsite_id = opis.itemsite_id\nJOIN wo parent_wo ON wm.womatl_wo_id = parent_wo.wo_id\n AND parent_wo.wo_status IN ('R','E','I')\nJOIN itemsite fis ON parent_wo.wo_itemsite_id = fis.itemsite_id\nJOIN item fi ON fis.itemsite_item_id = fi.item_id\n-- Find the manufactured part (non-outside-process material on same WO)\nLEFT JOIN LATERAL (\n SELECT mi2.item_number\n FROM womatl wm2\n JOIN itemsite mis2 ON wm2.womatl_itemsite_id = mis2.itemsite_id\n JOIN item mi2 ON mis2.itemsite_item_id = mi2.item_id\n JOIN classcode cc2 ON mi2.item_classcode_id = cc2.classcode_id\n WHERE wm2.womatl_wo_id = parent_wo.wo_id\n AND wm2.womatl_id != wm.womatl_id\n AND cc2.classcode_code != 'EXTLAB'\n AND mi2.item_type != 'O'\n ORDER BY mi2.item_number\n LIMIT 1\n) mi ON true\nWHERE cc.classcode_code = 'EXTLAB'\n AND opi.item_type = 'O'\n AND ph.pohead_status = 'O'\n AND pi.poitem_status = 'O'\n AND pi.poitem_qty_received < pi.poitem_qty_ordered\nORDER BY days_out DESC, vendor, finished_pn;\n", "encodeParamsToggle": true, "paginationType": "NONE", "pluginSpecifiedTemplates": [ {"value": true} ], "timeoutInMillisecond": 30000 }, "confirmBeforeExecute": false, "datasource": { "id": "xTuple_GoLive", "isAutoGenerated": false, "name": "xTuple_GoLive", "pluginId": "postgres-plugin" }, "dynamicBindingPathList": [], "name": "at_vendor", "pageId": "Operations - External Process", "runBehaviour": "AUTOMATIC", "userSetOnLoad": false } }