From 9de81cda7755965ed45603d09fd4818bb7758e30 Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Fri, 4 Jan 2019 10:54:24 +0530 Subject: [PATCH 1/2] Added Customer contact column in accounts Receivable --- .../accounts_receivable/accounts_receivable.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index 121d5b0213..22d4d94cd0 100755 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -32,6 +32,15 @@ class ReceivablePayableReport(object): columns += [_(args.get("party_type")) + ":Link/" + args.get("party_type") + ":200"] + if args.get("party_type") == 'Customer': + columns.append({ + "label": _("Customer Contact"), + "fieldtype": "Link", + "fieldname": "contact", + "options":"Contact", + "width": 100 + }) + if party_naming_by == "Naming Series": columns += [args.get("party_type") + " Name::110"] @@ -282,6 +291,9 @@ class ReceivablePayableReport(object): if party_naming_by == "Naming Series": row += [self.get_party_name(gle.party_type, gle.party)] + if args.get("party_type") == 'Customer': + row += [self.get_customer_contact(gle.party_type, gle.party)] + # get due date if not due_date: due_date = self.voucher_details.get(gle.voucher_no, {}).get("due_date", "") @@ -407,6 +419,9 @@ class ReceivablePayableReport(object): def get_party_name(self, party_type, party_name): return self.get_party_map(party_type).get(party_name, {}).get("customer_name" if party_type == "Customer" else "supplier_name") or "" + def get_customer_contact(self, party_type, party_name): + return self.get_party_map(party_type).get(party_name, {}).get("customer_primary_contact") + def get_territory(self, party_name): return self.get_party_map("Customer").get(party_name, {}).get("territory") or "" @@ -419,7 +434,7 @@ class ReceivablePayableReport(object): def get_party_map(self, party_type): if not hasattr(self, "party_map"): if party_type == "Customer": - select_fields = "name, customer_name, territory, customer_group" + select_fields = "name, customer_name, territory, customer_group, customer_primary_contact" elif party_type == "Supplier": select_fields = "name, supplier_name, supplier_group" From eabf260706319d20ce3d04f9c45068d4726ecb7d Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Fri, 4 Jan 2019 12:34:28 +0530 Subject: [PATCH 2/2] fix :Test cases for accounts receivable report --- .../accounts_receivable/test_accounts_receivable.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py index 34e6c83e01..f911eaa5c1 100644 --- a/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py @@ -21,24 +21,24 @@ class TestAccountsReceivable(unittest.TestCase): expected_data = [[100,30], [100,50], [100,20]] - self.assertEqual(expected_data[0], report[1][0][6:8]) - self.assertEqual(expected_data[1], report[1][1][6:8]) - self.assertEqual(expected_data[2], report[1][2][6:8]) + self.assertEqual(expected_data[0], report[1][0][7:9]) + self.assertEqual(expected_data[1], report[1][1][7:9]) + self.assertEqual(expected_data[2], report[1][2][7:9]) make_payment(name) report = execute(filters) expected_data_after_payment = [[100,50], [100,20]] - self.assertEqual(expected_data_after_payment[0], report[1][0][6:8]) - self.assertEqual(expected_data_after_payment[1], report[1][1][6:8]) + self.assertEqual(expected_data_after_payment[0], report[1][0][7:9]) + self.assertEqual(expected_data_after_payment[1], report[1][1][7:9]) make_credit_note(name) report = execute(filters) expected_data_after_credit_note = [[100,100,30,100,-30]] - self.assertEqual(expected_data_after_credit_note[0], report[1][0][6:11]) + self.assertEqual(expected_data_after_credit_note[0], report[1][0][7:12]) def make_sales_invoice():