Skip to content

Commit dd0fc10

Browse files
rohitwaghchaurenabinhait
authored andcommitted
[Fix] PDC amount, PDC print layout issue (frappe#13062)
1 parent d283ee7 commit dd0fc10

File tree

2 files changed

+43
-21
lines changed

2 files changed

+43
-21
lines changed

erpnext/accounts/report/accounts_receivable/accounts_receivable.html

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
<style>
2-
@media screen {
3-
.print-format {
4-
padding: 8mm;
5-
}
6-
}
7-
</style>
1+
{% if(filters.show_pdc_in_print) { %}
2+
<style>
3+
@media screen {
4+
.print-format {
5+
padding: 8mm;
6+
margin:4mm;
7+
font-size:10px;
8+
font-family: Tahoma, sans-serif;
9+
}
10+
}
11+
</style>
12+
{% } %}
813

914
<h2 class="text-center">{%= __(report.report_name) %}</h2>
1015
<h4 class="text-center">{%= filters.customer || filters.supplier %} </h4>
@@ -82,21 +87,24 @@ <h5 class="text-center">
8287
<tr>
8388
{% if(report.report_name === "Accounts Receivable" || report.report_name === "Accounts Payable") { %}
8489
<th style="width: 10%">{%= __("Date") %}</th>
85-
<th style="width: 10%">{%= __("Ref") %}</th>
90+
<th style="width: 15%">{%= __("Ref") %}</th>
91+
{% if(!filters.show_pdc_in_print) { %}
8692
<th style="width: 20%">{%= (filters.customer || filters.supplier) ? __("Remarks"): __("Party") %}</th>
93+
{% } %}
8794
<th style="width: 10%">{%= __("Invoiced Amount") %}</th>
8895
{% if(!filters.show_pdc_in_print) { %}
8996
<th style="width: 10%">{%= __("Paid Amount") %}</th>
9097
<th style="width: 10%">{%= report.report_name === "Accounts Receivable" ? __('Credit Note') : __('Debit Note') %}</th>
9198
{% } %}
92-
<th style="width: 6%">{%= __("Outstanding Amount") %}</th>
99+
<th style="width: 15%">{%= __("Outstanding Amount") %}</th>
93100
{% if(filters.show_pdc_in_print) { %}
94101
{% if(report.report_name === "Accounts Receivable") { %}
95-
<th style="width: 6%">{%= __("Customer LPO No.") %}</th>
102+
<th style="width: 10%">{%= __("Customer LPO No.") %}</th>
96103
{% } %}
97-
<th style="width: 6%">{%= __("PDC/LC Date") %}</th>
98-
<th style="width: 6%">{%= __("PDC/LC Ref") %}</th>
99-
<th style="width: 6%">{%= __("PDC/LC Amount") %}</th>
104+
<th style="width: 10%">{%= __("PDC/LC Date") %}</th>
105+
<th style="width: 10%">{%= __("PDC/LC Ref") %}</th>
106+
<th style="width: 10%">{%= __("PDC/LC Amount") %}</th>
107+
<th style="width: 10%">{%= __("Remaining Balance") %}</th>
100108
{% } %}
101109
{% } else { %}
102110
<th style="width: 40%">{%= (filters.customer || filters.supplier) ? __("Remarks"): __("Party") %}</th>
@@ -115,6 +123,7 @@ <h5 class="text-center">
115123
<td>{%= dateutil.str_to_user(data[i][__("Posting Date")]) %}</td>
116124
<td>{%= data[i][__("Voucher Type")] %}
117125
<br>{%= data[i][__("Voucher No")] %}</td>
126+
{% if(!filters.show_pdc_in_print) { %}
118127
<td>
119128
{% if(!(filters.customer || filters.supplier)) { %}
120129
{%= data[i][__("Customer")] || data[i][__("Supplier")] %}
@@ -127,6 +136,7 @@ <h5 class="text-center">
127136
<br>{%= __("Remarks") %}:
128137
{%= data[i][__("Remarks")] %}
129138
</td>
139+
{% } %}
130140
<td style="text-align: right">
131141
{%= format_currency(data[i]["Invoiced Amount"], data[i]["currency"]) %}</td>
132142

@@ -147,10 +157,13 @@ <h5 class="text-center">
147157
<td style="text-align: right">{%= frappe.datetime.str_to_user(data[i][__("PDC/LC Date")]) %}</td>
148158
<td style="text-align: right">{%= data[i][__("PDC/LC Ref")] %}</td>
149159
<td style="text-align: right">{%= format_currency(data[i][__("PDC/LC Amount")], data[i]["currency"]) %}</td>
160+
<td style="text-align: right">{%= format_currency(data[i][__("Remaining Balance")], data[i]["currency"]) %}</td>
150161
{% } %}
151162
{% } else { %}
152163
<td></td>
164+
{% if(!filters.show_pdc_in_print) { %}
153165
<td></td>
166+
{% } %}
154167
<td><b>{%= __("Total") %}</b></td>
155168
<td style="text-align: right">
156169
{%= format_currency(data[i]["Invoiced Amount"], data[i]["currency"] ) %}</td>
@@ -171,6 +184,7 @@ <h5 class="text-center">
171184
<td style="text-align: right">{%= frappe.datetime.str_to_user(data[i][__("PDC/LC Date")]) %}</td>
172185
<td style="text-align: right">{%= data[i][__("PDC/LC Ref")] %}</td>
173186
<td style="text-align: right">{%= format_currency(data[i][__("PDC/LC Amount")], data[i]["currency"]) %}</td>
187+
<td style="text-align: right">{%= format_currency(data[i][__("Remaining Balance")], data[i]["currency"]) %}</td>
174188
{% } %}
175189
{% } %}
176190
{% } else { %}

erpnext/accounts/report/accounts_receivable/accounts_receivable.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def get_data(self, party_naming_by, args):
159159
else:
160160
row.append(company_currency)
161161

162-
pdc = pdc_details.get(gle.voucher_no, {})
162+
pdc = pdc_details.get((gle.voucher_no, gle.party), {})
163163
remaining_balance = outstanding_amount - flt(pdc.get("pdc_amount"))
164164
row += [pdc.get("pdc_date"), pdc.get("pdc_ref"),
165165
flt(pdc.get("pdc_amount")), remaining_balance]
@@ -389,25 +389,33 @@ def get_pdc_details(party_type):
389389
on
390390
(pref.parent = pent.name)
391391
where
392-
pent.docstatus = 0 and pent.reference_date > pent.posting_date
392+
pent.docstatus < 2 and pent.reference_date >= pent.posting_date
393393
and pent.party_type = %s
394-
group by pref.reference_name""", party_type, as_dict=1):
395-
pdc_details.setdefault(pdc.invoice_no, pdc)
394+
group by pent.party, pref.reference_name""", party_type, as_dict=1):
395+
pdc_details.setdefault((pdc.invoice_no, pdc.party), pdc)
396+
397+
if scrub(party_type):
398+
amount_field = "jea.debit_in_account_currency + jea.credit_in_account_currency"
399+
else:
400+
amount_field = "jea.debit + jea.credit"
396401

397402
for pdc in frappe.db.sql("""
398403
select
399404
jea.reference_name as invoice_no, jea.party, jea.party_type,
400-
max(je.cheque_date) as pdc_date, sum(ifnull(je.total_amount,0)) as pdc_amount,
405+
max(je.cheque_date) as pdc_date, sum(ifnull({0},0)) as pdc_amount,
401406
GROUP_CONCAT(je.cheque_no SEPARATOR ', ') as pdc_ref
402407
from
403408
`tabJournal Entry` as je inner join `tabJournal Entry Account` as jea
404409
on
405410
(jea.parent = je.name)
406411
where
407-
je.docstatus = 0 and je.cheque_date > je.posting_date
412+
je.docstatus < 2 and je.cheque_date >= je.posting_date
408413
and jea.party_type = %s
409-
group by jea.reference_name""", party_type, as_dict=1):
410-
pdc_details.setdefault(pdc.invoice_no, pdc)
414+
group by jea.party, jea.reference_name""".format(amount_field), party_type, as_dict=1):
415+
if (pdc.invoice_no, pdc.party) in pdc_details:
416+
pdc_details[(pdc.invoice_no, pdc.party)]["pdc_amount"] += pdc.pdc_amount
417+
else:
418+
pdc_details.setdefault((pdc.invoice_no, pdc.party), pdc)
411419

412420
return pdc_details
413421

0 commit comments

Comments
 (0)