[fix] Fetch advance journal entry in invoice if it is tagged against linked order

This commit is contained in:
Nabin Hait 2016-09-05 16:16:53 +05:30
parent 6e4ab60e4c
commit ca627fb806

View File

@ -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)