fix: Ageing errors in PSOA
diff --git a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.html b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.html
index b623898..f61aacb 100644
--- a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.html
+++ b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.html
@@ -60,8 +60,8 @@
 		</tbody>
 </table>
 <br><br>
-{% if aging %}
-<h3 class="text-center">{{ _("Ageing Report Based On ") }} {{ aging.ageing_based_on }}</h3>
+{% if ageing %}
+<h3 class="text-center">{{ _("Ageing Report Based On ") }} {{ ageing.ageing_based_on }}</h3>
 <h5 class="text-center">
 	{{ _("Up to " ) }}  {{ frappe.format(filters.to_date, 'Date')}}
 </h5>
@@ -78,10 +78,10 @@
 	</thead>
 	<tbody>
 		<tr>
-			<td>{{ frappe.utils.fmt_money(aging.range1, currency=filters.presentation_currency) }}</td>
-			<td>{{ frappe.utils.fmt_money(aging.range2, currency=filters.presentation_currency) }}</td>
-			<td>{{ frappe.utils.fmt_money(aging.range3, currency=filters.presentation_currency) }}</td>
-			<td>{{ frappe.utils.fmt_money(aging.range4, currency=filters.presentation_currency) }}</td>
+			<td>{{ frappe.utils.fmt_money(ageing.range1, currency=filters.presentation_currency) }}</td>
+			<td>{{ frappe.utils.fmt_money(ageing.range2, currency=filters.presentation_currency) }}</td>
+			<td>{{ frappe.utils.fmt_money(ageing.range3, currency=filters.presentation_currency) }}</td>
+			<td>{{ frappe.utils.fmt_money(ageing.range4, currency=filters.presentation_currency) }}</td>
 		</tr>
 	</tbody>
 </table>
diff --git a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py
index b6149e8..62090c0 100644
--- a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py
+++ b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py
@@ -40,7 +40,7 @@
 
 def get_report_pdf(doc, consolidated=True):
 	statement_dict = {}
-	aging = ''
+	ageing = ''
 	base_template_path = "frappe/www/printview.html"
 	template_path = "erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.html"
 
@@ -56,8 +56,10 @@
 				'range4': 120,
 				'customer': entry.customer
 			})
-			col1, aging = get_ageing(ageing_filters)
-			aging[0]['ageing_based_on'] = doc.ageing_based_on
+			col1, ageing = get_ageing(ageing_filters)
+
+			if ageing:
+				ageing[0]['ageing_based_on'] = doc.ageing_based_on
 
 		tax_id = frappe.get_doc('Customer', entry.customer).tax_id
 		presentation_currency =  get_party_account_currency('Customer', entry.customer, doc.company) \
@@ -87,11 +89,14 @@
 
 		if len(res) == 3:
 			continue
+
 		html = frappe.render_template(template_path, \
-			{"filters": filters, "data": res, "aging": aging[0] if doc.include_ageing else None})
+			{"filters": filters, "data": res, "ageing": ageing[0] if (doc.include_ageing and ageing) else None})
+
 		html = frappe.render_template(base_template_path, {"body": html, \
 			"css": get_print_style(), "title": "Statement For " + entry.customer})
 		statement_dict[entry.customer] = html
+
 	if not bool(statement_dict):
 		return False
 	elif consolidated: