diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index 8b7ccaf7b7..6bdafd7abf 100755 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -453,14 +453,14 @@ def get_pdc_details(party_type, report_date): for pdc in frappe.db.sql(""" select pref.reference_name as invoice_no, pent.party, pent.party_type, - max(pent.reference_date) as pdc_date, sum(ifnull(pref.allocated_amount,0)) as pdc_amount, + max(pent.posting_date) as pdc_date, sum(ifnull(pref.allocated_amount,0)) as pdc_amount, GROUP_CONCAT(pent.reference_no SEPARATOR ', ') as pdc_ref from `tabPayment Entry` as pent inner join `tabPayment Entry Reference` as pref on (pref.parent = pent.name) where - pent.docstatus < 2 and pent.reference_date >= %s + pent.docstatus < 2 and pent.posting_date > %s and pent.party_type = %s group by pent.party, pref.reference_name""", (report_date, party_type), as_dict=1): pdc_details.setdefault((pdc.invoice_no, pdc.party), pdc) @@ -474,18 +474,23 @@ def get_pdc_details(party_type, report_date): for pdc in frappe.db.sql(""" select jea.reference_name as invoice_no, jea.party, jea.party_type, - max(je.cheque_date) as pdc_date, sum(ifnull({0},0)) as pdc_amount, + max(je.posting_date) as pdc_date, sum(ifnull({0},0)) as pdc_amount, GROUP_CONCAT(je.cheque_no SEPARATOR ', ') as pdc_ref from `tabJournal Entry` as je inner join `tabJournal Entry Account` as jea on (jea.parent = je.name) where - je.docstatus < 2 and je.cheque_date >= %s + je.docstatus < 2 and je.posting_date > %s and jea.party_type = %s group by jea.party, jea.reference_name""".format(amount_field), (report_date, party_type), as_dict=1): if (pdc.invoice_no, pdc.party) in pdc_details: - pdc_details[(pdc.invoice_no, pdc.party)]["pdc_amount"] += pdc.pdc_amount + key = (pdc.invoice_no, pdc.party) + pdc_details[key]["pdc_amount"] += pdc.pdc_amount + if pdc.pdc_ref: + pdc_details[key]["pdc_ref"] += ", " + pdc.pdc_ref + if pdc.pdc_date: + pdc_details[key]["pdc_date"] = max(pdc_details[key]["pdc_date"], pdc.pdc_date) else: pdc_details.setdefault((pdc.invoice_no, pdc.party), pdc)