Merge pull request #6972 from RobertSchouten/bankstatement

[fix] update bank recon statement printing for payment entries
diff --git a/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.html b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.html
index dd1609a..23d2a31 100644
--- a/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.html
+++ b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.html
@@ -8,7 +8,7 @@
 	<thead>
 		<tr>
 			<th style="width: 15%">{%= __("Posting Date") %}</th>
-			<th style="width: 15%">{%= __("Journal Entry") %}</th>
+			<th style="width: 15%">{%= __("Payment Entry") %}</th>
 			<th style="width: 40%">{%= __("Reference") %}</th>
 			<th style="width: 15%; text-align: right;">{%= __("Debit") %}</th>
 			<th style="width: 15%; text-align: right;">{%= __("Credit") %}</th>
@@ -19,10 +19,10 @@
 			{% if (data[i]["posting_date"]) { %}
 			<tr>
 				<td>{%= dateutil.str_to_user(data[i]["posting_date"]) %}</td>
-				<td>{%= data[i]["journal_entry"] %}</td>
+				<td>{%= data[i]["payment_entry"] %}</td>
 				<td>{%= __("Against") %}: {%= data[i]["against_account"] %}
-					{% if (data[i]["reference"]) { %}
-						<br>{%= __("Reference") %}: {%= data[i]["reference"] %}
+					{% if (data[i]["reference_no"]) { %}
+						<br>{%= __("Reference") %}: {%= data[i]["reference_no"] %}
 						{% if (data[i]["ref_date"]) { %}
 							<br>{%= __("Reference Date") %}: {%= dateutil.str_to_user(data[i]["ref_date"]) %}
 						{% } %}
@@ -38,7 +38,7 @@
 			<tr>
 				<td></td>
 				<td></td>
-				<td>{%= data[i]["journal_entry"] %}</td>
+				<td>{%= data[i]["payment_entry"] %}</td>
 				<td style="text-align: right">{%= format_currency(data[i]["debit"]) %}</td>
 				<td style="text-align: right">{%= format_currency(data[i]["credit"]) %}</td>
 			</tr>
diff --git a/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py
index 8ed338e..95b7ff7 100644
--- a/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py
+++ b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py
@@ -129,7 +129,7 @@
 			reference_no, reference_date as ref_date, 
 			if(paid_to=%(account)s, received_amount, 0) as debit, 
 			if(paid_from=%(account)s, paid_amount, 0) as credit, 
-			posting_date, party as against_account, clearance_date,
+			posting_date, ifnull(party,if(paid_from=%(account)s,paid_to,paid_from)) as against_account, clearance_date,
 			if(paid_to=%(account)s, paid_to_account_currency, paid_from_account_currency) as account_currency
 		from `tabPayment Entry`
 		where