From 423549e084b454a2edcf95e2ad555a1d6abb86c8 Mon Sep 17 00:00:00 2001 From: Saif Ur Rehman Date: Sat, 8 Sep 2018 15:48:55 +0500 Subject: [PATCH 1/2] Fixed PDC data in AR/AP report: -Get PDC date from posting_date instead of reference date since posting_date is the date at which the post dated cheque can be cleared -Get PDC data from submitted documents only --- .../accounts_receivable/accounts_receivable.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index abcfa73a07..fcd9f27282 100755 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -446,14 +446,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=1 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) @@ -467,18 +467,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=1 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) From a5a926967bb1d7f4b41d0221ef25ece92ac1d8e8 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Tue, 16 Oct 2018 11:27:23 +0530 Subject: [PATCH 2/2] Update accounts_receivable.py --- .../report/accounts_receivable/accounts_receivable.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index fcd9f27282..a212a566f6 100755 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -453,7 +453,7 @@ def get_pdc_details(party_type, report_date): on (pref.parent = pent.name) where - pent.docstatus=1 and pent.posting_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,7 +474,7 @@ def get_pdc_details(party_type, report_date): on (jea.parent = je.name) where - je.docstatus=1 and je.posting_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: