|
|
|
@ -346,6 +346,14 @@ async def get_spareparts_paginated(*, db_session, collector_db_session):
|
|
|
|
) as pr_po_details
|
|
|
|
) as pr_po_details
|
|
|
|
FROM pr_po_unified
|
|
|
|
FROM pr_po_unified
|
|
|
|
GROUP BY item_num
|
|
|
|
GROUP BY item_num
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
inv_summary AS (
|
|
|
|
|
|
|
|
SELECT
|
|
|
|
|
|
|
|
itemnum,
|
|
|
|
|
|
|
|
MAX(inv_curbaltotal) AS total_curbaltotal,
|
|
|
|
|
|
|
|
AVG(inv_avgcost) AS avg_cost
|
|
|
|
|
|
|
|
FROM wo_materials
|
|
|
|
|
|
|
|
GROUP BY itemnum
|
|
|
|
)
|
|
|
|
)
|
|
|
|
SELECT
|
|
|
|
SELECT
|
|
|
|
lss.itemnum,
|
|
|
|
lss.itemnum,
|
|
|
|
@ -355,16 +363,16 @@ async def get_spareparts_paginated(*, db_session, collector_db_session):
|
|
|
|
ROUND(CAST(lss.avg_qty_per_wo AS NUMERIC), 2) as avg_qty_per_wo,
|
|
|
|
ROUND(CAST(lss.avg_qty_per_wo AS NUMERIC), 2) as avg_qty_per_wo,
|
|
|
|
lss.min_qty_used,
|
|
|
|
lss.min_qty_used,
|
|
|
|
lss.max_qty_used,
|
|
|
|
lss.max_qty_used,
|
|
|
|
COALESCE(i.inv_curbaltotal,0) as current_balance_total,
|
|
|
|
COALESCE(i.total_curbaltotal,0) as current_balance_total,
|
|
|
|
COALESCE(ap.total_pr_qty,0) as total_pr_qty,
|
|
|
|
COALESCE(ap.total_pr_qty,0) as total_pr_qty,
|
|
|
|
COALESCE(ap.total_po_qty,0) as total_po_qty,
|
|
|
|
COALESCE(ap.total_po_qty,0) as total_po_qty,
|
|
|
|
COALESCE(ap.total_po_received,0) as total_po_received,
|
|
|
|
COALESCE(ap.total_po_received,0) as total_po_received,
|
|
|
|
ap.pr_po_details
|
|
|
|
ap.pr_po_details
|
|
|
|
FROM location_sparepart_stats lss
|
|
|
|
FROM location_sparepart_stats lss
|
|
|
|
LEFT JOIN item_descriptions id ON lss.itemnum = id.item_num
|
|
|
|
LEFT JOIN item_descriptions id ON lss.itemnum = id.item_num
|
|
|
|
LEFT JOIN wo_materials i ON lss.itemnum = i.itemnum
|
|
|
|
LEFT JOIN inv_summary i ON lss.itemnum = i.itemnum
|
|
|
|
LEFT JOIN pr_po_agg ap ON lss.itemnum = ap.item_num
|
|
|
|
LEFT JOIN pr_po_agg ap ON lss.itemnum = ap.item_num
|
|
|
|
ORDER BY lss.location_tag, lss.itemnum
|
|
|
|
ORDER BY lss.location_tag, lss.itemnum;
|
|
|
|
""")
|
|
|
|
""")
|
|
|
|
|
|
|
|
|
|
|
|
overhaul = await get_overview_overhaul(db_session=db_session)
|
|
|
|
overhaul = await get_overview_overhaul(db_session=db_session)
|
|
|
|
|