From dd0fc1084ec283e2854d0869577cee0699854641 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Fri, 23 Feb 2018 16:20:46 +0530 Subject: [PATCH] [Fix] PDC amount, PDC print layout issue (#13062) --- .../accounts_receivable.html | 40 +++++++++++++------ .../accounts_receivable.py | 24 +++++++---- 2 files changed, 43 insertions(+), 21 deletions(-) diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.html b/erpnext/accounts/report/accounts_receivable/accounts_receivable.html index b622ab499e..d96fc996bc 100644 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.html +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.html @@ -1,10 +1,15 @@ - +{% if(filters.show_pdc_in_print) { %} + +{% } %}

{%= __(report.report_name) %}

{%= filters.customer || filters.supplier %}

@@ -82,21 +87,24 @@ {% if(report.report_name === "Accounts Receivable" || report.report_name === "Accounts Payable") { %} {%= __("Date") %} - {%= __("Ref") %} + {%= __("Ref") %} + {% if(!filters.show_pdc_in_print) { %} {%= (filters.customer || filters.supplier) ? __("Remarks"): __("Party") %} + {% } %} {%= __("Invoiced Amount") %} {% if(!filters.show_pdc_in_print) { %} {%= __("Paid Amount") %} {%= report.report_name === "Accounts Receivable" ? __('Credit Note') : __('Debit Note') %} {% } %} - {%= __("Outstanding Amount") %} + {%= __("Outstanding Amount") %} {% if(filters.show_pdc_in_print) { %} {% if(report.report_name === "Accounts Receivable") { %} - {%= __("Customer LPO No.") %} + {%= __("Customer LPO No.") %} {% } %} - {%= __("PDC/LC Date") %} - {%= __("PDC/LC Ref") %} - {%= __("PDC/LC Amount") %} + {%= __("PDC/LC Date") %} + {%= __("PDC/LC Ref") %} + {%= __("PDC/LC Amount") %} + {%= __("Remaining Balance") %} {% } %} {% } else { %} {%= (filters.customer || filters.supplier) ? __("Remarks"): __("Party") %} @@ -115,6 +123,7 @@ {%= dateutil.str_to_user(data[i][__("Posting Date")]) %} {%= data[i][__("Voucher Type")] %}
{%= data[i][__("Voucher No")] %} + {% if(!filters.show_pdc_in_print) { %} {% if(!(filters.customer || filters.supplier)) { %} {%= data[i][__("Customer")] || data[i][__("Supplier")] %} @@ -127,6 +136,7 @@
{%= __("Remarks") %}: {%= data[i][__("Remarks")] %} + {% } %} {%= format_currency(data[i]["Invoiced Amount"], data[i]["currency"]) %} @@ -147,10 +157,13 @@ {%= frappe.datetime.str_to_user(data[i][__("PDC/LC Date")]) %} {%= data[i][__("PDC/LC Ref")] %} {%= format_currency(data[i][__("PDC/LC Amount")], data[i]["currency"]) %} + {%= format_currency(data[i][__("Remaining Balance")], data[i]["currency"]) %} {% } %} {% } else { %} + {% if(!filters.show_pdc_in_print) { %} + {% } %} {%= __("Total") %} {%= format_currency(data[i]["Invoiced Amount"], data[i]["currency"] ) %} @@ -171,6 +184,7 @@ {%= frappe.datetime.str_to_user(data[i][__("PDC/LC Date")]) %} {%= data[i][__("PDC/LC Ref")] %} {%= format_currency(data[i][__("PDC/LC Amount")], data[i]["currency"]) %} + {%= format_currency(data[i][__("Remaining Balance")], data[i]["currency"]) %} {% } %} {% } %} {% } else { %} diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index 4f83db1441..02f247b8b0 100644 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -159,7 +159,7 @@ class ReceivablePayableReport(object): else: row.append(company_currency) - pdc = pdc_details.get(gle.voucher_no, {}) + pdc = pdc_details.get((gle.voucher_no, gle.party), {}) remaining_balance = outstanding_amount - flt(pdc.get("pdc_amount")) row += [pdc.get("pdc_date"), pdc.get("pdc_ref"), flt(pdc.get("pdc_amount")), remaining_balance] @@ -389,25 +389,33 @@ def get_pdc_details(party_type): on (pref.parent = pent.name) where - pent.docstatus = 0 and pent.reference_date > pent.posting_date + pent.docstatus < 2 and pent.reference_date >= pent.posting_date and pent.party_type = %s - group by pref.reference_name""", party_type, as_dict=1): - pdc_details.setdefault(pdc.invoice_no, pdc) + group by pent.party, pref.reference_name""", party_type, as_dict=1): + pdc_details.setdefault((pdc.invoice_no, pdc.party), pdc) + + if scrub(party_type): + amount_field = "jea.debit_in_account_currency + jea.credit_in_account_currency" + else: + amount_field = "jea.debit + jea.credit" 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(je.total_amount,0)) as pdc_amount, + max(je.cheque_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 = 0 and je.cheque_date > je.posting_date + je.docstatus < 2 and je.cheque_date >= je.posting_date and jea.party_type = %s - group by jea.reference_name""", party_type, as_dict=1): - pdc_details.setdefault(pdc.invoice_no, pdc) + group by jea.party, jea.reference_name""".format(amount_field), 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 + else: + pdc_details.setdefault((pdc.invoice_no, pdc.party), pdc) return pdc_details