Item valuation rate

Hi guys,

Is there a easy way in ERPNext code to get current Item valuation rate ?
I have checked erpnext.stock.stock_ledger.py but it still seems quite complicated.

My situation is that sometimes, the Customer have Sales Return of defect products.
These does not go to any warehouse but rather will be discarded.
Therefore, what will record is only a Credit Note and I need to get the Item Valuation to generate that.

Many Thanks
Nathan

please check at Bin table …
see this thread Valuation ratelocation in database

Thank you! Actually in stock_ledger.py there is a get_valuation_rate function I think I can use that as well