mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-03 12:19:12 +00:00
Added an exist check for accounts.utils.get_balance_on
This commit is contained in:
@@ -46,6 +46,12 @@ def get_balance_on(account=None, date=None):
|
|||||||
account = frappe.form_dict.get("account")
|
account = frappe.form_dict.get("account")
|
||||||
date = frappe.form_dict.get("date")
|
date = frappe.form_dict.get("date")
|
||||||
|
|
||||||
|
acc = frappe.db.get_value('Account', account, \
|
||||||
|
['lft', 'rgt', 'report_type', 'group_or_ledger'], as_dict=1)
|
||||||
|
|
||||||
|
if not acc:
|
||||||
|
frappe.throw(_("Account {0} does not exist").format(account), frappe.DoesNotExistError)
|
||||||
|
|
||||||
cond = []
|
cond = []
|
||||||
if date:
|
if date:
|
||||||
cond.append("posting_date <= '%s'" % date)
|
cond.append("posting_date <= '%s'" % date)
|
||||||
@@ -65,9 +71,6 @@ def get_balance_on(account=None, date=None):
|
|||||||
# hence, assuming balance as 0.0
|
# hence, assuming balance as 0.0
|
||||||
return 0.0
|
return 0.0
|
||||||
|
|
||||||
acc = frappe.db.get_value('Account', account, \
|
|
||||||
['lft', 'rgt', 'report_type', 'group_or_ledger'], as_dict=1)
|
|
||||||
|
|
||||||
# for pl accounts, get balance within a fiscal year
|
# for pl accounts, get balance within a fiscal year
|
||||||
if acc.report_type == 'Profit and Loss':
|
if acc.report_type == 'Profit and Loss':
|
||||||
cond.append("posting_date >= '%s' and voucher_type != 'Period Closing Voucher'" \
|
cond.append("posting_date >= '%s' and voucher_type != 'Period Closing Voucher'" \
|
||||||
|
|||||||
Reference in New Issue
Block a user