[optimization] get balance on

This commit is contained in:
Anand Doshi 2015-09-21 19:28:59 +05:30
parent b8b8de7a49
commit e4dfeb651f
2 changed files with 13 additions and 4 deletions

View File

@ -330,7 +330,7 @@
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"search_index": 1,
"set_only_once": 0,
"unique": 0
},
@ -511,7 +511,7 @@
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"modified": "2015-09-11 15:51:26",
"modified": "2015-09-21 15:51:26",
"modified_by": "Administrator",
"module": "Accounts",
"name": "GL Entry",

View File

@ -476,9 +476,18 @@ class JournalEntry(AccountsController):
frappe.throw("Accounts table cannot be blank.")
def set_account_and_party_balance(self):
account_balance = {}
party_balance = {}
for d in self.get("accounts"):
d.account_balance = get_balance_on(account=d.account, date=self.posting_date)
d.party_balance = get_balance_on(party_type=d.party_type, party=d.party, date=self.posting_date)
if d.account not in account_balance:
account_balance[d.account] = get_balance_on(account=d.account, date=self.posting_date)
if (d.party_type, d.party) not in party_balance:
party_balance[(d.party_type, d.party)] = get_balance_on(party_type=d.party_type,
party=d.party, date=self.posting_date)
d.account_balance = account_balance[d.account]
d.party_balance = party_balance[(d.party_type, d.party)]
@frappe.whitelist()
def get_default_bank_cash_account(company, voucher_type, mode_of_payment=None):