Merge branch 'develop' of github.com:frappe/erpnext into feature-pick-list
This commit is contained in:
		
						commit
						dd63b656c7
					
				| @ -119,19 +119,11 @@ def get_gl_entries(filters): | ||||
| 	select_fields = """, debit, credit, debit_in_account_currency, | ||||
| 		credit_in_account_currency """ | ||||
| 
 | ||||
| 	group_by_statement = '' | ||||
| 	order_by_statement = "order by posting_date, account" | ||||
| 
 | ||||
| 	if filters.get("group_by") == _("Group by Voucher"): | ||||
| 		order_by_statement = "order by posting_date, voucher_type, voucher_no" | ||||
| 
 | ||||
| 	if filters.get("group_by") == _("Group by Voucher (Consolidated)"): | ||||
| 		group_by_statement = "group by voucher_type, voucher_no, account, cost_center" | ||||
| 
 | ||||
| 		select_fields = """, sum(debit) as debit, sum(credit) as credit, | ||||
| 			sum(debit_in_account_currency) as debit_in_account_currency, | ||||
| 			sum(credit_in_account_currency) as  credit_in_account_currency""" | ||||
| 
 | ||||
| 	if filters.get("include_default_book_entries"): | ||||
| 		filters['company_fb'] = frappe.db.get_value("Company", | ||||
| 			filters.get("company"), 'default_finance_book') | ||||
| @ -144,11 +136,10 @@ def get_gl_entries(filters): | ||||
| 			against_voucher_type, against_voucher, account_currency, | ||||
| 			remarks, against, is_opening {select_fields} | ||||
| 		from `tabGL Entry` | ||||
| 		where company=%(company)s {conditions} {group_by_statement} | ||||
| 		where company=%(company)s {conditions} | ||||
| 		{order_by_statement} | ||||
| 		""".format( | ||||
| 			select_fields=select_fields, conditions=get_conditions(filters), | ||||
| 			group_by_statement=group_by_statement, | ||||
| 			order_by_statement=order_by_statement | ||||
| 		), | ||||
| 		filters, as_dict=1) | ||||
| @ -185,7 +176,8 @@ def get_conditions(filters): | ||||
| 	if not (filters.get("account") or filters.get("party") or | ||||
| 		filters.get("group_by") in ["Group by Account", "Group by Party"]): | ||||
| 		conditions.append("posting_date >=%(from_date)s") | ||||
| 		conditions.append("posting_date <=%(to_date)s") | ||||
| 
 | ||||
| 	conditions.append("(posting_date <=%(to_date)s or is_opening = 'Yes')") | ||||
| 
 | ||||
| 	if filters.get("project"): | ||||
| 		conditions.append("project in %(project)s") | ||||
| @ -286,6 +278,7 @@ def initialize_gle_map(gl_entries, filters): | ||||
| def get_accountwise_gle(filters, gl_entries, gle_map): | ||||
| 	totals = get_totals_dict() | ||||
| 	entries = [] | ||||
| 	consolidated_gle = OrderedDict() | ||||
| 	group_by = group_by_field(filters.get('group_by')) | ||||
| 
 | ||||
| 	def update_value_in_dict(data, key, gle): | ||||
| @ -310,12 +303,20 @@ def get_accountwise_gle(filters, gl_entries, gle_map): | ||||
| 			update_value_in_dict(totals, 'total', gle) | ||||
| 			if filters.get("group_by") != _('Group by Voucher (Consolidated)'): | ||||
| 				gle_map[gle.get(group_by)].entries.append(gle) | ||||
| 			else: | ||||
| 				entries.append(gle) | ||||
| 			elif filters.get("group_by") == _('Group by Voucher (Consolidated)'): | ||||
| 				key = (gle.get("voucher_type"), gle.get("voucher_no"), | ||||
| 					gle.get("account"), gle.get("cost_center")) | ||||
| 				if key not in consolidated_gle: | ||||
| 					consolidated_gle.setdefault(key, gle) | ||||
| 				else: | ||||
| 					update_value_in_dict(consolidated_gle, key, gle) | ||||
| 
 | ||||
| 			update_value_in_dict(gle_map[gle.get(group_by)].totals, 'closing', gle) | ||||
| 			update_value_in_dict(totals, 'closing', gle) | ||||
| 
 | ||||
| 	for key, value in consolidated_gle.items(): | ||||
| 		entries.append(value) | ||||
| 
 | ||||
| 	return totals, entries | ||||
| 
 | ||||
| def get_result_as_list(data, filters): | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user