Slow moving stocks may lead to issues like expiry (in case of food items), obsolescence, and high holding costs.
That's why you need the Inventory Aging Report. It
helps you maintain a healthy business by tracking how quickly your inventory moves.
It identifies the slow and fast moving inventory, and also lets you plan your warehouse capacity.
This tracks the stock in hand by joining different tables.
SELECT /*sum of Quantity On Hand from below query*/ T1.* SUM (T1. Quantity ) OVER( PARTITION BY T1. "Product ID" , T1. "Warehouse ID" ) AS 'Quantity On Hand', /*calculate cumulative sum of items count in reverse order until it's equal or more that Quantity On Hand*/ sum(if ( T1 . "In/Out" = 'In' , T1 . Quantity , 0 )) OVER(PARTITION BY T1 . "Product ID" , T1. "Warehouse ID" ORDER BY T1. "Transaction Date" DESC ) "Reverse Cumulative Total" /*stock in hand from Stock In Flow*/ FROM (SELECT 'In' "In/Out", "Transaction Date", "Warehouse ID", "Product ID", sum ( "Quantity In") "Quantity", "Price (BCY)" "Purchase Price" FROM "Stock In Flow Table" WHERE "Stock In Flow Table" . "EntityType" != 'transfer_order' GROUP BY 1, 2, 3, 4, 6 UNION ALL /*stock in hand from Stock Out Flow*/ SELECT 'Out', "Transaction Date", "Warehouse ID", "Product ID", -1 * sum ( "Quantity Out" ), null FROM "Stock Out Flow Table" WHERE "Stock Out Flow Table" . "EntityType" != 'transfer_order' GROUP BY 1, 2, 3, 4 UNION ALL /*stock in hand from Transfer Order*/ SELECT ' In', "Date", "Warehouse ID", "Product ID", sum(if( "Transfer Order". "Status" = 'transferred' , "Transferred Quantity" , 0 )), if ( "Transfer Order" . "Status" = 'transferred' , "Cost Price" , null )
FROM
"Transfer Order"
LEFT JOIN "Transfer Order Items" ON "Transfer Order" . "Transfer Order ID" = "Transfer Order Items" . "Transfer Order ID" WHERE "Status" not in ( 'draft' ) GROUP BY 1, 2, 3, 4, 6 UNION ALL /*stock in hand from Transfer Order Item*/ SELECT 'Out', "Date", "Warehouse ID", "Product ID", sum ( "Transferred Quantity"), "Cost Price" FROM "Transfer Order" LEFT JOIN "Transfer Order Items" ON "Transfer Order" . "Transfer Order ID" = "Transfer Order Items". "Transfer Order ID" WHERE "Status" not in ( 'draft' ) GROUP BY 1, 2, 3, 4,
6
) AS T1 |
The below query tracks the age of each inventory and bucket them into the following groups.
SELECT "In/Out", "Product ID", "Quantity", "Quantity On Hand", "Reverse Cumulative Total", "Transaction Date", "Warehouse ID", "Purchase Price", /*identify the Transaction Date by comparing Reverse Cumulative Total and Quantity On Hand */ if(min(if( "Reverse Cumulative Total" - "Quantity On Hand" >= 0 , "Reverse Cumulative Total" -"Quantity On Hand " , 99999999999 )) OVER ( PARTITION BY "Product ID" , "Warehouse ID" ORDER BY "Transaction Date" DESC ) != 99999999999 , ( "Quantity On Hand" -("Reverse Cumulative Total" -"Quantity" )), "Quantity" ) "Final Qty" ,
if(min(if(
"Reverse Cumulative Total" - "Quantity On Hand"
>=
0
,
"Reverse Cumulative Total" -"Quantity On Hand"
,
99999999999
)) OVER ( PARTITION
BY
"Product ID" , "Warehouse ID"
ORDER
BY
"Transaction Date"
DESC
) !=
99999999999
, (
"Quantity On Hand" -("Reverse Cumulative Total" -"Quantity" )) * "Purchase Price" , "Quantity" * "Purchase Price"
)
'Inventory valuation',
/*classify into different age tier*/ if ( Datediff ( current_date(), "Transaction Date" ) >= 0 AND Datediff ( current_date() , "Transaction Date" ) <= 5 , '0-5 days', if( Datediff ( current_date() , "Transaction Date" ) >= 6 AND Datediff ( current_date() , "Transaction Date" ) <= 10 , ' 6-10 days', if ( Datediff ( current_date() , "Transaction Date" ) >= 11 AND Datediff ( current_date() , "Transaction Date" ) <= 15 , ' 11- 15 days', if( Datediff ( current_date() , "Transaction Date" ) >= 16 AND Datediff (current_date(), "Transaction Date" ) <= 21 , '16-20 days', 'greater than 20 days')))) 'Age tier' FROM "Stock In Hand" WHERE "In/Out" = 'In' AND "Quantity On Hand" - ("Reverse Cumulative Total" -"Quantity" ) > 0 |
Now you can create the inventory aging pivot over the Inventory Age Tier query table.
You can explore the solution by copying the workspace from the below link.
https://analytics.zoho.com/workspace/19601000018963001