@frappe.whitelist()
def get_stock_balance(item_code, warehouse, posting_date=None, posting_time=None, with_valuation_rate=False):
 from erpnext.stock.stock_ledger import get_previous_sle
 if (not posting_date):
  posting_date = nowdate()
 if (not posting_time):
  posting_time = nowtime()
 last_entry = get_previous_sle({u'item_code': item_code, u'warehouse': warehouse, u'posting_date': posting_date, u'posting_time': posting_time})
 if with_valuation_rate:
  return ((last_entry.qty_after_transaction, last_entry.valuation_rate) if last_entry else (0.0, 0.0))
 else:
  return (last_entry.qty_after_transaction or 0.0)

@ frappe . whitelist ( ) def get_stock_balance ( item_code , warehouse , posting_date = None , posting_time = None , with_valuation_rate = False ) : from erpnext . stock . stock_ledger import get_previous_sle if ( not posting_date ) : posting_date = nowdate ( ) if ( not posting_time ) : posting_time = nowtime ( ) last_entry = get_previous_sle ( { u'item_code' : item_code , u'warehouse' : warehouse , u'posting_date' : posting_date , u'posting_time' : posting_time } ) if with_valuation_rate : return ( ( last_entry . qty_after_transaction , last_entry . valuation_rate ) if last_entry else ( 0.0 , 0.0 ) ) else : return ( last_entry . qty_after_transaction or 0.0 )
returns stock balance quantity at given warehouse on given posting date or current date .