System generated commit, initial commit
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"gitSyncId": "11976947d24e48cf90c738f1_c8a3dcce-d31d-42fe-9aa7-7773bd28f1d9",
|
||||
"id": "Operations - Unused Items_unused_items",
|
||||
"pluginId": "postgres-plugin",
|
||||
"pluginType": "DB",
|
||||
"unpublishedAction": {
|
||||
"actionConfiguration": {
|
||||
"body": "SELECT\n i.item_number AS \"Item Number\",\n COALESCE(NULLIF(i.item_descrip1, ''), i.item_descrip2) 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\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": [
|
||||
{
|
||||
"key": "body"
|
||||
}
|
||||
],
|
||||
"name": "unused_items",
|
||||
"pageId": "Operations - Unused Items",
|
||||
"runBehaviour": "AUTOMATIC",
|
||||
"userSetOnLoad": false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
SELECT
|
||||
i.item_number AS "Item Number",
|
||||
COALESCE(NULLIF(i.item_descrip1, ''), i.item_descrip2) AS "Description",
|
||||
CASE i.item_type
|
||||
WHEN 'P' THEN 'Purchased'
|
||||
WHEN 'M' THEN 'Manufactured'
|
||||
WHEN 'R' THEN 'Reference'
|
||||
WHEN 'T' THEN 'Tooling'
|
||||
WHEN 'O' THEN 'Outside Process'
|
||||
WHEN 'B' THEN 'Breeder'
|
||||
WHEN 'C' THEN 'Co-Product'
|
||||
WHEN 'F' THEN 'Phantom'
|
||||
ELSE i.item_type
|
||||
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",
|
||||
(CURRENT_DATE - COALESCE(last_txn.last_transaction_date, i.item_created, cc.comment_date)::date) AS "Days Unused"
|
||||
FROM item i
|
||||
LEFT JOIN classcode clc ON clc.classcode_id = i.item_classcode_id
|
||||
LEFT JOIN (
|
||||
SELECT bomitem_item_id, COUNT(DISTINCT bomitem_parent_item_id) AS num_boms
|
||||
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'
|
||||
AND cc.comment_text = 'Created'
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
isite.itemsite_item_id,
|
||||
MAX(ih.invhist_transdate) AS last_transaction_date
|
||||
FROM itemsite isite
|
||||
JOIN invhist ih ON ih.invhist_itemsite_id = isite.itemsite_id
|
||||
GROUP BY isite.itemsite_item_id
|
||||
) last_txn ON last_txn.itemsite_item_id = i.item_id
|
||||
WHERE i.item_active
|
||||
AND (CURRENT_DATE - COALESCE(last_txn.last_transaction_date, i.item_created, cc.comment_date)::date)
|
||||
>= '{{UnusedDays.text}}'::int
|
||||
ORDER BY "Days Unused" DESC
|
||||
Reference in New Issue
Block a user