Merge pull request #15365 from SaiFi0102/AR-AP-PDC-Fix

Fixed PDC data in AR/AP report
This commit is contained in:
rohitwaghchaure 2018-10-16 11:27:53 +05:30 committed by GitHub
commit b7debc8573
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -453,14 +453,14 @@ def get_pdc_details(party_type, report_date):
for pdc in frappe.db.sql(""" for pdc in frappe.db.sql("""
select select
pref.reference_name as invoice_no, pent.party, pent.party_type, 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 GROUP_CONCAT(pent.reference_no SEPARATOR ', ') as pdc_ref
from from
`tabPayment Entry` as pent inner join `tabPayment Entry Reference` as pref `tabPayment Entry` as pent inner join `tabPayment Entry Reference` as pref
on on
(pref.parent = pent.name) (pref.parent = pent.name)
where where
pent.docstatus < 2 and pent.reference_date >= %s pent.docstatus < 2 and pent.posting_date > %s
and pent.party_type = %s and pent.party_type = %s
group by pent.party, pref.reference_name""", (report_date, party_type), as_dict=1): group by pent.party, pref.reference_name""", (report_date, party_type), as_dict=1):
pdc_details.setdefault((pdc.invoice_no, pdc.party), pdc) 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(""" for pdc in frappe.db.sql("""
select select
jea.reference_name as invoice_no, jea.party, jea.party_type, 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 GROUP_CONCAT(je.cheque_no SEPARATOR ', ') as pdc_ref
from from
`tabJournal Entry` as je inner join `tabJournal Entry Account` as jea `tabJournal Entry` as je inner join `tabJournal Entry Account` as jea
on on
(jea.parent = je.name) (jea.parent = je.name)
where where
je.docstatus < 2 and je.cheque_date >= %s je.docstatus < 2 and je.posting_date > %s
and jea.party_type = %s and jea.party_type = %s
group by jea.party, jea.reference_name""".format(amount_field), (report_date, party_type), as_dict=1): 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: 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: else:
pdc_details.setdefault((pdc.invoice_no, pdc.party), pdc) pdc_details.setdefault((pdc.invoice_no, pdc.party), pdc)