@frappe.whitelist()
def get_account_balance_and_party_type(account, date, company, debit=None, credit=None, exchange_rate=None):
 if (not frappe.has_permission(u'Account')):
  frappe.msgprint(_(u'No Permission'), raise_exception=1)
 company_currency = get_company_currency(company)
 account_details = frappe.db.get_value(u'Account', account, [u'account_type', u'account_currency'], as_dict=1)
 if (not account_details):
  return
 if (account_details.account_type == u'Receivable'):
  party_type = u'Customer'
 elif (account_details.account_type == u'Payable'):
  party_type = u'Supplier'
 else:
  party_type = u''
 grid_values = {u'balance': get_balance_on(account, date), u'party_type': party_type, u'account_type': account_details.account_type, u'account_currency': (account_details.account_currency or company_currency), u'exchange_rate': get_exchange_rate(date, account, account_details.account_currency, company, debit=debit, credit=credit, exchange_rate=exchange_rate)}
 if (not party_type):
  grid_values[u'party'] = u''
 return grid_values

@ frappe . whitelist ( ) def get_account_balance_and_party_type ( account , date , company , debit = None , credit = None , exchange_rate = None ) : if ( not frappe . has_permission ( u'Account' ) ) : frappe . msgprint ( _ ( u'No Permission' ) , raise_exception = 1 ) company_currency = get_company_currency ( company ) account_details = frappe . db . get_value ( u'Account' , account , [ u'account_type' , u'account_currency' ] , as_dict = 1 ) if ( not account_details ) : return if ( account_details . account_type == u'Receivable' ) : party_type = u'Customer' elif ( account_details . account_type == u'Payable' ) : party_type = u'Supplier' else : party_type = u'' grid_values = { u'balance' : get_balance_on ( account , date ) , u'party_type' : party_type , u'account_type' : account_details . account_type , u'account_currency' : ( account_details . account_currency or company_currency ) , u'exchange_rate' : get_exchange_rate ( date , account , account_details . account_currency , company , debit = debit , credit = credit , exchange_rate = exchange_rate ) } if ( not party_type ) : grid_values [ u'party' ] = u'' return grid_values
returns dict of account balance and party type to be set in journal entry on selection of account .