diff --git a/pages/Operations - Unused Items/queries/unused_items/metadata.json b/pages/Operations - Unused Items/queries/unused_items/metadata.json index aebe43a..a8203b3 100644 --- a/pages/Operations - Unused Items/queries/unused_items/metadata.json +++ b/pages/Operations - Unused Items/queries/unused_items/metadata.json @@ -5,7 +5,7 @@ "pluginType": "DB", "unpublishedAction": { "actionConfiguration": { - "body": "SELECT\n i.item_number AS \"Item Number\",\n i.item_descrip1 AS \"Description\",\n CASE i.item_type\n WHEN 'P' THEN 'Purchased'\n WHEN 'M' THEN 'Manufactured'\n WHEN 'R' THEN 'Reference'\n WHEN 'T' THEN 'Tooling'\n WHEN 'O' THEN 'Outside Process'\n WHEN 'B' THEN 'Breeder'\n WHEN 'C' THEN 'Co-Product'\n WHEN 'F' THEN 'Phantom'\n ELSE i.item_type\n END AS \"Item Type\",\n clc.classcode_code AS \"Class Code\",\n COALESCE(bom_count.num_boms, 0) AS \"BOMs Used In\",\n cc.comment_user AS \"Created By\",\n COALESCE(i.item_created, cc.comment_date)::date AS \"Date Created\",\n last_txn.last_transaction_date::date AS \"Last Transaction\",\n (CURRENT_DATE - COALESCE(last_txn.last_transaction_date, i.item_created, cc.comment_date)::date) AS \"Days Unused\"\nFROM item i\nLEFT JOIN classcode clc ON clc.classcode_id = i.item_classcode_id\nLEFT JOIN (\n SELECT bomitem_item_id, COUNT(DISTINCT bomitem_parent_item_id) AS num_boms\n FROM bomitem\n GROUP BY bomitem_item_id\n) bom_count ON bom_count.bomitem_item_id = i.item_id\nLEFT JOIN comment cc\n ON cc.comment_source_id = i.item_id\n AND cc.comment_source = 'I'\n AND cc.comment_text = 'Created'\nLEFT JOIN (\n SELECT\n isite.itemsite_item_id,\n MAX(ih.invhist_transdate) AS last_transaction_date\n FROM itemsite isite\n JOIN invhist ih ON ih.invhist_itemsite_id = isite.itemsite_id\n GROUP BY isite.itemsite_item_id\n) last_txn ON last_txn.itemsite_item_id = i.item_id\nWHERE i.item_active\n AND (CURRENT_DATE - COALESCE(last_txn.last_transaction_date, i.item_created, cc.comment_date)::date)\n >= '{{UnusedDays.text}}'::int\nORDER BY \"Days Unused\" DESC", + "body": "SELECT\n i.item_number AS \"Item Number\",\n i.item_descrip1 AS \"Description\",\n CASE i.item_type\n WHEN 'P' THEN 'Purchased'\n WHEN 'M' THEN 'Manufactured'\n WHEN 'R' THEN 'Reference'\n WHEN 'T' THEN 'Tooling'\n WHEN 'O' THEN 'Outside Process'\n WHEN 'B' THEN 'Breeder'\n WHEN 'C' THEN 'Co-Product'\n WHEN 'F' THEN 'Phantom'\n ELSE i.item_type\n END AS \"Item Type\",\n clc.classcode_code AS \"Class Code\",\n COALESCE(bom_count.num_boms, 0) AS \"BOMs Used In\",\n COALESCE(qoh.qty_on_hand, 0) AS \"QOH\",\n cc.comment_user AS \"Created By\",\n COALESCE(i.item_created, cc.comment_date)::date AS \"Date Created\",\n last_txn.last_transaction_date::date AS \"Last Transaction\",\n (CURRENT_DATE - COALESCE(last_txn.last_transaction_date, i.item_created, cc.comment_date)::date) AS \"Days Unused\"\nFROM item i\nLEFT JOIN classcode clc ON clc.classcode_id = i.item_classcode_id\nLEFT JOIN (\n SELECT bomitem_item_id, COUNT(DISTINCT bomitem_parent_item_id) AS num_boms\n FROM bomitem\n GROUP BY bomitem_item_id\n) bom_count ON bom_count.bomitem_item_id = i.item_id\nLEFT JOIN (\n SELECT itemsite_item_id, SUM(itemsite_qtyonhand) AS qty_on_hand\n FROM itemsite\n GROUP BY itemsite_item_id\n) qoh ON qoh.itemsite_item_id = i.item_id\nLEFT JOIN comment cc\n ON cc.comment_source_id = i.item_id\n AND cc.comment_source = 'I'\n AND cc.comment_text = 'Created'\nLEFT JOIN (\n SELECT\n isite.itemsite_item_id,\n MAX(ih.invhist_transdate) AS last_transaction_date\n FROM itemsite isite\n JOIN invhist ih ON ih.invhist_itemsite_id = isite.itemsite_id\n GROUP BY isite.itemsite_item_id\n) last_txn ON last_txn.itemsite_item_id = i.item_id\nWHERE i.item_active\n AND (CURRENT_DATE - COALESCE(last_txn.last_transaction_date, i.item_created, cc.comment_date)::date)\n >= '{{UnusedDays.text}}'::int\nORDER BY \"Days Unused\" DESC", "encodeParamsToggle": true, "paginationType": "NONE", "pluginSpecifiedTemplates": [ diff --git a/pages/Operations - Unused Items/queries/unused_items/unused_items.txt b/pages/Operations - Unused Items/queries/unused_items/unused_items.txt index 0d18fe2..275b402 100644 --- a/pages/Operations - Unused Items/queries/unused_items/unused_items.txt +++ b/pages/Operations - Unused Items/queries/unused_items/unused_items.txt @@ -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' diff --git a/pages/Operations - Unused Items/widgets/Table1.json b/pages/Operations - Unused Items/widgets/Table1.json index ef83e59..02799e1 100644 --- a/pages/Operations - Unused Items/widgets/Table1.json +++ b/pages/Operations - Unused Items/widgets/Table1.json @@ -37,6 +37,7 @@ "Item Type", "Class Code", "BOMs Used In", + "QOH", "Created By", "Date Created", "Last Transaction", @@ -60,6 +61,7 @@ {"key": "primaryColumns.Item Type.computedValue"}, {"key": "primaryColumns.Class Code.computedValue"}, {"key": "primaryColumns.BOMs Used In.computedValue"}, + {"key": "primaryColumns.QOH.computedValue"}, {"key": "primaryColumns.Created By.computedValue"}, {"key": "primaryColumns.Date Created.computedValue"}, {"key": "primaryColumns.Last Transaction.computedValue"}, @@ -251,6 +253,37 @@ "verticalAlignment": "CENTER", "width": 150 }, + "QOH": { + "alias": "QOH", + "allowCellWrapping": false, + "allowSameOptionsInNewRow": true, + "columnType": "number", + "computedValue": "{{(() => { const tableData = Table1.processedTableData || []; return tableData.length > 0 ? tableData.map((currentRow, currentIndex) => (currentRow[\"QOH\"])) : [] })()}}", + "currencyCode": "USD", + "decimals": 0, + "enableFilter": true, + "enableSort": true, + "horizontalAlignment": "LEFT", + "id": "QOH", + "index": 5, + "isCellEditable": false, + "isCellVisible": true, + "isDerived": false, + "isDisabled": false, + "isDiscardVisible": true, + "isEditable": false, + "isSaveVisible": true, + "isVisible": true, + "label": "QOH", + "notation": "standard", + "originalId": "QOH", + "sticky": "", + "textSize": "0.775rem", + "thousandSeparator": true, + "validation": {}, + "verticalAlignment": "CENTER", + "width": 150 + }, "Created By": { "alias": "Created By", "allowCellWrapping": false, @@ -263,7 +296,7 @@ "enableSort": true, "horizontalAlignment": "LEFT", "id": "Created By", - "index": 5, + "index": 6, "isCellEditable": false, "isCellVisible": true, "isDerived": false, @@ -294,7 +327,7 @@ "enableSort": true, "horizontalAlignment": "LEFT", "id": "Date Created", - "index": 6, + "index": 7, "isCellEditable": false, "isCellVisible": true, "isDerived": false, @@ -325,7 +358,7 @@ "enableSort": true, "horizontalAlignment": "LEFT", "id": "Last Transaction", - "index": 7, + "index": 8, "isCellEditable": false, "isCellVisible": true, "isDerived": false, @@ -356,7 +389,7 @@ "enableSort": true, "horizontalAlignment": "LEFT", "id": "Days Unused", - "index": 8, + "index": 9, "isCellEditable": false, "isCellVisible": true, "isDerived": false,