Try ERPNext Buy Support Partners Foundation

Sales Register Report missing mode of payment


at sales register report, mode of payment is missing for non-pos transactions

Are you sure you’ve linked the Payment Entries with the Invoice? Maybe that’s the missing link.

Thanks

Jay

I had the same issue. When looked deeper it becomes clear that only POS invoices have mode of payment in the sales register.

Yes, Sir
I’m sure, I had made payment via payment entry
I can see only Payment Mode from POS sales

If you have only one payment entry for individual invoice. Here is the patch you can use before generating the report.

 .../report/sales_register/sales_register.py        | 36 +++++++++++++++++-----
 1 file changed, 29 insertions(+), 7 deletions(-)

diff --git a/erpnext/accounts/report/sales_register/sales_register.py b/erpnext/accounts/report/sales_register/sales_register.py
index b6e61b1306..c4c72a9a7e 100644
--- a/erpnext/accounts/report/sales_register/sales_register.py
+++ b/erpnext/accounts/report/sales_register/sales_register.py
@@ -28,7 +28,8 @@ def _execute(filters, additional_table_columns=None, additional_query_columns=No
 	invoice_cc_wh_map = get_invoice_cc_wh_map(invoice_list)
 	invoice_so_dn_map = get_invoice_so_dn_map(invoice_list)
 	company_currency = frappe.get_cached_value('Company',  filters.get("company"),  "default_currency")
-	mode_of_payments = get_mode_of_payments([inv.name for inv in invoice_list])
+	#mode_of_payments = get_mode_of_payments([inv.name for inv in invoice_list])
+	mode_of_payments = get_mode_of_payments(invoice_list)
 
 	data = []
 	for inv in invoice_list:
@@ -448,12 +449,33 @@ def get_invoice_cc_wh_map(invoice_list):
 
 def get_mode_of_payments(invoice_list):
 	mode_of_payments = {}
+	invoice_list_names = ",".join(['"' + invoice['name'] + '"' for invoice in invoice_list])
 	if invoice_list:
-		inv_mop = frappe.db.sql("""select parent, mode_of_payment
-			from `tabSales Invoice Payment` where parent in (%s) group by parent, mode_of_payment""" %
-			', '.join(['%s']*len(invoice_list)), tuple(invoice_list), as_dict=1)
-
-		for d in inv_mop:
-			mode_of_payments.setdefault(d.parent, []).append(d.mode_of_payment)
+                inv_mop = frappe.db.sql("""select a.name as parent, ifnull(b.mode_of_payment, '') as mode_of_payment
+			from `tabSales Invoice` a, `tabSales Invoice Payment` b
+			where a.name = b.parent
+			and a.docstatus = 1
+			and a.name in ({invoice_list_names})
+			union
+			select a.name as parent, ifnull(b.mode_of_payment, '') as mode_of_payment
+			from `tabSales Invoice` a, `tabPayment Entry` b,`tabPayment Entry Reference` c
+			where a.name = c.reference_name
+			and b.name = c.parent
+			and b.docstatus = 1
+			and a.name in ({invoice_list_names})
+			union
+			select a.name as parent, ifnull(a.voucher_type,'') as mode_of_payment
+			from `tabJournal Entry` a, `tabJournal Entry Account` b
+			where a.name = b.parent
+			and a.docstatus = 1
+			and b.reference_type = "Sales Invoice"
+			and b.reference_name in ({invoice_list_names})
+                        """.format(invoice_list_names=invoice_list_names), as_dict=1)
+	#	inv_mop = frappe.db.sql("""select parent, mode_of_payment
+	#		from `tabSales Invoice Payment` where parent in (%s) group by parent, mode_of_payment""" %
+	#		', '.join(['%s']*len(invoice_list)), tuple(invoice_list), as_dict=1)
+
+                for d in inv_mop:
+                    mode_of_payments.setdefault(d.parent, []).append(d.mode_of_payment)
 
 	return mode_of_payments
1 Like

@mujeerhashmi It works, man. Mode of Payment Filter is still need to fix as it is showing inconsistant result after workaround.
Please let us know if you got the fix for the Filter also.
Thanks you.

Export it to excel and work.

1 Like

Ok man, thanks again.