Skip to content

Commit

Permalink
Merge pull request #15365 from SaiFi0102/AR-AP-PDC-Fix
Browse files Browse the repository at this point in the history
Fixed PDC data in AR/AP report
  • Loading branch information
rohitwaghchaure committed Oct 16, 2018
2 parents 606c504 + a5a9269 commit b7debc8
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions erpnext/accounts/report/accounts_receivable/accounts_receivable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

Expand Down

0 comments on commit b7debc8

Please sign in to comment.