fix: GL Entries for AP/AR Summary without SQL join

SQL query modified to fetch only those GL Entries for Accounts Payable Summary and Accounts Receivable Summary reports where the corresponding payment entry is not in cancelled state.
This commit is contained in:
UrvashiKishnani 2021-03-02 08:20:03 +04:00 committed by GitHub
parent 10e4b9d4e8
commit 810a36105c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -606,20 +606,19 @@ def get_partywise_advanced_payment_amount(party_type, posting_date = None, futur
cond = "1=1" cond = "1=1"
if posting_date: if posting_date:
if future_payment: if future_payment:
cond = "gle.posting_date <= '{0}' OR DATE(creation) <= '{0}' """.format(posting_date) cond = "posting_date <= '{0}' OR DATE(creation) <= '{0}' """.format(posting_date)
else: else:
cond = "gle.posting_date <= '{0}'".format(posting_date) cond = "posting_date <= '{0}'".format(posting_date)
if company: if company:
cond += "and gle.company = {0}".format(frappe.db.escape(company)) cond += "and company = {0}".format(frappe.db.escape(company))
data = frappe.db.sql(""" SELECT gle.party, sum(gle.{0}) as amount data = frappe.db.sql(""" SELECT party, sum({0}) as amount
FROM `tabGL Entry` gle FROM `tabGL Entry`
INNER JOIN `tabPayment Entry` pe ON pe.name = gle.voucher_no
WHERE WHERE
gle.party_type = %s and gle.against_voucher is null party_type = %s and against_voucher is null
and pe.docstatus = 1 and is_cancelled = 0
and {1} GROUP BY gle.party""" and {1} GROUP BY party"""
.format(("credit") if party_type == "Customer" else "debit", cond) , party_type) .format(("credit") if party_type == "Customer" else "debit", cond) , party_type)
if data: if data: