From 9f58e59a2c8a3ab723bd9f2973ed31ac9e80fe72 Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Wed, 29 Jan 2020 21:41:56 +0530 Subject: [PATCH 1/2] fix: Label and UX fixes while creating payment entry against customer --- erpnext/accounts/doctype/bank_account/bank_account.json | 6 ++++-- erpnext/accounts/doctype/payment_entry/payment_entry.py | 4 +++- erpnext/selling/doctype/customer/customer.js | 8 ++++++++ erpnext/selling/doctype/customer/customer.json | 6 ++++-- erpnext/selling/doctype/customer/customer.py | 6 ++++++ 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/doctype/bank_account/bank_account.json b/erpnext/accounts/doctype/bank_account/bank_account.json index 8e30b8555cb..c8ae26d9f2c 100644 --- a/erpnext/accounts/doctype/bank_account/bank_account.json +++ b/erpnext/accounts/doctype/bank_account/bank_account.json @@ -1,4 +1,5 @@ { + "actions": [], "allow_import": 1, "allow_rename": 1, "creation": "2017-05-29 21:35:13.136357", @@ -82,7 +83,7 @@ "default": "0", "fieldname": "is_default", "fieldtype": "Check", - "label": "Is the Default Account" + "label": "Is Default Account" }, { "default": "0", @@ -211,7 +212,8 @@ "read_only": 1 } ], - "modified": "2019-10-02 01:34:12.417601", + "links": [], + "modified": "2020-01-29 20:42:26.458316", "modified_by": "Administrator", "module": "Accounts", "name": "Bank Account", diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 214d6088667..d65e5640263 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -102,7 +102,9 @@ class PaymentEntry(AccountsController): self.bank = bank_data.bank self.bank_account_no = bank_data.bank_account_no - self.set(field, bank_data.account) + + if not self.get(field): + self.set(field, bank_data.account) def validate_allocated_amount(self): for d in self.get("references"): diff --git a/erpnext/selling/doctype/customer/customer.js b/erpnext/selling/doctype/customer/customer.js index 30220614e9b..0a9f9b8f0a7 100644 --- a/erpnext/selling/doctype/customer/customer.js +++ b/erpnext/selling/doctype/customer/customer.js @@ -55,6 +55,14 @@ frappe.ui.form.on("Customer", { } } }) + + frm.set_query('default_bank_account', function(c) { + return { + filters: { + 'is_company_account': 1 + } + } + }); }, customer_primary_address: function(frm){ if(frm.doc.customer_primary_address){ diff --git a/erpnext/selling/doctype/customer/customer.json b/erpnext/selling/doctype/customer/customer.json index 250973b7497..89ce325a847 100644 --- a/erpnext/selling/doctype/customer/customer.json +++ b/erpnext/selling/doctype/customer/customer.json @@ -1,4 +1,5 @@ { + "actions": [], "allow_events_in_timeline": 1, "allow_import": 1, "allow_rename": 1, @@ -122,7 +123,7 @@ { "fieldname": "default_bank_account", "fieldtype": "Link", - "label": "Default Bank Account", + "label": "Default Company Bank Account", "options": "Bank Account" }, { @@ -470,7 +471,8 @@ "icon": "fa fa-user", "idx": 363, "image_field": "image", - "modified": "2020-01-24 15:06:03.483799", + "links": [], + "modified": "2020-01-29 20:36:37.879581", "modified_by": "Administrator", "module": "Selling", "name": "Customer", diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py index 6ee02190bad..3248c998b60 100644 --- a/erpnext/selling/doctype/customer/customer.py +++ b/erpnext/selling/doctype/customer/customer.py @@ -54,6 +54,7 @@ class Customer(TransactionBase): self.validate_credit_limit_on_change() self.set_loyalty_program() self.check_customer_group_change() + self.validate_default_bank_account() # set loyalty program tier if frappe.db.exists('Customer', self.name): @@ -72,6 +73,11 @@ class Customer(TransactionBase): if self.customer_group != frappe.db.get_value('Customer', self.name, 'customer_group'): frappe.flags.customer_group_changed = True + def validate_default_bank_account(self): + if self.default_bank_account: + is_company_account = frappe.db.get_value('Bank Account', self.default_bank_account, 'is_company_account') + frappe.throw(_("{0} is not a company bank account").format(frappe.bold(self.default_bank_account))) + def on_update(self): self.validate_name_with_customer_group() self.create_primary_contact() From 3ed574532de1e034637678b7a85490f94cab4c48 Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Wed, 29 Jan 2020 21:45:17 +0530 Subject: [PATCH 2/2] fix: filter --- erpnext/selling/doctype/customer/customer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/selling/doctype/customer/customer.js b/erpnext/selling/doctype/customer/customer.js index 0a9f9b8f0a7..6db4102a7bf 100644 --- a/erpnext/selling/doctype/customer/customer.js +++ b/erpnext/selling/doctype/customer/customer.js @@ -56,7 +56,7 @@ frappe.ui.form.on("Customer", { } }) - frm.set_query('default_bank_account', function(c) { + frm.set_query('default_bank_account', function() { return { filters: { 'is_company_account': 1