From ca627fb806599e52819c451ba554a238910991e6 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 5 Sep 2016 16:16:53 +0530 Subject: [PATCH] [fix] Fetch advance journal entry in invoice if it is tagged against linked order --- erpnext/controllers/accounts_controller.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 432d09a987..8927da7f78 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -662,7 +662,7 @@ def get_advance_journal_entries(party_type, party, party_account, amount_field, .format(order_doctype, order_condition)) reference_condition = " and (" + " or ".join(conditions) + ")" if conditions else "" - + journal_entries = frappe.db.sql(""" select "Journal Entry" as reference_type, t1.name as reference_name, @@ -674,8 +674,7 @@ def get_advance_journal_entries(party_type, party, party_account, amount_field, t1.name = t2.parent and t2.account = %s and t2.party_type = %s and t2.party = %s and t2.is_advance = 'Yes' and t1.docstatus = 1 - and {1} > 0 - and (ifnull(t2.reference_name, '')='' {2}) + and {1} > 0 {2} order by t1.posting_date""".format(amount_field, dr_or_cr, reference_condition), [party_account, party_type, party] + order_list, as_dict=1)